Prevent theme box from saving theme setting until initialized

This commit is contained in:
Adam Honse 2021-05-30 21:08:23 -07:00
parent a5928518c1
commit d8252281ce
2 changed files with 15 additions and 4 deletions

View file

@ -23,6 +23,12 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
std::string theme = theme_settings["theme"];
ui->ComboBoxTheme->setCurrentText(QString::fromStdString(theme));
}
else
{
ui->ComboBoxTheme->setCurrentText(QString::fromStdString(("light")));
}
theme_initialized = true;
#else
ui->ComboBoxTheme->hide();
ui->ThemeLabel->hide();
@ -59,10 +65,13 @@ OpenRGBSettingsPage::~OpenRGBSettingsPage()
void OpenRGBSettingsPage::on_ComboBoxTheme_currentTextChanged(const QString theme)
{
json theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Theme");
theme_settings["theme"] = theme.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("Theme", theme_settings);
SaveSettings();
if(theme_initialized)
{
json theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Theme");
theme_settings["theme"] = theme.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("Theme", theme_settings);
SaveSettings();
}
}
void OpenRGBSettingsPage::on_CheckboxMinimizeOnClose_clicked()

View file

@ -20,6 +20,8 @@ private:
Ui::OpenRGBSettingsPageUi *ui;
void SaveSettings();
bool theme_initialized = false;
private slots:
void on_ComboBoxTheme_currentTextChanged(const QString);
void on_CheckboxMinimizeOnClose_clicked();