Add autoremove disabled buttons at startup

This commit is contained in:
lupoDharkael
2017-05-24 20:17:59 +02:00
parent 127b2d25e1
commit 976cd01a31

View File

@@ -45,7 +45,6 @@ Controller::Controller(QObject *parent) : QObject(parent),
qApp->installNativeEventFilter(m_nativeEventFilter);
connect(m_nativeEventFilter, &NativeEventFilter::activated, this, &Controller::slotPrintHotkey);
QString StyleSheet = Button::getStyle();
qApp->setStyleSheet(StyleSheet);
@@ -94,6 +93,18 @@ void Controller::initDefaults() {
buttons << i;
}
settings.setValue("buttons", QVariant::fromValue(buttons));
} else {
// disabled buttons cleanup
int higherValue = static_cast<int>(Button::Type::last) - 1;
QList<int> buttons = settings.value("buttons").value<QList<int> >();
QMutableListIterator<int> i(buttons);
while (i.hasNext()) {
if (i.next() > higherValue) {
i.remove();
}
}
settings.setValue("buttons", QVariant::fromValue(buttons));
}
}