Commit 2155e62a authored by Sebastian Schmidt's avatar Sebastian Schmidt Committed by Aleix Pol Gonzalez

Add a checkbox to enable dark GTK3 Themes

BUG: 346469
parent 0a637d4d
......@@ -72,6 +72,7 @@ bool AppearanceGTK3::saveSettings(const QString& file) const
flow3 << "gtk-menu-images=" << m_settings["show_icons_menus"] << "\n";
flow3 << "gtk-button-images=" << m_settings["show_icons_buttons"] << "\n";
flow3 << "gtk-primary-button-warps-slider=" << m_settings["primary_button_warps_slider"] << "\n";
flow3 << "gtk-application-prefer-dark-theme=" << m_settings["application_prefer_dark_theme"] << "\n";
return true;
}
......@@ -88,7 +89,8 @@ bool AppearanceGTK3::loadSettings(const QString& path)
{"toolbar_style", "GTK_TOOLBAR_ICONS"},
{"show_icons_buttons", "0"},
{"show_icons_menus", "0"},
{"primary_button_warps_slider", "false"}
{"primary_button_warps_slider", "false"},
{"application_prefer_dark_theme", "false"}
};
for(auto it = foundSettings.constBegin(), itEnd = foundSettings.constEnd(); it!=itEnd; ++it) {
......@@ -110,6 +112,8 @@ bool AppearanceGTK3::loadSettings(const QString& path)
m_settings["show_icons_menus"] = *it;
else if (it.key() == "gtk-primary-button-warps-slider")
m_settings["primary_button_warps_slider"] = *it;
else if (it.key() == "gtk-application-prefer-dark-theme")
m_settings["application_prefer_dark_theme"] = *it;
else
qWarning() << "unknown field" << it.key();
}
......@@ -127,3 +131,13 @@ QString AppearanceGTK3::defaultConfigFile() const
return root+"/gtk-3.0/settings.ini";
}
bool AppearanceGTK3::getApplicationPreferDarkTheme() const
{
return m_settings["application_prefer_dark_theme"] == "1" || m_settings["application_prefer_dark_theme"] == "true";
}
void AppearanceGTK3::setApplicationPreferDarkTheme(const bool& enable)
{
m_settings["application_prefer_dark_theme"] = enable ? "true" : "false";
}
......@@ -33,6 +33,8 @@ public:
bool saveSettings(const QString& file) const override;
bool loadSettings(const QString& path) override;
QString defaultConfigFile() const override;
bool getApplicationPreferDarkTheme() const;
void setApplicationPreferDarkTheme(const bool& enable);
};
#endif // APPEARANCEGTK3_H
......@@ -54,6 +54,8 @@ QString AppearenceGTK::getTheme() const { return gtk2Appearance()->getTheme(); }
void AppearenceGTK::setTheme(const QString& name) { return gtk2Appearance()->setTheme(name); }
QString AppearenceGTK::getThemeGtk3() const { return gtk3Appearance()->getTheme(); }
void AppearenceGTK::setThemeGtk3(const QString& name) { return gtk3Appearance()->setTheme(name); }
bool AppearenceGTK::getApplicationPreferDarkTheme() const { return ((AppearanceGTK3*)gtk3Appearance())->getApplicationPreferDarkTheme(); }
void AppearenceGTK::setApplicationPreferDarkTheme(const bool& enable) { return ((AppearanceGTK3*)gtk3Appearance())->setApplicationPreferDarkTheme(enable); }
////////////////////////////////////
// Methods responsible of file creation
......
......@@ -40,6 +40,7 @@ public:
void setTheme(const QString&);
void setThemeGtk3(const QString &theme);
void setApplicationPreferDarkTheme(const bool& enable);
void setCursor(const QString&);
void setIcon(const QString&);
void setIconFallback(const QString&);
......@@ -52,6 +53,7 @@ public:
QString getTheme() const;
QString getThemeGtk3() const;
bool getApplicationPreferDarkTheme() const;
QString getCursor() const;
QString getIcon() const;
......
......@@ -107,6 +107,7 @@ GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args )
//UI changes
connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged()));
connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged()));
connect(ui->checkBox_theme_gtk3_prefer_dark, SIGNAL(clicked(bool)), this, SLOT(appChanged()));
connect(ui->cb_cursor, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged()));
connect(ui->cb_icon, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged()));
connect(ui->cb_icon_fallback ,SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged()));
......@@ -149,6 +150,7 @@ void GTKConfigKCModule::syncUI()
{
appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText());
appareance->setTheme(ui->cb_theme->currentText());
appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked());
appareance->setCursor(ui->cb_cursor->itemData(ui->cb_cursor->currentIndex(), CursorThemesModel::DirNameRole).toString());
appareance->setIcon(ui->cb_icon->itemData(ui->cb_icon->currentIndex(), IconThemesModel::DirNameRole).toString());
appareance->setIconFallback(ui->cb_icon_fallback->itemData(ui->cb_icon_fallback->currentIndex(), IconThemesModel::DirNameRole).toString());
......@@ -410,6 +412,9 @@ void GTKConfigKCModule::refreshThemesUi(bool useConfig)
useConfig ? appareance->getThemeGtk3() : ui->cb_theme_gtk3->currentText(),
appareance->gtk3Appearance()->installedThemesNames());
// dark theme for gtk3
ui->checkBox_theme_gtk3_prefer_dark->setChecked(appareance->getApplicationPreferDarkTheme());
//cursors
QString currentCursor = useConfig ? appareance->getCursor() : ui->cb_cursor->currentText();
int currentCursorIdx = ui->cb_cursor->findData(currentCursor, CursorThemesModel::DirNameRole);
......
......@@ -389,16 +389,30 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Font:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="KFontRequester" name="font"/>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox_theme_gtk3_prefer_dark">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Prefer Dark GTK3 Theme</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment