File 2001-themes.patch of Package kf6-ktexteditor
diff --git a/src/utils/kateconfig.cpp b/src/utils/kateconfig.cpp
index c57cdbeb31b4710cb1d4a101a6283c2f33333faa..6d31c23c25d2468bffd7af8504319316144c77d6 100644
--- a/src/utils/kateconfig.cpp
+++ b/src/utils/kateconfig.cpp
@@ -667,6 +667,8 @@ KateRendererConfig::KateRendererConfig()
// Init all known config entries
addConfigEntry(ConfigEntry(AutoColorThemeSelection, "Auto Color Theme Selection", QString(), true));
+ addConfigEntry(ConfigEntry(DefaultLightTheme, "Default Light Theme", QString(), QString()));
+ addConfigEntry(ConfigEntry(DefaultDarkTheme, "Default Dark Theme", QString(), QString()));
// Never forget to finalize or the <CommandName> becomes not available
finalizeConfigEntries();
@@ -877,9 +879,14 @@ void KateRendererConfig::setSchemaInternal(const QString &schema)
// for the global config, we honor the auto selection based on the palette
// do the same if the set theme really doesn't exist, we need a valid theme or the rendering will be broken in bad ways!
if ((isGlobal() && value(AutoColorThemeSelection).toBool()) || !KateHlManager::self()->repository().theme(schema).isValid()) {
- // always choose some theme matching the current application palette
- // we will arrive here after palette changed signals, too!
- m_schema = KateHlManager::self()->repository().themeForPalette(qGuiApp->palette()).name();
+ const QPalette uiPalette = qGuiApp->palette();
+ const bool isDarkUi = uiPalette.color(QPalette::Base).lightness() < 128;
+ m_schema = value(isDarkUi ? DefaultDarkTheme : DefaultLightTheme).toString();
+ if (m_schema.isEmpty() || !KateHlManager::self()->repository().theme(m_schema).isValid()) {
+ // always choose some theme matching the current application palette
+ // we will arrive here after palette changed signals, too!
+ m_schema = KateHlManager::self()->repository().themeForPalette(uiPalette).name();
+ }
} else {
// take user given theme 1:1
m_schema = schema;
diff --git a/src/utils/kateconfig.h b/src/utils/kateconfig.h
index eac0c484e7198b17925c8e8a65b105e2c4e37c58..ab4d5a40c0d8d3adf33add5fe0e65a123bf5f949 100644
--- a/src/utils/kateconfig.h
+++ b/src/utils/kateconfig.h
@@ -1375,7 +1375,9 @@ public:
/**
* auto-select the color theme based on application palette
*/
- AutoColorThemeSelection
+ AutoColorThemeSelection,
+ DefaultLightTheme,
+ DefaultDarkTheme,
};
public: