Commit 5634d3a8 authored by David Redondo's avatar David Redondo 🏎

Use default scheme option of KColorSchemeManager if available

Since KF 5.67 Kcolorschememanager has a system theme option that reacts to system
theme changes so we don't need to read the system color scheme if the user didn't
set a custom scheme.
parent 03bed527
......@@ -63,7 +63,14 @@ QString ColorSchemeChooser::loadCurrentScheme() const
{
KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup cg(config, "UiSettings");
#if KCONFIGWIDGETS_VERSION >= QT_VERSION_CHECK(5, 67, 0)
// Since 5.67 KColorSchemeManager includes a system color scheme option that reacts to system
// scheme changes. This scheme will be activated if we pass an empty string to KColorSchemeManager
// So no need anymore to read the the current global scheme ourselves if no custom one is configured.
return cg.readEntry("ColorScheme");
#else
return cg.readEntry("ColorScheme", currentDesktopDefaultScheme());
#endif
}
void ColorSchemeChooser::saveCurrentScheme(const QString &name)
......@@ -74,6 +81,7 @@ void ColorSchemeChooser::saveCurrentScheme(const QString &name)
cg.sync();
}
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 67, 0)
QString ColorSchemeChooser::currentDesktopDefaultScheme() const
{
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
......@@ -85,6 +93,7 @@ QString ColorSchemeChooser::currentDesktopDefaultScheme() const
const QString name = KConfigGroup(schemeFile, "General").readEntry("Name", scheme);
return name;
}
#endif
QString ColorSchemeChooser::currentSchemeName() const
{
......@@ -93,7 +102,12 @@ QString ColorSchemeChooser::currentSchemeName() const
QAction* const action = menu()->activeAction();
if(action) return KLocalizedString::removeAcceleratorMarker(action->text());
#if KCONFIGWIDGETS_VERSION >= QT_VERSION_CHECK(5, 67, 0)
// See above
return QString();
#else
return currentDesktopDefaultScheme();
#endif
}
void ColorSchemeChooser::slotSchemeChanged(QAction* triggeredAction)
......
......@@ -23,6 +23,9 @@
#define COLORSCHEMECHOOSER_H
#include <QAction>
#include <QtGlobal>
#include <kconfigwidgets_version.h>
#include "mainwindow.h"
......@@ -47,7 +50,9 @@ private Q_SLOTS:
private:
QString loadCurrentScheme() const;
void saveCurrentScheme(const QString &name);
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 67, 0)
QString currentDesktopDefaultScheme() const;
#endif
};
} // namespace KDevelop
......
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