Commit d9d49d5c authored by Mikhail Zolotukhin's avatar Mikhail Zolotukhin
Browse files

[GTK Integration] Apply the same theme for GTK2 and GTK3 applications

GTK configuration in Plasma depends on xsettings daemon, that has no
separation between GTK2 and GTK3 theme, therefore separate themes for
GTK2 and GTK3 are impossible, while this daemon is working. The daemon
itself provides the functionality to apply settings to GTK applications
without restarting them.

The functionality to apply different themes to applications, depending on
the framework version isn't necessary, when 99% of the themes are
compatible with both versions and when most of the applications are
using the last GTK version anyway.

Given all that, I think, that a theme selection must be narrowed to one
and only one theme for both versions of the GTK framework.

CCBUG: 423141
parent 3cc6f9db
......@@ -43,7 +43,7 @@ kcoreaddons_desktop_to_json(kcm_style "kcm_style.desktop")
install(FILES stylesettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES style_widgetstyle_default_breeze.upd style_widgetstyle_default_breeze.pl DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update)
install(FILES gtk2_themes.knsrc gtk3_themes.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR})
install(FILES gtk_themes.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR})
install(FILES kcm_style.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(TARGETS kcm_style DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
......
[KNewStuff3]
Name=GTK 2.x Themes
Name[az]=GTK 2.x Mövzuları
Name[ca]=Temes GTK 2.x
Name[cs]=Motivy GTK 2.x
Name[da]=GTK 2.x-temaer
Name[de]=GTK 2.x-Designs
Name[en_GB]=GTK 2.x Themes
Name[es]=Temas de GTK 2.x
Name[et]=GTK 2.x teemad
Name[eu]=GTK 2.x gaiak
Name[fi]=Gtk 2.x -teemat
Name[fr]=Thèmes GTK 2.x
Name[ia]=Themas de GTK 2.x
Name[id]=Tema-tema GTK 2.x
Name[it]=Temi GTK 2.x
Name[ko]=GTK 2.x 테마
Name[lt]=GTK 2.x apipavidalinimai
Name[nl]=GTK 2.x thema's
Name[nn]=GTK 2.x-tema
Name[pt]=Temas do GTK 2.x
Name[pt_BR]=Temas GTK 2.x
Name[ru]=Темы GTK 2.x
Name[sk]=Témy GTK 2.x
Name[sl]=Teme GTK 2.x
Name[sv]=GTK 2.x-teman
Name[uk]=Теми GTK 2.x
Name[x-test]=xxGTK 2.x Themesxx
Name[zh_CN]=GTK 2.x 主题
Name[zh_TW]=GTK 2.x 主題
Categories=GTK 2.x Theme/Style
Uncompress=always
InstallPath=.themes
[KNewStuff3]
Name=GTK 3.x Themes
Name=GNOME/GTK Application Styles
Name[az]=GTK 3.x Mövzuları
Name[ca]=Temes GTK 3.x
Name[cs]=Motivy GTK 3.x
......
......@@ -33,61 +33,39 @@
GtkPage::GtkPage(QObject *parent)
: QObject(parent)
, m_gtk2ThemesModel(new GtkThemesModel(this))
, m_gtk3ThemesModel(new GtkThemesModel(this))
, m_gtkThemesModel(new GtkThemesModel(this))
, gtkConfigInterface(
QStringLiteral("org.kde.GtkConfig"),
QStringLiteral("/GtkConfig"),
QStringLiteral("org.kde.GtkConfig")
)
{
connect(m_gtk2ThemesModel, &GtkThemesModel::themeRemoved, this, &GtkPage::onThemeRemoved);
connect(m_gtk3ThemesModel, &GtkThemesModel::themeRemoved, this, &GtkPage::onThemeRemoved);
connect(m_gtkThemesModel, &GtkThemesModel::themeRemoved, this, &GtkPage::onThemeRemoved);
connect(m_gtk2ThemesModel, &GtkThemesModel::selectedThemeChanged, this, [this](){
Q_EMIT gtkThemeSettingsChanged();
});
connect(m_gtk3ThemesModel, &GtkThemesModel::selectedThemeChanged, this, [this](){
connect(m_gtkThemesModel, &GtkThemesModel::selectedThemeChanged, this, [this](){
Q_EMIT gtkThemeSettingsChanged();
});
}
GtkPage::~GtkPage()
{
delete m_gtk2ThemesModel;
delete m_gtk3ThemesModel;
}
QString GtkPage::gtk2ThemeFromConfig()
{
QDBusReply<QString> dbusReply = gtkConfigInterface.call(QStringLiteral("gtk2Theme"));
return dbusReply.value();
delete m_gtkThemesModel;
}
QString GtkPage::gtk3ThemeFromConfig()
QString GtkPage::gtkThemeFromConfig()
{
QDBusReply<QString> dbusReply = gtkConfigInterface.call(QStringLiteral("gtk3Theme"));
QDBusReply<QString> dbusReply = gtkConfigInterface.call(QStringLiteral("gtkTheme"));
return dbusReply.value();
}
bool GtkPage::gtk2PreviewAvailable()
bool GtkPage::gtkPreviewAvailable()
{
return !QStandardPaths::findExecutable(QStringLiteral("gtk_preview"), {CMAKE_INSTALL_FULL_LIBEXECDIR}).isEmpty();
}
bool GtkPage::gtk3PreviewAvailable()
{
return !QStandardPaths::findExecutable(QStringLiteral("gtk3_preview"), {CMAKE_INSTALL_FULL_LIBEXECDIR}).isEmpty();
}
void GtkPage::showGtk2Preview()
{
gtkConfigInterface.call(QStringLiteral("showGtk2ThemePreview"), m_gtk2ThemesModel->selectedTheme());
}
void GtkPage::showGtk3Preview()
void GtkPage::showGtkPreview()
{
gtkConfigInterface.call(QStringLiteral("showGtk3ThemePreview"), m_gtk3ThemesModel->selectedTheme());
gtkConfigInterface.call(QStringLiteral("showGtkThemePreview"), m_gtkThemesModel->selectedTheme());
}
void GtkPage::onThemeRemoved()
......@@ -139,20 +117,16 @@ void GtkPage::installGtkThemeFromFile(const QUrl &fileUrl)
void GtkPage::save()
{
gtkConfigInterface.call(QStringLiteral("setGtk2Theme"), m_gtk2ThemesModel->selectedTheme());
gtkConfigInterface.call(QStringLiteral("setGtk3Theme"), m_gtk3ThemesModel->selectedTheme());
gtkConfigInterface.call(QStringLiteral("setGtkTheme"), m_gtkThemesModel->selectedTheme());
}
void GtkPage::defaults()
{
Q_EMIT selectGtk2ThemeInCombobox(QStringLiteral("Breeze"));
Q_EMIT selectGtk3ThemeInCombobox(QStringLiteral("Breeze"));
Q_EMIT selectGtkThemeInCombobox(QStringLiteral("Breeze"));
}
void GtkPage::load()
{
m_gtk2ThemesModel->loadGtk2();
m_gtk3ThemesModel->loadGtk3();
Q_EMIT selectGtk2ThemeInCombobox(gtk2ThemeFromConfig());
Q_EMIT selectGtk3ThemeInCombobox(gtk3ThemeFromConfig());
m_gtkThemesModel->load();
Q_EMIT selectGtkThemeInCombobox(gtkThemeFromConfig());
}
......@@ -30,8 +30,7 @@ class GtkPage : public QObject
{
Q_OBJECT
Q_PROPERTY(GtkThemesModel *gtk2ThemesModel MEMBER m_gtk2ThemesModel NOTIFY gtk2ThemesModelChanged)
Q_PROPERTY(GtkThemesModel *gtk3ThemesModel MEMBER m_gtk3ThemesModel NOTIFY gtk3ThemesModelChanged)
Q_PROPERTY(GtkThemesModel *gtkThemesModel MEMBER m_gtkThemesModel NOTIFY gtkThemesModelChanged)
public:
GtkPage(QObject *parent = nullptr);
......@@ -42,14 +41,11 @@ public:
void defaults();
public Q_SLOTS:
QString gtk2ThemeFromConfig();
QString gtk3ThemeFromConfig();
QString gtkThemeFromConfig();
bool gtk2PreviewAvailable();
bool gtk3PreviewAvailable();
bool gtkPreviewAvailable();
void showGtk2Preview();
void showGtk3Preview();
void showGtkPreview();
void installGtkThemeFromFile(const QUrl &fileUrl);
......@@ -57,18 +53,15 @@ public Q_SLOTS:
void onGhnsEntriesChanged(const QQmlListReference &changedEnties);
Q_SIGNALS:
void gtk2ThemesModelChanged(GtkThemesModel *model);
void gtk3ThemesModelChanged(GtkThemesModel *model);
void gtkThemesModelChanged(GtkThemesModel *model);
void showErrorMessage(const QString &message);
void selectGtk2ThemeInCombobox(const QString &themeName);
void selectGtk3ThemeInCombobox(const QString &themeName);
void selectGtkThemeInCombobox(const QString &themeName);
void gtkThemeSettingsChanged();
private:
GtkThemesModel *m_gtk2ThemesModel;
GtkThemesModel *m_gtk3ThemesModel;
GtkThemesModel *m_gtkThemesModel;
QDBusInterface gtkConfigInterface;
};
......@@ -35,23 +35,7 @@ GtkThemesModel::GtkThemesModel(QObject* parent)
}
void GtkThemesModel::loadGtk2()
{
QMap<QString, QString> gtk2ThemesNames;
for (const QString &possibleThemePath : possiblePathsToThemes()) {
// If the directory has a gtk-2.0 directory inside, it is the GTK2 theme for sure
QDir possibleThemeDirectory(possibleThemePath);
bool hasGtk2DirectoryInside = possibleThemeDirectory.exists(QStringLiteral("gtk-2.0"));
if (hasGtk2DirectoryInside) {
gtk2ThemesNames.insert(possibleThemeDirectory.dirName(), possibleThemeDirectory.path());
}
}
setThemesList(gtk2ThemesNames);
}
void GtkThemesModel::loadGtk3()
void GtkThemesModel::load()
{
QMap<QString, QString> gtk3ThemesNames;
......
......@@ -39,8 +39,7 @@ public:
ThemePathRole
};
void loadGtk2();
void loadGtk3();
void load();
void setThemesList(const QMap<QString, QString> &themes);
QMap<QString, QString> themesList();
......
......@@ -55,81 +55,41 @@ Kirigami.Page {
wideMode: true
Row {
Kirigami.FormData.label: i18n("GTK2 theme:")
Kirigami.FormData.label: i18n("GTK theme:")
Flow {
spacing: Kirigami.Units.smallSpacing
QtControls.ComboBox {
id: gtk2ThemeCombo
model: kcm.gtkPage.gtk2ThemesModel
currentIndex: model.findThemeIndex(kcm.gtkPage.gtk2ThemeFromConfig())
id: gtkThemeCombo
model: kcm.gtkPage.gtkThemesModel
currentIndex: model.findThemeIndex(kcm.gtkPage.gtkThemeFromConfig())
onCurrentTextChanged: function() {
model.selectedTheme = currentText
gtk2RemoveButton.enabled = model.selectedThemeRemovable()
gtkRemoveButton.enabled = model.selectedThemeRemovable()
}
onActivated: model.setSelectedThemeDirty()
textRole: "theme-name"
Connections {
target: kcm.gtkPage
onSelectGtk2ThemeInCombobox: function(themeName) {
gtk2ThemeCombo.currentIndex = gtk2ThemeCombo.model.findThemeIndex(themeName)
onSelectGtkThemeInCombobox: function(themeName) {
gtkThemeCombo.currentIndex = gtkThemeCombo.model.findThemeIndex(themeName)
}
}
}
QtControls.Button {
id: gtk2RemoveButton
id: gtkRemoveButton
icon.name: "edit-delete"
onClicked: gtk2ThemeCombo.model.removeSelectedTheme()
onClicked: gtkThemeCombo.model.removeSelectedTheme()
}
QtControls.Button {
icon.name: "preview"
text: i18n("Preview...")
onClicked: kcm.gtkPage.showGtk2Preview()
visible: kcm.gtkPage.gtk2PreviewAvailable()
}
}
}
Row {
Kirigami.FormData.label: i18n("GTK3 theme:")
Flow {
spacing: Kirigami.Units.smallSpacing
QtControls.ComboBox {
id: gtk3ThemeCombo
model: kcm.gtkPage.gtk3ThemesModel
currentIndex: model.findThemeIndex(kcm.gtkPage.gtk3ThemeFromConfig())
onCurrentTextChanged: function() {
model.selectedTheme = currentText
gtk3RemoveButton.enabled = model.selectedThemeRemovable()
}
onActivated: model.setSelectedThemeDirty()
textRole: "theme-name"
Connections {
target: kcm.gtkPage
onSelectGtk3ThemeInCombobox: function(themeName) {
gtk3ThemeCombo.currentIndex = gtk3ThemeCombo.model.findThemeIndex(themeName)
}
}
}
QtControls.Button {
id: gtk3RemoveButton
icon.name: "edit-delete"
onClicked: gtk3ThemeCombo.model.removeSelectedTheme()
}
QtControls.Button {
icon.name: "preview"
text: i18n("Preview...")
onClicked: kcm.gtkPage.showGtk3Preview()
visible: kcm.gtkPage.gtk3PreviewAvailable()
onClicked: kcm.gtkPage.showGtkPreview()
visible: kcm.gtkPage.gtkPreviewAvailable()
}
}
......@@ -152,50 +112,12 @@ Kirigami.Page {
onClicked: fileDialogLoader.active = true
}
QtControls.Button {
icon.name: "get-hot-new-stuff"
text: i18n("Download New GNOME/GTK Application Styles...")
onClicked: ghnsMenu.open()
QtControls.Menu {
id: ghnsMenu
QtControls.MenuItem {
icon.name: "get-hot-new-stuff"
text: i18n("Download New GNOME/GTK2 Application Styles...")
onClicked: function() {
ghnsMenu.close()
gtk2NewStuffButton.showDialog()
}
NewStuff.Button {
id: gtk2NewStuffButton
downloadNewWhat: i18n("GNOME/GTK2 Application Styles")
configFile: "gtk2_themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.gtkPage.onGhnsEntriesChanged(gtk2NewStuffButton.changedEntries);
visible: false
}
}
QtControls.MenuItem {
icon.name: "get-hot-new-stuff"
text: i18n("Download New GNOME/GTK3 Application Styles...")
onClicked: function() {
ghnsMenu.close()
gtk3NewStuffButton.showDialog()
}
NewStuff.Button {
id: gtk3NewStuffButton
downloadNewWhat: i18n("GNOME/GTK3 Application Styles")
configFile: "gtk3_themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.gtkPage.onGhnsEntriesChanged(gtk3NewStuffButton.changedEntries);
visible: false
}
}
}
NewStuff.Button {
id: gtkNewStuffButton
text: i18n("Get New GNOME/GTK Application Styles...")
configFile: "gtk_themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.gtkPage.onGhnsEntriesChanged(gtkNewStuffButton.changedEntries);
}
}
}
......
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