- Timestamp:
- Aug 4, 2017 10:06:38 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.cpp
r68295 r68296 25 25 # include <QHBoxLayout> 26 26 # include <QLabel> 27 # include <QMouseEvent> 27 28 # include <QPainter> 28 29 # ifdef VBOX_WS_MAC … … 45 46 class QHBoxLayout; 46 47 class QLabel; 48 class QMouseEvent; 47 49 #ifdef VBOX_WS_MAC 48 50 class QStackedLayout; … … 82 84 protected: 83 85 84 /** Handles any Qt @a pEvent. */85 virtual bool event(QEvent *pEvent) /* override */;86 87 86 /** Handles paint @a pEvent. */ 88 87 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 88 89 /** Handles mouse-release @a pEvent. */ 90 virtual void mouseReleaseEvent(QMouseEvent *pEvent) /* override */; 91 /** Handles mouse-enter @a pEvent. */ 92 virtual void enterEvent(QEvent *pEvent) /* override */; 93 /** Handles mouse-leave @a pEvent. */ 94 virtual void leaveEvent(QEvent *pEvent) /* override */; 89 95 90 96 private slots: … … 154 160 /* And call for repaint: */ 155 161 update(); 156 }157 158 bool UITabBarItem::event(QEvent *pEvent)159 {160 /* Handle known event types: */161 switch (pEvent->type())162 {163 /* Update the hovered state on/off: */164 case QEvent::Enter:165 {166 #ifdef VBOX_WS_MAC167 m_pLayoutStacked->setCurrentWidget(m_pButtonClose);168 #endif169 m_fHovered = true;170 update();171 break;172 }173 case QEvent::Leave:174 {175 #ifdef VBOX_WS_MAC176 m_pLayoutStacked->setCurrentWidget(m_pLabelIcon);177 #endif178 m_fHovered = false;179 update();180 break;181 }182 183 /* Notify listeners about the item was clicked: */184 case QEvent::MouseButtonRelease:185 {186 emit sigClicked(this);187 break;188 }189 190 default: break;191 }192 /* Call to base-class: */193 return QWidget::event(pEvent);194 162 } 195 163 … … 279 247 } 280 248 249 void UITabBarItem::mouseReleaseEvent(QMouseEvent *pEvent) 250 { 251 /* We are interested in left button only: */ 252 if (pEvent->button() != Qt::LeftButton) 253 return QWidget::mouseReleaseEvent(pEvent); 254 255 /* Notify listeners about the item was clicked: */ 256 emit sigClicked(this); 257 } 258 259 void UITabBarItem::enterEvent(QEvent *pEvent) 260 { 261 /* Make sure button isn't hovered: */ 262 if (m_fHovered) 263 return QWidget::enterEvent(pEvent); 264 265 /* Invert hovered state: */ 266 #ifdef VBOX_WS_MAC 267 m_pLayoutStacked->setCurrentWidget(m_pButtonClose); 268 #endif 269 m_fHovered = true; 270 /* And call for repaint: */ 271 update(); 272 } 273 274 void UITabBarItem::leaveEvent(QEvent *pEvent) 275 { 276 /* Make sure button is hovered: */ 277 if (!m_fHovered) 278 return QWidget::enterEvent(pEvent); 279 280 /* Invert hovered state: */ 281 #ifdef VBOX_WS_MAC 282 m_pLayoutStacked->setCurrentWidget(m_pLabelIcon); 283 #endif 284 m_fHovered = false; 285 /* And call for repaint: */ 286 update(); 287 } 288 281 289 void UITabBarItem::prepare() 282 290 {
Note:
See TracChangeset
for help on using the changeset viewer.