VirtualBox

Changeset 52645 in vbox for trunk


Ignore:
Timestamp:
Sep 8, 2014 11:42:02 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95941
Message:

FE/Qt: 7462: Runtime UI: Action to enable/disable menu-bar presence; Allow to enable/disable/configure menu-bar through menu-bar context menu.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52583 r52645  
    582582        case UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar:           strResult = "MenuBar"; break;
    583583        case UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings:   strResult = "MenuBarSettings"; break;
     584        case UIExtraDataMetaDefs::RuntimeMenuViewActionType_ToggleMenuBar:     strResult = "ToggleMenuBar"; break;
    584585        case UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar:         strResult = "StatusBar"; break;
    585586        case UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBarSettings: strResult = "StatusBarSettings"; break;
     
    610611    keys << "MenuBar";           values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar;
    611612    keys << "MenuBarSettings";   values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings;
     613    keys << "ToggleMenuBar";     values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_ToggleMenuBar;
    612614    keys << "StatusBar";         values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar;
    613615    keys << "StatusBarSettings"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBarSettings;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r52190 r52645  
    7878const char* UIExtraDataDefs::GUI_LastScaleWindowPosition = "GUI/LastScaleWindowPosition";
    7979const char* UIExtraDataDefs::GUI_Geometry_State_Max = "max";
     80const char* UIExtraDataDefs::GUI_MenuBar_Enabled = "GUI/MenuBar/Enabled";
    8081const char* UIExtraDataDefs::GUI_RestrictedRuntimeMenus = "GUI/RestrictedRuntimeMenus";
    8182#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52583 r52645  
    142142        /** Holds machine-window geometry maximized state flag. */
    143143        extern const char* GUI_Geometry_State_Max;
     144        /** Holds Runtime UI menu-bar availability status. */
     145        extern const char* GUI_MenuBar_Enabled;
    144146        /** Holds restricted Runtime UI menu types. */
    145147        extern const char* GUI_RestrictedRuntimeMenus;
     
    368370        RuntimeMenuViewActionType_MenuBar           = RT_BIT(5),
    369371        RuntimeMenuViewActionType_MenuBarSettings   = RT_BIT(6),
    370         RuntimeMenuViewActionType_StatusBar         = RT_BIT(7),
    371         RuntimeMenuViewActionType_StatusBarSettings = RT_BIT(8),
    372         RuntimeMenuViewActionType_ToggleStatusBar   = RT_BIT(9),
    373         RuntimeMenuViewActionType_Resize            = RT_BIT(10),
    374         RuntimeMenuViewActionType_Multiscreen       = RT_BIT(11),
     372        RuntimeMenuViewActionType_ToggleMenuBar     = RT_BIT(7),
     373        RuntimeMenuViewActionType_StatusBar         = RT_BIT(8),
     374        RuntimeMenuViewActionType_StatusBarSettings = RT_BIT(9),
     375        RuntimeMenuViewActionType_ToggleStatusBar   = RT_BIT(10),
     376        RuntimeMenuViewActionType_Resize            = RT_BIT(11),
     377        RuntimeMenuViewActionType_Multiscreen       = RT_BIT(12),
    375378        RuntimeMenuViewActionType_All               = 0xFFFF
    376379    };
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r52583 r52645  
    24892489}
    24902490
     2491bool UIExtraDataManager::menuBarEnabled(const QString &strID)
     2492{
     2493    /* 'True' unless feature restricted: */
     2494    return !isFeatureRestricted(GUI_MenuBar_Enabled, strID);
     2495}
     2496
     2497void UIExtraDataManager::setMenuBarEnabled(bool fEnabled, const QString &strID)
     2498{
     2499    /* 'False' if feature restricted, null-string otherwise: */
     2500    setExtraDataString(GUI_MenuBar_Enabled, toFeatureRestricted(!fEnabled), strID);
     2501}
     2502
    24912503UIExtraDataMetaDefs::MenuType UIExtraDataManager::restrictedRuntimeMenuTypes(const QString &strID)
    24922504{
     
    34413453    {
    34423454        /* Status-bar configuration change: */
    3443         if (strKey == GUI_RestrictedRuntimeMenus ||
     3455        if (strKey == GUI_MenuBar_Enabled ||
     3456            strKey == GUI_RestrictedRuntimeMenus ||
    34443457#ifdef Q_WS_MAC
    34453458            strKey == GUI_RestrictedRuntimeApplicationMenuActions ||
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r52583 r52645  
    286286        void setMachineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QRect &geometry, bool fMaximized, const QString &strID);
    287287
     288        /** Returns whether Runtime UI menu-bar is enabled. */
     289        bool menuBarEnabled(const QString &strID);
     290        /** Defines whether Runtime UI menu-bar is @a fEnabled. */
     291        void setMenuBarEnabled(bool fEnabled, const QString &strID);
     292
    288293        /** Returns restricted Runtime UI menu types. */
    289294        UIExtraDataMetaDefs::MenuType restrictedRuntimeMenuTypes(const QString &strID);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52589 r52645  
    875875        setName(QApplication::translate("UIActionPool", "&Menu Bar Settings..."));
    876876        setStatusTip(QApplication::translate("UIActionPool", "Opens window to configure menu-bar"));
     877    }
     878};
     879
     880class UIActionToggleMenuBar : public UIActionToggle
     881{
     882    Q_OBJECT;
     883
     884public:
     885
     886    UIActionToggleMenuBar(UIActionPool *pParent)
     887        : UIActionToggle(pParent, ":/menubar_on_16px.png", ":/menubar_16px.png",
     888                                  ":/menubar_on_disabled_16px.png", ":/menubar_disabled_16px.png") {}
     889
     890protected:
     891
     892    /** Returns action extra-data ID. */
     893    virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuViewActionType_ToggleMenuBar; }
     894    /** Returns action extra-data key. */
     895    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_ToggleMenuBar); }
     896    /** Returns whether action is allowed. */
     897    virtual bool isAllowed() const { return actionPool()->toRuntime()->isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_ToggleMenuBar); }
     898
     899    QString shortcutExtraDataID() const
     900    {
     901        return QString("ToggleMenuBar");
     902    }
     903
     904    void retranslateUi()
     905    {
     906        setName(QApplication::translate("UIActionPool", "Show Menu &Bar"));
     907        setStatusTip(QApplication::translate("UIActionPool", "Toggle menu-bar visibility for this machine"));
    877908    }
    878909};
     
    19101941    m_pool[UIActionIndexRT_M_View_M_MenuBar] = new UIActionMenuMenuBar(this);
    19111942    m_pool[UIActionIndexRT_M_View_M_MenuBar_S_Settings] = new UIActionSimpleShowMenuBarSettingsWindow(this);
     1943    m_pool[UIActionIndexRT_M_View_M_MenuBar_T_Visibility] = new UIActionToggleMenuBar(this);
    19121944    m_pool[UIActionIndexRT_M_View_M_StatusBar] = new UIActionMenuStatusBar(this);
    19131945    m_pool[UIActionIndexRT_M_View_M_StatusBar_S_Settings] = new UIActionSimpleShowStatusBarSettingsWindow(this);
     
    23772409    /* 'Menu Bar Settings' action: */
    23782410    addAction(pMenu, action(UIActionIndexRT_M_View_M_MenuBar_S_Settings));
     2411    /* 'Toggle Menu Bar' action: */
     2412    addAction(pMenu, action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility));
    23792413
    23802414    /* Mark menu as valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r52583 r52645  
    7272    UIActionIndexRT_M_View_M_MenuBar,
    7373    UIActionIndexRT_M_View_M_MenuBar_S_Settings,
     74    UIActionIndexRT_M_View_M_MenuBar_T_Visibility,
    7475    UIActionIndexRT_M_View_M_StatusBar,
    7576    UIActionIndexRT_M_View_M_StatusBar_S_Settings,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r52579 r52645  
    868868    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar));
    869869    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings));
     870    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility));
    870871    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar));
    871872    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52558 r52645  
    11891189        pGuestAutoresizeSwitch->setChecked(gEDataManager->guestScreenAutoResizeEnabled(strMachineID));
    11901190
     1191        /* Menu-bar options: */
     1192        {
     1193            const bool fEnabledGlobally = !vboxGlobal().settings().isFeatureActive("noMenuBar");
     1194            const bool fEnabledForMachine = gEDataManager->menuBarEnabled(strMachineID);
     1195            const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
     1196            QAction *pActionMenuBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings);
     1197            pActionMenuBarSettings->setEnabled(fEnabled);
     1198            QAction *pActionMenuBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility);
     1199            pActionMenuBarSwitch->blockSignals(true);
     1200            pActionMenuBarSwitch->setChecked(fEnabled);
     1201            pActionMenuBarSwitch->blockSignals(false);
     1202        }
     1203
    11911204        /* Status-bar options: */
    1192         const bool fEnabledGlobally = !vboxGlobal().settings().isFeatureActive("noStatusBar");
    1193         const bool fEnabledForMachine = gEDataManager->statusBarEnabled(strMachineID);
    1194         const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
    1195         QAction *pActionStatusBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings);
    1196         pActionStatusBarSettings->setEnabled(fEnabled);
    1197         QAction *pActionStatusBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility);
    1198         pActionStatusBarSwitch->blockSignals(true);
    1199         pActionStatusBarSwitch->setChecked(fEnabled);
    1200         pActionStatusBarSwitch->blockSignals(false);
     1205        {
     1206            const bool fEnabledGlobally = !vboxGlobal().settings().isFeatureActive("noStatusBar");
     1207            const bool fEnabledForMachine = gEDataManager->statusBarEnabled(strMachineID);
     1208            const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
     1209            QAction *pActionStatusBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings);
     1210            pActionStatusBarSettings->setEnabled(fEnabled);
     1211            QAction *pActionStatusBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility);
     1212            pActionStatusBarSwitch->blockSignals(true);
     1213            pActionStatusBarSwitch->setChecked(fEnabled);
     1214            pActionStatusBarSwitch->blockSignals(false);
     1215        }
    12011216
    12021217        /* What is the default close action and the restricted are? */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r52478 r52645  
    8181    AssertReturnVoid(isMachineWindowsCreated());
    8282
    83     /* Prevent user from opening another one editor: */
     83    /* Make sure menu-bar is enabled: */
     84    const bool fEnabled = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->isChecked();
     85    AssertReturnVoid(fEnabled);
     86
     87    /* Prevent user from opening another one editor or toggle menu-bar: */
    8488    actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(false);
     89    actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->setEnabled(false);
    8590    /* Create menu-bar editor: */
    8691    UIMenuBarEditorWindow *pMenuBarEditor = new UIMenuBarEditorWindow(activeMachineWindow(), actionPool());
     
    101106void UIMachineLogicNormal::sltMenuBarSettingsClosed()
    102107{
    103     /* Allow user to open editor again: */
     108    /* Make sure menu-bar is enabled: */
     109    const bool fEnabled = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->isChecked();
     110    AssertReturnVoid(fEnabled);
     111
     112    /* Allow user to open editor and toggle menu-bar again: */
    104113    actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(true);
     114    actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->setEnabled(true);
     115}
     116
     117void UIMachineLogicNormal::sltToggleMenuBar()
     118{
     119    /* Do not process if window(s) missed! */
     120    AssertReturnVoid(isMachineWindowsCreated());
     121
     122    /* Invert menu-bar availability option: */
     123    const bool fEnabled = gEDataManager->menuBarEnabled(vboxGlobal().managedVMUuid());
     124    gEDataManager->setMenuBarEnabled(!fEnabled, vboxGlobal().managedVMUuid());
    105125}
    106126
     
    196216    connect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings), SIGNAL(triggered(bool)),
    197217            this, SLOT(sltOpenMenuBarSettings()));
     218    connect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility), SIGNAL(triggered(bool)),
     219            this, SLOT(sltToggleMenuBar()));
    198220    connect(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings), SIGNAL(triggered(bool)),
    199221            this, SLOT(sltOpenStatusBarSettings()));
     
    262284    disconnect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings), SIGNAL(triggered(bool)),
    263285               this, SLOT(sltOpenMenuBarSettings()));
     286    disconnect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility), SIGNAL(triggered(bool)),
     287               this, SLOT(sltToggleMenuBar()));
    264288    disconnect(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings), SIGNAL(triggered(bool)),
    265289               this, SLOT(sltOpenStatusBarSettings()));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r52478 r52645  
    4242    void sltCheckForRequestedVisualStateType();
    4343
    44     /* View menu functionality: */
     44    /** Opens menu-bar editor.*/
    4545    void sltOpenMenuBarSettings();
     46    /** Handles menu-bar editor closing.*/
    4647    void sltMenuBarSettingsClosed();
     48    /** Toggles menu-bar presence.*/
     49    void sltToggleMenuBar();
     50
     51    /** Opens status-bar editor.*/
    4752    void sltOpenStatusBarSettings();
     53    /** Handles status-bar editor closing.*/
    4854    void sltStatusBarSettingsClosed();
     55    /** Toggles status-bar presence.*/
    4956    void sltToggleStatusBar();
     57
     58    /** Handles guest-screen toggle requests. */
    5059    void sltHandleActionTriggerViewScreenToggle(int iIndex, bool fEnabled);
     60    /** Handles guest-screen resize requests. */
    5161    void sltHandleActionTriggerViewScreenResize(int iIndex, const QSize &size);
    5262
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r52638 r52645  
    118118void UIMachineWindowNormal::sltHandleMenuBarConfigurationChange()
    119119{
     120    /* Check whether menu-bar is enabled: */
     121    const bool fEnabled = gEDataManager->menuBarEnabled(vboxGlobal().managedVMUuid());
     122    /* Update settings action 'enable' state: */
     123    QAction *pActionMenuBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings);
     124    pActionMenuBarSettings->setEnabled(fEnabled);
     125    /* Update switch action 'checked' state: */
     126    QAction *pActionMenuBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility);
     127    pActionMenuBarSwitch->blockSignals(true);
     128    pActionMenuBarSwitch->setChecked(fEnabled);
     129    pActionMenuBarSwitch->blockSignals(false);
     130
     131    /* Update menu-bar visibility: */
     132    menuBar()->setVisible(pActionMenuBarSwitch->isChecked());
    120133    /* Update menu-bar: */
    121134    updateMenu();
     135
     136    /* Normalize geometry without moving: */
     137    normalizeGeometry(false /* adjust position */);
     138}
     139
     140void UIMachineWindowNormal::sltHandleMenuBarContextMenuRequest(const QPoint &position)
     141{
     142    /* Raise action's context-menu: */
     143    actionPool()->action(UIActionIndexRT_M_View_M_MenuBar)->menu()->exec(menuBar()->mapToGlobal(position));
    122144}
    123145#endif /* !RT_OS_DARWIN */
     
    138160    /* Update status-bar visibility: */
    139161    statusBar()->setVisible(pActionStatusBarSwitch->isChecked());
     162    /* Update status-bar indicators-pool: */
    140163    m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible());
    141164
     
    214237    AssertPtrReturnVoid(menuBar());
    215238    {
    216         /* Post-configure menu-bar: */
     239        /* Configure menu-bar: */
     240        menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
     241        connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
     242                this, SLOT(sltHandleMenuBarContextMenuRequest(const QPoint&)));
    217243        connect(gEDataManager, SIGNAL(sigMenuBarConfigurationChange()),
    218244                this, SLOT(sltHandleMenuBarConfigurationChange()));
     
    284310#ifndef Q_WS_MAC
    285311        /* Update menu-bar visibility: */
    286         menuBar()->setHidden(vboxGlobal().settings().isFeatureActive("noMenuBar"));
     312        menuBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->isChecked());
    287313#endif /* !Q_WS_MAC */
    288314        /* Update status-bar visibility: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r52516 r52645  
    6262    /** Handles menu-bar configuration-change. */
    6363    void sltHandleMenuBarConfigurationChange();
     64    /** Handles menu-bar context-menu-request. */
     65    void sltHandleMenuBarContextMenuRequest(const QPoint &position);
    6466#endif /* !RT_OS_DARWIN */
    6567
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