tools/designer/src/lib/shared/qdesigner_menu.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
    86     }
    86     }
    87 }
    87 }
    88 
    88 
    89 QDesignerMenu::QDesignerMenu(QWidget *parent) :
    89 QDesignerMenu::QDesignerMenu(QWidget *parent) :
    90     QMenu(parent),
    90     QMenu(parent),
       
    91     m_subMenuPixmap(QPixmap(QLatin1String(":/trolltech/formeditor/images/submenu.png"))),
    91     m_currentIndex(0),
    92     m_currentIndex(0),
    92     m_addItem(new SpecialMenuAction(this)),
    93     m_addItem(new SpecialMenuAction(this)),
    93     m_addSeparator(new SpecialMenuAction(this)),
    94     m_addSeparator(new SpecialMenuAction(this)),
    94     m_showSubMenuTimer(new QTimer(this)),
    95     m_showSubMenuTimer(new QTimer(this)),
    95     m_deactivateWindowTimer(new QTimer(this)),
    96     m_deactivateWindowTimer(new QTimer(this)),
   548     fw->commandHistory()->push(cmd);
   549     fw->commandHistory()->push(cmd);
   549 }
   550 }
   550 
   551 
   551 QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
   552 QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
   552 {
   553 {
   553     static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
       
   554     const QRect g = actionGeometry(action);
   554     const QRect g = actionGeometry(action);
   555     const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2;
   555     const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - m_subMenuPixmap.width() - 2) : 2;
   556     const int y = g.top() + (g.height() - pm.height())/2 + 1;
   556     const int y = g.top() + (g.height() - m_subMenuPixmap.height())/2 + 1;
   557     return QRect(x, y, pm.width(), pm.height());
   557     return QRect(x, y, m_subMenuPixmap.width(), m_subMenuPixmap.height());
   558 }
   558 }
   559 
   559 
   560 bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const
   560 bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const
   561 {
   561 {
   562     return action != 0
   562     return action != 0
   589             lg.setColorAt(0.7, QColor(0, 0, 0, 32));
   589             lg.setColorAt(0.7, QColor(0, 0, 0, 32));
   590             lg.setColorAt(1.0, Qt::transparent);
   590             lg.setColorAt(1.0, Qt::transparent);
   591 
   591 
   592             p.fillRect(g, lg);
   592             p.fillRect(g, lg);
   593         } else if (hasSubMenuPixmap(a)) {
   593         } else if (hasSubMenuPixmap(a)) {
   594             static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
   594             p.drawPixmap(subMenuPixmapRect(a).topLeft(), m_subMenuPixmap);
   595             p.drawPixmap(subMenuPixmapRect(a).topLeft(), pm);
       
   596         }
   595         }
   597     }
   596     }
   598 
   597 
   599     if (!hasFocus() || !current || m_dragging)
   598     if (!hasFocus() || !current || m_dragging)
   600         return;
   599         return;