From 77951ce927a0b2b1c1fae540be8d85368318e18d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 1 Jul 2022 16:00:40 +0200 Subject: Native style, StyleItemScrollbar: don't draw the scrollbar as sunken when using an override state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we specify an override state from QML, like NeverHovered, we also don't want the scrollbar to be drawn as pressed (sunken). The point with the override state is to lock the image to a certain state that doesn't change. This will fix a drawing issue on macOS, where the scrollbar becomes far too dark when you drag on it. Change-Id: I7f62e7ebd6d1ebbe808e035f63485ed292661bc1 Reviewed-by: Jan Arve Sæther (cherry picked from commit 5a8ac8f3d57c5381afb6a4d79990b0d7a5298936) Reviewed-by: Qt Cherry-pick Bot --- src/quicknativestyle/items/qquickstyleitemscrollbar.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quicknativestyle/items/qquickstyleitemscrollbar.cpp b/src/quicknativestyle/items/qquickstyleitemscrollbar.cpp index 32e7066836..c328ab6d1f 100644 --- a/src/quicknativestyle/items/qquickstyleitemscrollbar.cpp +++ b/src/quicknativestyle/items/qquickstyleitemscrollbar.cpp @@ -101,8 +101,10 @@ void QQuickStyleItemScrollBar::initStyleOption(QStyleOptionSlider &styleOption) // the handle, depending on if it's hovered or not if (m_overrideState == AlwaysHovered) { + styleOption.state &= ~QStyle::State_Sunken; styleOption.activeSubControls = (styleOption.subControls & (QStyle::SC_ScrollBarSlider | QStyle::SC_ScrollBarGroove | QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)); } else if (m_overrideState == NeverHovered) { + styleOption.state &= ~QStyle::State_Sunken; styleOption.activeSubControls &= ~(styleOption.subControls & (QStyle::SC_ScrollBarSlider | QStyle::SC_ScrollBarGroove | QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)); } else if (m_overrideState == AlwaysSunken) { styleOption.state |= QStyle::State_Sunken; -- cgit v1.2.3