From c08dc1e04f4e9301621223d64b5b34ee9bbad84a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 13 Jun 2017 15:21:24 +0200 Subject: Read more KDE configuration in the KDE platform theme Adds the hints that are read and used by the plasma-integration platform theme, so naked Qt applications can integrate just as well on this front. Change-Id: I45a113e0081ea96c8cf543c22b28b69280ae7619 Reviewed-by: Friedemann Kleint Reviewed-by: David Faure --- .../themes/genericunix/qgenericunixthemes.cpp | 49 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 2b4c6a000f..323e8fd13b 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -264,10 +264,6 @@ public: QKdeThemePrivate(const QStringList &kdeDirs, int kdeVersion) : kdeDirs(kdeDirs) , kdeVersion(kdeVersion) - , toolButtonStyle(Qt::ToolButtonTextBesideIcon) - , toolBarIconSize(0) - , singleClick(true) - , wheelScrollLines(3) { } static QString kdeGlobals(const QString &kdeDir, int kdeVersion) @@ -290,10 +286,15 @@ public: QString iconThemeName; QString iconFallbackThemeName; QStringList styleNames; - int toolButtonStyle; - int toolBarIconSize; - bool singleClick; - int wheelScrollLines; + int toolButtonStyle = Qt::ToolButtonTextBesideIcon; + int toolBarIconSize = 0; + bool singleClick = true; + bool showIconsOnPushButtons = true; + int wheelScrollLines = 3; + int doubleClickInterval = 400; + int startDragDist = 10; + int startDragTime = 500; + int cursorBlinkRate = 1000; }; void QKdeThemePrivate::refresh() @@ -329,6 +330,10 @@ void QKdeThemePrivate::refresh() if (singleClickValue.isValid()) singleClick = singleClickValue.toBool(); + const QVariant showIconsOnPushButtonsValue = readKdeSetting(QStringLiteral("KDE/ShowIconsOnPushButtons"), kdeDirs, kdeVersion, kdeSettings); + if (showIconsOnPushButtonsValue.isValid()) + showIconsOnPushButtons = showIconsOnPushButtonsValue.toBool(); + const QVariant themeValue = readKdeSetting(QStringLiteral("Icons/Theme"), kdeDirs, kdeVersion, kdeSettings); if (themeValue.isValid()) iconThemeName = themeValue.toString(); @@ -352,6 +357,24 @@ void QKdeThemePrivate::refresh() if (wheelScrollLinesValue.isValid()) wheelScrollLines = wheelScrollLinesValue.toInt(); + const QVariant doubleClickIntervalValue = readKdeSetting(QStringLiteral("KDE/DoubleClickInterval"), kdeDirs, kdeVersion, kdeSettings); + if (doubleClickIntervalValue.isValid()) + doubleClickInterval = doubleClickIntervalValue.toInt(); + + const QVariant startDragDistValue = readKdeSetting(QStringLiteral("KDE/StartDragDist"), kdeDirs, kdeVersion, kdeSettings); + if (startDragDistValue.isValid()) + startDragDist = startDragDistValue.toInt(); + + const QVariant startDragTimeValue = readKdeSetting(QStringLiteral("KDE/StartDragTime"), kdeDirs, kdeVersion, kdeSettings); + if (startDragTimeValue.isValid()) + startDragTime = startDragTimeValue.toInt(); + + const QVariant cursorBlinkRateValue = readKdeSetting(QStringLiteral("KDE/CursorBlinkRate"), kdeDirs, kdeVersion, kdeSettings); + if (cursorBlinkRateValue.isValid()) { + cursorBlinkRate = cursorBlinkRateValue.toInt(); + cursorBlinkRate = cursorBlinkRate > 0 ? qBound(200, cursorBlinkRate, 2000) : 0; + } + // Read system font, ignore 'smallestReadableFont' if (QFont *systemFont = kdeFont(readKdeSetting(QStringLiteral("font"), kdeDirs, kdeVersion, kdeSettings))) resources.fonts[QPlatformTheme::SystemFont] = systemFont; @@ -527,7 +550,7 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const case QPlatformTheme::UseFullScreenForPopupMenu: return QVariant(true); case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: - return QVariant(true); + return QVariant(d->showIconsOnPushButtons); case QPlatformTheme::DialogButtonBoxLayout: return QVariant(QPlatformDialogHelper::KdeLayout); case QPlatformTheme::ToolButtonStyle: @@ -550,6 +573,14 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(d->singleClick); case QPlatformTheme::WheelScrollLines: return QVariant(d->wheelScrollLines); + case QPlatformTheme::MouseDoubleClickInterval: + return QVariant(d->doubleClickInterval); + case QPlatformTheme::StartDragTime: + return QVariant(d->startDragTime); + case QPlatformTheme::StartDragDistance: + return QVariant(d->startDragDist); + case QPlatformTheme::CursorFlashTime: + return QVariant(d->cursorBlinkRate); case QPlatformTheme::UiEffects: return QVariant(int(HoverEffect)); default: -- cgit v1.2.3