Exemple #1
0
void KbPerf::popDpi(quint64 pushIdx){
    if(!pushedDpis.contains(pushIdx)) {   
      return;
    }
    pushedDpis.remove(pushIdx);
    if (pushedDpis.isEmpty()) {
        _curDpi(dpi(dpiBaseIdx));
    } else {
        // Set the DPI to the last-pushed value still on the stack
        _curDpi(map_last(pushedDpis));
    } 
    _needsUpdate = _needsSave = true;
}
Exemple #2
0
void KbPerf::baseDpiIdx(int newIdx) {
    if (pushedDpis.isEmpty() && dpiBaseIdx == newIdx)
        return;
    pushedDpis.clear();
    dpiBaseIdx = newIdx;
    _curDpi(dpi(dpiBaseIdx));
    _needsUpdate = _needsSave = true; 
}
Exemple #3
0
void KbPerf::dpi(int index, const QPoint& newValue){
    if(index < 0 || index >= DPI_COUNT)
        return;
    dpiX[index] = newValue.x();
    dpiY[index] = newValue.y();
    // Update current DPI if needed
    if(dpiBaseIdx == index && pushedDpis.isEmpty()) {
        _curDpi(QPoint(dpiX[index], dpiY[index]));
    }
    _needsUpdate = _needsSave = true;
}
Exemple #4
0
void KbPerf::popDpi(quint64 pushIdx){
    if(pushIdx == 0 || !pushedDpis.contains(pushIdx))
        return;
    pushedDpis.remove(pushIdx);
    // Set the DPI to the last-pushed value still on the stack
    _curDpi(map_last(pushedDpis));
    // If all values have been popped, remove the original DPI
    if(pushedDpis.count() == 1)
        pushedDpis.clear();
    _needsUpdate = _needsSave = true;
}
Exemple #5
0
quint64 KbPerf::pushDpi(const QPoint& newDpi){
    if(pushedDpis.isEmpty())
        // Push original DPI
        pushedDpis[0] = curDpi();
    quint64 index = runningPushIdx++;
    if(runningPushIdx == 0)
        runningPushIdx = 1;
    pushedDpis[index] = newDpi;
    _curDpi(newDpi);
    return index;
}
Exemple #6
0
KbPerf::KbPerf(KbMode* parent, const KbPerf& other) :
    QObject(parent), dpiCurX(other.dpiCurX), dpiCurY(other.dpiCurY), dpiBaseIdx(other.dpiBaseIdx), runningPushIdx(1),
    _iOpacity(other._iOpacity), light100Color(other.light100Color), muteNAColor(other.muteNAColor), _dpiIndicator(other._dpiIndicator),
    _liftHeight(other._liftHeight), _angleSnap(other._angleSnap),
    _needsUpdate(true), _needsSave(true) {
    memcpy(dpiX, other.dpiX, sizeof(dpiX));
    memcpy(dpiY, other.dpiY, sizeof(dpiY));
    for(int i = 0; i < DPI_COUNT + 1; i++)
        dpiClr[i] = other.dpiClr[i];
    memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
    for(int i = 0; i < I_COUNT; i++){
        iColor[i][0] = other.iColor[i][0];
        iColor[i][1] = other.iColor[i][1];
    }
    memcpy(iEnable, other.iEnable, sizeof(iEnable));
    memcpy(hwIType, other.hwIType, sizeof(hwIType));
    // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
    _curDpi(dpi(dpiBaseIdx));
}
Exemple #7
0
const KbPerf& KbPerf::operator= (const KbPerf& other){
    dpiCurX = other.dpiCurX; dpiCurY = other.dpiCurY; dpiBaseIdx = other.dpiBaseIdx; runningPushIdx = 1;
    _iOpacity = other._iOpacity; light100Color = other.light100Color; muteNAColor = other.muteNAColor; _dpiIndicator = other._dpiIndicator;
    _liftHeight = other._liftHeight; _angleSnap = other._angleSnap;
    _needsUpdate = true; _needsSave = true;
    memcpy(dpiX, other.dpiX, sizeof(dpiX));
    memcpy(dpiY, other.dpiY, sizeof(dpiY));
    for(int i = 0; i < DPI_COUNT + 1; i++)
        dpiClr[i] = other.dpiClr[i];
    memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
    for(int i = 0; i < I_COUNT; i++){
        iColor[i][0] = other.iColor[i][0];
        iColor[i][1] = other.iColor[i][1];
    }
    memcpy(iEnable, other.iEnable, sizeof(iEnable));
    memcpy(hwIType, other.hwIType, sizeof(hwIType));
    // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
    _curDpi(dpi(dpiBaseIdx));
    return other;
}
Exemple #8
0
quint64 KbPerf::pushDpi(const QPoint& newDpi){
    quint64 index = runningPushIdx++;
    pushedDpis[index] = newDpi;
    _curDpi(newDpi);
    return index;
}
Exemple #9
0
void KbPerf::load(CkbSettings& settings){
    pushedDpis.clear();
    runningPushIdx = 1;
    _needsSave = false;
    bool readIndicators = true;
    if(!settings.containsGroup("Performance/Indicators")){
        // Read old indicator settings from the lighting group, if present
        // (ckb <= v0.2.0)
        SGroup group(settings, "Lighting");
        if(settings.contains("InactiveIndicators")){
            bool inOk = false;
            int inactive = settings.value("InactiveIndicators").toInt(&inOk);
            if(!inOk || inactive > 2)
                inactive = 2;
            if(inactive == 1)
                _iOpacity = 0.75f;
            else if(inactive == 0)
                _iOpacity = 0.5f;
            else if(inactive < 0){
                // Indicators disabled
                iEnable[MODE] = iEnable[MACRO] = iEnable[LIGHT] = iEnable[LOCK]  = iEnable[MUTE] = false;
            }
            bool showMute = (settings.value("ShowMute").toInt(&inOk) != 0);
            if(inOk && !showMute)
                iEnable[MUTE] = false;
            readIndicators = false;
        }
    }
    SGroup group(settings, "Performance");
    // Read DPI settings
    {
        SGroup group(settings, "DPI");
        for(int i = 0; i < DPI_COUNT; i++){
            QString iStr = QString::number(i);
            QPoint value = settings.value(iStr).toPoint();
            if(value.isNull())
                continue;
            dpiX[i] = value.x(); dpiY[i] = value.y();
            QColor color = settings.value(iStr + "RGB").toString();
            if(color.isValid())
                dpiClr[i] = color;
            if(i != 0)
                dpiOn[i] = !settings.value(iStr + "Disabled").toBool();
        }
        QColor color = settings.value("6RGB").toString();
        if(color.isValid())
            dpiClr[OTHER] = color;
        if (settings.contains("CurIdx")) {
            dpiBaseIdx = settings.value("CurIdx").toInt();
        } else {
            // If there isn't a setting for current DPI stage, pick the first
            // enabled one. Failing that just pick stage 1.
            dpiBaseIdx = 1;
            for (int i = 1; i < DPI_COUNT; i++) {
                if (dpiOn[i]) {
                    dpiBaseIdx = i;
                    break;
                }
            }	 
        }
        _curDpi(dpi(dpiBaseIdx));
    }
    // Read misc. mouse settings
    _liftHeight = (height)settings.value("LiftHeight").toInt();
    if(_liftHeight < LOW || _liftHeight > HIGH)
        _liftHeight = MEDIUM;
    _angleSnap = settings.value("AngleSnap").toBool();
    if(settings.contains("NoIndicator")){
        // ckb <= v0.2.0
        _dpiIndicator = !settings.value("NoIndicator").toBool();
    } else {
        _dpiIndicator = settings.value("Indicators/DPI", true).toBool();
    }
    // Read indicator settings
    if(readIndicators){
        SGroup group(settings, "Indicators");
        _iOpacity = settings.value("Opacity", 100).toInt() / 100.f;
        for(int i = 0; i < I_COUNT; i++){
            SGroup group(settings, QString::number(i));
            QColor color = settings.value("RGB0").toString();
            if(color.isValid())
                iColor[i][0] = color;
            color = settings.value("RGB1").toString();
            if(color.isValid())
                iColor[i][1] = color;
            if(i == LIGHT){
                color = settings.value("RGB2").toString();
                if(color.isValid())
                    light100Color = color;
            } else if(i == MUTE){
                color = settings.value("RGB2").toString();
                if(color.isValid())
                    muteNAColor = color;
            }
            if(i <= HW_IMAX){
                iEnable[i] = settings.value("Enable", false).toBool();
                hwIType[i] = (i_hw)settings.value("Hardware", (int)NORMAL).toInt();
            } else {
                iEnable[i] = settings.value("Enable", true).toBool();
            }
        }
    }
    emit didLoad();
}
Exemple #10
0
void KbPerf::curDpi(const QPoint& newDpi){
    while(pushedDpis.count() > 0)
        popDpi(pushedDpis.keys().last());
    _curDpi(newDpi);
}