Fix bug that restore default settings when all wiimotedev actions are removed
This commit is contained in:
parent
7dc36761e9
commit
8359190a2f
|
@ -239,6 +239,7 @@ void SettingsDialog::accept() {
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||||
|
s.setValue("first_conf", false);
|
||||||
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
|
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
|
||||||
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
|
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
|
||||||
s.setValue("use_active_action", wiimotedev_config_->ui_->wiimotedev_active->isChecked());
|
s.setValue("use_active_action", wiimotedev_config_->ui_->wiimotedev_active->isChecked());
|
||||||
|
|
|
@ -136,6 +136,15 @@ void WiimotedevShortcutsConfig::AddShortcut(quint64 button, quint32 action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimotedevShortcutsConfig::LoadSettings(){
|
void WiimotedevShortcutsConfig::LoadSettings(){
|
||||||
|
settings_.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||||
|
bool first_conf = settings_.value("first_conf", true).toBool();
|
||||||
|
settings_.endGroup();
|
||||||
|
|
||||||
|
if (first_conf) {
|
||||||
|
DefaultSettings();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||||
settings_.sync();
|
settings_.sync();
|
||||||
ui_->list->clear();
|
ui_->list->clear();
|
||||||
|
@ -155,7 +164,6 @@ void WiimotedevShortcutsConfig::LoadSettings(){
|
||||||
ui_->list->sortItems(1, Qt::AscendingOrder);
|
ui_->list->sortItems(1, Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WiimotedevShortcutsConfig::DefaultSettings()
|
void WiimotedevShortcutsConfig::DefaultSettings()
|
||||||
{
|
{
|
||||||
ui_->list->clear();
|
ui_->list->clear();
|
||||||
|
|
|
@ -59,27 +59,16 @@ void WiimotedevShortcuts::ReloadSettings() {
|
||||||
|
|
||||||
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||||
|
|
||||||
if (!settings_.allKeys().count()) {
|
quint64 fvalue, svalue;
|
||||||
actions_[WIIMOTE_BTN_LEFT] = PlayerPreviousTrack;
|
bool fvalid, svalid;
|
||||||
actions_[WIIMOTE_BTN_RIGHT] = PlayerNextTrack;
|
|
||||||
actions_[WIIMOTE_BTN_RIGHT] = PlayerNextTrack;
|
|
||||||
actions_[WIIMOTE_BTN_SHIFT_LEFT] = PlayerPreviousTrack;
|
|
||||||
actions_[WIIMOTE_BTN_SHIFT_RIGHT] = PlayerNextTrack;
|
|
||||||
actions_[WIIMOTE_BTN_PLUS] = PlayerIncVolume;
|
|
||||||
actions_[WIIMOTE_BTN_MINUS] = PlayerDecVolume;
|
|
||||||
actions_[WIIMOTE_BTN_1] = PlayerTogglePause;
|
|
||||||
actions_[WIIMOTE_BTN_2] = PlayerShowOSD;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
quint64 fvalue, svalue;
|
foreach (const QString& str, settings_.allKeys()) {
|
||||||
bool fvalid, svalid;
|
fvalue = str.toULongLong(&fvalid, 10);
|
||||||
|
svalue = settings_.value(str, 0).toULongLong(&svalid);
|
||||||
foreach (const QString& str, settings_.allKeys()) {
|
if (fvalid && svalid)
|
||||||
fvalue = str.toULongLong(&fvalid, 10);
|
actions_[fvalue] = svalue;
|
||||||
svalue = settings_.value(str, 0).toULongLong(&svalid);
|
|
||||||
if (fvalid && svalid) actions_[fvalue] = svalue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_.endGroup();
|
settings_.endGroup();
|
||||||
|
|
||||||
settings_.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
settings_.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||||
|
@ -88,7 +77,6 @@ void WiimotedevShortcuts::ReloadSettings() {
|
||||||
wiimotedev_active_ = settings_.value("use_active_action", true).toBool();
|
wiimotedev_active_ = settings_.value("use_active_action", true).toBool();
|
||||||
wiimotedev_focus_ = settings_.value("only_when_focused", false).toBool();
|
wiimotedev_focus_ = settings_.value("only_when_focused", false).toBool();
|
||||||
wiimotedev_notification_ = settings_.value("use_notification", true).toBool();
|
wiimotedev_notification_ = settings_.value("use_notification", true).toBool();
|
||||||
|
|
||||||
settings_.endGroup();
|
settings_.endGroup();
|
||||||
|
|
||||||
SetWiimotedevInterfaceActived(wiimotedev_enable_);
|
SetWiimotedevInterfaceActived(wiimotedev_enable_);
|
||||||
|
|
Loading…
Reference in New Issue