VirtualBox

Changeset 52100 in vbox


Ignore:
Timestamp:
Jul 18, 2014 12:58:30 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95112
Message:

FE/Qt: 3646: Runtime UI: Toggle-status-bar action.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r52035 r52100  
    109109const char* UIExtraDataDefs::GUI_MiniToolBarAutoHide = "GUI/MiniToolBarAutoHide";
    110110const char* UIExtraDataDefs::GUI_MiniToolBarAlignment = "GUI/MiniToolBarAlignment";
     111const char* UIExtraDataDefs::GUI_StatusBar_Enabled = "GUI/StatusBar/Enabled";
    111112const char* UIExtraDataDefs::GUI_RestrictedStatusBarIndicators = "GUI/RestrictedStatusBarIndicators";
    112113const char* UIExtraDataDefs::GUI_StatusBar_IndicatorOrder = "GUI/StatusBar/IndicatorOrder";
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52097 r52100  
    201201        /** Holds mini-toolbar alignment. */
    202202        extern const char* GUI_MiniToolBarAlignment;
     203        /** Holds Runtime UI status-bar availability status. */
     204        extern const char* GUI_StatusBar_Enabled;
    203205        /** Holds restricted Runtime UI status-bar indicators. */
    204206        extern const char* GUI_RestrictedStatusBarIndicators;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r52035 r52100  
    17831783           << GUI_HiDPI_Optimization
    17841784           << GUI_ShowMiniToolBar << GUI_MiniToolBarAutoHide << GUI_MiniToolBarAlignment
    1785            << GUI_RestrictedStatusBarIndicators << GUI_StatusBar_IndicatorOrder
     1785           << GUI_StatusBar_Enabled << GUI_RestrictedStatusBarIndicators << GUI_StatusBar_IndicatorOrder
    17861786#ifdef Q_WS_MAC
    17871787           << GUI_PresentationModeEnabled
     
    28042804    }
    28052805    setExtraDataString(GUI_MiniToolBarAlignment, QString(), strID);
     2806}
     2807
     2808bool UIExtraDataManager::statusBarEnabled(const QString &strID)
     2809{
     2810    /* 'True' unless feature restricted: */
     2811    return !isFeatureRestricted(GUI_StatusBar_Enabled, strID);
     2812}
     2813
     2814void UIExtraDataManager::setStatusBarEnabled(bool fEnabled, const QString &strID)
     2815{
     2816    /* 'False' if feature restricted, null-string otherwise: */
     2817    setExtraDataString(GUI_StatusBar_Enabled, toFeatureRestricted(!fEnabled), strID);
    28062818}
    28072819
     
    31653177    {
    31663178        /* Status-bar configuration change: */
    3167         if (strKey == GUI_RestrictedStatusBarIndicators ||
     3179        if (strKey == GUI_StatusBar_Enabled ||
     3180            strKey == GUI_RestrictedStatusBarIndicators ||
    31683181            strKey == GUI_StatusBar_IndicatorOrder)
    31693182            emit sigStatusBarConfigurationChange();
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r52035 r52100  
    364364        void setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID);
    365365
     366        /** Returns whether Runtime UI status-bar is enabled. */
     367        bool statusBarEnabled(const QString &strID);
     368        /** Defines whether Runtime UI status-bar is @a fEnabled. */
     369        void setStatusBarEnabled(bool fEnabled, const QString &strID);
     370
    366371        /** Returns restricted Runtime UI status-bar indicator list. */
    367372        QList<IndicatorType> restrictedStatusBarIndicators(const QString &strID);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52097 r52100  
    738738        setName(QApplication::translate("UIActionPool", "&Status Bar Settings..."));
    739739        setStatusTip(QApplication::translate("UIActionPool", "Opens window to configure status-bar"));
     740    }
     741};
     742
     743class UIActionToggleStatusBar : public UIActionToggle
     744{
     745    Q_OBJECT;
     746
     747public:
     748
     749    UIActionToggleStatusBar(UIActionPool *pParent)
     750        : UIActionToggle(pParent)
     751    {
     752        retranslateUi();
     753    }
     754
     755protected:
     756
     757    QString shortcutExtraDataID() const
     758    {
     759        return QString("ToggleStatusBar");
     760    }
     761
     762    void retranslateUi()
     763    {
     764        setName(QApplication::translate("UIActionPool", "Show Status &Bar"));
     765        setStatusTip(QApplication::translate("UIActionPool", "Toggle status-bar visibility for this machine"));
    740766    }
    741767};
     
    13881414    m_pool[UIActionIndexRuntime_Simple_AdjustWindow] = new UIActionSimplePerformWindowAdjust(this);
    13891415    m_pool[UIActionIndexRuntime_Simple_StatusBarSettings] = new UIActionSimpleShowStatusBarSettingsWindow(this);
     1416    m_pool[UIActionIndexRuntime_Toggle_StatusBar] = new UIActionToggleStatusBar(this);
    13901417
    13911418    /* 'Devices' actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r52097 r52100  
    5656    UIActionIndexRuntime_Menu_StatusBar,
    5757    UIActionIndexRuntime_Simple_StatusBarSettings,
     58    UIActionIndexRuntime_Toggle_StatusBar,
    5859
    5960    /* 'Devices' menu actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r52035 r52100  
    917917    , m_pSession(pSession)
    918918    , m_session(m_pSession->session())
     919    , m_fEnabled(false)
    919920    , m_pTimerAutoUpdate(0)
    920921{
     
    10401041void UIIndicatorsPool::updatePool()
    10411042{
    1042     /* Recache status-bar configuration: */
     1043    /* Acquire status-bar availability: */
     1044    m_fEnabled = gEDataManager->statusBarEnabled(vboxGlobal().managedVMUuid());
     1045    /* If status-bar is not enabled: */
     1046    if (!m_fEnabled)
     1047    {
     1048        /* Remove all indicators: */
     1049        while (!m_pool.isEmpty())
     1050        {
     1051            const IndicatorType firstType = m_pool.keys().first();
     1052            delete m_pool.value(firstType);
     1053            m_pool.remove(firstType);
     1054        }
     1055        /* And return: */
     1056        return;
     1057    }
     1058
     1059    /* Acquire status-bar restrictions: */
    10431060    m_restrictions = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid());
     1061    /* Remove restricted indicators: */
     1062    foreach (const IndicatorType &indicatorType, m_restrictions)
     1063    {
     1064        if (m_pool.contains(indicatorType))
     1065        {
     1066            delete m_pool.value(indicatorType);
     1067            m_pool.remove(indicatorType);
     1068        }
     1069    }
     1070
     1071    /* Acquire status-bar order: */
    10441072    m_order = gEDataManager->statusBarIndicatorOrder(vboxGlobal().managedVMUuid());
    1045 
    10461073    /* Make sure the order is complete taking restrictions into account: */
    10471074    for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType)
     
    10601087            m_order << type;
    10611088    }
    1062 
    1063     /* Remove restricted indicators: */
    1064     foreach (const IndicatorType &indicatorType, m_restrictions)
    1065         if (m_pool.contains(indicatorType))
    1066         {
    1067             delete m_pool.value(indicatorType);
    1068             m_pool.remove(indicatorType);
    1069         }
    10701089
    10711090    /* Add/Update allowed indicators: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h

    r52035 r52100  
    105105    /** Holds the session reference. */
    106106    CSession &m_session;
     107    /** Holds whether status-bar is enabled. */
     108    bool m_fEnabled;
    107109    /** Holds the cached restrictions. */
    108110    QList<IndicatorType> m_restrictions;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r52097 r52100  
    859859    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_StatusBar));
    860860    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings));
     861    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar));
    861862    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_HardDisks));
    862863    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_StorageSettings));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r52097 r52100  
    413413        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_StatusBar));
    414414        gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings));
     415        gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar));
    415416    }
    416417    else
     
    418419        gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->setEnabled(false);
    419420        gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings)->setEnabled(false);
     421        gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->setEnabled(false);
    420422    }
    421423}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52086 r52100  
    10731073void UISession::loadSessionSettings()
    10741074{
    1075    /* Get uisession machine: */
    1076     CMachine machine = session().GetConsole().GetMachine();
    1077 
    10781075    /* Load extra-data settings: */
    10791076    {
     
    11061103                                           RuntimeMenuHelpActionType_All);
    11071104
    1108         /* Temporary: */
    1109         QString strSettings;
    1110 
    11111105#ifndef Q_WS_MAC
    11121106        /* Load/prepare user's machine-window icon: */
     
    11391133        /* Should we allow snapshot operations? */
    11401134        m_fSnapshotOperationsAllowed = gEDataManager->machineSnapshotOperationsEnabled(vboxGlobal().managedVMUuid());
     1135
     1136        /* Status-bar options: */
     1137        const bool fEnabledGlobally = !vboxGlobal().settings().isFeatureActive("noStatusBar");
     1138        const bool fEnabledForMachine = gEDataManager->statusBarEnabled(vboxGlobal().managedVMUuid());
     1139        const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
     1140        QAction *pActionStatusBarSettings = gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings);
     1141        pActionStatusBarSettings->setEnabled(fEnabled);
     1142        QAction *pActionStatusBarSwitch = gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar);
     1143        pActionStatusBarSwitch->blockSignals(true);
     1144        pActionStatusBarSwitch->setChecked(fEnabled);
     1145        pActionStatusBarSwitch->blockSignals(false);
    11411146
    11421147        /* What is the default close action and the restricted are? */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r52097 r52100  
    7575    AssertReturnVoid(isMachineWindowsCreated());
    7676
    77     /* Prevent user from opening another one editor: */
     77    /* Make sure status-bar is enabled: */
     78    const bool fEnabled = gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->isChecked();
     79    AssertReturnVoid(fEnabled);
     80
     81    /* Prevent user from opening another one editor or toggle status-bar: */
    7882    gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings)->setEnabled(false);
     83    gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->setEnabled(false);
    7984    /* Create status-bar editor: */
    8085    UIStatusBarEditorWindow *pStatusBarEditor = new UIStatusBarEditorWindow(activeMachineWindow());
     
    95100void UIMachineLogicNormal::sltStatusBarSettingsClosed()
    96101{
    97     /* Allow user to open editor again: */
     102    /* Make sure status-bar is enabled: */
     103    const bool fEnabled = gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->isChecked();
     104    AssertReturnVoid(fEnabled);
     105
     106    /* Allow user to open editor and toggle status-bar again: */
    98107    gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings)->setEnabled(true);
     108    gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->setEnabled(true);
     109}
     110
     111void UIMachineLogicNormal::sltToggleStatusBar()
     112{
     113    /* Do not process if window(s) missed! */
     114    AssertReturnVoid(isMachineWindowsCreated());
     115
     116    /* Invert status-bar availability option: */
     117    const bool fEnabled = gEDataManager->statusBarEnabled(vboxGlobal().managedVMUuid());
     118    gEDataManager->setStatusBarEnabled(!fEnabled, vboxGlobal().managedVMUuid());
    99119}
    100120
     
    154174    connect(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings), SIGNAL(triggered(bool)),
    155175            this, SLOT(sltOpenStatusBarSettings()));
     176    connect(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar), SIGNAL(triggered(bool)),
     177            this, SLOT(sltToggleStatusBar()));
    156178
    157179    /* "Device" actions connections: */
     
    218240    disconnect(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings), SIGNAL(triggered(bool)),
    219241               this, SLOT(sltOpenStatusBarSettings()));
     242    disconnect(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar), SIGNAL(triggered(bool)),
     243               this, SLOT(sltToggleStatusBar()));
    220244
    221245    /* Call to base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r52097 r52100  
    4242    void sltOpenStatusBarSettings();
    4343    void sltStatusBarSettingsClosed();
     44    void sltToggleStatusBar();
    4445
    4546    /* Devices menu functionality: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r52097 r52100  
    113113}
    114114
     115void UIMachineWindowNormal::sltHandleStatusBarConfigurationChange()
     116{
     117    /* Check whether status-bar is enabled: */
     118    const bool fEnabled = gEDataManager->statusBarEnabled(vboxGlobal().managedVMUuid());
     119    /* Update settings action 'enable' state: */
     120    QAction *pActionStatusBarSettings = gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings);
     121    pActionStatusBarSettings->setEnabled(fEnabled);
     122    /* Update switch action 'checked' state: */
     123    QAction *pActionStatusBarSwitch = gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar);
     124    pActionStatusBarSwitch->blockSignals(true);
     125    pActionStatusBarSwitch->setChecked(fEnabled);
     126    pActionStatusBarSwitch->blockSignals(false);
     127
     128    /* Update status-bar visibility: */
     129    statusBar()->setVisible(pActionStatusBarSwitch->isChecked());
     130    m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible());
     131
     132    /* Normalize geometry without moving: */
     133    normalizeGeometry(false);
     134}
     135
    115136void UIMachineWindowNormal::sltHandleStatusBarContextMenuRequest(const QPoint &position)
    116137{
     
    211232            statusBar()->addPermanentWidget(m_pIndicatorsPool, 0);
    212233        }
     234        /* Post-configure status-bar: */
     235        connect(gEDataManager, SIGNAL(sigStatusBarConfigurationChange()),
     236                this, SLOT(sltHandleStatusBarConfigurationChange()));
    213237    }
    214238
     
    253277    /* Load GUI customizations: */
    254278    {
    255         VBoxGlobalSettings settings = vboxGlobal().settings();
    256279#ifndef Q_WS_MAC
    257         menuBar()->setHidden(settings.isFeatureActive("noMenuBar"));
     280        /* Update menu-bar visibility: */
     281        menuBar()->setHidden(vboxGlobal().settings().isFeatureActive("noMenuBar"));
    258282#endif /* !Q_WS_MAC */
    259         statusBar()->setHidden(settings.isFeatureActive("noStatusBar"));
    260         if (statusBar()->isHidden())
    261             m_pIndicatorsPool->setAutoUpdateIndicatorStates(false);
     283        /* Update status-bar visibility: */
     284        statusBar()->setVisible(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->isChecked());
     285        m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible());
    262286    }
    263287
     
    449473                m_pIndicatorsPool->setAutoUpdateIndicatorStates(false);
    450474            else if (uisession()->isRunning())
    451                 m_pIndicatorsPool->setAutoUpdateIndicatorStates(true);
     475                m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible());
    452476        }
    453477    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r52097 r52100  
    5959    void sltCPUExecutionCapChange();
    6060
     61    /** Handles status-bar configuration-change: */
     62    void sltHandleStatusBarConfigurationChange();
    6163    /** Handles status-bar context-menu-request: */
    6264    void sltHandleStatusBarContextMenuRequest(const QPoint &position);
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