tools/designer/src/lib/shared/qdesigner_menu.cpp
changeset 18 2f34d5167611
parent 0 1918ee327afb
child 33 3e2da88830cd
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the Qt Designer of the Qt Toolkit.
     7 ** This file is part of the Qt Designer of the Qt Toolkit.
     8 **
     8 **
    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;