VirtualBox

Ignore:
Timestamp:
Jul 11, 2014 2:32:04 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94926
Message:

FE/Qt: Runtime UI: Status-bar indicator rework/cleanup (part 1).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
10 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r51937 r51992  
    268268        src/extensions/QIRichToolButton.h \
    269269        src/extensions/QISplitter.h \
    270         src/extensions/QIStateIndicator.h \
    271270        src/extensions/QIStatusBar.h \
     271        src/extensions/QIStatusBarIndicator.h \
    272272        src/extensions/QITabWidget.h \
    273273        src/extensions/QITableView.h \
     
    538538        src/extensions/QIRichToolButton.cpp \
    539539        src/extensions/QISplitter.cpp \
    540         src/extensions/QIStateIndicator.cpp \
    541540        src/extensions/QIStatusBar.cpp \
     541        src/extensions/QIStatusBarIndicator.cpp \
    542542        src/extensions/QITableView.cpp \
    543543        src/extensions/QITreeView.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStatusBarIndicator.cpp

    r51961 r51992  
    11/* $Id$ */
    22/** @file
    3  *
    4  * VBox frontends: Qt GUI ("VirtualBox"):
    5  * VirtualBox Qt extensions: QIStateIndicator class implementation
     3 * VBox Qt GUI - QIStatusBarIndicator interface implementation.
    64 */
    75
    86/*
    9  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    108 *
    119 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1816 */
    1917
    20 #include "QIStateIndicator.h"
    21 
    22 /* Qt includes */
     18/* Qt includes: */
    2319#include <QIcon>
    2420#include <QPainter>
     21#include <QHBoxLayout>
     22#include <QLabel>
    2523#ifdef Q_WS_MAC
    2624# include <QContextMenuEvent>
    27 #endif
     25#endif /* Q_WS_MAC */
    2826
    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
     31QIStatusBarIndicator::QIStatusBarIndicator(QWidget *pParent /* = 0 */)
     32    : QWidget(pParent)
    3333{
     34    /* Configure size-policy: */
    3435    setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
    3536}
    3637
    37 QIStateIndicator::~QIStateIndicator()
    38 {
    39     qDeleteAll (mStateIcons);
    40 }
    41 
    42 QSize QIStateIndicator::sizeHint() const
    43 {
    44     return mSize;
    45 }
    46 
    47 QPixmap QIStateIndicator::stateIcon(int state) const
    48 {
    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 
    8838#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)
     39void QIStatusBarIndicator::mousePressEvent(QMouseEvent *pEvent)
    9440{
    9541    /* Do this for the left mouse button event only, cause in the case of the
     
    9743     * triggered twice. Also this isn't necessary for the middle mouse button
    9844     * which would be some kind of overstated. */
    99     if (aEv->button() == Qt::LeftButton)
     45    if (pEvent->button() == Qt::LeftButton)
    10046    {
    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();
    10551        else
    106             QFrame::mousePressEvent (aEv);
     52            QWidget::mousePressEvent(pEvent);
    10753    }
    10854    else
    109         QFrame::mousePressEvent (aEv);
     55        QWidget::mousePressEvent(pEvent);
    11056}
    11157#endif /* Q_WS_MAC */
    11258
    113 void QIStateIndicator::mouseDoubleClickEvent (QMouseEvent * e)
     59void QIStatusBarIndicator::mouseDoubleClickEvent(QMouseEvent *pEvent)
    11460{
    115     emit mouseDoubleClicked (this, e);
     61    emit sigMouseDoubleClick(this, pEvent);
    11662}
    11763
    118 void QIStateIndicator::contextMenuEvent (QContextMenuEvent * e)
     64void QIStatusBarIndicator::contextMenuEvent(QContextMenuEvent *pEvent)
    11965{
    120     emit contextMenuRequested (this, e);
     66    emit sigContextMenuRequest(this, pEvent);
    12167}
    12268
     69
     70QIStateStatusBarIndicator::QIStateStatusBarIndicator(QWidget *pParent /* = 0 */)
     71  : QIStatusBarIndicator(pParent)
     72  , m_iState(0)
     73{
     74}
     75
     76QIcon QIStateStatusBarIndicator::stateIcon(int iState) const
     77{
     78    /* Check if state-icon was set before: */
     79    return m_icons.value(iState, QIcon());
     80}
     81
     82void 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
     90void QIStateStatusBarIndicator::paintEvent(QPaintEvent*)
     91{
     92    QPainter painter(this);
     93    drawContents(&painter);
     94}
     95
     96void 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
     103QITextStatusBarIndicator::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
     123QString QITextStatusBarIndicator::text() const
     124{
     125    return m_pLabel->text();
     126}
     127
     128void QITextStatusBarIndicator::setText(const QString &strText)
     129{
     130    m_pLabel->setText(strText);
     131}
     132
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStatusBarIndicator.h

    r51961 r51992  
    11/** @file
    2  *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VirtualBox Qt extensions: QIStateIndicator class declaration
     2 * VBox Qt GUI - QIStatusBarIndicator interface declaration.
    53 */
    64
    75/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     6 * Copyright (C) 2006-2014 Oracle Corporation
    97 *
    108 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1715 */
    1816
    19 #ifndef __QIStateIndicator_h__
    20 #define __QIStateIndicator_h__
     17#ifndef ___QIStatusBarIndicators_h___
     18#define ___QIStatusBarIndicators_h___
    2119
    22 /* Qt includes */
    23 #include <QFrame>
    24 #include <QHash>
     20/* Qt includes: */
     21#include <QWidget>
     22#include <QMap>
     23#include <QIcon>
    2524
    26 /* GUI includes: */
    27 #include "QIWithRetranslateUI.h"
     25/* Forward declarations: */
     26class QLabel;
    2827
    29 class QIStateIndicator : public QIWithRetranslateUI<QFrame>
     28/** QWidget extension used as status-bar indicator. */
     29class QIStatusBarIndicator : public QWidget
     30{
     31    Q_OBJECT;
     32
     33signals:
     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
     40public:
     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
     48protected:
     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. */
     66class QIStateStatusBarIndicator : public QIStatusBarIndicator
    3067{
    3168    Q_OBJECT;
     
    3370public:
    3471
    35     QIStateIndicator(QWidget *pParent = 0);
    36     ~QIStateIndicator();
     72    /** Constructor, passes @a pParent to the QIStatusBarIndicator constructor. */
     73    QIStateStatusBarIndicator(QWidget *pParent = 0);
    3774
    38     virtual QSize sizeHint() const;
     75    /** Returns current state. */
     76    int state() const { return m_iState; }
    3977
    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);
    4882
    4983public slots:
    5084
    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); }
    6089
    6190protected:
    6291
    63     virtual void paintEvent (QPaintEvent *aEv);
    64     virtual void drawContents (QPainter *aPainter);
     92    /** Paint-event handler. */
     93    virtual void paintEvent(QPaintEvent *pEvent);
    6594
    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);
    7197
    7298private:
    7399
    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;
    91104};
    92105
    93 #endif // __QIStateIndicator_h__
     106/** QIStatusBarIndicator extension used as status-bar state indicator. */
     107class QITextStatusBarIndicator : public QIStatusBarIndicator
     108{
     109    Q_OBJECT;
    94110
     111public:
     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
     121private:
     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  
    482482    IndicatorType_OpticalDisks,
    483483    IndicatorType_FloppyDisks,
     484    IndicatorType_USB,
    484485    IndicatorType_Network,
    485     IndicatorType_USB,
    486486    IndicatorType_SharedFolders,
    487487    IndicatorType_VideoCapture,
     
    489489    IndicatorType_Mouse,
    490490    IndicatorType_Keyboard,
     491    IndicatorType_KeyboardExtension,
    491492    IndicatorType_Max
    492493};
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.cpp

    r42901 r51992  
    115115    {
    116116        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()));
    118118    }
    119119}
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManagerIndicator.h

    r46650 r51992  
    2525
    2626/* Local includes: */
    27 #include "QIStateIndicator.h"
     27#include "QIStatusBarIndicator.h"
    2828
    2929/* Forward declarations: */
     
    3939
    4040/* Network-manager status-bar indicator: */
    41 class UINetworkManagerIndicator : public QIStateIndicator
     41class UINetworkManagerIndicator : public QIStateStatusBarIndicator
    4242{
    4343    Q_OBJECT;
     44
     45public:
     46
     47    /** Update routine. */
     48    void updateAppearance();
    4449
    4550protected:
     
    8994    /* Update stuff: */
    9095    void recalculateIndicatorState();
    91     void updateAppearance();
    9296
    9397    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/precomp.h

    r51304 r51992  
    176176#include "QIRichToolButton.h"
    177177#include "QISplitter.h"
    178 #include "QIStateIndicator.h"
    179178#include "QIStatusBar.h"
     179#include "QIStatusBarIndicator.h"
    180180#include "QIToolButton.h"
    181181#include "QITreeView.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r51322 r51992  
    11/* $Id$ */
    22/** @file
    3  *
    4  * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIIndicatorsPool class implementation
     3 * VBox Qt GUI - UIIndicatorsPool class implementation.
    64 */
    75
    86/*
    9  * Copyright (C) 2010-2012 Oracle Corporation
     7 * Copyright (C) 2010-2013 Oracle Corporation
    108 *
    119 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2119#include <QTimer>
    2220#include <QPainter>
     21#include <QHBoxLayout>
    2322
    2423/* GUI includes: */
    2524#include "UIIndicatorsPool.h"
    26 #include "VBoxGlobal.h"
     25#include "QIWithRetranslateUI.h"
    2726#include "UIExtraDataManager.h"
    2827#include "UIMachineDefs.h"
    2928#include "UIConverter.h"
    3029#include "UIAnimationFramework.h"
     30#include "UISession.h"
    3131#include "UIMedium.h"
    3232#include "UIIconPool.h"
     33#include "UIHostComboEditor.h"
     34#include "QIStatusBarIndicator.h"
     35#include "VBoxGlobal.h"
    3336
    3437/* COM includes: */
     
    5053#include <iprt/time.h>
    5154
    52 class UIIndicatorHardDisks : public QIStateIndicator
     55
     56/** QIStateStatusBarIndicator extension for Runtime UI. */
     57class UISessionStateStatusBarIndicator : public QIWithRetranslateUI<QIStateStatusBarIndicator>
    5358{
    5459    Q_OBJECT;
     
    5661public:
    5762
    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
     69protected:
     70
     71    /** Holds the session reference. */
     72    CSession &m_session;
     73};
     74
     75/** UISessionStateStatusBarIndicator extension for Runtime UI: Hard-drive indicator. */
     76class UIIndicatorHardDrive : public UISessionStateStatusBarIndicator
     77{
     78    Q_OBJECT;
     79
     80public:
     81
     82    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
     83    UIIndicatorHardDrive(CSession &session)
     84        : UISessionStateStatusBarIndicator(session)
    6085    {
    6186        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/hd_16px.png"));
     
    6792    }
    6893
     94private:
     95
     96    /** Retranslation routine. */
    6997    void retranslateUi()
    7098    {
     
    72100    }
    73101
     102    /** Update routine. */
    74103    void updateAppearance()
    75104    {
     
    109138        setState(fAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null);
    110139    }
    111 
    112 protected:
    113     /* For compatibility reason we do it here, later this should be moved to
    114      * QIStateIndicator. */
    115     CSession &m_session;
    116140};
    117141
    118 class UIIndicatorOpticalDisks : public QIStateIndicator
     142/** UISessionStateStatusBarIndicator extension for Runtime UI: Optical-drive indicator. */
     143class UIIndicatorOpticalDisks : public UISessionStateStatusBarIndicator
    119144{
    120145    Q_OBJECT;
     
    122147public:
    123148
     149    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    124150    UIIndicatorOpticalDisks(CSession &session)
    125       : m_session(session)
     151        : UISessionStateStatusBarIndicator(session)
    126152    {
    127153        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/cd_16px.png"));
     
    133159    }
    134160
     161private:
     162
     163    /** Retranslation routine. */
    135164    void retranslateUi()
    136165    {
     
    138167    }
    139168
     169    /** Update routine. */
    140170    void updateAppearance()
    141171    {
     
    179209        setState(fAttachmentsMounted ? KDeviceActivity_Idle : KDeviceActivity_Null);
    180210    }
    181 
    182 protected:
    183     /* For compatibility reason we do it here, later this should be moved to
    184      * QIStateIndicator. */
    185     CSession &m_session;
    186211};
    187212
    188 class UIIndicatorFloppyDisks : public QIStateIndicator
     213/** UISessionStateStatusBarIndicator extension for Runtime UI: Floppy-drive indicator. */
     214class UIIndicatorFloppyDisks : public UISessionStateStatusBarIndicator
    189215{
    190216    Q_OBJECT;
     
    192218public:
    193219
     220    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    194221    UIIndicatorFloppyDisks(CSession &session)
    195       : m_session(session)
     222        : UISessionStateStatusBarIndicator(session)
    196223    {
    197224        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/fd_16px.png"));
     
    203230    }
    204231
     232private:
     233
     234    /** Retranslation routine. */
    205235    void retranslateUi()
    206236    {
     
    208238    }
    209239
     240    /** Update routine. */
    210241    void updateAppearance()
    211242    {
     
    249280        setState(fAttachmentsMounted ? KDeviceActivity_Idle : KDeviceActivity_Null);
    250281    }
    251 
    252 protected:
    253     /* For compatibility reason we do it here, later this should be moved to
    254      * QIStateIndicator. */
    255     CSession &m_session;
    256282};
    257283
    258 class UIIndicatorNetwork : public QIStateIndicator
     284/** UISessionStateStatusBarIndicator extension for Runtime UI: Network indicator. */
     285class UIIndicatorNetwork : public UISessionStateStatusBarIndicator
    259286{
    260287    Q_OBJECT;
     
    262289public:
    263290
     291    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    264292    UIIndicatorNetwork(CSession &session)
    265       : m_session(session)
    266       , m_pUpdateTimer(new QTimer(this))
     293        : UISessionStateStatusBarIndicator(session)
     294        , m_pUpdateTimer(new QTimer(this))
    267295    {
    268296        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/nw_16px.png"));
     
    277305    }
    278306
     307private slots:
     308
     309    /** Updates network IP addresses. */
     310    void sltUpdateNetworkIPs()
     311    {
     312        updateAppearance();
     313    }
     314
     315private:
     316
     317    /** Retranslation routine. */
    279318    void retranslateUi()
    280319    {
     
    282321    }
    283322
     323    /** Update routine. */
    284324    void updateAppearance()
    285325    {
     
    348388        setToolTip(strToolTip.arg(strFullData));
    349389    }
    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. */
    361392    QTimer *m_pUpdateTimer;
    362393};
    363394
    364 class UIIndicatorUSB : public QIStateIndicator
     395/** UISessionStateStatusBarIndicator extension for Runtime UI: USB indicator. */
     396class UIIndicatorUSB : public UISessionStateStatusBarIndicator
    365397{
    366398    Q_OBJECT;
     
    368400public:
    369401
     402    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    370403    UIIndicatorUSB(CSession &session)
    371       : m_session(session)
     404        : UISessionStateStatusBarIndicator(session)
    372405    {
    373406        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/usb_16px.png"));
     
    379412    }
    380413
     414private:
     415
     416    /** Retranslation routine. */
    381417    void retranslateUi()
    382418    {
     
    384420    }
    385421
     422    /** Update routine. */
    386423    void updateAppearance()
    387424    {
     
    416453        setToolTip(strToolTip.arg(strFullData));
    417454    }
    418 
    419 protected:
    420     /* For compatibility reason we do it here, later this should be moved to
    421      * QIStateIndicator. */
    422     CSession &m_session;
    423455};
    424456
    425 class UIIndicatorSharedFolders : public QIStateIndicator
     457/** UISessionStateStatusBarIndicator extension for Runtime UI: Shared-folders indicator. */
     458class UIIndicatorSharedFolders : public UISessionStateStatusBarIndicator
    426459{
    427460    Q_OBJECT;
     
    429462public:
    430463
     464    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    431465    UIIndicatorSharedFolders(CSession &session)
    432       : m_session(session)
     466        : UISessionStateStatusBarIndicator(session)
    433467    {
    434468        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/sf_16px.png"));
     
    440474    }
    441475
     476private:
     477
     478    /** Retranslation routine. */
    442479    void retranslateUi()
    443480    {
     
    445482    }
    446483
     484    /** Update routine. */
    447485    void updateAppearance()
    448486    {
     
    491529        setToolTip(strToolTip.arg(strFullData));
    492530    }
    493 
    494 protected:
    495     /* For compatibility reason we do it here, later this should be moved to
    496      * QIStateIndicator. */
    497     CSession &m_session;
    498531};
    499532
    500 class UIIndicatorVideoCapture : public QIStateIndicator
     533/** UISessionStateStatusBarIndicator extension for Runtime UI: Video-capture indicator. */
     534class UIIndicatorVideoCapture : public UISessionStateStatusBarIndicator
    501535{
    502536    Q_OBJECT;
     
    505539    Q_PROPERTY(double rotationAngle READ rotationAngle WRITE setRotationAngle);
    506540
    507 public:
    508 
    509     /* State enumerator: */
     541    /** Video-capture states. */
    510542    enum UIIndicatorStateVideoCapture
    511543    {
     
    514546    };
    515547
    516     /* Constructor: */
     548public:
     549
     550    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    517551    UIIndicatorVideoCapture(CSession &session)
    518         : m_session(session)
     552        : UISessionStateStatusBarIndicator(session)
    519553        , m_pAnimation(0)
    520554        , m_dRotationAngle(0)
     
    533567    }
    534568
    535     /* API: Update stuff: */
     569private 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
     591private:
     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. */
    536622    void updateAppearance()
    537623    {
     
    563649    }
    564650
    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. */
    619652    double rotationAngleStart() const { return 0; }
     653    /** Returns rotation finish angle. */
    620654    double rotationAngleFinal() const { return 360; }
     655    /** Returns current rotation angle. */
    621656    double rotationAngle() const { return m_dRotationAngle; }
     657    /** Defines current rotation angle. */
    622658    void setRotationAngle(double dRotationAngle) { m_dRotationAngle = dRotationAngle; update(); }
    623659
    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. */
    627661    UIAnimationLoop *m_pAnimation;
     662    /** Holds current rotation angle. */
    628663    double m_dRotationAngle;
    629664};
    630665
    631 class UIIndicatorFeatures : public QIStateIndicator
     666/** UISessionStateStatusBarIndicator extension for Runtime UI: Features indicator. */
     667class UIIndicatorFeatures : public UISessionStateStatusBarIndicator
    632668{
    633669    Q_OBJECT;
     
    635671public:
    636672
     673    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    637674    UIIndicatorFeatures(CSession &session)
    638       : m_session(session)
     675        : UISessionStateStatusBarIndicator(session)
    639676    {
    640677        setStateIcon(0, UIIconPool::iconSet(":/vtx_amdv_disabled_16px.png"));
     
    644681    }
    645682
     683private:
     684
     685    /** Retranslation routine. */
    646686    void retranslateUi()
    647687    {
     
    649689    }
    650690
     691    /** Update routine. */
    651692    void updateAppearance()
    652693    {
     
    696737        setState(bVirtEnabled);
    697738    }
    698 
    699 protected:
    700     /* For compatibility reason we do it here, later this should be moved to
    701      * QIStateIndicator. */
    702     CSession &m_session;
    703739};
    704740
    705 class UIIndicatorMouse : public QIStateIndicator
     741/** UISessionStateStatusBarIndicator extension for Runtime UI: Mouse indicator. */
     742class UIIndicatorMouse : public UISessionStateStatusBarIndicator
    706743{
    707744    Q_OBJECT;
     
    709746public:
    710747
     748    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    711749    UIIndicatorMouse(CSession &session)
    712       : m_session(session)
     750        : UISessionStateStatusBarIndicator(session)
    713751    {
    714752        setStateIcon(0, UIIconPool::iconSet(":/mouse_disabled_16px.png"));
     
    721759    }
    722760
    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/>&nbsp;&nbsp;pointer is not captured</nobr><br>"
    727                       "<nobr><img src=:/mouse_16px.png/>&nbsp;&nbsp;pointer is captured</nobr><br>"
    728                       "<nobr><img src=:/mouse_seamless_16px.png/>&nbsp;&nbsp;mouse integration (MI) is On</nobr><br>"
    729                       "<nobr><img src=:/mouse_can_seamless_16px.png/>&nbsp;&nbsp;MI is Off, pointer is captured</nobr><br>"
    730                       "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/>&nbsp;&nbsp;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 
     761private slots:
     762
     763    /** Handles state change. */
    736764    void setState(int iState)
    737765    {
     
    740768            !(iState & UIMouseStateType_MouseCaptured))
    741769        {
    742             QIStateIndicator::setState(4);
     770            QIStateStatusBarIndicator::setState(4);
    743771        }
    744772        else
    745773        {
    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
     778private:
     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/>&nbsp;&nbsp;pointer is not captured</nobr><br>"
     786                   "<nobr><img src=:/mouse_16px.png/>&nbsp;&nbsp;pointer is captured</nobr><br>"
     787                   "<nobr><img src=:/mouse_seamless_16px.png/>&nbsp;&nbsp;mouse integration (MI) is On</nobr><br>"
     788                   "<nobr><img src=:/mouse_can_seamless_16px.png/>&nbsp;&nbsp;MI is Off, pointer is captured</nobr><br>"
     789                   "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/>&nbsp;&nbsp;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() {}
    754795};
    755796
    756 class UIIndicatorKeyboard : public QIStateIndicator
     797/** UISessionStateStatusBarIndicator extension for Runtime UI: Keyboard indicator. */
     798class UIIndicatorKeyboard : public UISessionStateStatusBarIndicator
    757799{
    758800    Q_OBJECT;
     
    760802public:
    761803
     804    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    762805    UIIndicatorKeyboard(CSession &session)
    763       : m_session(session)
     806        : UISessionStateStatusBarIndicator(session)
    764807    {
    765808        setStateIcon(0, UIIconPool::iconSet(":/hostkey_16px.png"));
     
    771814    }
    772815
     816private:
     817
     818    /** Retranslation routine. */
    773819    void retranslateUi()
    774820    {
    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() {}
    783828};
    784829
    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. */
     831class UIIndicatorKeyboardExtension : public QIWithRetranslateUI<QITextStatusBarIndicator>
     832{
     833    Q_OBJECT;
     834
     835public:
     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
     847public slots:
     848
     849    /** Update routine. */
     850    void sltUpdateAppearance()
     851    {
     852        setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     853    }
     854
     855private:
     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
     870UIIndicatorsPool::UIIndicatorsPool(UISession *pSession, QWidget *pParent /* = 0 */)
     871    : QWidget(pParent)
     872    , m_pSession(pSession)
     873    , m_session(m_pSession->session())
     874    , m_pTimerAutoUpdate(0)
    789875{
    790876    /* Prepare: */
     
    798884}
    799885
    800 QIStateIndicator* UIIndicatorsPool::indicator(IndicatorType index)
    801 {
    802     /* Just return what already exists: */
    803     return m_pool[index];
     886void 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
     904void 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
     916void 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
     933void 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        }
    804943}
    805944
    806945void UIIndicatorsPool::prepare()
    807946{
    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
     955void UIIndicatorsPool::prepareConnections()
     956{
     957    /* Listen for the status-bar configuration changes: */
     958    connect(gEDataManager, SIGNAL(sigStatusBarConfigurationChange()),
     959            this, SLOT(sltHandleConfigurationChange()));
     960}
     961
     962void 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
     976void 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
     989void 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
     1036void 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
     1047void 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);
    8341055    }
    8351056}
     
    8371058void UIIndicatorsPool::cleanup()
    8381059{
    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
     1066int 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
     1077void 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);
    8451101    }
    8461102}
    8471103
    8481104#include "UIIndicatorsPool.moc"
     1105
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h

    r51187 r51992  
    11/** @file
    2  *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    4  * UIIndicatorsPool class declaration
     2 * VBox Qt GUI - UIIndicatorsPool class declaration.
    53 */
    64
     
    1715 */
    1816
    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>
    2124
    2225/* GUI includes: */
    23 #include "QIStateIndicator.h"
    2426#include "UIExtraDataDefs.h"
    2527
     28/* COM includes: */
     29#include "COMEnums.h"
     30
    2631/* Forward declarations: */
     32class UISession;
    2733class CSession;
     34class QIStatusBarIndicator;
     35class QHBoxLayout;
     36class QTimer;
    2837
    29 /* Indicator pool interface/prototype: */
    30 class UIIndicatorsPool : public QObject
     38/** QWidget extension
     39  * providing Runtime UI with status-bar indicators. */
     40class UIIndicatorsPool : public QWidget
    3141{
    3242    Q_OBJECT;
    3343
     44signals:
     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
    3451public:
    3552
    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. */
    3857    ~UIIndicatorsPool();
    3958
    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
     68private slots:
     69
     70    /** Handles indicator-states auto-update. */
     71    void sltAutoUpdateIndicatorStates();
     72
     73    /** Handles context-menu request. */
     74    void sltContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent);
    4275
    4376private:
    4477
    45     /* Helpers: Prepare/cleanup stuff: */
     78    /** Prepare routine. */
    4679    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. */
    4795    void cleanup();
    4896
    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. */
    50106    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;
    52115};
    53116
    54 #endif // __UIIndicatorsPool_h__
    55 
     117#endif /* !___UIIndicatorsPool_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r51679 r51992  
    3737#include "UIMachineView.h"
    3838#include "QIStatusBar.h"
    39 #include "QIStateIndicator.h"
    40 #include "UIHostComboEditor.h"
     39#include "QIStatusBarIndicator.h"
    4140#ifdef Q_WS_MAC
    4241# include "VBoxUtils.h"
     
    5251UIMachineWindowNormal::UIMachineWindowNormal(UIMachineLogic *pMachineLogic, ulong uScreenId)
    5352    : UIMachineWindow(pMachineLogic, uScreenId)
    54     , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this))
    55     , m_pNameHostkey(0)
    56     , m_pIdleTimer(0)
     53    , m_pIndicatorsPool(0)
    5754{
    5855}
     
    115112}
    116113
    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()));
     114void 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);
    197134}
    198135
     
    249186    UIMachineWindow::prepareStatusBar();
    250187
    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    }
    371203
    372204#ifdef Q_WS_MAC
     
    390222#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    391223
    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 
    396224#ifdef Q_WS_MAC
    397225    /* Beta label? */
     
    409237    UIMachineWindow::prepareHandlers();
    410238
    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)
    413247        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)
    417250        connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)),
    418                 indicatorsPool()->indicator(IndicatorType_Mouse), SLOT(setState(int)));
     251                pMouseIndicator, SLOT(setState(int)));
     252
    419253    /* 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());
    424258}
    425259
     
    440274        statusBar()->setHidden(settings.isFeatureActive("noStatusBar"));
    441275        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);
    465277    }
    466278
     
    533345}
    534346
    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 
    562347bool UIMachineWindowNormal::event(QEvent *pEvent)
    563348{
     
    671456        if (!statusBar()->isHidden())
    672457        {
    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);
    705480}
    706481
     
    716491}
    717492
    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  
    2020#define __UIMachineWindowNormal_h__
    2121
    22 /* Global includes: */
    23 #include <QLabel>
    24 
    2522/* Local includes: */
    2623#include "UIMachineWindow.h"
     
    2926class CMediumAttachment;
    3027class UIIndicatorsPool;
    31 class QIStateIndicator;
    3228
    3329/* Normal machine-window implementation: */
     
    5854    void sltCPUExecutionCapChange();
    5955
    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);
    6458
    6559private:
     
    7771    //void cleanupHandlers() {}
    7872    //coid cleanupVisualState() {}
    79     void cleanupStatusBar();
     73    //void cleanupStatusBar() {}
    8074    //void cleanupMenu() {}
    8175    //void cleanupConsoleConnections() {}
    82 
    83     /* Translate stuff: */
    84     void retranslateUi();
    8576
    8677    /* Show stuff: */
     
    9788
    9889    /* Helpers: */
    99     UIIndicatorsPool* indicatorsPool() { return m_pIndicatorsPool; }
    10090    bool isMaximizedChecked();
    101     void updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType);
    10291
    103     /* Widgets: */
     92    /** Holds the indicator-pool instance. */
    10493    UIIndicatorsPool *m_pIndicatorsPool;
    105     QLabel *m_pNameHostkey;
    10694
    107     /* Variables: */
    108     QTimer *m_pIdleTimer;
     95    /** Holds current window geometry. */
    10996    QRect m_normalGeometry;
    11097
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r51937 r51992  
    13501350
    13511351    /* Add network-manager indicator: */
    1352     QIStateIndicator *pIndicator = gNetworkManager->indicator();
     1352    UINetworkManagerIndicator *pIndicator = gNetworkManager->indicator();
    13531353    statusBar()->addPermanentWidget(pIndicator);
    13541354    pIndicator->updateAppearance();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette