Changeset 47761 in vbox
- Timestamp:
- Aug 15, 2013 1:02:43 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIWarningPane.cpp
r47616 r47761 21 21 #include <QHBoxLayout> 22 22 #include <QLabel> 23 #include <QEvent> 23 24 24 25 /* GUI includes: */ … … 29 30 , m_pLabelIcon(0) 30 31 , m_pLabelText(0) 32 , m_fHovered(false) 31 33 { 32 34 /* Prepare: */ … … 52 54 void UIWarningPane::prepareContent() 53 55 { 56 /* Configure self: */ 57 setMouseTracking(true); 58 installEventFilter(this); 54 59 /* Create layout: */ 55 60 QHBoxLayout *pLayout = new QHBoxLayout(this); … … 59 64 /* Create icon label: */ 60 65 m_pLabelIcon = new QLabel; 66 { 67 /* Configure icon label: */ 68 m_pLabelIcon->setMouseTracking(true); 69 m_pLabelIcon->installEventFilter(this); 70 } 61 71 /* Create text label: */ 62 72 m_pLabelText = new QLabel; 73 { 74 /* Configure text label: */ 75 m_pLabelText->setMouseTracking(true); 76 m_pLabelText->installEventFilter(this); 77 } 63 78 /* Add widgets into layout: */ 64 79 pLayout->addWidget(m_pLabelIcon); … … 67 82 } 68 83 84 bool UIWarningPane::eventFilter(QObject *pWatched, QEvent *pEvent) 85 { 86 /* Depending on event-type: */ 87 switch (pEvent->type()) 88 { 89 /* Anything is hovered: */ 90 case QEvent::MouseMove: 91 { 92 /* Hover warning-pane if not yet hovered: */ 93 if (!m_fHovered) 94 { 95 m_fHovered = true; 96 emit sigHoverEnter(); 97 } 98 break; 99 } 100 /* Warning-pane is unhovered: */ 101 case QEvent::Leave: 102 { 103 /* Unhover warning-pane if hovered: */ 104 if (pWatched == this && m_fHovered) 105 { 106 m_fHovered = false; 107 emit sigHoverLeave(); 108 } 109 break; 110 } 111 /* Default case: */ 112 default: break; 113 } 114 /* Call to base-class: */ 115 return QWidget::eventFilter(pWatched, pEvent); 116 } 117 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIWarningPane.h
r47616 r47761 31 31 Q_OBJECT; 32 32 33 signals: 34 35 /* Notifiers: Hover stuff: */ 36 void sigHoverEnter(); 37 void sigHoverLeave(); 38 33 39 public: 34 40 … … 46 52 void prepareContent(); 47 53 54 /* Handler: Event processing stuff: */ 55 bool eventFilter(QObject *pWatched, QEvent *pEvent); 56 48 57 /* Variables: Widgets: */ 49 58 QLabel *m_pLabelIcon; 50 59 QLabel *m_pLabelText; 60 61 /* Variable: Hover stuff: */ 62 bool m_fHovered; 51 63 }; 52 64
Note:
See TracChangeset
for help on using the changeset viewer.