Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a26cd1

Browse files
committed
Fix nested setting groups
1 parent 5b84e58 commit 5a26cd1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/ui/mainwindow.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,8 @@ void MainWindow::uiInit()
11021102

11031103
settings->beginGroup("Client_forceButtonsEnabled");
11041104
keepButtonsEnabled = settings->value("state", false).toBool();
1105-
ui->Set_Client_forceEnabledBox->setChecked(keepButtonsEnabled);
11061105
settings->endGroup();
1106+
ui->Set_Client_forceEnabledBox->setChecked(keepButtonsEnabled);
11071107

11081108
// the disconnect detection doesn't work well on Linux/macOS
11091109
// So it should be disabled on these platforms
@@ -1115,8 +1115,8 @@ void MainWindow::uiInit()
11151115
#else
11161116
keepClientActive = settings->value("state", true).toBool();
11171117
#endif
1118-
ui->Set_Client_keepClientActiveBox->setChecked(keepClientActive);
11191118
settings->endGroup();
1119+
ui->Set_Client_keepClientActiveBox->setChecked(keepClientActive);
11201120

11211121
QDirIterator configFiles(":/config/");
11221122
ui->Set_Client_configFileBox->blockSignals(true);
@@ -1139,11 +1139,17 @@ void MainWindow::uiInit()
11391139
ui->Set_Client_configFileBox->blockSignals(false);
11401140
on_Set_Client_configFileBox_currentIndexChanged(ui->Set_Client_configFileBox->currentIndex());
11411141

1142+
// setValue() will trigger valueChanged()
1143+
// setValue(settings->value()) will create a nested group
1144+
// call endGroup() before apply the value
11421145
settings->beginGroup("UI");
1143-
ui->Set_UI_Opacity_Box->setValue(settings->value("Opacity", 100).toInt());
1146+
int opacity = settings->value("Opacity", 100).toInt();
11441147
int themeId = ui->Set_UI_Theme_nameBox->findData(settings->value("Theme_Name", "(none)").toString());
1148+
settings->endGroup();
1149+
ui->Set_UI_Opacity_Box->setValue(opacity);
11451150
ui->Set_UI_Theme_nameBox->setCurrentIndex((themeId == -1) ? 0 : themeId);
11461151

1152+
settings->beginGroup("UI");
11471153
// QApplication::font() might return wrong result
11481154
// If fonts are not specified in config file, don't touch them.
11491155
QString tmpFontName;
@@ -1157,7 +1163,7 @@ void MainWindow::uiInit()
11571163
ui->Set_UI_Font_sizeBox->setValue(tmpFontSize);
11581164
fontValid = true;
11591165
}
1160-
// The default values should be the same as MF_dataWidget's and MF_keyWidget's.
1166+
// The default font should be the same as MF_dataWidget's and MF_keyWidget's.
11611167
tmpFontName = settings->value("DataFont_Name", "Consolas").toString();
11621168
tmpFontSize = settings->value("DataFont_Size", 12).toInt();
11631169
if(!tmpFontName.isEmpty() && tmpFontSize != -1 && tmpFontName == QFont(tmpFontName).family())

0 commit comments

Comments
 (0)