diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ include(KDECMakeSettings) set(REQUIRED_QT_VERSION 5.5.0) -find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets DBus X11Extras) +find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets DBus X11Extras QuickControls2) set(KF5_DEP_VERSION "5.33.0") diff --git a/src/platformtheme/CMakeLists.txt b/src/platformtheme/CMakeLists.txt --- a/src/platformtheme/CMakeLists.txt +++ b/src/platformtheme/CMakeLists.txt @@ -47,6 +47,7 @@ PRIVATE Qt5::DBus Qt5::X11Extras + Qt5::QuickControls2 KF5::ConfigWidgets KF5::ConfigCore KF5::IconThemes diff --git a/src/platformtheme/kdeplatformtheme.cpp b/src/platformtheme/kdeplatformtheme.cpp --- a/src/platformtheme/kdeplatformtheme.cpp +++ b/src/platformtheme/kdeplatformtheme.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -394,15 +395,19 @@ //force QtQuickControls2 to use the desktop theme as default void KdePlatformTheme::setQtQuickControlsTheme() { - //if the user has explicitly set something else, don't meddle - if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) { + //if the user is running only a QGuiApplication, explicitely unset the QQC1 desktop style and abort + //as this style is all about QWidgets and we know setting this will make it crash + if (!qobject_cast(qApp)) { + if (qgetenv("QT_QUICK_CONTROLS_1_STYLE").right(7) == "Desktop") { + qunsetenv("QT_QUICK_CONTROLS_1_STYLE"); + } return; } - //if the user is running only a QGuiApplication. Abort as this style is all about QWidgets and we know setting this will make it crash - if (!qobject_cast(qApp)) { + //if the user has explicitly set something else, don't meddle + if (!QQuickStyle::name().isEmpty()) { return; } - qputenv("QT_QUICK_CONTROLS_STYLE", "org.kde.desktop"); + QQuickStyle::setStyle(QLatin1String("org.kde.desktop")); } #include "kdeplatformtheme.moc"