From f4466ed7b6474a0b93c6fb6fb5c6105ffe97e731 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 1 Sep 2023 15:53:39 +0200 Subject: [PATCH] QmlDesigner: Apply theming to transient scrollbars Change-Id: Iea76d981447f2367615ce624da399ecb984cb662 Reviewed-by: Thomas Hartmann --- .../imports/HelperWidgets/ScrollBar.qml | 6 ++++-- .../imports/StudioTheme/ControlStyle.qml | 3 ++- .../imports/StudioTheme/Values.qml | 1 + .../projects/shared-plugin/name/Constants.qml.tpl | 2 +- share/qtcreator/themes/design-light.creatortheme | 5 +++-- share/qtcreator/themes/design.creatortheme | 5 +++-- src/libs/utils/theme/theme.h | 5 +++-- src/plugins/qmldesignerbase/studio/studiostyle.cpp | 7 ++++--- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml index 7a710e720d2..43456d46ddd 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml @@ -8,6 +8,8 @@ import StudioTheme 1.0 as StudioTheme T.ScrollBar { id: control + property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle + property bool show: false property bool otherInUse: false property bool isNeeded: control.size < 1.0 @@ -31,12 +33,12 @@ T.ScrollBar { implicitWidth: control.thickness implicitHeight: control.thickness radius: width / 2 - color: "#D9D9D9" + color: control.inUse ? control.style.scrollBar.handleHover : control.style.scrollBar.handle } background: Rectangle { id: controlTrack - color: "#D9D9D9" + color: control.style.scrollBar.track opacity: control.inUse || control.otherInUse ? 0.3 : 0.0 radius: width / 2 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/ControlStyle.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/ControlStyle.qml index a759560117d..460ff6db3f3 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/ControlStyle.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/ControlStyle.qml @@ -150,7 +150,8 @@ QtObject { component ScrollBarColors: QtObject { property color track: Values.themeScrollBarTrack - property color handle: Values.themeScrollBarHandle + property color handle: Values.themeScrollBarHandle_idle + property color handleHover: Values.themeScrollBarHandle } property ScrollBarColors scrollBar: ScrollBarColors {} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml index a1089313673..388f82d0470 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml @@ -383,6 +383,7 @@ QtObject { property color themeScrollBarTrack: Theme.color(Theme.DSscrollBarTrack) property color themeScrollBarHandle: Theme.color(Theme.DSscrollBarHandle) + property color themeScrollBarHandle_idle: Theme.color(Theme.DSscrollBarHandle_idle) property color themeSectionHeadBackground: Theme.color(Theme.DSsectionHeadBackground) diff --git a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl index 6fcae14ea65..cc5da7be55a 100644 --- a/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl +++ b/share/qtcreator/qmldesigner/studio_templates/projects/shared-plugin/name/Constants.qml.tpl @@ -21,7 +21,7 @@ QtObject { pixelSize: Qt.application.font.pixelSize * 1.6 }) - readonly property color backgroundColor: "#c2c2c2" + readonly property color backgroundColor: "#EAEAEA" @if %{IsQt6Project} diff --git a/share/qtcreator/themes/design-light.creatortheme b/share/qtcreator/themes/design-light.creatortheme index b0f34fcfbdd..46fc695570a 100644 --- a/share/qtcreator/themes/design-light.creatortheme +++ b/share/qtcreator/themes/design-light.creatortheme @@ -169,8 +169,9 @@ DSsliderHandleHover=ff606060 DSsliderHandleFocus=ff0492c9 DSsliderHandleInteraction=ff2aafd3 -DSscrollBarTrack=ffb5b4b4 -DSscrollBarHandle=ff9b9b9b +DSscrollBarTrack=smokeGrey +DSscrollBarHandle=shadowGrey +DSscrollBarHandle_idle=slateGrey DSsectionHeadBackground=ffd8d8d8 diff --git a/share/qtcreator/themes/design.creatortheme b/share/qtcreator/themes/design.creatortheme index 9a7065311ac..1d8295145e4 100644 --- a/share/qtcreator/themes/design.creatortheme +++ b/share/qtcreator/themes/design.creatortheme @@ -135,8 +135,9 @@ DSnavigatorTextSelected=highlightBlue QmlDesigner_BackgroundColorDarkAlternate=dawnGrey ;TODO -DSscrollBarTrack=dawnGrey -DSscrollBarHandle=offBlack +DSscrollBarTrack=smokeGrey +DSscrollBarHandle=concreteGrey +DSscrollBarHandle_idle=slateGrey DSdockWidgetTitleBar=dawnGrey DSdockWidgetSplitter=fullBlack diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index 7a24c7fbd03..c3aa8842818 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -342,6 +342,9 @@ public: DSpopoutButtonBorder_hover, DSpopoutButtonBorder_interaction, DSpopoutButtonBorder_disabled, + DSscrollBarTrack, + DSscrollBarHandle, + DSscrollBarHandle_idle, /*Legacy QtDS*/ DSiconColor, @@ -365,8 +368,6 @@ public: DSsliderHandleHover, DSsliderHandleFocus, DSsliderHandleInteraction, - DSscrollBarTrack, - DSscrollBarHandle, DSsectionHeadBackground, DSstateDefaultHighlight, DSstateSeparatorColor, diff --git a/src/plugins/qmldesignerbase/studio/studiostyle.cpp b/src/plugins/qmldesignerbase/studio/studiostyle.cpp index cec8a323686..59f19e9f5c7 100644 --- a/src/plugins/qmldesignerbase/studio/studiostyle.cpp +++ b/src/plugins/qmldesignerbase/studio/studiostyle.cpp @@ -736,7 +736,8 @@ void StudioStyle::drawComplexControl( bool enabled = scrollBar->state & QStyle::State_Enabled; bool hovered = enabled && scrollBar->state & QStyle::State_MouseOver; - QColor buttonColor = hovered ? "#D9D9D9" : "#9B9B9B"; + QColor buttonColor = creatorTheme()->color(hovered ? Theme::DSscrollBarHandle + : Theme::DSscrollBarHandle_idle); QColor gradientStartColor = buttonColor.lighter(118); QColor gradientStopColor = buttonColor; if (hasTransientStyle) { @@ -755,12 +756,12 @@ void StudioStyle::drawComplexControl( painter->save(); painter->setPen(Qt::NoPen); if (hasTransientStyle) { - QColor brushColor("#D9D9D9"); + QColor brushColor(creatorTheme()->color(Theme::DSscrollBarTrack)); brushColor.setAlpha(0.3 * 255); painter->setBrush(QBrush(brushColor)); painter->drawRoundedRect(scrollBarGroove, 4, 4); } else { - painter->setBrush(QBrush("#773E3E")); + painter->setBrush(QBrush(creatorTheme()->color(Theme::DSscrollBarTrack))); painter->drawRect(rect); } painter->restore();