Skip to content

Commit

Permalink
Fixed bug when removing dpi modes set to default_dpi or switched_dpi
Browse files Browse the repository at this point in the history
  • Loading branch information
dslul committed Nov 29, 2018
1 parent 4cfd457 commit 8d9a556
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions logiconf-gui/Page2.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Page2Form {
print("current index: " + DevCom.getDPIIndex() + " list length: "+dpilist.length)
if(DevCom.getDPIIndex()+1 > dpilist.length)
DevCom.setDPIIndex(dpilist.length-1)
if(DevCom.getDefaultDpi()+1 > dpilist.length)
DevCom.setDefaultDpi(dpilist.length-1)
if(DevCom.getSwitchedDpi()+1 > dpilist.length)
DevCom.setSwitchedDpi(dpilist.length-1)
DevCom.applySettings()
btnApply.enabled = false;
var current = DevCom.getDPIIndex()
Expand Down
20 changes: 20 additions & 0 deletions logiconf-gui/devicecommunicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ void DeviceCommunicator::setReportRate(int rate)
tmpprofile.settings.at("report_rate") = std::move(HIDPP::Setting(rate));
}

int DeviceCommunicator::getDefaultDpi()
{
return hidprofile->settings.at("default_dpi").get<int>();
}

void DeviceCommunicator::setDefaultDpi(int level)
{
tmpprofile.settings.at("default_dpi") = std::move(HIDPP::Setting(level));
}

int DeviceCommunicator::getSwitchedDpi()
{
return hidprofile->settings.at("switched_dpi").get<int>();
}

void DeviceCommunicator::setSwitchedDpi(int level)
{
tmpprofile.settings.at("switched_dpi") = std::move(HIDPP::Setting(level));
}

void DeviceCommunicator::setDPI(int level, int dpi)
{
tmpprofile.modes[level].at("dpi") = std::move(HIDPP::Setting(dpi));
Expand Down
4 changes: 4 additions & 0 deletions logiconf-gui/devicecommunicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class DeviceCommunicator : public QObject
explicit DeviceCommunicator(QObject *parent = 0);
Q_INVOKABLE int getReportRate();
Q_INVOKABLE void setReportRate(int rate);
Q_INVOKABLE int getDefaultDpi();
Q_INVOKABLE void setDefaultDpi(int level);
Q_INVOKABLE int getSwitchedDpi();
Q_INVOKABLE void setSwitchedDpi(int level);
Q_INVOKABLE void setDPI(int level, int dpi);
Q_INVOKABLE void removeDPILevel(int level);
Q_INVOKABLE void addDPILevel(int dpi);
Expand Down

0 comments on commit 8d9a556

Please sign in to comment.