From 07695b0e6ada07af61c96a441ae61a5ee31aa82f Mon Sep 17 00:00:00 2001 From: reionwong Date: Sat, 11 Sep 2021 17:35:56 +0800 Subject: [PATCH] Improve MenuProxy --- debian/control | 1 + gmenuproxy/menuproxy.cpp | 38 ++++++++++++++++++-------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/debian/control b/debian/control index ba7cd67..1c56d04 100644 --- a/debian/control +++ b/debian/control @@ -24,6 +24,7 @@ Build-Depends: cmake, libpolkit-agent-1-dev, libkf5windowsystem-dev, libkf5globalaccel-dev, + libkf5coreaddons-dev, libqt5x11extras5-dev, qtbase5-dev, qtdeclarative5-dev, diff --git a/gmenuproxy/menuproxy.cpp b/gmenuproxy/menuproxy.cpp index 09ceee6..6c8b2ab 100644 --- a/gmenuproxy/menuproxy.cpp +++ b/gmenuproxy/menuproxy.cpp @@ -221,26 +221,24 @@ void MenuProxy::writeGtk3Settings() // mostly taken from kde-gtk-config QSettings cfg(gtk3SettingsIniPath(), QSettings::IniFormat); - // cfg.beginGroup("Settings"); - // auto cfg = KSharedConfig::openConfig(gtk3SettingsIniPath(), KConfig::NoGlobals); - // KConfigGroup group(cfg, "Settings"); - - // QStringList gtkModules = group.readEntry("gtk-modules", QString()).split(QLatin1Char(':'), Qt::SkipEmptyParts); - // addOrRemoveAppMenuGtkModule(gtkModules); - - // if (!gtkModules.isEmpty()) { - // group.writeEntry("gtk-modules", gtkModules.join(QLatin1Char(':'))); - // } else { - // group.deleteEntry("gtk-modules"); - // } - - // qDebug() << " gtk-modules:" << gtkModules; - - // if (m_enabled) { - // group.writeEntry("gtk-shell-shows-menubar", 1); - // } else { - // group.deleteEntry("gtk-shell-shows-menubar"); - // } + cfg.beginGroup(QStringLiteral("Settings")); + + QStringList gtkModules = cfg.value(QStringLiteral("gtk-modules")).toString().split(QLatin1Char(':')); + addOrRemoveAppMenuGtkModule(gtkModules); + + if (!gtkModules.isEmpty()) { + cfg.setValue(QStringLiteral("gtk-modules"), gtkModules.join(QLatin1Char(':'))); + } else { + cfg.remove(QStringLiteral("gtk-modules")); + } + + qDebug() << " gtk-modules:" << gtkModules; + + if (m_enabled) { + cfg.setValue(QStringLiteral("gtk-shell-shows-menubar"), 1); + } else { + cfg.remove(QStringLiteral("gtk-shell-shows-menubar")); + } qDebug() << " gtk-shell-shows-menubar:" << (m_enabled ? 1 : 0);