OSDN Git Service

show preview even of the desktop style
authorIvailo Monev <xakepa10@gmail.com>
Sun, 20 Nov 2022 16:51:12 +0000 (18:51 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 20 Nov 2022 16:51:12 +0000 (18:51 +0200)
the desktop style is now determined by QT_PLATFORM_PLUGIN and
DESKTOP_SESSION environment variables with fallback to cleanlooks style so
even if it is the fallback style there is something to show but if it is
not the fallback the user will be able to preview the style chosen by
QGuiPlatformPlugin

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/kernel/qguiplatformplugin.h
src/tools/qtconfig/mainwindow.cpp

index c0af11c..eb71db6 100644 (file)
@@ -73,7 +73,7 @@ class Q_GUI_EXPORT QGuiPlatformPlugin : public QObject
 };
 
 // internal
-QGuiPlatformPlugin *qt_guiPlatformPlugin();
+Q_GUI_EXPORT QGuiPlatformPlugin *qt_guiPlatformPlugin();
 
 QT_END_NAMESPACE
 
index c8aa503..71b03ff 100644 (file)
@@ -43,6 +43,7 @@
 #include <QCloseEvent>
 #include <QDebug>
 #include <QPixmap>
+#include <QGuiPlatformPlugin>
 
 #include <stdlib.h>
 
@@ -477,25 +478,26 @@ void MainWindow::paletteSelected(int)
 
 void MainWindow::updateStyleLayout()
 {
-    QString currentStyle = ui->guiStyleCombo->currentText();
-    bool autoStyle = (currentStyle == desktopThemeName);
-    ui->previewFrame->setPreviewVisible(!autoStyle);
-    ui->buildPaletteGroup->setEnabled(!autoStyle);
+    ui->previewFrame->setPreviewVisible(true);
+    ui->buildPaletteGroup->setEnabled(true);
 }
 
 void MainWindow::styleSelected(const QString &stylename)
 {
+    QString realstyle(stylename);
     if (stylename == desktopThemeName) {
-        setModified(true);
-    } else {
-        QStyle *style = QStyleFactory::create(stylename);
-        if (!style)
-            return;
-        setStyleHelper(ui->previewFrame, style);
-        delete previewstyle;
-        previewstyle = style;
-        setModified(true);
+        QGuiPlatformPlugin* platformplugin = qt_guiPlatformPlugin();
+        if (platformplugin) {
+            realstyle = platformplugin->styleName();
+        }
     }
+    QStyle *style = QStyleFactory::create(realstyle);
+    if (!style)
+        return;
+    setStyleHelper(ui->previewFrame, style);
+    delete previewstyle;
+    previewstyle = style;
+    setModified(true);
     updateStyleLayout();
 }