Changeset 51992 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 11, 2014 2:32:04 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94926
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r51937 r51992 268 268 src/extensions/QIRichToolButton.h \ 269 269 src/extensions/QISplitter.h \ 270 src/extensions/QIStateIndicator.h \271 270 src/extensions/QIStatusBar.h \ 271 src/extensions/QIStatusBarIndicator.h \ 272 272 src/extensions/QITabWidget.h \ 273 273 src/extensions/QITableView.h \ … … 538 538 src/extensions/QIRichToolButton.cpp \ 539 539 src/extensions/QISplitter.cpp \ 540 src/extensions/QIStateIndicator.cpp \541 540 src/extensions/QIStatusBar.cpp \ 541 src/extensions/QIStatusBarIndicator.cpp \ 542 542 src/extensions/QITableView.cpp \ 543 543 src/extensions/QITreeView.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStatusBarIndicator.cpp
r51961 r51992 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIStateIndicator class implementation 3 * VBox Qt GUI - QIStatusBarIndicator interface implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 #include "QIStateIndicator.h" 21 22 /* Qt includes */ 18 /* Qt includes: */ 23 19 #include <QIcon> 24 20 #include <QPainter> 21 #include <QHBoxLayout> 22 #include <QLabel> 25 23 #ifdef Q_WS_MAC 26 24 # include <QContextMenuEvent> 27 #endif 25 #endif /* Q_WS_MAC */ 28 26 29 QIStateIndicator::QIStateIndicator(QWidget *pParent /* = 0*/) 30 : QIWithRetranslateUI<QFrame>(pParent) 31 , mState(0) 32 , mSize(0, 0) 27 /* GUI includes: */ 28 #include "QIStatusBarIndicator.h" 29 30 31 QIStatusBarIndicator::QIStatusBarIndicator(QWidget *pParent /* = 0 */) 32 : QWidget(pParent) 33 33 { 34 /* Configure size-policy: */ 34 35 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 35 36 } 36 37 37 QIStateIndicator::~QIStateIndicator()38 {39 qDeleteAll (mStateIcons);40 }41 42 QSize QIStateIndicator::sizeHint() const43 {44 return mSize;45 }46 47 QPixmap QIStateIndicator::stateIcon(int state) const48 {49 /* Check if state-icon was set before: */50 Icon *pIcon = mStateIcons[state];51 return pIcon ? pIcon->pixmap : QPixmap();52 }53 54 void QIStateIndicator::setStateIcon(int state, const QIcon &icon)55 {56 /* Get minimum size: */57 QSize size = icon.availableSizes().first();58 59 /* Get pixmap of size above: */60 QPixmap pixmap = icon.pixmap(size);61 62 /* Assign that pixmap to state-pixmap: */63 mStateIcons.insert(state, new Icon(pixmap));64 65 /* Adjust minimum size-hint: */66 mSize = mSize.expandedTo(size);67 }68 69 void QIStateIndicator::setState (int aState)70 {71 mState = aState;72 repaint();73 }74 75 void QIStateIndicator::paintEvent (QPaintEvent * /* aEv */)76 {77 QPainter painter (this);78 drawContents (&painter);79 }80 81 void QIStateIndicator::drawContents (QPainter *aPainter)82 {83 Icon *icon = mStateIcons [mState];84 if (icon)85 aPainter->drawPixmap(contentsRect().topLeft(), icon->pixmap);86 }87 88 38 #ifdef Q_WS_MAC 89 /** 90 * Make the left button also show the context menu to make things 91 * simpler for users with single mouse button mice (laptops++). 92 */ 93 void QIStateIndicator::mousePressEvent (QMouseEvent *aEv) 39 void QIStatusBarIndicator::mousePressEvent(QMouseEvent *pEvent) 94 40 { 95 41 /* Do this for the left mouse button event only, cause in the case of the … … 97 43 * triggered twice. Also this isn't necessary for the middle mouse button 98 44 * which would be some kind of overstated. */ 99 if ( aEv->button() == Qt::LeftButton)45 if (pEvent->button() == Qt::LeftButton) 100 46 { 101 QContextMenuEvent qme (QContextMenuEvent::Mouse, aEv->pos(), aEv->globalPos());102 emit contextMenuRequested (this, &qme);103 if ( qme.isAccepted())104 aEv->accept();47 QContextMenuEvent cme(QContextMenuEvent::Mouse, pEvent->pos(), pEvent->globalPos()); 48 emit sigContextMenuRequest(this, &cme); 49 if (cme.isAccepted()) 50 pEvent->accept(); 105 51 else 106 Q Frame::mousePressEvent (aEv);52 QWidget::mousePressEvent(pEvent); 107 53 } 108 54 else 109 Q Frame::mousePressEvent (aEv);55 QWidget::mousePressEvent(pEvent); 110 56 } 111 57 #endif /* Q_WS_MAC */ 112 58 113 void QIStat eIndicator::mouseDoubleClickEvent (QMouseEvent * e)59 void QIStatusBarIndicator::mouseDoubleClickEvent(QMouseEvent *pEvent) 114 60 { 115 emit mouseDoubleClicked (this, e);61 emit sigMouseDoubleClick(this, pEvent); 116 62 } 117 63 118 void QIStat eIndicator::contextMenuEvent (QContextMenuEvent * e)64 void QIStatusBarIndicator::contextMenuEvent(QContextMenuEvent *pEvent) 119 65 { 120 emit contextMenuRequested (this, e);66 emit sigContextMenuRequest(this, pEvent); 121 67 } 122 68 69 70 QIStateStatusBarIndicator::QIStateStatusBarIndicator(QWidget *pParent /* = 0 */) 71 : QIStatusBarIndicator(pParent) 72 , m_iState(0) 73 { 74 } 75 76 QIcon QIStateStatusBarIndicator::stateIcon(int iState) const 77 { 78 /* Check if state-icon was set before: */ 79 return m_icons.value(iState, QIcon()); 80 } 81 82 void QIStateStatusBarIndicator::setStateIcon(int iState, const QIcon &icon) 83 { 84 /* Adjust size-hint: */ 85 m_size = m_size.expandedTo(icon.availableSizes().first()); 86 /* Cache passed-icon: */ 87 m_icons[iState] = icon; 88 } 89 90 void QIStateStatusBarIndicator::paintEvent(QPaintEvent*) 91 { 92 QPainter painter(this); 93 drawContents(&painter); 94 } 95 96 void QIStateStatusBarIndicator::drawContents(QPainter *pPainter) 97 { 98 if (m_icons.contains(m_iState)) 99 pPainter->drawPixmap(contentsRect().topLeft(), m_icons.value(m_iState).pixmap(m_size)); 100 } 101 102 103 QITextStatusBarIndicator::QITextStatusBarIndicator(QWidget *pParent /* = 0 */) 104 : QIStatusBarIndicator(pParent) 105 { 106 /* Create main-layout: */ 107 QHBoxLayout *pMainLayout = new QHBoxLayout(this); 108 if (pMainLayout) 109 { 110 /* Configure main-layout: */ 111 pMainLayout->setContentsMargins(0, 0, 0, 0); 112 pMainLayout->setSpacing(0); 113 /* Crete label: */ 114 m_pLabel = new QLabel; 115 if (m_pLabel) 116 { 117 /* Add label into main-layout: */ 118 pMainLayout->addWidget(m_pLabel); 119 } 120 } 121 } 122 123 QString QITextStatusBarIndicator::text() const 124 { 125 return m_pLabel->text(); 126 } 127 128 void QITextStatusBarIndicator::setText(const QString &strText) 129 { 130 m_pLabel->setText(strText); 131 } 132 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStatusBarIndicator.h
r51961 r51992 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIStateIndicator class declaration 2 * VBox Qt GUI - QIStatusBarIndicator interface declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIStateIndicator_h__20 #define __ QIStateIndicator_h__17 #ifndef ___QIStatusBarIndicators_h___ 18 #define ___QIStatusBarIndicators_h___ 21 19 22 /* Qt includes */ 23 #include <QFrame> 24 #include <QHash> 20 /* Qt includes: */ 21 #include <QWidget> 22 #include <QMap> 23 #include <QIcon> 25 24 26 /* GUI includes: */27 #include "QIWithRetranslateUI.h" 25 /* Forward declarations: */ 26 class QLabel; 28 27 29 class QIStateIndicator : public QIWithRetranslateUI<QFrame> 28 /** QWidget extension used as status-bar indicator. */ 29 class QIStatusBarIndicator : public QWidget 30 { 31 Q_OBJECT; 32 33 signals: 34 35 /** Notifies about mouse-double-click-event: */ 36 void sigMouseDoubleClick(QIStatusBarIndicator *pIndicator, QMouseEvent *pEvent); 37 /** Notifies about context-menu-request-event: */ 38 void sigContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent); 39 40 public: 41 42 /** Constructor, passes @a pParent to the QWidget constructor. */ 43 QIStatusBarIndicator(QWidget *pParent = 0); 44 45 /** Returns size-hint. */ 46 virtual QSize sizeHint() const { return m_size.isValid() ? m_size : QWidget::sizeHint(); } 47 48 protected: 49 50 #ifdef Q_WS_MAC 51 /** Mac OS X: Mouse-press-event handler. 52 * Make the left button also show the context-menu to make things 53 * simpler for users with single mouse button mice (laptops++). */ 54 virtual void mousePressEvent(QMouseEvent *pEvent); 55 #endif /* Q_WS_MAC */ 56 /** Mouse-double-click-event handler. */ 57 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent); 58 /** Context-menu-event handler. */ 59 virtual void contextMenuEvent(QContextMenuEvent *pEvent); 60 61 /** Holds currently cached size. */ 62 QSize m_size; 63 }; 64 65 /** QIStatusBarIndicator extension used as status-bar state indicator. */ 66 class QIStateStatusBarIndicator : public QIStatusBarIndicator 30 67 { 31 68 Q_OBJECT; … … 33 70 public: 34 71 35 QIStateIndicator(QWidget *pParent = 0);36 ~QIStateIndicator();72 /** Constructor, passes @a pParent to the QIStatusBarIndicator constructor. */ 73 QIStateStatusBarIndicator(QWidget *pParent = 0); 37 74 38 virtual QSize sizeHint() const; 75 /** Returns current state. */ 76 int state() const { return m_iState; } 39 77 40 int state () const { return mState; } 41 42 /** Returns state-icon for passed @a state. */ 43 QPixmap stateIcon(int state) const; 44 /** Defines state-icon for passed @a state as @a icon. */ 45 void setStateIcon(int state, const QIcon &icon); 46 47 virtual void updateAppearance() {} 78 /** Returns state-icon for passed @a iState. */ 79 QIcon stateIcon(int iState) const; 80 /** Defines state-icon for passed @a iState as @a icon. */ 81 void setStateIcon(int iState, const QIcon &icon); 48 82 49 83 public slots: 50 84 51 virtual void setState (int aState); 52 virtual void setState (bool aState) { setState ((int) aState); } 53 54 signals: 55 56 void mouseDoubleClicked (QIStateIndicator *aIndicator, 57 QMouseEvent *aEv); 58 void contextMenuRequested (QIStateIndicator *aIndicator, 59 QContextMenuEvent *aEv); 85 /** Defines int @a state. */ 86 virtual void setState(int iState) { m_iState = iState; repaint(); } 87 /** Defines bool @a state. */ 88 virtual void setState(bool fState) { setState((int)fState); } 60 89 61 90 protected: 62 91 63 virtual void paintEvent (QPaintEvent *aEv);64 virtual void drawContents (QPainter *aPainter);92 /** Paint-event handler. */ 93 virtual void paintEvent(QPaintEvent *pEvent); 65 94 66 #ifdef Q_WS_MAC 67 virtual void mousePressEvent (QMouseEvent *aEv); 68 #endif 69 virtual void mouseDoubleClickEvent (QMouseEvent *aEv); 70 virtual void contextMenuEvent (QContextMenuEvent *aEv); 95 /** Draw-contents routine. */ 96 virtual void drawContents(QPainter *pPainter); 71 97 72 98 private: 73 99 74 int mState; 75 QSize mSize; 76 77 struct Icon 78 { 79 Icon (const QPixmap &aPixmap) 80 : pixmap (aPixmap) 81 , bgPixmap (NULL) {} 82 83 QPixmap pixmap; 84 QPixmap cached; 85 QColor bgColor; 86 const QPixmap *bgPixmap; 87 QPoint bgOff; 88 }; 89 90 QHash <int, Icon *> mStateIcons; 100 /** Holds current state. */ 101 int m_iState; 102 /** Holds cached state icons. */ 103 QMap<int, QIcon> m_icons; 91 104 }; 92 105 93 #endif // __QIStateIndicator_h__ 106 /** QIStatusBarIndicator extension used as status-bar state indicator. */ 107 class QITextStatusBarIndicator : public QIStatusBarIndicator 108 { 109 Q_OBJECT; 94 110 111 public: 112 113 /** Constructor, passes @a pParent to the QIStatusBarIndicator constructor. */ 114 QITextStatusBarIndicator(QWidget *pParent = 0); 115 116 /** Returns text. */ 117 QString text() const; 118 /** Defines @a strText. */ 119 void setText(const QString &strText); 120 121 private: 122 123 /** Holds the label instance. */ 124 QLabel *m_pLabel; 125 }; 126 127 #endif /* !___QIStatusBarIndicators_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r51931 r51992 482 482 IndicatorType_OpticalDisks, 483 483 IndicatorType_FloppyDisks, 484 IndicatorType_USB, 484 485 IndicatorType_Network, 485 IndicatorType_USB,486 486 IndicatorType_SharedFolders, 487 487 IndicatorType_VideoCapture, … … 489 489 IndicatorType_Mouse, 490 490 IndicatorType_Keyboard, 491 IndicatorType_KeyboardExtension, 491 492 IndicatorType_Max 492 493 }; -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.cpp
r42901 r51992 115 115 { 116 116 m_pNetworkManagerIndicator = new UINetworkManagerIndicator; 117 connect(m_pNetworkManagerIndicator, SIGNAL( mouseDoubleClicked(QIStateIndicator*, QMouseEvent *)), this, SLOT(show()));117 connect(m_pNetworkManagerIndicator, SIGNAL(sigMouseDoubleClick(QIStateStatusBarIndicator*, QMouseEvent *)), this, SLOT(show())); 118 118 } 119 119 } -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManagerIndicator.h
r46650 r51992 25 25 26 26 /* Local includes: */ 27 #include "QIStat eIndicator.h"27 #include "QIStatusBarIndicator.h" 28 28 29 29 /* Forward declarations: */ … … 39 39 40 40 /* Network-manager status-bar indicator: */ 41 class UINetworkManagerIndicator : public QIState Indicator41 class UINetworkManagerIndicator : public QIStateStatusBarIndicator 42 42 { 43 43 Q_OBJECT; 44 45 public: 46 47 /** Update routine. */ 48 void updateAppearance(); 44 49 45 50 protected: … … 89 94 /* Update stuff: */ 90 95 void recalculateIndicatorState(); 91 void updateAppearance();92 96 93 97 /* Variables: */ -
trunk/src/VBox/Frontends/VirtualBox/src/precomp.h
r51304 r51992 176 176 #include "QIRichToolButton.h" 177 177 #include "QISplitter.h" 178 #include "QIStateIndicator.h"179 178 #include "QIStatusBar.h" 179 #include "QIStatusBarIndicator.h" 180 180 #include "QIToolButton.h" 181 181 #include "QITreeView.h" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
r51322 r51992 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIIndicatorsPool class implementation 3 * VBox Qt GUI - UIIndicatorsPool class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2010-201 2Oracle Corporation7 * Copyright (C) 2010-2013 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 19 #include <QTimer> 22 20 #include <QPainter> 21 #include <QHBoxLayout> 23 22 24 23 /* GUI includes: */ 25 24 #include "UIIndicatorsPool.h" 26 #include " VBoxGlobal.h"25 #include "QIWithRetranslateUI.h" 27 26 #include "UIExtraDataManager.h" 28 27 #include "UIMachineDefs.h" 29 28 #include "UIConverter.h" 30 29 #include "UIAnimationFramework.h" 30 #include "UISession.h" 31 31 #include "UIMedium.h" 32 32 #include "UIIconPool.h" 33 #include "UIHostComboEditor.h" 34 #include "QIStatusBarIndicator.h" 35 #include "VBoxGlobal.h" 33 36 34 37 /* COM includes: */ … … 50 53 #include <iprt/time.h> 51 54 52 class UIIndicatorHardDisks : public QIStateIndicator 55 56 /** QIStateStatusBarIndicator extension for Runtime UI. */ 57 class UISessionStateStatusBarIndicator : public QIWithRetranslateUI<QIStateStatusBarIndicator> 53 58 { 54 59 Q_OBJECT; … … 56 61 public: 57 62 58 UIIndicatorHardDisks(CSession &session) 59 : m_session(session) 63 /** Constructor which remembers passed @a session object. */ 64 UISessionStateStatusBarIndicator(CSession &session) : m_session(session) {} 65 66 /** Abstract update routine. */ 67 virtual void updateAppearance() = 0; 68 69 protected: 70 71 /** Holds the session reference. */ 72 CSession &m_session; 73 }; 74 75 /** UISessionStateStatusBarIndicator extension for Runtime UI: Hard-drive indicator. */ 76 class UIIndicatorHardDrive : public UISessionStateStatusBarIndicator 77 { 78 Q_OBJECT; 79 80 public: 81 82 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 83 UIIndicatorHardDrive(CSession &session) 84 : UISessionStateStatusBarIndicator(session) 60 85 { 61 86 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/hd_16px.png")); … … 67 92 } 68 93 94 private: 95 96 /** Retranslation routine. */ 69 97 void retranslateUi() 70 98 { … … 72 100 } 73 101 102 /** Update routine. */ 74 103 void updateAppearance() 75 104 { … … 109 138 setState(fAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 110 139 } 111 112 protected:113 /* For compatibility reason we do it here, later this should be moved to114 * QIStateIndicator. */115 CSession &m_session;116 140 }; 117 141 118 class UIIndicatorOpticalDisks : public QIStateIndicator 142 /** UISessionStateStatusBarIndicator extension for Runtime UI: Optical-drive indicator. */ 143 class UIIndicatorOpticalDisks : public UISessionStateStatusBarIndicator 119 144 { 120 145 Q_OBJECT; … … 122 147 public: 123 148 149 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 124 150 UIIndicatorOpticalDisks(CSession &session) 125 : m_session(session)151 : UISessionStateStatusBarIndicator(session) 126 152 { 127 153 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/cd_16px.png")); … … 133 159 } 134 160 161 private: 162 163 /** Retranslation routine. */ 135 164 void retranslateUi() 136 165 { … … 138 167 } 139 168 169 /** Update routine. */ 140 170 void updateAppearance() 141 171 { … … 179 209 setState(fAttachmentsMounted ? KDeviceActivity_Idle : KDeviceActivity_Null); 180 210 } 181 182 protected:183 /* For compatibility reason we do it here, later this should be moved to184 * QIStateIndicator. */185 CSession &m_session;186 211 }; 187 212 188 class UIIndicatorFloppyDisks : public QIStateIndicator 213 /** UISessionStateStatusBarIndicator extension for Runtime UI: Floppy-drive indicator. */ 214 class UIIndicatorFloppyDisks : public UISessionStateStatusBarIndicator 189 215 { 190 216 Q_OBJECT; … … 192 218 public: 193 219 220 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 194 221 UIIndicatorFloppyDisks(CSession &session) 195 : m_session(session)222 : UISessionStateStatusBarIndicator(session) 196 223 { 197 224 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/fd_16px.png")); … … 203 230 } 204 231 232 private: 233 234 /** Retranslation routine. */ 205 235 void retranslateUi() 206 236 { … … 208 238 } 209 239 240 /** Update routine. */ 210 241 void updateAppearance() 211 242 { … … 249 280 setState(fAttachmentsMounted ? KDeviceActivity_Idle : KDeviceActivity_Null); 250 281 } 251 252 protected:253 /* For compatibility reason we do it here, later this should be moved to254 * QIStateIndicator. */255 CSession &m_session;256 282 }; 257 283 258 class UIIndicatorNetwork : public QIStateIndicator 284 /** UISessionStateStatusBarIndicator extension for Runtime UI: Network indicator. */ 285 class UIIndicatorNetwork : public UISessionStateStatusBarIndicator 259 286 { 260 287 Q_OBJECT; … … 262 289 public: 263 290 291 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 264 292 UIIndicatorNetwork(CSession &session) 265 : m_session(session)266 , m_pUpdateTimer(new QTimer(this))293 : UISessionStateStatusBarIndicator(session) 294 , m_pUpdateTimer(new QTimer(this)) 267 295 { 268 296 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/nw_16px.png")); … … 277 305 } 278 306 307 private slots: 308 309 /** Updates network IP addresses. */ 310 void sltUpdateNetworkIPs() 311 { 312 updateAppearance(); 313 } 314 315 private: 316 317 /** Retranslation routine. */ 279 318 void retranslateUi() 280 319 { … … 282 321 } 283 322 323 /** Update routine. */ 284 324 void updateAppearance() 285 325 { … … 348 388 setToolTip(strToolTip.arg(strFullData)); 349 389 } 350 protected slots: 351 352 void sltUpdateNetworkIPs() 353 { 354 updateAppearance(); 355 } 356 357 protected: 358 /* For compatibility reason we do it here, later this should be moved to 359 * QIStateIndicator. */ 360 CSession &m_session; 390 391 /** Holds the auto-update timer instance. */ 361 392 QTimer *m_pUpdateTimer; 362 393 }; 363 394 364 class UIIndicatorUSB : public QIStateIndicator 395 /** UISessionStateStatusBarIndicator extension for Runtime UI: USB indicator. */ 396 class UIIndicatorUSB : public UISessionStateStatusBarIndicator 365 397 { 366 398 Q_OBJECT; … … 368 400 public: 369 401 402 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 370 403 UIIndicatorUSB(CSession &session) 371 : m_session(session)404 : UISessionStateStatusBarIndicator(session) 372 405 { 373 406 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/usb_16px.png")); … … 379 412 } 380 413 414 private: 415 416 /** Retranslation routine. */ 381 417 void retranslateUi() 382 418 { … … 384 420 } 385 421 422 /** Update routine. */ 386 423 void updateAppearance() 387 424 { … … 416 453 setToolTip(strToolTip.arg(strFullData)); 417 454 } 418 419 protected:420 /* For compatibility reason we do it here, later this should be moved to421 * QIStateIndicator. */422 CSession &m_session;423 455 }; 424 456 425 class UIIndicatorSharedFolders : public QIStateIndicator 457 /** UISessionStateStatusBarIndicator extension for Runtime UI: Shared-folders indicator. */ 458 class UIIndicatorSharedFolders : public UISessionStateStatusBarIndicator 426 459 { 427 460 Q_OBJECT; … … 429 462 public: 430 463 464 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 431 465 UIIndicatorSharedFolders(CSession &session) 432 : m_session(session)466 : UISessionStateStatusBarIndicator(session) 433 467 { 434 468 setStateIcon(KDeviceActivity_Idle, UIIconPool::iconSet(":/sf_16px.png")); … … 440 474 } 441 475 476 private: 477 478 /** Retranslation routine. */ 442 479 void retranslateUi() 443 480 { … … 445 482 } 446 483 484 /** Update routine. */ 447 485 void updateAppearance() 448 486 { … … 491 529 setToolTip(strToolTip.arg(strFullData)); 492 530 } 493 494 protected:495 /* For compatibility reason we do it here, later this should be moved to496 * QIStateIndicator. */497 CSession &m_session;498 531 }; 499 532 500 class UIIndicatorVideoCapture : public QIStateIndicator 533 /** UISessionStateStatusBarIndicator extension for Runtime UI: Video-capture indicator. */ 534 class UIIndicatorVideoCapture : public UISessionStateStatusBarIndicator 501 535 { 502 536 Q_OBJECT; … … 505 539 Q_PROPERTY(double rotationAngle READ rotationAngle WRITE setRotationAngle); 506 540 507 public: 508 509 /* State enumerator: */ 541 /** Video-capture states. */ 510 542 enum UIIndicatorStateVideoCapture 511 543 { … … 514 546 }; 515 547 516 /* Constructor: */ 548 public: 549 550 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 517 551 UIIndicatorVideoCapture(CSession &session) 518 : m_session(session)552 : UISessionStateStatusBarIndicator(session) 519 553 , m_pAnimation(0) 520 554 , m_dRotationAngle(0) … … 533 567 } 534 568 535 /* API: Update stuff: */ 569 private slots: 570 571 /** Handles state change. */ 572 void setState(int iState) 573 { 574 /* Update animation state: */ 575 switch (iState) 576 { 577 case UIIndicatorStateVideoCapture_Disabled: 578 m_pAnimation->stop(); 579 m_dRotationAngle = 0; 580 break; 581 case UIIndicatorStateVideoCapture_Enabled: 582 m_pAnimation->start(); 583 break; 584 default: 585 break; 586 } 587 /* Call to base-class: */ 588 QIStateStatusBarIndicator::setState(iState); 589 } 590 591 private: 592 593 /** Retranslation routine. */ 594 void retranslateUi() 595 { 596 updateAppearance(); 597 } 598 599 /** Paint-event handler. */ 600 void paintEvent(QPaintEvent*) 601 { 602 /* Create new painter: */ 603 QPainter painter(this); 604 /* Configure painter for *enabled* state: */ 605 if (state() == UIIndicatorStateVideoCapture_Enabled) 606 { 607 /* Configure painter for smooth animation: */ 608 painter.setRenderHint(QPainter::Antialiasing); 609 painter.setRenderHint(QPainter::SmoothPixmapTransform); 610 /* Shift rotation origin according pixmap center: */ 611 painter.translate(height() / 2, height() / 2); 612 /* Rotate painter: */ 613 painter.rotate(rotationAngle()); 614 /* Unshift rotation origin according pixmap center: */ 615 painter.translate(- height() / 2, - height() / 2); 616 } 617 /* Draw contents: */ 618 drawContents(&painter); 619 } 620 621 /** Update routine. */ 536 622 void updateAppearance() 537 623 { … … 563 649 } 564 650 565 public slots: 566 567 /* Handler: State stuff: */ 568 void setState(int iState) 569 { 570 /* Update animation state: */ 571 switch (iState) 572 { 573 case UIIndicatorStateVideoCapture_Disabled: 574 m_pAnimation->stop(); 575 m_dRotationAngle = 0; 576 break; 577 case UIIndicatorStateVideoCapture_Enabled: 578 m_pAnimation->start(); 579 break; 580 default: 581 break; 582 } 583 584 /* Call to base-class: */ 585 QIStateIndicator::setState(iState); 586 } 587 588 protected: 589 590 /* Handler: Translate stuff: */ 591 void retranslateUi() 592 { 593 updateAppearance(); 594 } 595 596 /* Handler: Paint stuff: */ 597 void paintEvent(QPaintEvent*) 598 { 599 /* Create new painter: */ 600 QPainter painter(this); 601 /* Configure painter for *enabled* state: */ 602 if (state() == UIIndicatorStateVideoCapture_Enabled) 603 { 604 /* Configure painter for smooth animation: */ 605 painter.setRenderHint(QPainter::Antialiasing); 606 painter.setRenderHint(QPainter::SmoothPixmapTransform); 607 /* Shift rotation origin according pixmap center: */ 608 painter.translate(height() / 2, height() / 2); 609 /* Rotate painter: */ 610 painter.rotate(rotationAngle()); 611 /* Unshift rotation origin according pixmap center: */ 612 painter.translate(- height() / 2, - height() / 2); 613 } 614 /* Draw contents: */ 615 drawContents(&painter); 616 } 617 618 /* Properties: Rotation stuff: */ 651 /** Returns rotation start angle. */ 619 652 double rotationAngleStart() const { return 0; } 653 /** Returns rotation finish angle. */ 620 654 double rotationAngleFinal() const { return 360; } 655 /** Returns current rotation angle. */ 621 656 double rotationAngle() const { return m_dRotationAngle; } 657 /** Defines current rotation angle. */ 622 658 void setRotationAngle(double dRotationAngle) { m_dRotationAngle = dRotationAngle; update(); } 623 659 624 /* For compatibility reason we do it here, 625 * later this should be moved to QIStateIndicator. */ 626 CSession &m_session; 660 /** Holds the rotation animation instance. */ 627 661 UIAnimationLoop *m_pAnimation; 662 /** Holds current rotation angle. */ 628 663 double m_dRotationAngle; 629 664 }; 630 665 631 class UIIndicatorFeatures : public QIStateIndicator 666 /** UISessionStateStatusBarIndicator extension for Runtime UI: Features indicator. */ 667 class UIIndicatorFeatures : public UISessionStateStatusBarIndicator 632 668 { 633 669 Q_OBJECT; … … 635 671 public: 636 672 673 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 637 674 UIIndicatorFeatures(CSession &session) 638 : m_session(session)675 : UISessionStateStatusBarIndicator(session) 639 676 { 640 677 setStateIcon(0, UIIconPool::iconSet(":/vtx_amdv_disabled_16px.png")); … … 644 681 } 645 682 683 private: 684 685 /** Retranslation routine. */ 646 686 void retranslateUi() 647 687 { … … 649 689 } 650 690 691 /** Update routine. */ 651 692 void updateAppearance() 652 693 { … … 696 737 setState(bVirtEnabled); 697 738 } 698 699 protected:700 /* For compatibility reason we do it here, later this should be moved to701 * QIStateIndicator. */702 CSession &m_session;703 739 }; 704 740 705 class UIIndicatorMouse : public QIStateIndicator 741 /** UISessionStateStatusBarIndicator extension for Runtime UI: Mouse indicator. */ 742 class UIIndicatorMouse : public UISessionStateStatusBarIndicator 706 743 { 707 744 Q_OBJECT; … … 709 746 public: 710 747 748 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 711 749 UIIndicatorMouse(CSession &session) 712 : m_session(session)750 : UISessionStateStatusBarIndicator(session) 713 751 { 714 752 setStateIcon(0, UIIconPool::iconSet(":/mouse_disabled_16px.png")); … … 721 759 } 722 760 723 void retranslateUi() 724 { 725 setToolTip(QApplication::translate("UIIndicatorsPool", "Indicates whether the host mouse pointer is captured by the guest OS:<br>" 726 "<nobr><img src=:/mouse_disabled_16px.png/> pointer is not captured</nobr><br>" 727 "<nobr><img src=:/mouse_16px.png/> pointer is captured</nobr><br>" 728 "<nobr><img src=:/mouse_seamless_16px.png/> mouse integration (MI) is On</nobr><br>" 729 "<nobr><img src=:/mouse_can_seamless_16px.png/> MI is Off, pointer is captured</nobr><br>" 730 "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/> MI is Off, pointer is not captured</nobr><br>" 731 "Note that the mouse integration feature requires Guest Additions to be installed in the guest OS.")); 732 } 733 734 public slots: 735 761 private slots: 762 763 /** Handles state change. */ 736 764 void setState(int iState) 737 765 { … … 740 768 !(iState & UIMouseStateType_MouseCaptured)) 741 769 { 742 QIState Indicator::setState(4);770 QIStateStatusBarIndicator::setState(4); 743 771 } 744 772 else 745 773 { 746 QIStateIndicator::setState(iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured)); 747 } 748 } 749 750 protected: 751 /* For compatibility reason we do it here, later this should be moved to 752 * QIStateIndicator. */ 753 CSession &m_session; 774 QIStateStatusBarIndicator::setState(iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured)); 775 } 776 } 777 778 private: 779 780 /** Retranslation routine. */ 781 void retranslateUi() 782 { 783 setToolTip(QApplication::translate("UIIndicatorsPool", 784 "Indicates whether the host mouse pointer is captured by the guest OS:<br>" 785 "<nobr><img src=:/mouse_disabled_16px.png/> pointer is not captured</nobr><br>" 786 "<nobr><img src=:/mouse_16px.png/> pointer is captured</nobr><br>" 787 "<nobr><img src=:/mouse_seamless_16px.png/> mouse integration (MI) is On</nobr><br>" 788 "<nobr><img src=:/mouse_can_seamless_16px.png/> MI is Off, pointer is captured</nobr><br>" 789 "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/> MI is Off, pointer is not captured</nobr><br>" 790 "Note that the mouse integration feature requires Guest Additions to be installed in the guest OS.")); 791 } 792 793 /** Update routine. */ 794 void updateAppearance() {} 754 795 }; 755 796 756 class UIIndicatorKeyboard : public QIStateIndicator 797 /** UISessionStateStatusBarIndicator extension for Runtime UI: Keyboard indicator. */ 798 class UIIndicatorKeyboard : public UISessionStateStatusBarIndicator 757 799 { 758 800 Q_OBJECT; … … 760 802 public: 761 803 804 /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */ 762 805 UIIndicatorKeyboard(CSession &session) 763 : m_session(session)806 : UISessionStateStatusBarIndicator(session) 764 807 { 765 808 setStateIcon(0, UIIconPool::iconSet(":/hostkey_16px.png")); … … 771 814 } 772 815 816 private: 817 818 /** Retranslation routine. */ 773 819 void retranslateUi() 774 820 { 775 setToolTip(QApplication::translate("UIIndicatorsPool", "Indicates whether the keyboard is captured by the guest OS " 776 "(<img src=:/hostkey_captured_16px.png/>) or not (<img src=:/hostkey_16px.png/>).")); 777 } 778 779 protected: 780 /* For compatibility reason we do it here, later this should be moved to 781 * QIStateIndicator. */ 782 CSession &m_session; 821 setToolTip(QApplication::translate("UIIndicatorsPool", 822 "Indicates whether the keyboard is captured by the guest OS " 823 "(<img src=:/hostkey_captured_16px.png/>) or not (<img src=:/hostkey_16px.png/>).")); 824 } 825 826 /** Update routine. */ 827 void updateAppearance() {} 783 828 }; 784 829 785 UIIndicatorsPool::UIIndicatorsPool(CSession &session, QObject *pParent) 786 : QObject(pParent) 787 , m_session(session) 788 , m_pool(IndicatorType_Max) 830 /** QITextStatusBarIndicator extension for Runtime UI: Keyboard-extension indicator. */ 831 class UIIndicatorKeyboardExtension : public QIWithRetranslateUI<QITextStatusBarIndicator> 832 { 833 Q_OBJECT; 834 835 public: 836 837 /** Constructor. */ 838 UIIndicatorKeyboardExtension() 839 { 840 /* Make sure host-combination label will be updated: */ 841 connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)), 842 this, SLOT(sltUpdateAppearance())); 843 /* Translate finally: */ 844 retranslateUi(); 845 } 846 847 public slots: 848 849 /** Update routine. */ 850 void sltUpdateAppearance() 851 { 852 setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())); 853 } 854 855 private: 856 857 /** Retranslation routine. */ 858 void retranslateUi() 859 { 860 sltUpdateAppearance(); 861 setToolTip(QApplication::translate("UIMachineWindowNormal", 862 "Shows the currently assigned Host key.<br>" 863 "This key, when pressed alone, toggles the keyboard and mouse " 864 "capture state. It can also be used in combination with other keys " 865 "to quickly perform actions from the main menu.")); 866 } 867 }; 868 869 870 UIIndicatorsPool::UIIndicatorsPool(UISession *pSession, QWidget *pParent /* = 0 */) 871 : QWidget(pParent) 872 , m_pSession(pSession) 873 , m_session(m_pSession->session()) 874 , m_pTimerAutoUpdate(0) 789 875 { 790 876 /* Prepare: */ … … 798 884 } 799 885 800 QIStateIndicator* UIIndicatorsPool::indicator(IndicatorType index) 801 { 802 /* Just return what already exists: */ 803 return m_pool[index]; 886 void UIIndicatorsPool::updateAppearance(IndicatorType indicatorType) 887 { 888 /* Skip missed indicators: */ 889 if (!m_pool.contains(indicatorType)) 890 return; 891 892 /* Get indicator: */ 893 QIStatusBarIndicator *pIndicator = m_pool.value(indicatorType); 894 895 /* Assert indicators with NO appearance: */ 896 UISessionStateStatusBarIndicator *pSessionStateIndicator = 897 qobject_cast<UISessionStateStatusBarIndicator*>(pIndicator); 898 AssertPtrReturnVoid(pSessionStateIndicator); 899 900 /* Update indicator appearance: */ 901 pSessionStateIndicator->updateAppearance(); 902 } 903 904 void UIIndicatorsPool::setAutoUpdateIndicatorStates(bool fEnabled) 905 { 906 /* Make sure auto-update timer exists: */ 907 AssertPtrReturnVoid(m_pTimerAutoUpdate); 908 909 /* Start/stop timer: */ 910 if (fEnabled) 911 m_pTimerAutoUpdate->start(100); 912 else 913 m_pTimerAutoUpdate->stop(); 914 } 915 916 void UIIndicatorsPool::sltAutoUpdateIndicatorStates() 917 { 918 /* Update states for following indicators: */ 919 if (m_pool.contains(IndicatorType_HardDisks)) 920 updateIndicatorStateForDevice(m_pool.value(IndicatorType_HardDisks), KDeviceType_HardDisk); 921 if (m_pool.contains(IndicatorType_OpticalDisks)) 922 updateIndicatorStateForDevice(m_pool.value(IndicatorType_OpticalDisks), KDeviceType_DVD); 923 if (m_pool.contains(IndicatorType_FloppyDisks)) 924 updateIndicatorStateForDevice(m_pool.value(IndicatorType_FloppyDisks), KDeviceType_Floppy); 925 if (m_pool.contains(IndicatorType_USB)) 926 updateIndicatorStateForDevice(m_pool.value(IndicatorType_USB), KDeviceType_USB); 927 if (m_pool.contains(IndicatorType_Network)) 928 updateIndicatorStateForDevice(m_pool.value(IndicatorType_Network), KDeviceType_Network); 929 if (m_pool.contains(IndicatorType_SharedFolders)) 930 updateIndicatorStateForDevice(m_pool.value(IndicatorType_SharedFolders), KDeviceType_SharedFolder); 931 } 932 933 void UIIndicatorsPool::sltContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent) 934 { 935 /* If that is one of pool indicators: */ 936 foreach (IndicatorType indicatorType, m_pool.keys()) 937 if (m_pool[indicatorType] == pIndicator) 938 { 939 /* Notify listener: */ 940 emit sigContextMenuRequest(indicatorType, pEvent->globalPos()); 941 return; 942 } 804 943 } 805 944 806 945 void UIIndicatorsPool::prepare() 807 946 { 808 /* Get the list of restricted indicators: */ 809 QList<IndicatorType> restrictedIndicators = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid()); 810 811 /* Populate indicator-pool: */ 812 for (int iIndex = 0; iIndex < IndicatorType_Max; ++iIndex) 813 { 814 /* Make sure indicator presence is permitted: */ 815 IndicatorType index = static_cast<IndicatorType>(iIndex); 816 if (restrictedIndicators.contains(index)) 817 continue; 818 819 /* Prepare indicator: */ 820 switch (index) 821 { 822 case IndicatorType_HardDisks: m_pool[index] = new UIIndicatorHardDisks(m_session); break; 823 case IndicatorType_OpticalDisks: m_pool[index] = new UIIndicatorOpticalDisks(m_session); break; 824 case IndicatorType_FloppyDisks: m_pool[index] = new UIIndicatorFloppyDisks(m_session); break; 825 case IndicatorType_Network: m_pool[index] = new UIIndicatorNetwork(m_session); break; 826 case IndicatorType_USB: m_pool[index] = new UIIndicatorUSB(m_session); break; 827 case IndicatorType_SharedFolders: m_pool[index] = new UIIndicatorSharedFolders(m_session); break; 828 case IndicatorType_VideoCapture: m_pool[index] = new UIIndicatorVideoCapture(m_session); break; 829 case IndicatorType_Features: m_pool[index] = new UIIndicatorFeatures(m_session); break; 830 case IndicatorType_Mouse: m_pool[index] = new UIIndicatorMouse(m_session); break; 831 case IndicatorType_Keyboard: m_pool[index] = new UIIndicatorKeyboard(m_session); break; 832 default: break; 833 } 947 /* Prepare connections: */ 948 prepareConnections(); 949 /* Prepare contents: */ 950 prepareContents(); 951 /* Prepare auto-update timer: */ 952 prepareUpdateTimer(); 953 } 954 955 void UIIndicatorsPool::prepareConnections() 956 { 957 /* Listen for the status-bar configuration changes: */ 958 connect(gEDataManager, SIGNAL(sigStatusBarConfigurationChange()), 959 this, SLOT(sltHandleConfigurationChange())); 960 } 961 962 void UIIndicatorsPool::prepareContents() 963 { 964 /* Create main-layout: */ 965 m_pMainLayout = new QHBoxLayout(this); 966 AssertPtrReturnVoid(m_pMainLayout); 967 { 968 /* Configure main-layout: */ 969 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 970 m_pMainLayout->setSpacing(5); 971 /* Update pool: */ 972 updatePool(); 973 } 974 } 975 976 void UIIndicatorsPool::prepareUpdateTimer() 977 { 978 /* Create auto-update timer: */ 979 m_pTimerAutoUpdate = new QTimer(this); 980 AssertPtrReturnVoid(m_pTimerAutoUpdate); 981 { 982 /* Configure auto-update timer: */ 983 connect(m_pTimerAutoUpdate, SIGNAL(timeout()), 984 this, SLOT(sltAutoUpdateIndicatorStates())); 985 setAutoUpdateIndicatorStates(true); 986 } 987 } 988 989 void UIIndicatorsPool::updatePool() 990 { 991 /* Recache the list of restricted indicators: */ 992 m_configuration = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid()); 993 994 /* Update indicators: */ 995 for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType) 996 { 997 /* Determine indicator presence: */ 998 const IndicatorType indicatorType = static_cast<IndicatorType>(iType); 999 bool fPresenceAllowed = !m_configuration.contains(indicatorType); 1000 1001 /* If presence restricted: */ 1002 if (!fPresenceAllowed && m_pool.contains(indicatorType)) 1003 { 1004 /* Cleanup indicator: */ 1005 delete m_pool.value(indicatorType); 1006 m_pool.remove(indicatorType); 1007 } 1008 /* If presence allowed: */ 1009 else if (fPresenceAllowed && !m_pool.contains(indicatorType)) 1010 { 1011 /* Create indicator: */ 1012 switch (indicatorType) 1013 { 1014 case IndicatorType_HardDisks: m_pool[indicatorType] = new UIIndicatorHardDrive(m_session); break; 1015 case IndicatorType_OpticalDisks: m_pool[indicatorType] = new UIIndicatorOpticalDisks(m_session); break; 1016 case IndicatorType_FloppyDisks: m_pool[indicatorType] = new UIIndicatorFloppyDisks(m_session); break; 1017 case IndicatorType_USB: m_pool[indicatorType] = new UIIndicatorUSB(m_session); break; 1018 case IndicatorType_Network: m_pool[indicatorType] = new UIIndicatorNetwork(m_session); break; 1019 case IndicatorType_SharedFolders: m_pool[indicatorType] = new UIIndicatorSharedFolders(m_session); break; 1020 case IndicatorType_VideoCapture: m_pool[indicatorType] = new UIIndicatorVideoCapture(m_session); break; 1021 case IndicatorType_Features: m_pool[indicatorType] = new UIIndicatorFeatures(m_session); break; 1022 case IndicatorType_Mouse: m_pool[indicatorType] = new UIIndicatorMouse(m_session); break; 1023 case IndicatorType_Keyboard: m_pool[indicatorType] = new UIIndicatorKeyboard(m_session); break; 1024 case IndicatorType_KeyboardExtension: m_pool[indicatorType] = new UIIndicatorKeyboardExtension; break; 1025 default: break; 1026 } 1027 /* Configure indicator: */ 1028 connect(m_pool.value(indicatorType), SIGNAL(sigContextMenuRequest(QIStatusBarIndicator*, QContextMenuEvent*)), 1029 this, SLOT(sltContextMenuRequest(QIStatusBarIndicator*, QContextMenuEvent*))); 1030 /* Insert indicator into main-layout: */ 1031 m_pMainLayout->insertWidget(indicatorPosition(indicatorType), m_pool.value(indicatorType)); 1032 } 1033 } 1034 } 1035 1036 void UIIndicatorsPool::cleanupUpdateTimer() 1037 { 1038 /* Destroy auto-update timer: */ 1039 AssertPtrReturnVoid(m_pTimerAutoUpdate); 1040 { 1041 m_pTimerAutoUpdate->stop(); 1042 delete m_pTimerAutoUpdate; 1043 m_pTimerAutoUpdate = 0; 1044 } 1045 } 1046 1047 void UIIndicatorsPool::cleanupContents() 1048 { 1049 /* Cleanup indicators: */ 1050 while (!m_pool.isEmpty()) 1051 { 1052 const IndicatorType firstType = m_pool.keys().first(); 1053 delete m_pool.value(firstType); 1054 m_pool.remove(firstType); 834 1055 } 835 1056 } … … 837 1058 void UIIndicatorsPool::cleanup() 838 1059 { 839 /* Wipe-out indicator-pool: */ 840 for (int iIndex = 0; iIndex < IndicatorType_Max; ++iIndex) 841 { 842 /* Wipe-out indicator: */ 843 delete m_pool[iIndex]; 844 m_pool[iIndex] = 0; 1060 /* Cleanup auto-update timer: */ 1061 cleanupUpdateTimer(); 1062 /* Cleanup indicators: */ 1063 cleanupContents(); 1064 } 1065 1066 int UIIndicatorsPool::indicatorPosition(IndicatorType indicatorType) const 1067 { 1068 int iPosition = 0; 1069 foreach (const IndicatorType &iteratedIndicatorType, m_pool.keys()) 1070 if (iteratedIndicatorType == indicatorType) 1071 return iPosition; 1072 else 1073 ++iPosition; 1074 return iPosition; 1075 } 1076 1077 void UIIndicatorsPool::updateIndicatorStateForDevice(QIStatusBarIndicator *pIndicator, KDeviceType deviceType) 1078 { 1079 /* Assert indicators with NO state: */ 1080 QIStateStatusBarIndicator *pStateIndicator = qobject_cast<QIStateStatusBarIndicator*>(pIndicator); 1081 AssertPtrReturnVoid(pStateIndicator); 1082 1083 /* Skip indicators with NULL state: */ 1084 if (pStateIndicator->state() == KDeviceActivity_Null) 1085 return; 1086 1087 /* Paused VM have all indicator states set to IDLE: */ 1088 if (m_pSession->isPaused()) 1089 { 1090 /* If current state differs from IDLE => set the IDLE one: */ 1091 if (pStateIndicator->state() != KDeviceActivity_Idle) 1092 pStateIndicator->setState(KDeviceActivity_Idle); 1093 } 1094 else 1095 { 1096 /* Get actual indicator state: */ 1097 const int iState = m_session.GetConsole().GetDeviceActivity(deviceType); 1098 /* If curren state differs from actual => set the actual one: */ 1099 if (pStateIndicator->state() != iState) 1100 pStateIndicator->setState(iState); 845 1101 } 846 1102 } 847 1103 848 1104 #include "UIIndicatorsPool.moc" 1105 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h
r51187 r51992 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIIndicatorsPool class declaration 2 * VBox Qt GUI - UIIndicatorsPool class declaration. 5 3 */ 6 4 … … 17 15 */ 18 16 19 #ifndef __UIIndicatorsPool_h__ 20 #define __UIIndicatorsPool_h__ 17 #ifndef ___UIIndicatorsPool_h___ 18 #define ___UIIndicatorsPool_h___ 19 20 /* Qt includes: */ 21 #include <QWidget> 22 #include <QList> 23 #include <QMap> 21 24 22 25 /* GUI includes: */ 23 #include "QIStateIndicator.h"24 26 #include "UIExtraDataDefs.h" 25 27 28 /* COM includes: */ 29 #include "COMEnums.h" 30 26 31 /* Forward declarations: */ 32 class UISession; 27 33 class CSession; 34 class QIStatusBarIndicator; 35 class QHBoxLayout; 36 class QTimer; 28 37 29 /* Indicator pool interface/prototype: */ 30 class UIIndicatorsPool : public QObject 38 /** QWidget extension 39 * providing Runtime UI with status-bar indicators. */ 40 class UIIndicatorsPool : public QWidget 31 41 { 32 42 Q_OBJECT; 33 43 44 signals: 45 46 /** Notifies about context menu request. 47 * @param indicatorType reflects which type of indicator it is, 48 * @param position reflects contex-menu position. */ 49 void sigContextMenuRequest(IndicatorType indicatorType, const QPoint &position); 50 34 51 public: 35 52 36 /* Constructor/destructor: */ 37 UIIndicatorsPool(CSession &session, QObject *pParent); 53 /** Constructor, passes @a pParent to the QWidget constructor. 54 * @param pSession is used to retrieve appearance information. */ 55 UIIndicatorsPool(UISession *pSession, QWidget *pParent = 0); 56 /** Destructor. */ 38 57 ~UIIndicatorsPool(); 39 58 40 /* API indicator access stuff: */ 41 QIStateIndicator* indicator(IndicatorType index); 59 /** Returns indicator corresponding to passed @a indicatorType. */ 60 QIStatusBarIndicator* indicator(IndicatorType indicatorType) const { return m_pool.value(indicatorType); } 61 62 /** Updates appearance for passed @a indicatorType. */ 63 void updateAppearance(IndicatorType indicatorType); 64 65 /** Defines whether indicator-states auto-update is @a fEnabled. */ 66 void setAutoUpdateIndicatorStates(bool fEnabled); 67 68 private slots: 69 70 /** Handles indicator-states auto-update. */ 71 void sltAutoUpdateIndicatorStates(); 72 73 /** Handles context-menu request. */ 74 void sltContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent); 42 75 43 76 private: 44 77 45 /* Helpers: Prepare/cleanup stuff:*/78 /** Prepare routine. */ 46 79 void prepare(); 80 /** Prepare connections routine: */ 81 void prepareConnections(); 82 /** Prepare contents routine. */ 83 void prepareContents(); 84 /** Prepare update-timer routine: */ 85 void prepareUpdateTimer(); 86 87 /** Update pool routine. */ 88 void updatePool(); 89 90 /** Cleanup update-timer routine: */ 91 void cleanupUpdateTimer(); 92 /** Cleanup contents routine. */ 93 void cleanupContents(); 94 /** Cleanup routine. */ 47 95 void cleanup(); 48 96 49 /* Variables: */ 97 /** Returns position for passed @a indicatorType. */ 98 int indicatorPosition(IndicatorType indicatorType) const; 99 100 /** Updates state for passed @a pIndicator through @a deviceType. */ 101 void updateIndicatorStateForDevice(QIStatusBarIndicator *pIndicator, KDeviceType deviceType); 102 103 /** Holds the UI session reference. */ 104 UISession *m_pSession; 105 /** Holds the session reference. */ 50 106 CSession &m_session; 51 QVector<QIStateIndicator*> m_pool; 107 /** Holds the cached configuration. */ 108 QList<IndicatorType> m_configuration; 109 /** Holds cached indicator instances. */ 110 QMap<IndicatorType, QIStatusBarIndicator*> m_pool; 111 /** Holds the main-layout instance. */ 112 QHBoxLayout *m_pMainLayout; 113 /** Holds the auto-update timer instance. */ 114 QTimer *m_pTimerAutoUpdate; 52 115 }; 53 116 54 #endif // __UIIndicatorsPool_h__ 55 117 #endif /* !___UIIndicatorsPool_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r51679 r51992 37 37 #include "UIMachineView.h" 38 38 #include "QIStatusBar.h" 39 #include "QIStateIndicator.h" 40 #include "UIHostComboEditor.h" 39 #include "QIStatusBarIndicator.h" 41 40 #ifdef Q_WS_MAC 42 41 # include "VBoxUtils.h" … … 52 51 UIMachineWindowNormal::UIMachineWindowNormal(UIMachineLogic *pMachineLogic, ulong uScreenId) 53 52 : UIMachineWindow(pMachineLogic, uScreenId) 54 , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this)) 55 , m_pNameHostkey(0) 56 , m_pIdleTimer(0) 53 , m_pIndicatorsPool(0) 57 54 { 58 55 } … … 115 112 } 116 113 117 void UIMachineWindowNormal::sltUpdateIndicators() 118 { 119 /* Update indicators: */ 120 if (indicatorsPool()->indicator(IndicatorType_HardDisks)) 121 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_HardDisks), KDeviceType_HardDisk); 122 if (indicatorsPool()->indicator(IndicatorType_OpticalDisks)) 123 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_OpticalDisks), KDeviceType_DVD); 124 if (indicatorsPool()->indicator(IndicatorType_FloppyDisks)) 125 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_FloppyDisks), KDeviceType_Floppy); 126 if (indicatorsPool()->indicator(IndicatorType_USB)) 127 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_USB), KDeviceType_USB); 128 if (indicatorsPool()->indicator(IndicatorType_Network)) 129 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_Network), KDeviceType_Network); 130 if (indicatorsPool()->indicator(IndicatorType_SharedFolders)) 131 updateIndicatorState(indicatorsPool()->indicator(IndicatorType_SharedFolders), KDeviceType_SharedFolder); 132 } 133 134 void UIMachineWindowNormal::sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent) 135 { 136 /* Show hard-disks LED context menu: */ 137 if (pIndicator == indicatorsPool()->indicator(IndicatorType_HardDisks)) 138 { 139 if (gActionPool->action(UIActionIndexRuntime_Menu_HardDisks)->isEnabled()) 140 gActionPool->action(UIActionIndexRuntime_Menu_HardDisks)->menu()->exec(pEvent->globalPos()); 141 } 142 /* Show optical-disks LED context menu: */ 143 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_OpticalDisks)) 144 { 145 if (gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->isEnabled()) 146 gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->menu()->exec(pEvent->globalPos()); 147 } 148 /* Show floppy-disks LED context menu: */ 149 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_FloppyDisks)) 150 { 151 if (gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->isEnabled()) 152 gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->menu()->exec(pEvent->globalPos()); 153 } 154 /* Show usb LED context menu: */ 155 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_USB)) 156 { 157 if (gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->isEnabled()) 158 gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->menu()->exec(pEvent->globalPos()); 159 } 160 /* Show network LED context menu: */ 161 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_Network)) 162 { 163 if (gActionPool->action(UIActionIndexRuntime_Menu_Network)->isEnabled()) 164 gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu()->exec(pEvent->globalPos()); 165 } 166 /* Show shared-folders LED context menu: */ 167 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_SharedFolders)) 168 { 169 if (gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders)->isEnabled()) 170 gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders)->menu()->exec(pEvent->globalPos()); 171 } 172 /* Show video-capture LED context menu: */ 173 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_VideoCapture)) 174 { 175 if (gActionPool->action(UIActionIndexRuntime_Menu_VideoCapture)->isEnabled()) 176 gActionPool->action(UIActionIndexRuntime_Menu_VideoCapture)->menu()->exec(pEvent->globalPos()); 177 } 178 /* Show mouse LED context menu: */ 179 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_Mouse)) 180 { 181 if (gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration)->isEnabled()) 182 gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration)->menu()->exec(pEvent->globalPos()); 183 } 184 /* Show keyboard LED context menu: */ 185 else if (pIndicator == indicatorsPool()->indicator(IndicatorType_Keyboard)) 186 { 187 if (gActionPool->action(UIActionIndexRuntime_Menu_Keyboard)->isEnabled()) 188 gActionPool->action(UIActionIndexRuntime_Menu_Keyboard)->menu()->exec(pEvent->globalPos()); 189 } 190 } 191 192 void UIMachineWindowNormal::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */) 193 { 194 /* Update host-combination status-bar label: */ 195 if (m_pNameHostkey) 196 m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())); 114 void UIMachineWindowNormal::sltHandleIndicatorContextMenuRequest(IndicatorType indicatorType, const QPoint &position) 115 { 116 /* Determine action depending on indicator-type: */ 117 UIAction *pAction = 0; 118 switch (indicatorType) 119 { 120 case IndicatorType_HardDisks: pAction = gActionPool->action(UIActionIndexRuntime_Menu_HardDisks); break; 121 case IndicatorType_OpticalDisks: pAction = gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices); break; 122 case IndicatorType_FloppyDisks: pAction = gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices); break; 123 case IndicatorType_USB: pAction = gActionPool->action(UIActionIndexRuntime_Menu_USBDevices); break; 124 case IndicatorType_Network: pAction = gActionPool->action(UIActionIndexRuntime_Menu_Network); break; 125 case IndicatorType_SharedFolders: pAction = gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders); break; 126 case IndicatorType_VideoCapture: pAction = gActionPool->action(UIActionIndexRuntime_Menu_VideoCapture); break; 127 case IndicatorType_Mouse: pAction = gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration); break; 128 case IndicatorType_Keyboard: pAction = gActionPool->action(UIActionIndexRuntime_Menu_Keyboard); break; 129 default: break; 130 } 131 /* Raise action's context-menu: */ 132 if (pAction && pAction->isEnabled()) 133 pAction->menu()->exec(position); 197 134 } 198 135 … … 249 186 UIMachineWindow::prepareStatusBar(); 250 187 251 /* Setup: */ 252 setStatusBar(new QIStatusBar(this)); 253 QWidget *pIndicatorBox = new QWidget; 254 QHBoxLayout *pIndicatorBoxHLayout = new QHBoxLayout(pIndicatorBox); 255 pIndicatorBoxHLayout->setContentsMargins(0, 0, 0, 0); 256 pIndicatorBoxHLayout->setSpacing(5); 257 bool fAtLeastOneAddedToLeftSection = false; 258 259 /* Hard Disks: */ 260 if (QIStateIndicator *pLedHardDisks = indicatorsPool()->indicator(IndicatorType_HardDisks)) 261 { 262 pIndicatorBoxHLayout->addWidget(pLedHardDisks); 263 connect(pLedHardDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 264 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 265 fAtLeastOneAddedToLeftSection = true; 266 } 267 268 /* Optical Disks: */ 269 if (QIStateIndicator *pLedOpticalDisks = indicatorsPool()->indicator(IndicatorType_OpticalDisks)) 270 { 271 pIndicatorBoxHLayout->addWidget(pLedOpticalDisks); 272 connect(pLedOpticalDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 273 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 274 fAtLeastOneAddedToLeftSection = true; 275 } 276 277 /* Floppy Disks: */ 278 if (QIStateIndicator *pLedFloppyDisks = indicatorsPool()->indicator(IndicatorType_FloppyDisks)) 279 { 280 pIndicatorBoxHLayout->addWidget(pLedFloppyDisks); 281 connect(pLedFloppyDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 282 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 283 fAtLeastOneAddedToLeftSection = true; 284 } 285 286 /* USB: */ 287 if (QIStateIndicator *pLedUSB = indicatorsPool()->indicator(IndicatorType_USB)) 288 { 289 pIndicatorBoxHLayout->addWidget(pLedUSB); 290 connect(pLedUSB, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 291 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 292 fAtLeastOneAddedToLeftSection = true; 293 } 294 295 /* Network: */ 296 if (QIStateIndicator *pLedNetwork = indicatorsPool()->indicator(IndicatorType_Network)) 297 { 298 pIndicatorBoxHLayout->addWidget(pLedNetwork); 299 connect(pLedNetwork, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 300 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 301 fAtLeastOneAddedToLeftSection = true; 302 } 303 304 /* Shared Folders: */ 305 if (QIStateIndicator *pLedSharedFolders = indicatorsPool()->indicator(IndicatorType_SharedFolders)) 306 { 307 pIndicatorBoxHLayout->addWidget(pLedSharedFolders); 308 connect(pLedSharedFolders, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 309 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 310 fAtLeastOneAddedToLeftSection = true; 311 } 312 313 /* Video Capture: */ 314 if (QIStateIndicator *pLedVideoCapture = indicatorsPool()->indicator(IndicatorType_VideoCapture)) 315 { 316 pIndicatorBoxHLayout->addWidget(pLedVideoCapture); 317 connect(pLedVideoCapture, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 318 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 319 fAtLeastOneAddedToLeftSection = true; 320 } 321 322 /* Features: */ 323 if (QIStateIndicator *pLedFeatures = indicatorsPool()->indicator(IndicatorType_Features)) 324 { 325 pIndicatorBoxHLayout->addWidget(pLedFeatures); 326 fAtLeastOneAddedToLeftSection = true; 327 } 328 329 /* Separator: */ 330 if (fAtLeastOneAddedToLeftSection) 331 { 332 QFrame *pSeparator = new QFrame; 333 pSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken); 334 pIndicatorBoxHLayout->addWidget(pSeparator); 335 } 336 337 /* Mouse: */ 338 if (QIStateIndicator *pLedMouse = indicatorsPool()->indicator(IndicatorType_Mouse)) 339 { 340 pIndicatorBoxHLayout->addWidget(pLedMouse); 341 connect(pLedMouse, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 342 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 343 } 344 345 /* Keyboard: */ 346 if (QIStateIndicator *pLedKeyboard = indicatorsPool()->indicator(IndicatorType_Keyboard)) 347 { 348 if (QWidget *pContainerWidgetHostkey = new QWidget) 349 { 350 if (QHBoxLayout *pContainerLayoutHostkey = new QHBoxLayout(pContainerWidgetHostkey)) 351 { 352 pContainerLayoutHostkey->setContentsMargins(0, 0, 0, 0); 353 pContainerLayoutHostkey->setSpacing(3); 354 m_pNameHostkey = new QLabel(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())); 355 pContainerLayoutHostkey->addWidget(pLedKeyboard); 356 pContainerLayoutHostkey->addWidget(m_pNameHostkey); 357 } 358 pIndicatorBoxHLayout->addWidget(pContainerWidgetHostkey); 359 } 360 connect(pLedKeyboard, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 361 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 362 } 363 364 /* Add to status-bar: */ 365 statusBar()->addPermanentWidget(pIndicatorBox, 0); 366 367 /* Create & start timer to update LEDs: */ 368 m_pIdleTimer = new QTimer(this); 369 connect(m_pIdleTimer, SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 370 m_pIdleTimer->start(100); 188 /* Create status-bar: */ 189 setStatusBar(new QIStatusBar); 190 AssertPtrReturnVoid(statusBar()); 191 { 192 /* Create indicator-pool: */ 193 m_pIndicatorsPool = new UIIndicatorsPool(machineLogic()->uisession()); 194 AssertPtrReturnVoid(m_pIndicatorsPool); 195 { 196 /* Configure indicator-pool: */ 197 connect(m_pIndicatorsPool, SIGNAL(sigContextMenuRequest(IndicatorType, const QPoint&)), 198 this, SLOT(sltHandleIndicatorContextMenuRequest(IndicatorType, const QPoint&))); 199 /* Add indicator-pool into status-bar: */ 200 statusBar()->addPermanentWidget(m_pIndicatorsPool, 0); 201 } 202 } 371 203 372 204 #ifdef Q_WS_MAC … … 390 222 #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 391 223 392 /* Make sure host-combination LED will be updated: */393 connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),394 this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));395 396 224 #ifdef Q_WS_MAC 397 225 /* Beta label? */ … … 409 237 UIMachineWindow::prepareHandlers(); 410 238 411 /* Connect keyboard state-change handler: */ 412 if (indicatorsPool()->indicator(IndicatorType_Keyboard)) 239 /* Get keyboard/mouse indicators: */ 240 QIStateStatusBarIndicator *pKeyboardIndicator = 241 qobject_cast<QIStateStatusBarIndicator*>(m_pIndicatorsPool->indicator(IndicatorType_Keyboard)); 242 QIStateStatusBarIndicator *pMouseIndicator = 243 qobject_cast<QIStateStatusBarIndicator*>(m_pIndicatorsPool->indicator(IndicatorType_Mouse)); 244 245 /* Connect keyboard/mouse state-change handlers: */ 246 if (pKeyboardIndicator) 413 247 connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)), 414 indicatorsPool()->indicator(IndicatorType_Keyboard), SLOT(setState(int))); 415 /* Connect mouse state-change handler: */ 416 if (indicatorsPool()->indicator(IndicatorType_Mouse)) 248 pKeyboardIndicator, SLOT(setState(int))); 249 if (pMouseIndicator) 417 250 connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)), 418 indicatorsPool()->indicator(IndicatorType_Mouse), SLOT(setState(int))); 251 pMouseIndicator, SLOT(setState(int))); 252 419 253 /* Early initialize created connections: */ 420 if ( indicatorsPool()->indicator(IndicatorType_Keyboard))421 indicatorsPool()->indicator(IndicatorType_Keyboard)->setState(machineLogic()->keyboardHandler()->keyboardState());422 if ( indicatorsPool()->indicator(IndicatorType_Mouse))423 indicatorsPool()->indicator(IndicatorType_Mouse)->setState(machineLogic()->mouseHandler()->mouseState());254 if (pKeyboardIndicator) 255 pKeyboardIndicator->setState(machineLogic()->keyboardHandler()->keyboardState()); 256 if (pMouseIndicator) 257 pMouseIndicator->setState(machineLogic()->mouseHandler()->mouseState()); 424 258 } 425 259 … … 440 274 statusBar()->setHidden(settings.isFeatureActive("noStatusBar")); 441 275 if (statusBar()->isHidden()) 442 m_pIdleTimer->stop(); 443 } 444 445 /* Load availability settings: */ 446 { 447 /* USB Stuff: */ 448 if (indicatorsPool()->indicator(IndicatorType_USB)) 449 { 450 bool fUSBEnabled = !m.GetUSBDeviceFilters().isNull() 451 && !m.GetUSBControllers().isEmpty() 452 && m.GetUSBProxyAvailable(); 453 454 if (!fUSBEnabled) 455 { 456 /* Hide USB menu: */ 457 indicatorsPool()->indicator(IndicatorType_USB)->setHidden(true); 458 } 459 else 460 { 461 /* Toggle USB LED: */ 462 indicatorsPool()->indicator(IndicatorType_USB)->setState(KDeviceActivity_Idle); 463 } 464 } 276 m_pIndicatorsPool->setAutoUpdateIndicatorStates(false); 465 277 } 466 278 … … 533 345 } 534 346 535 void UIMachineWindowNormal::cleanupStatusBar()536 {537 /* Stop LED-update timer: */538 m_pIdleTimer->stop();539 m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT(sltUpdateIndicators()));540 541 /* Call to base-class: */542 UIMachineWindow::cleanupStatusBar();543 }544 545 void UIMachineWindowNormal::retranslateUi()546 {547 /* Call to base-class: */548 UIMachineWindow::retranslateUi();549 550 /* Translate host-combo LED: */551 if (m_pNameHostkey)552 {553 m_pNameHostkey->setToolTip(554 QApplication::translate("UIMachineWindowNormal", "Shows the currently assigned Host key.<br>"555 "This key, when pressed alone, toggles the keyboard and mouse "556 "capture state. It can also be used in combination with other keys "557 "to quickly perform actions from the main menu."));558 m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));559 }560 }561 562 347 bool UIMachineWindowNormal::event(QEvent *pEvent) 563 348 { … … 671 456 if (!statusBar()->isHidden()) 672 457 { 673 if (uisession()->isPaused() && m_pIdleTimer->isActive()) 674 m_pIdleTimer->stop(); 675 else if (uisession()->isRunning() && !m_pIdleTimer->isActive()) 676 m_pIdleTimer->start(100); 677 sltUpdateIndicators(); 678 } 679 } 680 if ((iElement & UIVisualElement_HDStuff) && 681 indicatorsPool()->indicator(IndicatorType_HardDisks)) 682 indicatorsPool()->indicator(IndicatorType_HardDisks)->updateAppearance(); 683 if ((iElement & UIVisualElement_CDStuff) && 684 indicatorsPool()->indicator(IndicatorType_OpticalDisks)) 685 indicatorsPool()->indicator(IndicatorType_OpticalDisks)->updateAppearance(); 686 if ((iElement & UIVisualElement_FDStuff) && 687 indicatorsPool()->indicator(IndicatorType_FloppyDisks)) 688 indicatorsPool()->indicator(IndicatorType_FloppyDisks)->updateAppearance(); 689 if ((iElement & UIVisualElement_NetworkStuff) && 690 indicatorsPool()->indicator(IndicatorType_Network)) 691 indicatorsPool()->indicator(IndicatorType_Network)->updateAppearance(); 692 if ((iElement & UIVisualElement_USBStuff) && 693 indicatorsPool()->indicator(IndicatorType_USB) && 694 !indicatorsPool()->indicator(IndicatorType_USB)->isHidden()) 695 indicatorsPool()->indicator(IndicatorType_USB)->updateAppearance(); 696 if ((iElement & UIVisualElement_SharedFolderStuff) && 697 indicatorsPool()->indicator(IndicatorType_SharedFolders)) 698 indicatorsPool()->indicator(IndicatorType_SharedFolders)->updateAppearance(); 699 if ((iElement & UIVisualElement_VideoCapture) && 700 indicatorsPool()->indicator(IndicatorType_VideoCapture)) 701 indicatorsPool()->indicator(IndicatorType_VideoCapture)->updateAppearance(); 702 if ((iElement & UIVisualElement_FeaturesStuff) && 703 indicatorsPool()->indicator(IndicatorType_Features)) 704 indicatorsPool()->indicator(IndicatorType_Features)->updateAppearance(); 458 if (uisession()->isPaused()) 459 m_pIndicatorsPool->setAutoUpdateIndicatorStates(false); 460 else if (uisession()->isRunning()) 461 m_pIndicatorsPool->setAutoUpdateIndicatorStates(true); 462 } 463 } 464 if (iElement & UIVisualElement_HDStuff) 465 m_pIndicatorsPool->updateAppearance(IndicatorType_HardDisks); 466 if (iElement & UIVisualElement_CDStuff) 467 m_pIndicatorsPool->updateAppearance(IndicatorType_OpticalDisks); 468 if (iElement & UIVisualElement_FDStuff) 469 m_pIndicatorsPool->updateAppearance(IndicatorType_FloppyDisks); 470 if (iElement & UIVisualElement_NetworkStuff) 471 m_pIndicatorsPool->updateAppearance(IndicatorType_Network); 472 if (iElement & UIVisualElement_USBStuff) 473 m_pIndicatorsPool->updateAppearance(IndicatorType_USB); 474 if (iElement & UIVisualElement_SharedFolderStuff) 475 m_pIndicatorsPool->updateAppearance(IndicatorType_SharedFolders); 476 if (iElement & UIVisualElement_VideoCapture) 477 m_pIndicatorsPool->updateAppearance(IndicatorType_VideoCapture); 478 if (iElement & UIVisualElement_FeaturesStuff) 479 m_pIndicatorsPool->updateAppearance(IndicatorType_Features); 705 480 } 706 481 … … 716 491 } 717 492 718 void UIMachineWindowNormal::updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType) 719 { 720 /* Do NOT update indicators with NULL state: */ 721 if (pIndicator->state() == KDeviceActivity_Null) 722 return; 723 724 /* Paused VM have all indicator states set to IDLE: */ 725 bool fPaused = uisession()->isPaused(); 726 if (fPaused) 727 { 728 /* If state differs from IDLE => set IDLE one: */ 729 if (pIndicator->state() != KDeviceActivity_Idle) 730 pIndicator->setState(KDeviceActivity_Idle); 731 } 732 else 733 { 734 /* Get current indicator state: */ 735 int state = session().GetConsole().GetDeviceActivity(deviceType); 736 /* If state differs => set new one: */ 737 if (pIndicator->state() != state) 738 pIndicator->setState(state); 739 } 740 } 741 493 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h
r49177 r51992 20 20 #define __UIMachineWindowNormal_h__ 21 21 22 /* Global includes: */23 #include <QLabel>24 25 22 /* Local includes: */ 26 23 #include "UIMachineWindow.h" … … 29 26 class CMediumAttachment; 30 27 class UIIndicatorsPool; 31 class QIStateIndicator;32 28 33 29 /* Normal machine-window implementation: */ … … 58 54 void sltCPUExecutionCapChange(); 59 55 60 /* LED connections: */ 61 void sltUpdateIndicators(); 62 void sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent); 63 void sltProcessGlobalSettingChange(const char *aPublicName, const char *aName); 56 /** Handles indicator context-menu-request: */ 57 void sltHandleIndicatorContextMenuRequest(IndicatorType indicatorType, const QPoint &position); 64 58 65 59 private: … … 77 71 //void cleanupHandlers() {} 78 72 //coid cleanupVisualState() {} 79 void cleanupStatusBar();73 //void cleanupStatusBar() {} 80 74 //void cleanupMenu() {} 81 75 //void cleanupConsoleConnections() {} 82 83 /* Translate stuff: */84 void retranslateUi();85 76 86 77 /* Show stuff: */ … … 97 88 98 89 /* Helpers: */ 99 UIIndicatorsPool* indicatorsPool() { return m_pIndicatorsPool; }100 90 bool isMaximizedChecked(); 101 void updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType);102 91 103 /* Widgets:*/92 /** Holds the indicator-pool instance. */ 104 93 UIIndicatorsPool *m_pIndicatorsPool; 105 QLabel *m_pNameHostkey;106 94 107 /* Variables: */ 108 QTimer *m_pIdleTimer; 95 /** Holds current window geometry. */ 109 96 QRect m_normalGeometry; 110 97 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r51937 r51992 1350 1350 1351 1351 /* Add network-manager indicator: */ 1352 QIStateIndicator *pIndicator = gNetworkManager->indicator();1352 UINetworkManagerIndicator *pIndicator = gNetworkManager->indicator(); 1353 1353 statusBar()->addPermanentWidget(pIndicator); 1354 1354 pIndicator->updateAppearance();
Note:
See TracChangeset
for help on using the changeset viewer.