summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenu_p.h
diff options
context:
space:
mode:
authorDongmei Wang <dongmei.wang@qt.io>2016-10-04 13:05:15 -0700
committerDongmei Wang <dongmei.wang@qt.io>2016-10-27 05:28:09 +0000
commitc8c3d39e2116251133fb3ee25b615a1522685861 (patch)
treef0c2f1e9c798efa86bac1a20d400a60b08fde740 /src/widgets/widgets/qmenu_p.h
parent7f0d43fd332519e2689ffbff8198590d768864bc (diff)
Paint menu scrollers, tear off on top of QWidgetAction items
The menu scrollers and the tear off items are painted in the layer of QMenu. In a case that QMenu contains QWidgetAction items, the items are painted under QWidgetAction items. They are visually hidden unless QWidgetAction items' background is transparent. The tear off doesn't work since QWidgetAction item on top of it grabs mouse events. To fix the issue, add two child widgets in QMenu, paint the scroll up and the tear off items in one child widget and the scroll down item in the other one. Both child widgets are painted on top of overlapping sibling menu item widgets. Change-Id: I7eaef21b667b388fbb78b60664f4a4bd91215309 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu_p.h')
-rw-r--r--src/widgets/widgets/qmenu_p.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 3166e6f6cd..64291e842f 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -276,7 +276,8 @@ public:
cancelAction(0),
#endif
scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
- hasCheckableItems(0), doChildEffects(false), platformMenu(0)
+ hasCheckableItems(0), doChildEffects(false), platformMenu(0),
+ scrollUpTearOffItem(nullptr), scrollDownItem(nullptr)
{ }
~QMenuPrivate()
@@ -445,6 +446,24 @@ public:
QPointer<QAction> actionAboutToTrigger;
QPointer<QWidget> noReplayFor;
+
+ class ScrollerTearOffItem : public QWidget {
+ public:
+ enum Type { ScrollUp, ScrollDown };
+ ScrollerTearOffItem(Type type, QMenuPrivate *mPrivate,
+ QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ void updateScrollerRects(const QRect &rect);
+
+ private:
+ QMenuPrivate *menuPrivate;
+ Type scrollType;
+ };
+ ScrollerTearOffItem *scrollUpTearOffItem;
+ ScrollerTearOffItem *scrollDownItem;
+
+ void drawScroller(QPainter *painter, ScrollerTearOffItem::Type type, const QRect &rect);
+ void drawTearOff(QPainter *painter, const QRect &rect);
};
#endif // QT_NO_MENU