VirtualBox

Ignore:
Timestamp:
Feb 25, 2011 12:33:58 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 5410: Add View menu: Initial commit.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp

    r35635 r36083  
    223223};
    224224
     225class PerformTakeSnapshotAction : public UISimpleAction
     226{
     227    Q_OBJECT;
     228
     229public:
     230
     231    PerformTakeSnapshotAction(QObject *pParent)
     232        : UISimpleAction(pParent,
     233                         ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png")
     234    {
     235        retranslateUi();
     236    }
     237
     238protected:
     239
     240    void retranslateUi()
     241    {
     242        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Take &Snapshot..."), gMS->shortcut(UIMachineShortcuts::TakeSnapshotShortcut)));
     243        setStatusTip(QApplication::translate("UIActionsPool", "Take a snapshot of the virtual machine"));
     244    }
     245};
     246
     247class ShowInformationDialogAction : public UISimpleAction
     248{
     249    Q_OBJECT;
     250
     251public:
     252
     253    ShowInformationDialogAction(QObject *pParent)
     254        : UISimpleAction(pParent,
     255                         ":/session_info_16px.png", ":/session_info_disabled_16px.png")
     256    {
     257        retranslateUi();
     258    }
     259
     260protected:
     261
     262    void retranslateUi()
     263    {
     264        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Session I&nformation"), gMS->shortcut(UIMachineShortcuts::InformationDialogShortcut)));
     265        setStatusTip(QApplication::translate("UIActionsPool", "Show Session Information Dialog"));
     266    }
     267};
     268
     269class MenuMouseIntegrationAction : public UIMenuAction
     270{
     271    Q_OBJECT;
     272
     273public:
     274
     275    MenuMouseIntegrationAction(QObject *pParent)
     276        : UIMenuAction(pParent)
     277    {
     278        retranslateUi();
     279    }
     280
     281protected:
     282
     283    void retranslateUi()
     284    {
     285    }
     286};
     287
     288class ToggleMouseIntegrationAction : public UIToggleAction
     289{
     290    Q_OBJECT;
     291
     292public:
     293
     294    ToggleMouseIntegrationAction(QObject *pParent)
     295        : UIToggleAction(pParent,
     296                         ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png",
     297                         ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png")
     298    {
     299        retranslateUi();
     300    }
     301
     302protected:
     303
     304    void retranslateUi()
     305    {
     306        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Disable &Mouse Integration"), gMS->shortcut(UIMachineShortcuts::MouseIntegrationShortcut)));
     307        setStatusTip(QApplication::translate("UIActionsPool", "Temporarily disable host mouse pointer integration"));
     308    }
     309};
     310
     311class PerformTypeCADAction : public UISimpleAction
     312{
     313    Q_OBJECT;
     314
     315public:
     316
     317    PerformTypeCADAction(QObject *pParent)
     318        : UISimpleAction(pParent,
     319                         ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
     320    {
     321        retranslateUi();
     322    }
     323
     324protected:
     325
     326    void retranslateUi()
     327    {
     328        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Del"), gMS->shortcut(UIMachineShortcuts::TypeCADShortcut)));
     329        setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Del sequence to the virtual machine"));
     330    }
     331};
     332
     333#ifdef Q_WS_X11
     334class PerformTypeCABSAction : public UISimpleAction
     335{
     336    Q_OBJECT;
     337
     338public:
     339
     340    PerformTypeCABSAction(QObject *pParent)
     341        : UISimpleAction(pParent,
     342                         ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
     343    {
     344        retranslateUi();
     345    }
     346
     347protected:
     348
     349    void retranslateUi()
     350    {
     351        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Backspace"), gMS->shortcut(UIMachineShortcuts::TypeCABSShortcut)));
     352        setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Backspace sequence to the virtual machine"));
     353    }
     354};
     355#endif
     356
     357class TogglePauseAction : public UIToggleAction
     358{
     359    Q_OBJECT;
     360
     361public:
     362
     363    TogglePauseAction(QObject *pParent)
     364        : UIToggleAction(pParent,
     365                         ":/pause_16px.png", ":/pause_disabled_16px.png")
     366    {
     367        retranslateUi();
     368    }
     369
     370protected:
     371
     372    void retranslateUi()
     373    {
     374        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Pause"), gMS->shortcut(UIMachineShortcuts::PauseShortcut)));
     375        setStatusTip(QApplication::translate("UIActionsPool", "Suspend the execution of the virtual machine"));
     376    }
     377};
     378
     379class PerformResetAction : public UISimpleAction
     380{
     381    Q_OBJECT;
     382
     383public:
     384
     385    PerformResetAction(QObject *pParent)
     386        : UISimpleAction(pParent,
     387                         ":/reset_16px.png", ":/reset_disabled_16px.png")
     388    {
     389        retranslateUi();
     390    }
     391
     392protected:
     393
     394    void retranslateUi()
     395    {
     396        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Reset"), gMS->shortcut(UIMachineShortcuts::ResetShortcut)));
     397        setStatusTip(QApplication::translate("UIActionsPool", "Reset the virtual machine"));
     398    }
     399};
     400
     401class PerformShutdownAction : public UISimpleAction
     402{
     403    Q_OBJECT;
     404
     405public:
     406
     407    PerformShutdownAction(QObject *pParent)
     408        : UISimpleAction(pParent,
     409                         ":/acpi_16px.png", ":/acpi_disabled_16px.png")
     410    {
     411        retranslateUi();
     412    }
     413
     414protected:
     415
     416    void retranslateUi()
     417    {
     418        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "ACPI Sh&utdown"), gMS->shortcut(UIMachineShortcuts::ShutdownShortcut)));
     419        setStatusTip(QApplication::translate("UIActionsPool", "Send the ACPI Power Button press event to the virtual machine"));
     420    }
     421};
     422
     423class PerformCloseAction : public UISimpleAction
     424{
     425    Q_OBJECT;
     426
     427public:
     428
     429    PerformCloseAction(QObject *pParent)
     430        : UISimpleAction(pParent,
     431                         ":/exit_16px.png")
     432    {
     433        setMenuRole(QAction::QuitRole);
     434        retranslateUi();
     435    }
     436
     437protected:
     438
     439    void retranslateUi()
     440    {
     441        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Close..."), gMS->shortcut(UIMachineShortcuts::CloseShortcut)));
     442        setStatusTip(QApplication::translate("UIActionsPool", "Close the virtual machine"));
     443    }
     444};
     445
     446class MenuViewAction : public UIMenuAction
     447{
     448    Q_OBJECT;
     449
     450public:
     451
     452    MenuViewAction(QObject *pParent)
     453        : UIMenuAction(pParent)
     454    {
     455        retranslateUi();
     456    }
     457
     458protected:
     459
     460    void retranslateUi()
     461    {
     462        menu()->setTitle(QApplication::translate("UIActionsPool", "&View"));
     463    }
     464};
     465
    225466class ToggleFullscreenModeAction : public UIToggleAction
    226467{
     
    337578};
    338579
    339 class MenuMouseIntegrationAction : public UIMenuAction
    340 {
    341     Q_OBJECT;
    342 
    343 public:
    344 
    345     MenuMouseIntegrationAction(QObject *pParent)
    346         : UIMenuAction(pParent)
    347     {
    348         retranslateUi();
    349     }
    350 
    351 protected:
    352 
    353     void retranslateUi()
    354     {
    355     }
    356 };
    357 
    358 class ToggleMouseIntegrationAction : public UIToggleAction
    359 {
    360     Q_OBJECT;
    361 
    362 public:
    363 
    364     ToggleMouseIntegrationAction(QObject *pParent)
    365         : UIToggleAction(pParent,
    366                          ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png",
    367                          ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png")
    368     {
    369         retranslateUi();
    370     }
    371 
    372 protected:
    373 
    374     void retranslateUi()
    375     {
    376         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Disable &Mouse Integration"), gMS->shortcut(UIMachineShortcuts::MouseIntegrationShortcut)));
    377         setStatusTip(QApplication::translate("UIActionsPool", "Temporarily disable host mouse pointer integration"));
    378     }
    379 };
    380 
    381 class PerformTypeCADAction : public UISimpleAction
    382 {
    383     Q_OBJECT;
    384 
    385 public:
    386 
    387     PerformTypeCADAction(QObject *pParent)
    388         : UISimpleAction(pParent,
    389                          ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
    390     {
    391         retranslateUi();
    392     }
    393 
    394 protected:
    395 
    396     void retranslateUi()
    397     {
    398         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Del"), gMS->shortcut(UIMachineShortcuts::TypeCADShortcut)));
    399         setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Del sequence to the virtual machine"));
    400     }
    401 };
    402 
    403 #ifdef Q_WS_X11
    404 class PerformTypeCABSAction : public UISimpleAction
    405 {
    406     Q_OBJECT;
    407 
    408 public:
    409 
    410     PerformTypeCABSAction(QObject *pParent)
    411         : UISimpleAction(pParent,
    412                          ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
    413     {
    414         retranslateUi();
    415     }
    416 
    417 protected:
    418 
    419     void retranslateUi()
    420     {
    421         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Backspace"), gMS->shortcut(UIMachineShortcuts::TypeCABSShortcut)));
    422         setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Backspace sequence to the virtual machine"));
    423     }
    424 };
    425 #endif
    426 
    427 class PerformTakeSnapshotAction : public UISimpleAction
    428 {
    429     Q_OBJECT;
    430 
    431 public:
    432 
    433     PerformTakeSnapshotAction(QObject *pParent)
    434         : UISimpleAction(pParent,
    435                          ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png")
    436     {
    437         retranslateUi();
    438     }
    439 
    440 protected:
    441 
    442     void retranslateUi()
    443     {
    444         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Take &Snapshot..."), gMS->shortcut(UIMachineShortcuts::TakeSnapshotShortcut)));
    445         setStatusTip(QApplication::translate("UIActionsPool", "Take a snapshot of the virtual machine"));
    446     }
    447 };
    448 
    449 class ShowInformationDialogAction : public UISimpleAction
    450 {
    451     Q_OBJECT;
    452 
    453 public:
    454 
    455     ShowInformationDialogAction(QObject *pParent)
    456         : UISimpleAction(pParent,
    457                          ":/session_info_16px.png", ":/session_info_disabled_16px.png")
    458     {
    459         retranslateUi();
    460     }
    461 
    462 protected:
    463 
    464     void retranslateUi()
    465     {
    466         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Session I&nformation"), gMS->shortcut(UIMachineShortcuts::InformationDialogShortcut)));
    467         setStatusTip(QApplication::translate("UIActionsPool", "Show Session Information Dialog"));
    468     }
    469 };
    470 
    471 class TogglePauseAction : public UIToggleAction
    472 {
    473     Q_OBJECT;
    474 
    475 public:
    476 
    477     TogglePauseAction(QObject *pParent)
    478         : UIToggleAction(pParent,
    479                          ":/pause_16px.png", ":/pause_disabled_16px.png")
    480     {
    481         retranslateUi();
    482     }
    483 
    484 protected:
    485 
    486     void retranslateUi()
    487     {
    488         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Pause"), gMS->shortcut(UIMachineShortcuts::PauseShortcut)));
    489         setStatusTip(QApplication::translate("UIActionsPool", "Suspend the execution of the virtual machine"));
    490     }
    491 };
    492 
    493 class PerformResetAction : public UISimpleAction
    494 {
    495     Q_OBJECT;
    496 
    497 public:
    498 
    499     PerformResetAction(QObject *pParent)
    500         : UISimpleAction(pParent,
    501                          ":/reset_16px.png", ":/reset_disabled_16px.png")
    502     {
    503         retranslateUi();
    504     }
    505 
    506 protected:
    507 
    508     void retranslateUi()
    509     {
    510         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Reset"), gMS->shortcut(UIMachineShortcuts::ResetShortcut)));
    511         setStatusTip(QApplication::translate("UIActionsPool", "Reset the virtual machine"));
    512     }
    513 };
    514 
    515 class PerformShutdownAction : public UISimpleAction
    516 {
    517     Q_OBJECT;
    518 
    519 public:
    520 
    521     PerformShutdownAction(QObject *pParent)
    522         : UISimpleAction(pParent,
    523                          ":/acpi_16px.png", ":/acpi_disabled_16px.png")
    524     {
    525         retranslateUi();
    526     }
    527 
    528 protected:
    529 
    530     void retranslateUi()
    531     {
    532         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "ACPI Sh&utdown"), gMS->shortcut(UIMachineShortcuts::ShutdownShortcut)));
    533         setStatusTip(QApplication::translate("UIActionsPool", "Send the ACPI Power Button press event to the virtual machine"));
    534     }
    535 };
    536 
    537 class PerformCloseAction : public UISimpleAction
    538 {
    539     Q_OBJECT;
    540 
    541 public:
    542 
    543     PerformCloseAction(QObject *pParent)
    544         : UISimpleAction(pParent,
    545                          ":/exit_16px.png")
    546     {
    547         setMenuRole(QAction::QuitRole);
    548         retranslateUi();
    549     }
    550 
    551 protected:
    552 
    553     void retranslateUi()
    554     {
    555         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Close..."), gMS->shortcut(UIMachineShortcuts::CloseShortcut)));
    556         setStatusTip(QApplication::translate("UIActionsPool", "Close the virtual machine"));
    557     }
    558 };
    559 
    560 class MenuViewAction : public UIMenuAction
    561 {
    562     Q_OBJECT;
    563 
    564 public:
    565 
    566     MenuViewAction(QObject *pParent)
    567         : UIMenuAction(pParent)
    568     {
    569         retranslateUi();
    570     }
    571 
    572 protected:
    573 
    574     void retranslateUi()
    575     {
    576         menu()->setTitle(QApplication::translate("UIActionsPool", "&View"));
    577     }
    578 };
    579 
    580580class MenuDevicesAction : public UIMenuAction
    581581{
     
    11141114{
    11151115    /* "Machine" menu actions: */
     1116    m_actionsPool[UIActionIndex_Simple_TakeSnapshot] = new PerformTakeSnapshotAction(this);
     1117    m_actionsPool[UIActionIndex_Simple_InformationDialog] = new ShowInformationDialogAction(this);
     1118    m_actionsPool[UIActionIndex_Toggle_MouseIntegration] = new ToggleMouseIntegrationAction(this);
     1119    m_actionsPool[UIActionIndex_Simple_TypeCAD] = new PerformTypeCADAction(this);
     1120#ifdef Q_WS_X11
     1121    m_actionsPool[UIActionIndex_Simple_TypeCABS] = new PerformTypeCABSAction(this);
     1122#endif
     1123    m_actionsPool[UIActionIndex_Toggle_Pause] = new TogglePauseAction(this);
     1124    m_actionsPool[UIActionIndex_Simple_Reset] = new PerformResetAction(this);
     1125    m_actionsPool[UIActionIndex_Simple_Shutdown] = new PerformShutdownAction(this);
     1126    m_actionsPool[UIActionIndex_Simple_Close] = new PerformCloseAction(this);
     1127
     1128    /* "View" menu actions: */
    11161129    m_actionsPool[UIActionIndex_Toggle_Fullscreen] = new ToggleFullscreenModeAction(this);
    11171130    m_actionsPool[UIActionIndex_Toggle_Seamless] = new ToggleSeamlessModeAction(this);
     
    11191132    m_actionsPool[UIActionIndex_Toggle_GuestAutoresize] = new ToggleGuestAutoresizeAction(this);
    11201133    m_actionsPool[UIActionIndex_Simple_AdjustWindow] = new PerformWindowAdjustAction(this);
    1121     m_actionsPool[UIActionIndex_Toggle_MouseIntegration] = new ToggleMouseIntegrationAction(this);
    1122     m_actionsPool[UIActionIndex_Simple_TypeCAD] = new PerformTypeCADAction(this);
    1123 #ifdef Q_WS_X11
    1124     m_actionsPool[UIActionIndex_Simple_TypeCABS] = new PerformTypeCABSAction(this);
    1125 #endif
    1126     m_actionsPool[UIActionIndex_Simple_TakeSnapshot] = new PerformTakeSnapshotAction(this);
    1127     m_actionsPool[UIActionIndex_Simple_InformationDialog] = new ShowInformationDialogAction(this);
    1128     m_actionsPool[UIActionIndex_Toggle_Pause] = new TogglePauseAction(this);
    1129     m_actionsPool[UIActionIndex_Simple_Reset] = new PerformResetAction(this);
    1130     m_actionsPool[UIActionIndex_Simple_Shutdown] = new PerformShutdownAction(this);
    1131     m_actionsPool[UIActionIndex_Simple_Close] = new PerformCloseAction(this);
    11321134
    11331135    /* "Devices" menu actions: */
     
    12261228        delete m_actionsPool[UIActionIndex_Menu_Machine];
    12271229    m_actionsPool[UIActionIndex_Menu_Machine] = new MenuMachineAction(this);
     1230    if (m_actionsPool[UIActionIndex_Menu_MouseIntegration])
     1231        delete m_actionsPool[UIActionIndex_Menu_MouseIntegration];
     1232    m_actionsPool[UIActionIndex_Menu_MouseIntegration] = new MenuMouseIntegrationAction(this);
     1233
    12281234    if (m_actionsPool[UIActionIndex_Menu_View])
    12291235        delete m_actionsPool[UIActionIndex_Menu_View];
    12301236    m_actionsPool[UIActionIndex_Menu_View] = new MenuViewAction(this);
    1231     if (m_actionsPool[UIActionIndex_Menu_MouseIntegration])
    1232         delete m_actionsPool[UIActionIndex_Menu_MouseIntegration];
    1233     m_actionsPool[UIActionIndex_Menu_MouseIntegration] = new MenuMouseIntegrationAction(this);
    12341237
    12351238    if (m_actionsPool[UIActionIndex_Menu_Devices])
     
    12481251        delete m_actionsPool[UIActionIndex_Menu_NetworkAdapters];
    12491252    m_actionsPool[UIActionIndex_Menu_NetworkAdapters] = new MenuNetworkAdaptersAction(this);
    1250 
    12511253    if (m_actionsPool[UIActionIndex_Menu_SharedFolders])
    12521254        delete m_actionsPool[UIActionIndex_Menu_SharedFolders];
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r35424 r36083  
    144144    {
    145145        QMenu *pMenuView = pActionsPool->action(UIActionIndex_Menu_View)->menu();
     146        prepareMenuView(pMenuView, pActionsPool);
    146147        preparedSubMenus << pMenuView;
    147148    }
     
    189190
    190191    /* Machine submenu: */
    191     pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Fullscreen));
    192     pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Seamless));
    193     pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Scale));
    194     pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_GuestAutoresize));
    195     pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_AdjustWindow));
     192    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TakeSnapshot));
     193    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InformationDialog));
    196194    pMenu->addSeparator();
    197195    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_MouseIntegration));
     
    201199    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TypeCABS));
    202200#endif
    203     pMenu->addSeparator();
    204     pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TakeSnapshot));
    205     pMenu->addSeparator();
    206     pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InformationDialog));
    207201    pMenu->addSeparator();
    208202    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Pause));
     
    213207#endif /* !Q_WS_MAC */
    214208    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Close));
     209}
     210
     211void UIMachineMenuBar::prepareMenuView(QMenu *pMenu, UIActionsPool *pActionsPool)
     212{
     213    /* Do not prepare if ready: */
     214    if (!pMenu->isEmpty())
     215        return;
     216
     217    /* View submenu: */
     218    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Fullscreen));
     219    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Seamless));
     220    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Scale));
     221    pMenu->addSeparator();
     222    pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_GuestAutoresize));
     223    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_AdjustWindow));
    215224}
    216225
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h

    r28800 r36083  
    4545    QList<QMenu*> prepareSubMenus(UIActionsPool *pActionsPool, UIMainMenuType fOptions = UIMainMenuType_All);
    4646    void prepareMenuMachine(QMenu *pMenu, UIActionsPool *pActionsPool);
     47    void prepareMenuView(QMenu *pMenu, UIActionsPool *pActionsPool);
    4748    void prepareMenuDevices(QMenu *pMenu, UIActionsPool *pActionsPool);
    4849#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp

    r29078 r36083  
    4949{
    5050    delete m_pScreenMap;
     51    while (!m_screenMenuList.isEmpty())
     52    {
     53        delete m_screenMenuList.first();
     54        m_screenMenuList.removeFirst();
     55    }
    5156}
    5257
    5358void UIMultiScreenLayout::initialize(QMenu *pMenu)
    5459{
    55     pMenu->clear();
    56     for (int i = 0; i < m_cGuestScreens; ++i)
    57     {
    58         QMenu *pScreenMenu = pMenu->addMenu(tr("Virtual Screen %1").arg(i + 1));
    59         QActionGroup *pScreenGroup = new QActionGroup(pScreenMenu);
    60         pScreenGroup->setExclusive(true);
    61         connect(pScreenGroup, SIGNAL(triggered(QAction*)),
    62                 this, SLOT(sltScreenLayoutChanged(QAction*)));
    63         for (int a = 0; a < m_cHostScreens; ++a)
    64         {
    65             QAction *pAction = pScreenGroup->addAction(tr("Use Host Screen %1").arg(a + 1));
    66             pAction->setCheckable(true);
    67             pAction->setData(RT_MAKE_U32(i, a));
    68         }
    69         pScreenMenu->addActions(pScreenGroup->actions());
     60    if (m_cHostScreens > 1)
     61    {
     62        pMenu->addSeparator();
     63        for (int i = 0; i < m_cGuestScreens; ++i)
     64        {
     65            m_screenMenuList << pMenu->addMenu(tr("Virtual Screen %1").arg(i + 1));
     66            m_screenMenuList.last()->menuAction()->setData(true);
     67            QActionGroup *pScreenGroup = new QActionGroup(m_screenMenuList.last());
     68            pScreenGroup->setExclusive(true);
     69            connect(pScreenGroup, SIGNAL(triggered(QAction*)), this, SLOT(sltScreenLayoutChanged(QAction*)));
     70            for (int a = 0; a < m_cHostScreens; ++a)
     71            {
     72                QAction *pAction = pScreenGroup->addAction(tr("Use Host Screen %1").arg(a + 1));
     73                pAction->setCheckable(true);
     74                pAction->setData(RT_MAKE_U32(i, a));
     75            }
     76            m_screenMenuList.last()->addActions(pScreenGroup->actions());
     77        }
    7078    }
    7179}
     
    8492    for (int i = 0; i < m_cGuestScreens; ++i)
    8593    {
    86         /* If the user ever selected a combination in the view menu, we have
    87          * the following entry: */
     94        /* If the user ever selected a combination in the view menu, we have the following entry: */
    8895        QString strTest = machine.GetExtraData(QString("%1%2").arg(VBoxDefs::GUI_VirtualScreenToHostScreen).arg(i));
    8996        bool fOk;
     
    127134    }
    128135
    129     QList<QAction*> actions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
    130     for (int i = 0; i < m_pScreenMap->size(); ++i)
    131     {
    132         int hostScreen = m_pScreenMap->value(i);
    133         QList<QAction*> actions1 = actions.at(i)->menu()->actions();
    134         for (int w = 0; w < actions1.size(); ++w)
    135         {
    136             QAction *pTmpAction = actions1.at(w);
     136    /* Get the list of all view-menu actions: */
     137    QList<QAction*> viewMenuActions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
     138    /* Get the list of all view related actions: */
     139    QList<QAction*> viewActions;
     140    for (int i = 0; i < viewMenuActions.size(); ++i)
     141    {
     142        if (viewMenuActions[i]->data().toBool())
     143            viewActions << viewMenuActions[i];
     144    }
     145    /* Mark currently chosen action: */
     146    for (int i = 0; i < viewActions.size(); ++i)
     147    {
     148        int iHostScreen = m_pScreenMap->value(i);
     149        QList<QAction*> screenActions = viewActions.at(i)->menu()->actions();
     150        for (int w = 0; w < screenActions.size(); ++w)
     151        {
     152            QAction *pTmpAction = screenActions.at(w);
    137153            pTmpAction->blockSignals(true);
    138             pTmpAction->setChecked(RT_HIWORD(pTmpAction->data().toInt()) == hostScreen);
     154            pTmpAction->setChecked(RT_HIWORD(pTmpAction->data().toInt()) == iHostScreen);
    139155            pTmpAction->blockSignals(false);
    140156        }
     
    222238    }
    223239
    224     /* Update the menu items. Even if we can't switch we have to revert the
    225      * menu items. */
    226     QList<QAction*> actions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
    227     /* Update the settings. */
    228     for (int i = 0; i < m_cGuestScreens; ++i)
    229     {
    230         int hostScreen = m_pScreenMap->value(i);
    231         machine.SetExtraData(QString("%1%2").arg(VBoxDefs::GUI_VirtualScreenToHostScreen).arg(i), QString::number(hostScreen));
    232         QList<QAction*> actions1 = actions.at(i)->menu()->actions();
    233         for (int w = 0; w < actions1.size(); ++w)
    234         {
    235             QAction *pTmpAction = actions1.at(w);
     240    /* Get the list of all view-menu actions: */
     241    QList<QAction*> viewMenuActions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
     242    /* Get the list of all view related actions: */
     243    QList<QAction*> viewActions;
     244    for (int i = 0; i < viewMenuActions.size(); ++i)
     245    {
     246        if (viewMenuActions[i]->data().toBool())
     247            viewActions << viewMenuActions[i];
     248    }
     249    /* Update the menu items. Even if we can't switch we have to revert the menu items. */
     250    for (int i = 0; i < viewActions.size(); ++i)
     251    {
     252        int iHostScreen = m_pScreenMap->value(i);
     253        machine.SetExtraData(QString("%1%2").arg(VBoxDefs::GUI_VirtualScreenToHostScreen).arg(i), QString::number(iHostScreen));
     254        QList<QAction*> screenActions = viewActions.at(i)->menu()->actions();
     255        for (int w = 0; w < screenActions.size(); ++w)
     256        {
     257            QAction *pTmpAction = screenActions.at(w);
    236258            pTmpAction->blockSignals(true);
    237             pTmpAction->setChecked(RT_HIWORD(pTmpAction->data().toInt()) == hostScreen);
     259            pTmpAction->setChecked(RT_HIWORD(pTmpAction->data().toInt()) == iHostScreen);
    238260            pTmpAction->blockSignals(false);
    239261        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h

    r29069 r36083  
    6363
    6464    QMap<int, int> *m_pScreenMap;
     65    QList<QMenu*> m_screenMenuList;
    6566};
    6667
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r31866 r36083  
    166166void UIMachineWindowFullscreen::prepareMenu()
    167167{
    168     UIMainMenuType fMenus = UIMainMenuType_All;
    169     /* Remove the view menu in the case there is one screen only. */
    170     if (QApplication::desktop()->numScreens() == 1)
    171         fMenus = UIMainMenuType(fMenus ^ UIMainMenuType_View);
    172168#ifdef Q_WS_MAC
    173     setMenuBar(uisession()->newMenuBar(fMenus));
     169    setMenuBar(uisession()->newMenuBar());
    174170#endif /* Q_WS_MAC */
    175     m_pMainMenu = uisession()->newMenu(fMenus);
     171    m_pMainMenu = uisession()->newMenu();
    176172}
    177173
     
    193189        m_pMiniToolBar->updateDisplay(true, true);
    194190        QList<QMenu*> menus;
    195         UIMainMenuType fMenu = UIMainMenuType(UIMainMenuType_Machine | UIMainMenuType_Devices);
    196         if (QApplication::desktop()->numScreens() > 1)
    197             fMenu = UIMainMenuType(fMenu | UIMainMenuType_View);
    198         QList<QAction*> actions = uisession()->newMenu(fMenu)->actions();
     191        QList<QAction*> actions = uisession()->newMenu()->actions();
    199192        for (int i=0; i < actions.size(); ++i)
    200193            menus << actions.at(i)->menu();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r35808 r36083  
    376376void UIMachineWindowNormal::prepareMenu()
    377377{
    378     /* No view menu in normal mode */
    379     setMenuBar(uisession()->newMenuBar(UIMainMenuType(UIMainMenuType_All ^ UIMainMenuType_View)));
     378    setMenuBar(uisession()->newMenuBar());
    380379}
    381380
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r35865 r36083  
    230230void UIMachineWindowScale::prepareMenu()
    231231{
    232     UIMainMenuType fMenus = UIMainMenuType(UIMainMenuType_All ^ UIMainMenuType_View);
    233 #ifdef Q_WS_MAC
    234     setMenuBar(uisession()->newMenuBar(fMenus));
     232#ifdef Q_WS_MAC
     233    setMenuBar(uisession()->newMenuBar());
    235234#endif /* Q_WS_MAC */
    236     /* No view menu in normal mode: */
    237     m_pMainMenu = uisession()->newMenu(fMenus);
     235    m_pMainMenu = uisession()->newMenu();
    238236}
    239237
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r33540 r36083  
    215215void UIMachineWindowSeamless::prepareMenu()
    216216{
    217     UIMainMenuType fMenus = UIMainMenuType_All;
    218     /* Remove the view menu in the case there is one screen only. */
    219     if (QApplication::desktop()->numScreens() == 1)
    220         fMenus = UIMainMenuType(fMenus ^ UIMainMenuType_View);
    221 #ifdef Q_WS_MAC
    222     setMenuBar(uisession()->newMenuBar(fMenus));
    223 #endif /* Q_WS_MAC */
    224     m_pMainMenu = uisession()->newMenu(fMenus);
     217#ifdef Q_WS_MAC
     218    setMenuBar(uisession()->newMenuBar());
     219#endif /* Q_WS_MAC */
     220    m_pMainMenu = uisession()->newMenu();
    225221}
    226222
     
    244240        m_pMiniToolBar->updateDisplay(true, true);
    245241        QList<QMenu*> menus;
    246         UIMainMenuType fMenu = UIMainMenuType(UIMainMenuType_Machine | UIMainMenuType_Devices);
    247         if (QApplication::desktop()->numScreens() > 1)
    248             fMenu = UIMainMenuType(fMenu | UIMainMenuType_View);
    249         QList<QAction*> actions = uisession()->newMenu(fMenu)->actions();
     242        QList<QAction*> actions = uisession()->newMenu()->actions();
    250243        for (int i=0; i < actions.size(); ++i)
    251244            menus << actions.at(i)->menu();
Note: See TracChangeset for help on using the changeset viewer.

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