Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Add System theme, use when switching to Mac style

Freya Lupen726bee4e1ad1
diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cpp
index a4ef9a822f..84bc0912db 100644
--- a/libs/ui/KisMainWindow.cpp
+++ b/libs/ui/KisMainWindow.cpp
@@ -2449,6 +2449,17 @@ void KisMainWindow::slotUpdateWidgetStyle()
cfg.setWidgetStyle(key);
qApp->setProperty(currentUnderlyingStyleNameProperty, key);
qApp->setStyle(key);
+
+ // When switching to a style that uses system colors, reset the theme
+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
+ if (qApp->style()->name() == "macintosh") {
+ d->themeManager->setCurrentTheme("System");
+ }
+#else
+ if (qApp->style()->name() == "macos") {
+ d->themeManager->setCurrentTheme("System");
+ }
+#endif
}
}
}
diff --git a/libs/ui/thememanager.cpp b/libs/ui/thememanager.cpp
index 8327362702..3c88e709fd 100644
--- a/libs/ui/thememanager.cpp
+++ b/libs/ui/thememanager.cpp
@@ -132,6 +132,12 @@ void ThemeManager::setCurrentTheme(const QString& name)
void ThemeManager::slotChangePalette()
{
+ if (currentThemeName() == "System") {
+ qApp->setPalette(QPalette());
+ Q_EMIT signalThemeChanged();
+ return;
+ }
+
//qDebug() << "slotChangePalette" << sender();
// We must clear the icon cache before the palette is changed. That way
@@ -227,6 +233,11 @@ void ThemeManager::populateThemeMenu()
actionMap.insert(name, action);
}
+ // Add a "System" theme, which resets the palette to system colors
+ action = new QAction("System", d->themeMenuActionGroup);
+ action->setCheckable(true);
+ actionMap.insert("System", action);
+
// sort the list
QStringList actionMapKeys = actionMap.keys();
actionMapKeys.sort();