summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2016-02-05 16:41:20 -0800
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2016-02-11 04:50:36 +0000
commit9e8c84aa14ee26c04ab04ff28f0bab22e04887d6 (patch)
tree5136a2afb0bdcdfa5e0e27adebe5c02f4fa3d411 /src/widgets/styles
parentcc2938b5b6aa07210b04bd48ad8a2830701a06e5 (diff)
Add SH_ItemView_ScrollMode style hint and use it in QMacStyle
On OS X, the default scrolling mode of item views should be per pixel instead of per item. We enforce this through a new style hint. On all other platforms, the behavior remains the same. It's still possible to override the style hint by using the regular scroll mode setters. Any subsequent style change will result in a no-op once the setters have been called and until the properties are reset. Some auto-tests had to be update to to take the new behavior into account. [ChangeLog][QtWidgets][Styles] Added SH_ItemView_ScrollMode style hint. [ChangeLog][QtWidgets][Item Views] Item views scroll per pixel on OS X now. [ChangeLog][QtWidgets][Item Views] QAbstractItemView::verticalScrollMode and QAbstractItemView::horizontalScrollMode are now resettable. Change-Id: I3f923275c99aa4389323b52fc1c5455fe71f8d73 Task-number: QTBUG-50102 Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp3
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm3
-rw-r--r--src/widgets/styles/qstyle.cpp4
-rw-r--r--src/widgets/styles/qstyle.h1
4 files changed, 11 insertions, 0 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 17c2ea2ba8..c28a70e3f9 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5215,6 +5215,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Splitter_OpaqueResize:
ret = true;
break;
+ case SH_ItemView_ScrollMode:
+ ret = QAbstractItemView::ScrollPerItem;
+ break;
default:
ret = 0;
break;
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 009cc1b1b0..74554f6d3d 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -3043,6 +3043,9 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay;
}
break;
+ case SH_ItemView_ScrollMode:
+ ret = QAbstractItemView::ScrollPerPixel;
+ break;
default:
ret = QCommonStyle::styleHint(sh, opt, w, hret);
break;
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 34d5b49ee1..26bb227e29 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1978,6 +1978,10 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
tab is changed while dragging over the tabbar, in milliseconds. This
enum value has been introduced in Qt 5.4
+ \value SH_ItemView_ScrollMode The default vertical and horizontal scroll mode as specified
+ by the style. Can be overridden with QAbstractItemView::setVerticalScrollMode() and
+ QAbstractItemView::setHorizontalScrollMode(). This enum value has been introduced in Qt 5.7.
+
\sa styleHint()
*/
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 425acc8301..0f9c9379f5 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -732,6 +732,7 @@ public:
SH_Menu_SubMenuSloppyCloseTimeout,
SH_Menu_SubMenuResetWhenReenteringParent,
SH_Menu_SubMenuDontStartSloppyOnLeave,
+ SH_ItemView_ScrollMode,
// Add new style hint values here
SH_CustomBase = 0xf0000000