Fix Reset Settings for Themes #123

This commit is contained in:
Florian Märkl 2017-12-03 13:10:09 +01:00
parent b63d85b23d
commit 7d9cfca2d8
3 changed files with 18 additions and 8 deletions

View File

@ -443,10 +443,6 @@ void MainWindow::readSettings()
restoreGeometry(geo); restoreGeometry(geo);
QByteArray state = settings.value("state", QByteArray()).toByteArray(); QByteArray state = settings.value("state", QByteArray()).toByteArray();
restoreState(state); restoreState(state);
if (settings.value("dark").toBool())
{
this->setDarkTheme();
}
this->responsive = settings.value("responsive").toBool(); this->responsive = settings.value("responsive").toBool();
} }
@ -868,9 +864,7 @@ void MainWindow::on_actionReset_settings_triggered()
QMessageBox::Ok | QMessageBox::Cancel); QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok) if (ret == QMessageBox::Ok)
{ {
// Save options in settings Config()->resetAll();
QSettings settings;
settings.clear();
} }
} }

View File

@ -8,7 +8,7 @@ Configuration* Configuration::mPtr = nullptr;
Configuration::Configuration() : QObject() Configuration::Configuration() : QObject()
{ {
mPtr = this; mPtr = this;
loadDefaultTheme(); loadInitial();
} }
Configuration* Configuration::instance() Configuration* Configuration::instance()
@ -16,6 +16,18 @@ Configuration* Configuration::instance()
return mPtr; return mPtr;
} }
void Configuration::loadInitial()
{
setDarkTheme(s.value("dark").toBool());
}
void Configuration::resetAll()
{
s.clear();
loadInitial();
emit fontsUpdated();
}
void Configuration::loadDefaultTheme() void Configuration::loadDefaultTheme()
{ {
QColor color0 = QColor(0, 0, 0); QColor color0 = QColor(0, 0, 0);

View File

@ -15,6 +15,8 @@ private:
QSettings s; QSettings s;
static Configuration* mPtr; static Configuration* mPtr;
void loadInitial();
// Colors // Colors
void loadDefaultTheme(); void loadDefaultTheme();
void loadDarkTheme(); void loadDarkTheme();
@ -25,6 +27,8 @@ public:
Configuration(); Configuration();
static Configuration* instance(); static Configuration* instance();
void resetAll();
// Fonts // Fonts
const QFont getFont() const; const QFont getFont() const;
void setFont(const QFont &font); void setFont(const QFont &font);