Fix bug that restore default settings when all wiimotedev actions are removed

This commit is contained in:
Bartłomiej Burdukiewicz 2010-08-31 23:35:39 +00:00
parent 7dc36761e9
commit 8359190a2f
3 changed files with 18 additions and 21 deletions

View File

@ -239,6 +239,7 @@ void SettingsDialog::accept() {
s.endGroup();
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
s.setValue("first_conf", false);
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
s.setValue("use_active_action", wiimotedev_config_->ui_->wiimotedev_active->isChecked());

View File

@ -136,6 +136,15 @@ void WiimotedevShortcutsConfig::AddShortcut(quint64 button, quint32 action) {
}
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_.sync();
ui_->list->clear();
@ -155,7 +164,6 @@ void WiimotedevShortcutsConfig::LoadSettings(){
ui_->list->sortItems(1, Qt::AscendingOrder);
}
void WiimotedevShortcutsConfig::DefaultSettings()
{
ui_->list->clear();

View File

@ -59,27 +59,16 @@ void WiimotedevShortcuts::ReloadSettings() {
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
if (!settings_.allKeys().count()) {
actions_[WIIMOTE_BTN_LEFT] = PlayerPreviousTrack;
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;
bool fvalid, svalid;
quint64 fvalue, svalue;
bool fvalid, svalid;
foreach (const QString& str, settings_.allKeys()) {
fvalue = str.toULongLong(&fvalid, 10);
svalue = settings_.value(str, 0).toULongLong(&svalid);
if (fvalid && svalid) actions_[fvalue] = svalue;
}
foreach (const QString& str, settings_.allKeys()) {
fvalue = str.toULongLong(&fvalid, 10);
svalue = settings_.value(str, 0).toULongLong(&svalid);
if (fvalid && svalid)
actions_[fvalue] = svalue;
}
settings_.endGroup();
settings_.beginGroup(WiimotedevShortcuts::kSettingsGroup);
@ -88,7 +77,6 @@ void WiimotedevShortcuts::ReloadSettings() {
wiimotedev_active_ = settings_.value("use_active_action", true).toBool();
wiimotedev_focus_ = settings_.value("only_when_focused", false).toBool();
wiimotedev_notification_ = settings_.value("use_notification", true).toBool();
settings_.endGroup();
SetWiimotedevInterfaceActived(wiimotedev_enable_);