OSDN Git Service

QMenuPrivate cleanup
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 27 May 2019 20:10:15 +0000 (20:10 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 27 May 2019 20:10:15 +0000 (20:10 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/widgets/qmenu.cpp
src/gui/widgets/qmenu_p.h

index 6aa5ed2..949531a 100644 (file)
@@ -86,7 +86,7 @@ class QTornOffMenu : public QMenu
         Q_DECLARE_PUBLIC(QMenu)
     public:
         QTornOffMenuPrivate(QMenu *p) : causedMenu(p) {
-            tornoff = 1;
+            tornoff = true;
             causedPopup.widget = 0;
             causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action;
             causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack();
@@ -229,7 +229,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
         if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action))
             continue;
         //..and some members
-        hasCheckableItems |= action->isCheckable();
+        hasCheckableItems = (!hasCheckableItems && action->isCheckable());
         QIcon is = action->icon();
         if (!is.isNull()) {
             maxIconWidth = qMax<uint>(maxIconWidth, icone + 4);
@@ -503,7 +503,7 @@ void QMenuPrivate::setFirstActionActive()
 void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason reason, bool activateFirst)
 {
     Q_Q(QMenu);
-    tearoffHighlighted = 0;
+    tearoffHighlighted = false;
     // Reselect the currently active action in case mouse moved over other menu items when
     // moving from sub menu action to sub menu (QTBUG-20094).
     if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
@@ -908,7 +908,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
         q->update(tearRect);
         if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) {
             setCurrentAction(0);
-            tearoffHighlighted = 1;
+            tearoffHighlighted = true;
             if (e->type() == QEvent::MouseButtonRelease) {
                 if (!tornPopup)
                     tornPopup = new QTornOffMenu(q);
@@ -918,7 +918,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
             }
             return true;
         }
-        tearoffHighlighted = 0;
+        tearoffHighlighted = false;
     }
 
     if (q->frameGeometry().contains(e->globalPos())) //otherwise if the event is in our rect we want it..
@@ -1703,7 +1703,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
         d->scroll->scrollOffset = 0;
         d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
     }
-    d->tearoffHighlighted = 0;
+    d->tearoffHighlighted = false;
     d->motions = 0;
     d->doChildEffects = true;
     d->updateLayoutDirection();
@@ -2437,7 +2437,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
                             break;
                         }
                         if (!nextAction && d->tearoff)
-                            d->tearoffHighlighted = 1;
+                            d->tearoffHighlighted = true;
                     } else {
                         y += d->actionRects.at(i).height();
                         for(int next_i = i+1; true; next_i++) {
index b4cf81a..54788b4 100644 (file)
@@ -79,8 +79,8 @@ public:
                       selectAction(0),
                       cancelAction(0),
 #endif
-                      scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
-                      hasCheckableItems(0), sloppyDelayTimer(0), sloppyAction(0), doChildEffects(false)
+                      scroll(0), eventLoop(0), tearoff(false), tornoff(false), tearoffHighlighted(false),
+                      hasCheckableItems(false), sloppyDelayTimer(0), sloppyAction(0), doChildEffects(false)
     { }
     ~QMenuPrivate()
     {
@@ -175,7 +175,9 @@ public:
     inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }
 
     //tear off support
-    uint tearoff : 1, tornoff : 1, tearoffHighlighted : 1;
+    bool tearoff;
+    bool tornoff;
+    bool tearoffHighlighted;
     QPointer<QTornOffMenu> tornPopup;
 
     mutable bool hasCheckableItems;