Changeset 29964 in vbox
- Timestamp:
- Jun 1, 2010 5:48:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp
r29915 r29964 20 20 /* Global includes */ 21 21 #include <QtGlobal> 22 #include <QHelpEvent> 22 23 #include <QToolTip> 23 24 … … 25 26 #include "UIActionsPool.h" 26 27 #include "VBoxGlobal.h" 28 29 /* Extended QMenu class used in UIActions */ 30 class QIMenu : public QMenu 31 { 32 Q_OBJECT; 33 34 public: 35 36 /* QIMenu constructor: */ 37 QIMenu(QWidget *pParent = 0) : QMenu(pParent), m_fShowToolTips(false) {} 38 39 /* Setter/getter for 'show-tool-tips' feature: */ 40 void setShowToolTips(bool fShowToolTips) { m_fShowToolTips = fShowToolTips; } 41 bool isToolTipsShown() const { return m_fShowToolTips; } 42 43 private: 44 45 /* Event handler reimplementation: */ 46 bool event(QEvent *pEvent) 47 { 48 /* Handle particular event-types: */ 49 switch (pEvent->type()) 50 { 51 /* Tool-tip request handler: */ 52 case QEvent::ToolTip: 53 { 54 /* Get current help-event: */ 55 QHelpEvent *pHelpEvent = static_cast<QHelpEvent*>(pEvent); 56 /* Get action which caused help-event: */ 57 QAction *pAction = actionAt(pHelpEvent->pos()); 58 /* If action present => show action's tool-tip if needed: */ 59 if (pAction && m_fShowToolTips) 60 QToolTip::showText(pHelpEvent->globalPos(), pAction->toolTip()); 61 break; 62 } 63 default: 64 break; 65 } 66 /* Base-class event-handler: */ 67 return QMenu::event(pEvent); 68 } 69 70 /* Reflects 'show-tool-tip' feature activity: */ 71 bool m_fShowToolTips; 72 }; 27 73 28 74 /* Action activation event */ … … 120 166 if (!strIcon.isNull()) 121 167 setIcon(VBoxGlobal::iconSet(strIcon, strIconDis)); 122 setMenu(new Q Menu);168 setMenu(new QIMenu); 123 169 } 124 170 }; … … 593 639 ":/usb_16px.png", ":/usb_disabled_16px.png") 594 640 { 641 qobject_cast<QIMenu*>(menu())->setShowToolTips(true); 595 642 retranslateUi(); 596 643 } … … 601 648 { 602 649 menu()->setTitle(QApplication::translate("UIActionsPool", "&USB Devices")); 603 connect(menu(), SIGNAL(hovered(QAction*)), this, SLOT(sltPopupToolTip(QAction*)));604 }605 606 private slots:607 608 void sltPopupToolTip(QAction *pAction)609 {610 QToolTip::showText(QCursor::pos(), pAction->toolTip());611 650 } 612 651 };
Note:
See TracChangeset
for help on using the changeset viewer.