VirtualBox

Ignore:
Timestamp:
Jun 19, 2013 5:58:20 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86582
Message:

FE/Qt: Runtime UI: Possibility to hide (restrict) status-bar indicators one-by-one (using extra-data).

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r46647 r46686  
    6565const char* UIDefs::GUI_PassCAD = "GUI/PassCAD";
    6666const char* UIDefs::GUI_DefaultCloseAction = "GUI/DefaultCloseAction";
     67const char* UIDefs::GUI_RestrictedStatusBarIndicators = "GUI/RestrictedStatusBarIndicators";
    6768
    6869/* Mini tool-bar definitions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46682 r46686  
    137137    extern const char* GUI_PassCAD;
    138138    extern const char* GUI_DefaultCloseAction;
     139    extern const char* GUI_RestrictedStatusBarIndicators;
    139140
    140141    /* Mini tool-bar declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r46502 r46686  
    37213721    /* 'true' if guest-screen auto-mounting approved by the extra-data: */
    37223722    return isApprovedByExtraData(machine, GUI_AutomountGuestScreens);
     3723}
     3724
     3725/* static */
     3726bool VBoxGlobal::isItemRestrictedByExtraData(CMachine &machine,
     3727                                             const QString &strExtraDataKey,
     3728                                             const QString &strItemName)
     3729{
     3730    /* Load corresponding extra-data value: */
     3731    QString strExtraDataValue(machine.GetExtraData(strExtraDataKey));
     3732
     3733    /* 'false' if value was not set: */
     3734    if (strExtraDataValue.isEmpty())
     3735        return false;
     3736
     3737    /* Check if value represented as *string-list* contains passed *string-item*: */
     3738    return strExtraDataValue.split(",").contains(strItemName, Qt::CaseInsensitive);
     3739}
     3740
     3741/* static */
     3742bool VBoxGlobal::shouldWeShowStatusBarIndicator(CMachine &machine, const QString &strStatusBarIndicatorName)
     3743{
     3744    /* Check if list of restricted status-bar indicators contains passed status-bar indicator-name: */
     3745    return !isItemRestrictedByExtraData(machine, GUI_RestrictedStatusBarIndicators, strStatusBarIndicatorName);
    37233746}
    37243747
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r46433 r46686  
    383383                                    bool fIncludingMachineGeneralCheck = false);
    384384    static bool shouldWeAutoMountGuestScreens(CMachine &machine, bool fIncludingSanityCheck = true);
     385
     386    static bool isItemRestrictedByExtraData(CMachine &machine, const QString &strExtraDataKey, const QString &strItemName);
     387    static bool shouldWeShowStatusBarIndicator(CMachine &machine, const QString &strStatusBarIndicatorName);
    385388
    386389#ifdef RT_OS_LINUX
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r46682 r46686  
    757757void UIIndicatorsPool::prepare()
    758758{
     759    /* Access machine: */
     760    CMachine machine = m_session.GetMachine();
     761
    759762    /* Populate indicator-pool: */
    760763    for (int iIndex = 0; iIndex < IndicatorType_Max; ++iIndex)
    761764    {
     765        /* Make sure indicator presence is permitted: */
     766        IndicatorType index = static_cast<IndicatorType>(iIndex);
     767        QString strIndicatorExtraDataName = gpConverter->toInternalString(static_cast<IndicatorType>(index));
     768        if (!vboxGlobal().shouldWeShowStatusBarIndicator(machine, strIndicatorExtraDataName))
     769            continue;
     770
    762771        /* Prepare indicator: */
    763         IndicatorType index = static_cast<IndicatorType>(iIndex);
    764772        switch (index)
    765773        {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r46682 r46686  
    5151    : UIMachineWindow(pMachineLogic, uScreenId)
    5252    , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this))
     53    , m_pNameHostkey(0)
    5354    , m_pIdleTimer(0)
    5455{
     
    115116{
    116117    /* Update indicators: */
    117     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_HardDisks), KDeviceType_HardDisk);
    118     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_OpticalDisks), KDeviceType_DVD);
    119     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_FloppyDisks), KDeviceType_Floppy);
    120     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_USB), KDeviceType_USB);
    121     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_Network), KDeviceType_Network);
    122     updateIndicatorState(indicatorsPool()->indicator(IndicatorType_SharedFolders), KDeviceType_SharedFolder);
     118    if (indicatorsPool()->indicator(IndicatorType_HardDisks))
     119        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_HardDisks), KDeviceType_HardDisk);
     120    if (indicatorsPool()->indicator(IndicatorType_OpticalDisks))
     121        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_OpticalDisks), KDeviceType_DVD);
     122    if (indicatorsPool()->indicator(IndicatorType_FloppyDisks))
     123        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_FloppyDisks), KDeviceType_Floppy);
     124    if (indicatorsPool()->indicator(IndicatorType_USB))
     125        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_USB), KDeviceType_USB);
     126    if (indicatorsPool()->indicator(IndicatorType_Network))
     127        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_Network), KDeviceType_Network);
     128    if (indicatorsPool()->indicator(IndicatorType_SharedFolders))
     129        updateIndicatorState(indicatorsPool()->indicator(IndicatorType_SharedFolders), KDeviceType_SharedFolder);
    123130}
    124131
     
    172179{
    173180    /* Update host-combination status-bar label: */
    174     m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     181    if (m_pNameHostkey)
     182        m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
    175183}
    176184
     
    231239    VBoxGlobal::setLayoutMargin(pIndicatorBoxHLayout, 0);
    232240    pIndicatorBoxHLayout->setSpacing(5);
     241    bool fAtLeastOneAddedToLeftSection = false;
    233242
    234243    /* Hard Disks: */
    235     pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(IndicatorType_HardDisks));
     244    if (QIStateIndicator *pLedHardDisks = indicatorsPool()->indicator(IndicatorType_HardDisks))
     245    {
     246        pIndicatorBoxHLayout->addWidget(pLedHardDisks);
     247        fAtLeastOneAddedToLeftSection = true;
     248    }
    236249
    237250    /* Optical Disks: */
    238     QIStateIndicator *pLedOpticalDisks = indicatorsPool()->indicator(IndicatorType_OpticalDisks);
    239     pIndicatorBoxHLayout->addWidget(pLedOpticalDisks);
    240     connect(pLedOpticalDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    241             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     251    if (QIStateIndicator *pLedOpticalDisks = indicatorsPool()->indicator(IndicatorType_OpticalDisks))
     252    {
     253        pIndicatorBoxHLayout->addWidget(pLedOpticalDisks);
     254        connect(pLedOpticalDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     255                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     256        fAtLeastOneAddedToLeftSection = true;
     257    }
    242258
    243259    /* Floppy Disks: */
    244     QIStateIndicator *pLedFloppyDisks = indicatorsPool()->indicator(IndicatorType_FloppyDisks);
    245     pIndicatorBoxHLayout->addWidget(pLedFloppyDisks);
    246     connect(pLedFloppyDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    247             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     260    if (QIStateIndicator *pLedFloppyDisks = indicatorsPool()->indicator(IndicatorType_FloppyDisks))
     261    {
     262        pIndicatorBoxHLayout->addWidget(pLedFloppyDisks);
     263        connect(pLedFloppyDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     264                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     265        fAtLeastOneAddedToLeftSection = true;
     266    }
    248267
    249268    /* USB: */
    250     QIStateIndicator *pLedUSB = indicatorsPool()->indicator(IndicatorType_USB);
    251     pIndicatorBoxHLayout->addWidget(pLedUSB);
    252     connect(pLedUSB, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    253             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     269    if (QIStateIndicator *pLedUSB = indicatorsPool()->indicator(IndicatorType_USB))
     270    {
     271        pIndicatorBoxHLayout->addWidget(pLedUSB);
     272        connect(pLedUSB, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     273                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     274        fAtLeastOneAddedToLeftSection = true;
     275    }
    254276
    255277    /* Network: */
    256     QIStateIndicator *pLedNetwork = indicatorsPool()->indicator(IndicatorType_Network);
    257     pIndicatorBoxHLayout->addWidget(pLedNetwork);
    258     connect(pLedNetwork, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    259             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     278    if (QIStateIndicator *pLedNetwork = indicatorsPool()->indicator(IndicatorType_Network))
     279    {
     280        pIndicatorBoxHLayout->addWidget(pLedNetwork);
     281        connect(pLedNetwork, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     282                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     283        fAtLeastOneAddedToLeftSection = true;
     284    }
    260285
    261286    /* Shared Folders: */
    262     QIStateIndicator *pLedSharedFolders = indicatorsPool()->indicator(IndicatorType_SharedFolders);
    263     pIndicatorBoxHLayout->addWidget(pLedSharedFolders);
    264     connect(pLedSharedFolders, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    265             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     287    if (QIStateIndicator *pLedSharedFolders = indicatorsPool()->indicator(IndicatorType_SharedFolders))
     288    {
     289        pIndicatorBoxHLayout->addWidget(pLedSharedFolders);
     290        connect(pLedSharedFolders, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     291                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     292        fAtLeastOneAddedToLeftSection = true;
     293    }
    266294
    267295    /* Video Capture: */
    268     QIStateIndicator *pLedVideoCapture = indicatorsPool()->indicator(IndicatorType_VideoCapture);
    269     pIndicatorBoxHLayout->addWidget(pLedVideoCapture);
    270     connect(pLedVideoCapture, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    271             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     296    if (QIStateIndicator *pLedVideoCapture = indicatorsPool()->indicator(IndicatorType_VideoCapture))
     297    {
     298        pIndicatorBoxHLayout->addWidget(pLedVideoCapture);
     299        connect(pLedVideoCapture, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     300                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     301        fAtLeastOneAddedToLeftSection = true;
     302    }
    272303
    273304    /* Features: */
    274     pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(IndicatorType_Features));
     305    if (QIStateIndicator *pLedFeatures = indicatorsPool()->indicator(IndicatorType_Features))
     306    {
     307        pIndicatorBoxHLayout->addWidget(pLedFeatures);
     308        fAtLeastOneAddedToLeftSection = true;
     309    }
    275310
    276311    /* Separator: */
    277     QFrame *pSeparator = new QFrame;
    278     pSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
    279     pIndicatorBoxHLayout->addWidget(pSeparator);
     312    if (fAtLeastOneAddedToLeftSection)
     313    {
     314        QFrame *pSeparator = new QFrame;
     315        pSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
     316        pIndicatorBoxHLayout->addWidget(pSeparator);
     317    }
    280318
    281319    /* Mouse: */
    282     QIStateIndicator *pLedMouse = indicatorsPool()->indicator(IndicatorType_Mouse);
    283     pIndicatorBoxHLayout->addWidget(pLedMouse);
    284     connect(pLedMouse, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
    285             this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     320    if (QIStateIndicator *pLedMouse = indicatorsPool()->indicator(IndicatorType_Mouse))
     321    {
     322        pIndicatorBoxHLayout->addWidget(pLedMouse);
     323        connect(pLedMouse, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)),
     324                this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*)));
     325    }
    286326
    287327    /* Keyboard: */
    288     m_pCntHostkey = new QWidget;
    289     QHBoxLayout *pHostkeyLedContainerLayout = new QHBoxLayout(m_pCntHostkey);
    290     VBoxGlobal::setLayoutMargin(pHostkeyLedContainerLayout, 0);
    291     pHostkeyLedContainerLayout->setSpacing(3);
    292     pIndicatorBoxHLayout->addWidget(m_pCntHostkey);
    293     pHostkeyLedContainerLayout->addWidget(indicatorsPool()->indicator(IndicatorType_Keyboard));
    294     m_pNameHostkey = new QLabel(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
    295     pHostkeyLedContainerLayout->addWidget(m_pNameHostkey);
     328    if (QIStateIndicator *pLedKeyboard = indicatorsPool()->indicator(IndicatorType_Keyboard))
     329    {
     330        if (QWidget *pContainerWidgetHostkey = new QWidget)
     331        {
     332            if (QHBoxLayout *pContainerLayoutHostkey = new QHBoxLayout(pContainerWidgetHostkey))
     333            {
     334                VBoxGlobal::setLayoutMargin(pContainerLayoutHostkey, 0);
     335                pContainerLayoutHostkey->setSpacing(3);
     336                m_pNameHostkey = new QLabel(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     337                pContainerLayoutHostkey->addWidget(pLedKeyboard);
     338                pContainerLayoutHostkey->addWidget(m_pNameHostkey);
     339            }
     340            pIndicatorBoxHLayout->addWidget(pContainerWidgetHostkey);
     341        }
     342    }
    296343
    297344    /* Add to status-bar: */
     
    343390
    344391    /* Connect keyboard state-change handler: */
    345     connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(IndicatorType_Keyboard), SLOT(setState(int)));
     392    if (indicatorsPool()->indicator(IndicatorType_Keyboard))
     393        connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)),
     394                indicatorsPool()->indicator(IndicatorType_Keyboard), SLOT(setState(int)));
    346395    /* Connect mouse state-change handler: */
    347     connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(IndicatorType_Mouse), SLOT(setState(int)));
     396    if (indicatorsPool()->indicator(IndicatorType_Mouse))
     397        connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)),
     398                indicatorsPool()->indicator(IndicatorType_Mouse), SLOT(setState(int)));
    348399    /* Early initialize created connections: */
    349     indicatorsPool()->indicator(IndicatorType_Keyboard)->setState(machineLogic()->keyboardHandler()->keyboardState());
    350     indicatorsPool()->indicator(IndicatorType_Mouse)->setState(machineLogic()->mouseHandler()->mouseState());
     400    if (indicatorsPool()->indicator(IndicatorType_Keyboard))
     401        indicatorsPool()->indicator(IndicatorType_Keyboard)->setState(machineLogic()->keyboardHandler()->keyboardState());
     402    if (indicatorsPool()->indicator(IndicatorType_Mouse))
     403        indicatorsPool()->indicator(IndicatorType_Mouse)->setState(machineLogic()->mouseHandler()->mouseState());
    351404}
    352405
     
    430483    {
    431484        /* USB Stuff: */
    432         const CUSBController &usbController = m.GetUSBController();
    433         if (    usbController.isNull()
    434             || !usbController.GetEnabled()
    435             || !usbController.GetProxyAvailable())
     485        if (indicatorsPool()->indicator(IndicatorType_USB))
    436486        {
    437             /* Hide USB menu: */
    438             indicatorsPool()->indicator(IndicatorType_USB)->setHidden(true);
    439         }
    440         else
    441         {
    442             /* Toggle USB LED: */
    443             indicatorsPool()->indicator(IndicatorType_USB)->setState(
    444                 usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null);
     487            const CUSBController &usbController = m.GetUSBController();
     488            if (    usbController.isNull()
     489                || !usbController.GetEnabled()
     490                || !usbController.GetProxyAvailable())
     491            {
     492                /* Hide USB menu: */
     493                indicatorsPool()->indicator(IndicatorType_USB)->setHidden(true);
     494            }
     495            else
     496            {
     497                /* Toggle USB LED: */
     498                indicatorsPool()->indicator(IndicatorType_USB)->setState(
     499                    usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null);
     500            }
    445501        }
    446502    }
     
    495551
    496552    /* Translate host-combo LED: */
    497     m_pNameHostkey->setToolTip(
    498         QApplication::translate("UIMachineWindowNormal", "Shows the currently assigned Host key.<br>"
    499            "This key, when pressed alone, toggles the keyboard and mouse "
    500            "capture state. It can also be used in combination with other keys "
    501            "to quickly perform actions from the main menu."));
    502     m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     553    if (m_pNameHostkey)
     554    {
     555        m_pNameHostkey->setToolTip(
     556            QApplication::translate("UIMachineWindowNormal", "Shows the currently assigned Host key.<br>"
     557               "This key, when pressed alone, toggles the keyboard and mouse "
     558               "capture state. It can also be used in combination with other keys "
     559               "to quickly perform actions from the main menu."));
     560        m_pNameHostkey->setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     561    }
    503562}
    504563
     
    565624        }
    566625    }
    567     if (iElement & UIVisualElement_HDStuff)
     626    if ((iElement & UIVisualElement_HDStuff) &&
     627        indicatorsPool()->indicator(IndicatorType_HardDisks))
    568628        indicatorsPool()->indicator(IndicatorType_HardDisks)->updateAppearance();
    569     if (iElement & UIVisualElement_CDStuff)
     629    if ((iElement & UIVisualElement_CDStuff) &&
     630        indicatorsPool()->indicator(IndicatorType_OpticalDisks))
    570631        indicatorsPool()->indicator(IndicatorType_OpticalDisks)->updateAppearance();
    571     if (iElement & UIVisualElement_FDStuff)
     632    if ((iElement & UIVisualElement_FDStuff) &&
     633        indicatorsPool()->indicator(IndicatorType_FloppyDisks))
    572634        indicatorsPool()->indicator(IndicatorType_FloppyDisks)->updateAppearance();
    573     if (iElement & UIVisualElement_NetworkStuff)
     635    if ((iElement & UIVisualElement_NetworkStuff) &&
     636        indicatorsPool()->indicator(IndicatorType_Network))
    574637        indicatorsPool()->indicator(IndicatorType_Network)->updateAppearance();
    575     if (iElement & UIVisualElement_USBStuff &&
     638    if ((iElement & UIVisualElement_USBStuff) &&
     639        indicatorsPool()->indicator(IndicatorType_USB) &&
    576640        !indicatorsPool()->indicator(IndicatorType_USB)->isHidden())
    577641        indicatorsPool()->indicator(IndicatorType_USB)->updateAppearance();
    578     if (iElement & UIVisualElement_SharedFolderStuff)
     642    if ((iElement & UIVisualElement_SharedFolderStuff) &&
     643        indicatorsPool()->indicator(IndicatorType_SharedFolders))
    579644        indicatorsPool()->indicator(IndicatorType_SharedFolders)->updateAppearance();
    580     if (iElement & UIVisualElement_VideoCapture)
     645    if ((iElement & UIVisualElement_VideoCapture) &&
     646        indicatorsPool()->indicator(IndicatorType_VideoCapture))
    581647        indicatorsPool()->indicator(IndicatorType_VideoCapture)->updateAppearance();
    582     if (iElement & UIVisualElement_FeaturesStuff)
     648    if ((iElement & UIVisualElement_FeaturesStuff) &&
     649        indicatorsPool()->indicator(IndicatorType_Features))
    583650        indicatorsPool()->indicator(IndicatorType_Features)->updateAppearance();
    584651}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r46582 r46686  
    9595    /* Widgets: */
    9696    UIIndicatorsPool *m_pIndicatorsPool;
    97     QWidget *m_pCntHostkey;
    9897    QLabel *m_pNameHostkey;
    9998
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