aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle/items
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-08-26 11:02:25 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-08-26 09:40:45 +0000
commit2812d380e5999733aaaf2ace2bdbd0702ce293dc (patch)
tree5e986c7d33e4e550362ccb2783ab2c7e2579e690 /src/imports/nativestyle/items
parente8fcd9c1388d5a070b0a4fa39783f2a5339b9d6c (diff)
Native style: add hover effects to ScrollBar on macOS
Change-Id: I61bb0c2b1fd4dce2939bc4fe91a498a280802cb9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/nativestyle/items')
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp11
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemscrollbar.h17
2 files changed, 28 insertions, 0 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp b/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
index 7a462082..72f850a8 100644
--- a/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitemscrollbar.cpp
@@ -83,6 +83,17 @@ void QQuickStyleItemScrollBar::initStyleOption(QStyleOptionSlider &styleOption)
if (scrollBar->isPressed())
styleOption.state |= QStyle::State_Sunken;
+#ifdef Q_OS_MACOS
+ if (m_overrideState != None) {
+ // In ScrollBar.qml we fade between two versions of
+ // the handle, depending on if it's hovered or not
+ if (m_overrideState & AlwaysHovered)
+ styleOption.state |= QStyle::State_Sunken;
+ else if (m_overrideState & NeverHovered)
+ styleOption.state &= ~QStyle::State_Sunken;
+ }
+#endif
+
// The following values will let the handle fill 100% of the
// groove / imageSize. But when the handle is resized by
// QQuickScrollBar, it will end up with the correct size visually.
diff --git a/src/imports/nativestyle/items/qquickstyleitemscrollbar.h b/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
index e181d4ec..db241ad8 100644
--- a/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
+++ b/src/imports/nativestyle/items/qquickstyleitemscrollbar.h
@@ -46,6 +46,10 @@ class QQuickStyleItemScrollBar : public QQuickStyleItem
Q_PROPERTY(SubControl subControl MEMBER m_subControl)
+#ifdef Q_OS_MACOS
+ Q_PROPERTY(OverrideState overrideState MEMBER m_overrideState)
+#endif
+
QML_NAMED_ELEMENT(ScrollBar)
public:
@@ -55,6 +59,15 @@ public:
};
Q_ENUM(SubControl)
+#ifdef Q_OS_MACOS
+ enum OverrideState {
+ None = 0,
+ AlwaysHovered,
+ NeverHovered,
+ };
+ Q_ENUM(OverrideState)
+#endif
+
QFont styleFont(QQuickItem *control) override;
protected:
@@ -67,6 +80,10 @@ private:
private:
SubControl m_subControl = Groove;
+
+#ifdef Q_OS_MACOS
+ OverrideState m_overrideState = None;
+#endif
};
#endif // QQUICKSTYLEITEMSCROLLBAR_H