VirtualBox

Changeset 52130 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 22, 2014 3:52:00 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 7462: Runtime UI: Menu-bar, menu cleanup/rework (part 03).

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

Legend:

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

    r52120 r52130  
    263263        src/extensions/QIListView.h \
    264264        src/extensions/QIMainDialog.h \
     265        src/extensions/QIMenu.h \
    265266        src/extensions/QIMessageBox.h \
    266267        src/extensions/QIProcess.h \
     
    298299        src/runtime/UIMachine.h \
    299300        src/runtime/UIMachineLogic.h \
    300         src/runtime/UIMachineMenuBar.h \
    301301        src/runtime/UIMachineWindow.h \
    302302        src/runtime/UIMachineView.h \
     
    379379        src/widgets/UIHotKeyEditor.h \
    380380        src/widgets/UILineTextEdit.h \
     381        src/widgets/UIMenuBar.h \
    381382        src/widgets/UIPopupBox.h \
    382383        src/widgets/UIPopupPane.h \
     
    535536        src/extensions/QIListView.cpp \
    536537        src/extensions/QIMainDialog.cpp \
     538        src/extensions/QIMenu.cpp \
    537539        src/extensions/QIMessageBox.cpp \
    538540        src/extensions/QIProcess.cpp \
     
    574576        src/runtime/UIMachine.cpp \
    575577        src/runtime/UIMachineLogic.cpp \
    576         src/runtime/UIMachineMenuBar.cpp \
    577578        src/runtime/UIMachineView.cpp \
    578579        src/runtime/UIMachineWindow.cpp \
     
    656657        src/widgets/UIHotKeyEditor.cpp \
    657658        src/widgets/UILineTextEdit.cpp \
     659        src/widgets/UIMenuBar.cpp \
    658660        src/widgets/UIPopupBox.cpp \
    659661        src/widgets/UIPopupPane.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMenu.cpp

    r52129 r52130  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIMachineMenuBar class implementation.
     3 * VBox Qt GUI - QIMenu class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2010-2013 Oracle Corporation
     7 * Copyright (C) 2010-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 /* Qt includes: */
    19 #include <QPainter>
    20 #include <QPaintEvent>
    21 #include <QPixmapCache>
    22 
    2318/* GUI includes: */
    24 #include "UIMachineMenuBar.h"
    25 #include "UISession.h"
    26 #include "UIMachineLogic.h"
    27 #include "UIActionPoolRuntime.h"
    28 #include "VBoxGlobal.h"
    29 #include "UIMessageCenter.h"
    30 #include "UIImageTools.h"
    31 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    32 # include "UINetworkManager.h"
    33 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    34 
    35 /* COM includes: */
    36 #include "CMachine.h"
    37 
     19#include "QIMenu.h"
    3820
    3921QIMenu::QIMenu(QWidget *pParent /* = 0 */)
     
    4527{
    4628#ifdef Q_WS_WIN
     29    /* Windows host requires window-activation: */
    4730    activateWindow();
    4831#endif /* Q_WS_WIN */
     32    /* Focus next child: */
    4933    QMenu::focusNextChild();
    5034}
    5135
    52 
    53 UIMenuBar::UIMenuBar(QWidget *pParent /* = 0 */)
    54     : QMenuBar(pParent)
    55     , m_fShowBetaLabel(false)
    56 {
    57     /* Check for beta versions: */
    58     if (vboxGlobal().isBeta())
    59         m_fShowBetaLabel = true;
    60 }
    61 
    62 void UIMenuBar::paintEvent(QPaintEvent *pEvent)
    63 {
    64     QMenuBar::paintEvent(pEvent);
    65     if (m_fShowBetaLabel)
    66     {
    67         QPixmap betaLabel;
    68         const QString key("vbox:betaLabel");
    69         if (!QPixmapCache::find(key, betaLabel))
    70         {
    71             betaLabel = ::betaLabel();
    72             QPixmapCache::insert(key, betaLabel);
    73         }
    74         QSize s = size();
    75         QPainter painter(this);
    76         painter.setClipRect(pEvent->rect());
    77         painter.drawPixmap(s.width() - betaLabel.width() - 10, (height() - betaLabel.height()) / 2, betaLabel);
    78     }
    79 }
    80 
    81 
    82 UIMachineMenuBar::UIMachineMenuBar(UISession *pSession)
    83     : m_pSession(pSession)
    84 {
    85 }
    86 
    87 QMenu* UIMachineMenuBar::createMenu(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    88 {
    89     /* Create empty menu: */
    90     QMenu *pMenu = new QIMenu;
    91 
    92     /* Fill menu with prepared items: */
    93     foreach (QMenu *pSubMenu, prepareSubMenus(fOptions))
    94         pMenu->addMenu(pSubMenu);
    95 
    96     /* Return filled menu: */
    97     return pMenu;
    98 }
    99 
    100 QMenuBar* UIMachineMenuBar::createMenuBar(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    101 {
    102     /* Create empty menubar: */
    103     QMenuBar *pMenuBar = new UIMenuBar;
    104 
    105     /* Fill menubar with prepared items: */
    106     foreach (QMenu *pSubMenu, prepareSubMenus(fOptions))
    107         pMenuBar->addMenu(pSubMenu);
    108 
    109     /* Return filled menubar: */
    110     return pMenuBar;
    111 }
    112 
    113 QList<QMenu*> UIMachineMenuBar::prepareSubMenus(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    114 {
    115     /* Create empty submenu list: */
    116     QList<QMenu*> preparedSubMenus;
    117 
    118     /* Machine submenu: */
    119     if (fOptions & RuntimeMenuType_Machine)
    120     {
    121         QMenu *pMenuMachine = gActionPool->action(UIActionIndexRuntime_Menu_Machine)->menu();
    122         prepareMenuMachine(pMenuMachine);
    123         preparedSubMenus << pMenuMachine;
    124     }
    125 
    126     /* View submenu: */
    127     if (fOptions & RuntimeMenuType_View)
    128     {
    129         QMenu *pMenuView = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu();
    130         prepareMenuView(pMenuView);
    131         preparedSubMenus << pMenuView;
    132     }
    133 
    134     /* Devices submenu: */
    135     if (fOptions & RuntimeMenuType_Devices)
    136     {
    137         QMenu *pMenuDevices = gActionPool->action(UIActionIndexRuntime_Menu_Devices)->menu();
    138         prepareMenuDevices(pMenuDevices);
    139         preparedSubMenus << pMenuDevices;
    140     }
    141 
    142 #ifdef VBOX_WITH_DEBUGGER_GUI
    143     /* Debug submenu: */
    144     if (fOptions & RuntimeMenuType_Debug)
    145     {
    146         if (vboxGlobal().isDebuggerEnabled())
    147         {
    148             QMenu *pMenuDebug = gActionPool->action(UIActionIndexRuntime_Menu_Debug)->menu();
    149             prepareMenuDebug(pMenuDebug);
    150             preparedSubMenus << pMenuDebug;
    151         }
    152     }
    153 #endif /* VBOX_WITH_DEBUGGER_GUI */
    154 
    155     /* Help submenu: */
    156     if (fOptions & RuntimeMenuType_Help)
    157     {
    158         QMenu *pMenuHelp = gActionPool->action(UIActionIndex_Menu_Help)->menu();
    159         prepareMenuHelp(pMenuHelp);
    160         preparedSubMenus << pMenuHelp;
    161     }
    162 
    163     /* Return a list of prepared submenus: */
    164     return preparedSubMenus;
    165 }
    166 
    167 void UIMachineMenuBar::prepareMenuMachine(QMenu *pMenu)
    168 {
    169     /* Do not prepare if ready: */
    170     if (!pMenu->isEmpty())
    171         return;
    172 
    173 
    174     /* Separator #1? */
    175     bool fSeparator1 = false;
    176 
    177     /* Settings Dialog action: */
    178     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_SettingsDialog)
    179     {
    180         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    181         fSeparator1 = true;
    182     }
    183     else
    184         gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)->setEnabled(false);
    185     /* Take Snapshot action: */
    186     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TakeSnapshot &&
    187         m_pSession->isSnapshotOperationsAllowed())
    188     {
    189         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
    190         fSeparator1 = true;
    191     }
    192     else
    193         gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)->setEnabled(false);
    194     /* Take Screenshot action: */
    195     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TakeScreenshot)
    196     {
    197         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));
    198         fSeparator1 = true;
    199     }
    200     else
    201         gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot)->setEnabled(false);
    202     /* Information Dialog action: */
    203     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_InformationDialog)
    204     {
    205         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));
    206         fSeparator1 = true;
    207     }
    208     else
    209         gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog)->setEnabled(false);
    210 
    211     /* Separator #1: */
    212     if (fSeparator1)
    213         pMenu->addSeparator();
    214 
    215 
    216     /* Separator #2? */
    217     bool fSeparator2 = false;
    218 
    219     /* Keyboard Settings action: */
    220     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_KeyboardSettings)
    221     {
    222 //        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_KeyboardSettings));
    223 //        fSeparator2 = true;
    224     }
    225     else
    226         gActionPool->action(UIActionIndexRuntime_Simple_KeyboardSettings)->setEnabled(false);
    227 
    228     /* Mouse Integration action: */
    229     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_MouseIntegration)
    230     {
    231         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration));
    232         fSeparator2 = true;
    233     }
    234     else
    235         gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration)->setEnabled(false);
    236 
    237     /* Separator #2: */
    238     if (fSeparator2)
    239         pMenu->addSeparator();
    240 
    241 
    242     /* Separator #3? */
    243     bool fSeparator3 = false;
    244 
    245     /* Type CAD action: */
    246     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TypeCAD)
    247     {
    248         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));
    249         fSeparator3 = true;
    250     }
    251     else
    252         gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD)->setEnabled(false);
    253 #ifdef Q_WS_X11
    254     /* Type CABS action: */
    255     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TypeCABS)
    256     {
    257         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));
    258         fSeparator3 = true;
    259     }
    260     else
    261         gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS)->setEnabled(false);
    262 #endif /* Q_WS_X11 */
    263 
    264     /* Separator #3: */
    265     if (fSeparator3)
    266         pMenu->addSeparator();
    267 
    268 
    269     /* Separator #4? */
    270     bool fSeparator4 = false;
    271 
    272     /* Pause action: */
    273     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Pause)
    274     {
    275         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
    276         fSeparator4 = true;
    277     }
    278     else
    279         gActionPool->action(UIActionIndexRuntime_Toggle_Pause)->setEnabled(false);
    280     /* Reset action: */
    281     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Reset)
    282     {
    283         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
    284         fSeparator4 = true;
    285     }
    286     else
    287         gActionPool->action(UIActionIndexRuntime_Simple_Reset)->setEnabled(false);
    288     /* SaveState action: */
    289     if (!(m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_SaveState))
    290         gActionPool->action(UIActionIndexRuntime_Simple_Save)->setEnabled(false);
    291     /* Shutdown action: */
    292     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Shutdown)
    293     {
    294         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
    295         fSeparator4 = true;
    296     }
    297     else
    298         gActionPool->action(UIActionIndexRuntime_Simple_Shutdown)->setEnabled(false);
    299     /* PowerOff action: */
    300     if (!(m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_PowerOff))
    301         gActionPool->action(UIActionIndexRuntime_Simple_PowerOff)->setEnabled(false);
    302 
    303 #ifndef Q_WS_MAC
    304     /* Separator #3: */
    305     if (fSeparator4)
    306         pMenu->addSeparator();
    307 #endif /* !Q_WS_MAC */
    308 
    309 
    310     /* Close action: */
    311     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Close));
    312     if (m_pSession->isAllCloseActionsRestricted())
    313         gActionPool->action(UIActionIndexRuntime_Simple_Close)->setEnabled(false);
    314 }
    315 
    316 void UIMachineMenuBar::prepareMenuView(QMenu *pMenu)
    317 {
    318     /* Do not prepare if ready: */
    319     if (!pMenu->isEmpty())
    320         return;
    321 
    322 
    323     /* Mode flags: */
    324     bool fIsAllowedFullscreen = m_pSession->isVisualStateAllowed(UIVisualStateType_Fullscreen) &&
    325                                 (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Fullscreen);
    326     bool fIsAllowedSeamless = m_pSession->isVisualStateAllowed(UIVisualStateType_Seamless) &&
    327                               (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Seamless);
    328     bool fIsAllowedScale = m_pSession->isVisualStateAllowed(UIVisualStateType_Scale) &&
    329                            (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Scale);
    330 
    331     /* Fullscreen action: */
    332     gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->setEnabled(fIsAllowedFullscreen);
    333     if (fIsAllowedFullscreen)
    334         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
    335 
    336     /* Seamless action: */
    337     gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(fIsAllowedSeamless);
    338     if (fIsAllowedSeamless)
    339         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
    340 
    341     /* Scale action: */
    342     gActionPool->action(UIActionIndexRuntime_Toggle_Scale)->setEnabled(fIsAllowedScale);
    343     if (fIsAllowedScale)
    344         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
    345 
    346     /* Mode separator: */
    347     if (fIsAllowedFullscreen || fIsAllowedSeamless || fIsAllowedScale)
    348         pMenu->addSeparator();
    349 
    350 
    351     /* Separator #2? */
    352     bool fSeparator2 = false;
    353 
    354     /* Guest Autoresize action: */
    355     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_GuestAutoresize)
    356     {
    357         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
    358         fSeparator2 = true;
    359     }
    360     else
    361         gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(false);
    362 
    363     /* Adjust Window action: */
    364     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_AdjustWindow)
    365     {
    366         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
    367         fSeparator2 = true;
    368     }
    369     else
    370         gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow)->setEnabled(false);
    371 
    372     /* Separator #2: */
    373     if (fSeparator2)
    374         pMenu->addSeparator();
    375 
    376 
    377     /* Status-bar submenu: */
    378     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_StatusBar)
    379     {
    380         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_StatusBar));
    381         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings));
    382         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar));
    383     }
    384     else
    385     {
    386         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->setEnabled(false);
    387         gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings)->setEnabled(false);
    388         gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->setEnabled(false);
    389     }
    390 }
    391 
    392 void UIMachineMenuBar::prepareMenuDevices(QMenu *pMenu)
    393 {
    394     /* Do not prepare if ready: */
    395     if (!pMenu->isEmpty())
    396         return;
    397 
    398 
    399     /* Separator #1? */
    400     bool fSeparator1 = false;
    401 
    402     /* Optical Devices submenu: */
    403     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_OpticalDevices)
    404     {
    405         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices));
    406         fSeparator1 = true;
    407     }
    408     else
    409         gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->setEnabled(false);
    410     /* Floppy Devices submenu: */
    411     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_FloppyDevices)
    412     {
    413         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices));
    414         fSeparator1 = true;
    415     }
    416     else
    417         gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->setEnabled(false);
    418     /* USB Devices submenu: */
    419     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_USBDevices)
    420     {
    421         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices));
    422         fSeparator1 = true;
    423     }
    424     else
    425         gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->setEnabled(false);
    426     /* Web Cams submenu: */
    427     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_WebCams)
    428     {
    429         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_WebCams));
    430         fSeparator1 = true;
    431     }
    432     else
    433         gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->setEnabled(false);
    434     /* Shared Clipboard submenu: */
    435     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_SharedClipboard)
    436     {
    437         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard));
    438         fSeparator1 = true;
    439     }
    440     else
    441         gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard)->setEnabled(false);
    442     /* Drag&Drop submenu: */
    443     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_DragAndDrop)
    444     {
    445         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop));
    446         fSeparator1 = true;
    447     }
    448     else
    449         gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)->setEnabled(false);
    450     /* Network submenu: */
    451     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_NetworkSettings)
    452     {
    453         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_Network));
    454         gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings));
    455         fSeparator1 = true;
    456     }
    457     else
    458     {
    459         gActionPool->action(UIActionIndexRuntime_Menu_Network)->setEnabled(false);
    460         gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings)->setEnabled(false);
    461     }
    462     /* Shared Folders Settings action: */
    463     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_SharedFoldersSettings)
    464     {
    465         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersSettings));
    466         fSeparator1 = true;
    467     }
    468     else
    469         gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersSettings)->setEnabled(false);
    470 
    471     /* Separator #1: */
    472     if (fSeparator1)
    473         pMenu->addSeparator();
    474 
    475 
    476     /* Separator #2? */
    477     bool fSeparator2 = false;
    478 
    479     /* VRDE Server action: */
    480     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_VRDEServer)
    481     {
    482         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));
    483         if (!m_pSession->isExtensionPackUsable())
    484             gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer)->setEnabled(false);
    485         fSeparator2 = true;
    486     }
    487     else
    488         gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer)->setEnabled(false);
    489     /* Video Capture action: */
    490     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_VideoCapture)
    491     {
    492         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VideoCapture));
    493         fSeparator2 = true;
    494     }
    495     else
    496         gActionPool->action(UIActionIndexRuntime_Toggle_VideoCapture)->setEnabled(false);
    497 
    498     /* Separator #2: */
    499     if (fSeparator2)
    500         pMenu->addSeparator();
    501 
    502 
    503     /* Install Guest Tools action: */
    504     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_InstallGuestTools)
    505         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));
    506     else
    507         gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools)->setEnabled(false);
    508 }
    509 
    510 #ifdef VBOX_WITH_DEBUGGER_GUI
    511 void UIMachineMenuBar::prepareMenuDebug(QMenu *pMenu)
    512 {
    513     /* Do not prepare if ready: */
    514     if (!pMenu->isEmpty())
    515         return;
    516 
    517     /* Statistics action: */
    518     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_Statistics)
    519         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Statistics));
    520     else
    521         gActionPool->action(UIActionIndexRuntime_Simple_Statistics)->setEnabled(false);
    522     /* Command Line action: */
    523     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_CommandLine)
    524         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_CommandLine));
    525     else
    526         gActionPool->action(UIActionIndexRuntime_Simple_CommandLine)->setEnabled(false);
    527     /* Logging action: */
    528     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_Logging)
    529         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Logging));
    530     else
    531         gActionPool->action(UIActionIndexRuntime_Toggle_Logging)->setEnabled(false);
    532     /* Log Dialog action: */
    533     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_LogDialog)
    534         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_LogDialog));
    535     else
    536         gActionPool->action(UIActionIndex_Simple_LogDialog)->setEnabled(false);
    537 }
    538 #endif /* VBOX_WITH_DEBUGGER_GUI */
    539 
    540 void UIMachineMenuBar::prepareMenuHelp(QMenu *pMenu)
    541 {
    542     /* Do not prepare if ready: */
    543     if (!pMenu->isEmpty())
    544         return;
    545 
    546 
    547     /* Separator #1? */
    548     bool fSeparator1 = false;
    549 
    550     /* Contents action: */
    551     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_Contents)
    552     {
    553         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Contents));
    554         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_Contents), SIGNAL(triggered()),
    555                             &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    556         fSeparator1 = true;
    557     }
    558     else
    559         gActionPool->action(UIActionIndex_Simple_Contents)->setEnabled(false);
    560     /* Web Site action: */
    561     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_WebSite)
    562     {
    563         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_WebSite));
    564         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()),
    565                             &msgCenter(), SLOT(sltShowHelpWebDialog()));
    566         fSeparator1 = true;
    567     }
    568     else
    569         gActionPool->action(RuntimeMenuHelpActionType_WebSite)->setEnabled(false);
    570 
    571     /* Separator #1: */
    572     if (fSeparator1)
    573         pMenu->addSeparator();
    574 
    575 
    576     /* Separator #2? */
    577     bool fSeparator2 = false;
    578 
    579     /* Reset Warnings action: */
    580     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_ResetWarnings)
    581     {
    582         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_ResetWarnings));
    583         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
    584                             &msgCenter(), SLOT(sltResetSuppressedMessages()));
    585         fSeparator2 = true;
    586     }
    587     else
    588         gActionPool->action(UIActionIndex_Simple_ResetWarnings)->setEnabled(false);
    589 
    590     /* Separator #2: */
    591     if (fSeparator2)
    592         pMenu->addSeparator();
    593 
    594 
    595 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    596 # ifndef Q_WS_MAC
    597     /* Separator #3? */
    598     bool fSeparator3 = false;
    599 # endif /* !Q_WS_MAC */
    600 
    601     /* Reset Warnings action: */
    602     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_NetworkAccessManager)
    603     {
    604         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_NetworkAccessManager));
    605         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()),
    606                             gNetworkManager, SLOT(show()));
    607 # ifndef Q_WS_MAC
    608         fSeparator3 = true;
    609 # endif /* !Q_WS_MAC */
    610     }
    611     else
    612         gActionPool->action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(false);
    613 
    614 # ifndef Q_WS_MAC
    615     /* Separator #3: */
    616     if (fSeparator3)
    617         pMenu->addSeparator();
    618 # endif /* !Q_WS_MAC */
    619 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    620 
    621 
    622     /* About action: */
    623 #ifdef Q_WS_MAC
    624     if (m_pSession->allowedActionsMenuApplication() & RuntimeMenuApplicationActionType_About)
    625 #else /* !Q_WS_MAC */
    626     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_About)
    627 #endif /* Q_WS_MAC */
    628     {
    629         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_About));
    630         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
    631                             &msgCenter(), SLOT(sltShowHelpAboutDialog()));
    632     }
    633     else
    634         gActionPool->action(UIActionIndex_Simple_About)->setEnabled(false);
    635 
    636     /* Preferences action: */
    637 #ifdef Q_WS_MAC
    638     if (m_pSession->allowedActionsMenuApplication() & RuntimeMenuApplicationActionType_Preferences)
    639 #else /* !Q_WS_MAC */
    640     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_Preferences)
    641 #endif /* Q_WS_MAC */
    642     {
    643         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Preferences));
    644         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_Preferences), SIGNAL(triggered()),
    645                             m_pSession->machineLogic(), SLOT(sltShowGlobalPreferences()));
    646     }
    647     else
    648         gActionPool->action(UIActionIndex_Simple_Preferences)->setEnabled(false);
    649 }
    650 
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMenu.h

    r52129 r52130  
    11/** @file
    2  * VBox Qt GUI - UIMachineMenuBar class declaration.
     2 * VBox Qt GUI - QIMenu class declaration.
    33 */
    44
    55/*
    6  * Copyright (C) 2010-2013 Oracle Corporation
     6 * Copyright (C) 2010-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 */
    1616
    17 #ifndef ___UIMachineMenuBar_h___
    18 #define ___UIMachineMenuBar_h___
     17#ifndef ___QIMenu_h___
     18#define ___QIMenu_h___
    1919
    2020/* Qt includes: */
    21 #include <QList>
    2221#include <QMenu>
    23 #include <QMenuBar>
    24 
    25 /* GUI includes: */
    26 #include "UIExtraDataDefs.h"
    27 
    28 /* Forward declarations: */
    29 class UISession;
    30 
    3122
    3223/** QMenu extension
     
    3829public:
    3930
    40     /** Constructor. */
     31    /** Constructor, passes @a pParent to the QMenu constructor. */
    4132    QIMenu(QWidget *pParent = 0);
    4233
     
    4738};
    4839
    49 
    50 /** QMenuBar extension
    51   * which reflects BETA label when necessary. */
    52 class UIMenuBar: public QMenuBar
    53 {
    54     Q_OBJECT;
    55 
    56 public:
    57 
    58     /** Constructor. */
    59     UIMenuBar(QWidget *pParent = 0);
    60 
    61 protected:
    62 
    63     /** Paint event handler. */
    64     void paintEvent(QPaintEvent *pEvent);
    65 
    66 private:
    67 
    68     /** Reflects whether we should show BETA label or not. */
    69     bool m_fShowBetaLabel;
    70 };
    71 
    72 
    73 /**
    74  * Menubar factory for virtual machine (Runtime UI).
    75  * Provides client with the new menu/menubar whenever it necessary.
    76  */
    77 class UIMachineMenuBar
    78 {
    79 public:
    80 
    81     /** Constructor. Stores UI session pointer for further needs. */
    82     UIMachineMenuBar(UISession *pSession);
    83 
    84     /** Provides client with new menu. */
    85     QMenu* createMenu(RuntimeMenuType fOptions = RuntimeMenuType_All);
    86     /** Provides client with new menubar. */
    87     QMenuBar* createMenuBar(RuntimeMenuType fOptions = RuntimeMenuType_All);
    88 
    89 private:
    90 
    91     /** Populates all the sub-menus client need. */
    92     QList<QMenu*> prepareSubMenus(RuntimeMenuType fOptions = RuntimeMenuType_All);
    93     /** Populates <b>Machine</b> sub-menu. */
    94     void prepareMenuMachine(QMenu *pMenu);
    95     /** Populates <b>View</b> sub-menu. */
    96     void prepareMenuView(QMenu *pMenu);
    97     /** Populates <b>Devices</b> sub-menu. */
    98     void prepareMenuDevices(QMenu *pMenu);
    99 #ifdef VBOX_WITH_DEBUGGER_GUI
    100     /** Populates <b>Debug</b> sub-menu. */
    101     void prepareMenuDebug(QMenu *pMenu);
    102 #endif /* VBOX_WITH_DEBUGGER_GUI */
    103     /** Populates <b>Help</b> sub-menu. */
    104     void prepareMenuHelp(QMenu *pMenu);
    105 
    106     /** Contains pointer to parent UI session. */
    107     UISession *m_pSession;
    108 };
    109 
    110 #endif /* !___UIMachineMenuBar_h___ */
    111 
     40#endif /* !___QIMenu_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r52129 r52130  
    4343#include "UIMachineLogicSeamless.h"
    4444#include "UIMachineLogicScale.h"
    45 #include "UIMachineMenuBar.h"
     45#include "UIMenuBar.h"
    4646#include "UIMachineView.h"
    4747#include "UIMachineWindow.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52129 r52130  
    3434#include "UIMachineView.h"
    3535#include "UIMachineWindow.h"
    36 #include "UIMachineMenuBar.h"
    3736#include "UIMessageCenter.h"
    3837#include "UIPopupCenter.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r52129 r52130  
    2828#include "UIMachineWindowFullscreen.h"
    2929#include "UIMultiScreenLayout.h"
    30 #include "UIMachineMenuBar.h"
     30#include "QIMenu.h"
    3131#ifdef Q_WS_MAC
    3232# include "UIExtraDataManager.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r52129 r52130  
    4040#include "QIStatusBarIndicator.h"
    4141#ifndef Q_WS_MAC
    42 # include "UIMachineMenuBar.h"
     42# include "UIMenuBar.h"
    4343#else /* Q_WS_MAC */
    4444# include "VBoxUtils.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp

    r52129 r52130  
    2929#include "UIMachineWindow.h"
    3030#ifndef Q_WS_MAC
    31 # include "UIMachineMenuBar.h"
     31# include "QIMenu.h"
    3232#else /* Q_WS_MAC */
    3333# include "VBoxUtils.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIKeyboardHandlerSeamless.h

    r52129 r52130  
    4141#endif /* !Q_WS_MAC */
    4242
    43     /* Friend classes: */
     43    /* Friend class: */
    4444    friend class UIKeyboardHandler;
    4545};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r52129 r52130  
    3232#include "UIMultiScreenLayout.h"
    3333#ifndef Q_WS_MAC
    34 # include "UIMachineMenuBar.h"
     34# include "QIMenu.h"
    3535#else /* Q_WS_MAC */
    3636# include "VBoxUtils.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBar.cpp

    r52129 r52130  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIMachineMenuBar class implementation.
     3 * VBox Qt GUI - UIMenuBar class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2010-2013 Oracle Corporation
     7 * Copyright (C) 2010-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222
    2323/* GUI includes: */
    24 #include "UIMachineMenuBar.h"
    25 #include "UISession.h"
    26 #include "UIMachineLogic.h"
    27 #include "UIActionPoolRuntime.h"
     24#include "UIMenuBar.h"
     25#include "UIImageTools.h"
    2826#include "VBoxGlobal.h"
    29 #include "UIMessageCenter.h"
    30 #include "UIImageTools.h"
    31 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    32 # include "UINetworkManager.h"
    33 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    34 
    35 /* COM includes: */
    36 #include "CMachine.h"
    37 
    38 
    39 QIMenu::QIMenu(QWidget *pParent /* = 0 */)
    40     : QMenu(pParent)
    41 {
    42 }
    43 
    44 void QIMenu::sltHighlightFirstAction()
    45 {
    46 #ifdef Q_WS_WIN
    47     activateWindow();
    48 #endif /* Q_WS_WIN */
    49     QMenu::focusNextChild();
    50 }
    51 
    5227
    5328UIMenuBar::UIMenuBar(QWidget *pParent /* = 0 */)
     
    7954}
    8055
    81 
    82 UIMachineMenuBar::UIMachineMenuBar(UISession *pSession)
    83     : m_pSession(pSession)
    84 {
    85 }
    86 
    87 QMenu* UIMachineMenuBar::createMenu(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    88 {
    89     /* Create empty menu: */
    90     QMenu *pMenu = new QIMenu;
    91 
    92     /* Fill menu with prepared items: */
    93     foreach (QMenu *pSubMenu, prepareSubMenus(fOptions))
    94         pMenu->addMenu(pSubMenu);
    95 
    96     /* Return filled menu: */
    97     return pMenu;
    98 }
    99 
    100 QMenuBar* UIMachineMenuBar::createMenuBar(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    101 {
    102     /* Create empty menubar: */
    103     QMenuBar *pMenuBar = new UIMenuBar;
    104 
    105     /* Fill menubar with prepared items: */
    106     foreach (QMenu *pSubMenu, prepareSubMenus(fOptions))
    107         pMenuBar->addMenu(pSubMenu);
    108 
    109     /* Return filled menubar: */
    110     return pMenuBar;
    111 }
    112 
    113 QList<QMenu*> UIMachineMenuBar::prepareSubMenus(RuntimeMenuType fOptions /* = RuntimeMenuType_All */)
    114 {
    115     /* Create empty submenu list: */
    116     QList<QMenu*> preparedSubMenus;
    117 
    118     /* Machine submenu: */
    119     if (fOptions & RuntimeMenuType_Machine)
    120     {
    121         QMenu *pMenuMachine = gActionPool->action(UIActionIndexRuntime_Menu_Machine)->menu();
    122         prepareMenuMachine(pMenuMachine);
    123         preparedSubMenus << pMenuMachine;
    124     }
    125 
    126     /* View submenu: */
    127     if (fOptions & RuntimeMenuType_View)
    128     {
    129         QMenu *pMenuView = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu();
    130         prepareMenuView(pMenuView);
    131         preparedSubMenus << pMenuView;
    132     }
    133 
    134     /* Devices submenu: */
    135     if (fOptions & RuntimeMenuType_Devices)
    136     {
    137         QMenu *pMenuDevices = gActionPool->action(UIActionIndexRuntime_Menu_Devices)->menu();
    138         prepareMenuDevices(pMenuDevices);
    139         preparedSubMenus << pMenuDevices;
    140     }
    141 
    142 #ifdef VBOX_WITH_DEBUGGER_GUI
    143     /* Debug submenu: */
    144     if (fOptions & RuntimeMenuType_Debug)
    145     {
    146         if (vboxGlobal().isDebuggerEnabled())
    147         {
    148             QMenu *pMenuDebug = gActionPool->action(UIActionIndexRuntime_Menu_Debug)->menu();
    149             prepareMenuDebug(pMenuDebug);
    150             preparedSubMenus << pMenuDebug;
    151         }
    152     }
    153 #endif /* VBOX_WITH_DEBUGGER_GUI */
    154 
    155     /* Help submenu: */
    156     if (fOptions & RuntimeMenuType_Help)
    157     {
    158         QMenu *pMenuHelp = gActionPool->action(UIActionIndex_Menu_Help)->menu();
    159         prepareMenuHelp(pMenuHelp);
    160         preparedSubMenus << pMenuHelp;
    161     }
    162 
    163     /* Return a list of prepared submenus: */
    164     return preparedSubMenus;
    165 }
    166 
    167 void UIMachineMenuBar::prepareMenuMachine(QMenu *pMenu)
    168 {
    169     /* Do not prepare if ready: */
    170     if (!pMenu->isEmpty())
    171         return;
    172 
    173 
    174     /* Separator #1? */
    175     bool fSeparator1 = false;
    176 
    177     /* Settings Dialog action: */
    178     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_SettingsDialog)
    179     {
    180         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    181         fSeparator1 = true;
    182     }
    183     else
    184         gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)->setEnabled(false);
    185     /* Take Snapshot action: */
    186     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TakeSnapshot &&
    187         m_pSession->isSnapshotOperationsAllowed())
    188     {
    189         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
    190         fSeparator1 = true;
    191     }
    192     else
    193         gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)->setEnabled(false);
    194     /* Take Screenshot action: */
    195     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TakeScreenshot)
    196     {
    197         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));
    198         fSeparator1 = true;
    199     }
    200     else
    201         gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot)->setEnabled(false);
    202     /* Information Dialog action: */
    203     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_InformationDialog)
    204     {
    205         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));
    206         fSeparator1 = true;
    207     }
    208     else
    209         gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog)->setEnabled(false);
    210 
    211     /* Separator #1: */
    212     if (fSeparator1)
    213         pMenu->addSeparator();
    214 
    215 
    216     /* Separator #2? */
    217     bool fSeparator2 = false;
    218 
    219     /* Keyboard Settings action: */
    220     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_KeyboardSettings)
    221     {
    222 //        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_KeyboardSettings));
    223 //        fSeparator2 = true;
    224     }
    225     else
    226         gActionPool->action(UIActionIndexRuntime_Simple_KeyboardSettings)->setEnabled(false);
    227 
    228     /* Mouse Integration action: */
    229     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_MouseIntegration)
    230     {
    231         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration));
    232         fSeparator2 = true;
    233     }
    234     else
    235         gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration)->setEnabled(false);
    236 
    237     /* Separator #2: */
    238     if (fSeparator2)
    239         pMenu->addSeparator();
    240 
    241 
    242     /* Separator #3? */
    243     bool fSeparator3 = false;
    244 
    245     /* Type CAD action: */
    246     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TypeCAD)
    247     {
    248         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));
    249         fSeparator3 = true;
    250     }
    251     else
    252         gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD)->setEnabled(false);
    253 #ifdef Q_WS_X11
    254     /* Type CABS action: */
    255     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_TypeCABS)
    256     {
    257         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));
    258         fSeparator3 = true;
    259     }
    260     else
    261         gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS)->setEnabled(false);
    262 #endif /* Q_WS_X11 */
    263 
    264     /* Separator #3: */
    265     if (fSeparator3)
    266         pMenu->addSeparator();
    267 
    268 
    269     /* Separator #4? */
    270     bool fSeparator4 = false;
    271 
    272     /* Pause action: */
    273     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Pause)
    274     {
    275         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
    276         fSeparator4 = true;
    277     }
    278     else
    279         gActionPool->action(UIActionIndexRuntime_Toggle_Pause)->setEnabled(false);
    280     /* Reset action: */
    281     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Reset)
    282     {
    283         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
    284         fSeparator4 = true;
    285     }
    286     else
    287         gActionPool->action(UIActionIndexRuntime_Simple_Reset)->setEnabled(false);
    288     /* SaveState action: */
    289     if (!(m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_SaveState))
    290         gActionPool->action(UIActionIndexRuntime_Simple_Save)->setEnabled(false);
    291     /* Shutdown action: */
    292     if (m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_Shutdown)
    293     {
    294         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
    295         fSeparator4 = true;
    296     }
    297     else
    298         gActionPool->action(UIActionIndexRuntime_Simple_Shutdown)->setEnabled(false);
    299     /* PowerOff action: */
    300     if (!(m_pSession->allowedActionsMenuMachine() & RuntimeMenuMachineActionType_PowerOff))
    301         gActionPool->action(UIActionIndexRuntime_Simple_PowerOff)->setEnabled(false);
    302 
    303 #ifndef Q_WS_MAC
    304     /* Separator #3: */
    305     if (fSeparator4)
    306         pMenu->addSeparator();
    307 #endif /* !Q_WS_MAC */
    308 
    309 
    310     /* Close action: */
    311     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Close));
    312     if (m_pSession->isAllCloseActionsRestricted())
    313         gActionPool->action(UIActionIndexRuntime_Simple_Close)->setEnabled(false);
    314 }
    315 
    316 void UIMachineMenuBar::prepareMenuView(QMenu *pMenu)
    317 {
    318     /* Do not prepare if ready: */
    319     if (!pMenu->isEmpty())
    320         return;
    321 
    322 
    323     /* Mode flags: */
    324     bool fIsAllowedFullscreen = m_pSession->isVisualStateAllowed(UIVisualStateType_Fullscreen) &&
    325                                 (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Fullscreen);
    326     bool fIsAllowedSeamless = m_pSession->isVisualStateAllowed(UIVisualStateType_Seamless) &&
    327                               (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Seamless);
    328     bool fIsAllowedScale = m_pSession->isVisualStateAllowed(UIVisualStateType_Scale) &&
    329                            (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Scale);
    330 
    331     /* Fullscreen action: */
    332     gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->setEnabled(fIsAllowedFullscreen);
    333     if (fIsAllowedFullscreen)
    334         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
    335 
    336     /* Seamless action: */
    337     gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(fIsAllowedSeamless);
    338     if (fIsAllowedSeamless)
    339         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
    340 
    341     /* Scale action: */
    342     gActionPool->action(UIActionIndexRuntime_Toggle_Scale)->setEnabled(fIsAllowedScale);
    343     if (fIsAllowedScale)
    344         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
    345 
    346     /* Mode separator: */
    347     if (fIsAllowedFullscreen || fIsAllowedSeamless || fIsAllowedScale)
    348         pMenu->addSeparator();
    349 
    350 
    351     /* Separator #2? */
    352     bool fSeparator2 = false;
    353 
    354     /* Guest Autoresize action: */
    355     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_GuestAutoresize)
    356     {
    357         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
    358         fSeparator2 = true;
    359     }
    360     else
    361         gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(false);
    362 
    363     /* Adjust Window action: */
    364     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_AdjustWindow)
    365     {
    366         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
    367         fSeparator2 = true;
    368     }
    369     else
    370         gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow)->setEnabled(false);
    371 
    372     /* Separator #2: */
    373     if (fSeparator2)
    374         pMenu->addSeparator();
    375 
    376 
    377     /* Status-bar submenu: */
    378     if (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_StatusBar)
    379     {
    380         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_StatusBar));
    381         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings));
    382         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar));
    383     }
    384     else
    385     {
    386         gActionPool->action(UIActionIndexRuntime_Menu_StatusBar)->setEnabled(false);
    387         gActionPool->action(UIActionIndexRuntime_Simple_StatusBarSettings)->setEnabled(false);
    388         gActionPool->action(UIActionIndexRuntime_Toggle_StatusBar)->setEnabled(false);
    389     }
    390 }
    391 
    392 void UIMachineMenuBar::prepareMenuDevices(QMenu *pMenu)
    393 {
    394     /* Do not prepare if ready: */
    395     if (!pMenu->isEmpty())
    396         return;
    397 
    398 
    399     /* Separator #1? */
    400     bool fSeparator1 = false;
    401 
    402     /* Optical Devices submenu: */
    403     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_OpticalDevices)
    404     {
    405         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices));
    406         fSeparator1 = true;
    407     }
    408     else
    409         gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->setEnabled(false);
    410     /* Floppy Devices submenu: */
    411     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_FloppyDevices)
    412     {
    413         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices));
    414         fSeparator1 = true;
    415     }
    416     else
    417         gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->setEnabled(false);
    418     /* USB Devices submenu: */
    419     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_USBDevices)
    420     {
    421         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices));
    422         fSeparator1 = true;
    423     }
    424     else
    425         gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->setEnabled(false);
    426     /* Web Cams submenu: */
    427     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_WebCams)
    428     {
    429         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_WebCams));
    430         fSeparator1 = true;
    431     }
    432     else
    433         gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->setEnabled(false);
    434     /* Shared Clipboard submenu: */
    435     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_SharedClipboard)
    436     {
    437         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard));
    438         fSeparator1 = true;
    439     }
    440     else
    441         gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard)->setEnabled(false);
    442     /* Drag&Drop submenu: */
    443     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_DragAndDrop)
    444     {
    445         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop));
    446         fSeparator1 = true;
    447     }
    448     else
    449         gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)->setEnabled(false);
    450     /* Network submenu: */
    451     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_NetworkSettings)
    452     {
    453         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_Network));
    454         gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings));
    455         fSeparator1 = true;
    456     }
    457     else
    458     {
    459         gActionPool->action(UIActionIndexRuntime_Menu_Network)->setEnabled(false);
    460         gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings)->setEnabled(false);
    461     }
    462     /* Shared Folders Settings action: */
    463     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_SharedFoldersSettings)
    464     {
    465         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersSettings));
    466         fSeparator1 = true;
    467     }
    468     else
    469         gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersSettings)->setEnabled(false);
    470 
    471     /* Separator #1: */
    472     if (fSeparator1)
    473         pMenu->addSeparator();
    474 
    475 
    476     /* Separator #2? */
    477     bool fSeparator2 = false;
    478 
    479     /* VRDE Server action: */
    480     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_VRDEServer)
    481     {
    482         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));
    483         if (!m_pSession->isExtensionPackUsable())
    484             gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer)->setEnabled(false);
    485         fSeparator2 = true;
    486     }
    487     else
    488         gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer)->setEnabled(false);
    489     /* Video Capture action: */
    490     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_VideoCapture)
    491     {
    492         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VideoCapture));
    493         fSeparator2 = true;
    494     }
    495     else
    496         gActionPool->action(UIActionIndexRuntime_Toggle_VideoCapture)->setEnabled(false);
    497 
    498     /* Separator #2: */
    499     if (fSeparator2)
    500         pMenu->addSeparator();
    501 
    502 
    503     /* Install Guest Tools action: */
    504     if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_InstallGuestTools)
    505         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));
    506     else
    507         gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools)->setEnabled(false);
    508 }
    509 
    510 #ifdef VBOX_WITH_DEBUGGER_GUI
    511 void UIMachineMenuBar::prepareMenuDebug(QMenu *pMenu)
    512 {
    513     /* Do not prepare if ready: */
    514     if (!pMenu->isEmpty())
    515         return;
    516 
    517     /* Statistics action: */
    518     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_Statistics)
    519         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Statistics));
    520     else
    521         gActionPool->action(UIActionIndexRuntime_Simple_Statistics)->setEnabled(false);
    522     /* Command Line action: */
    523     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_CommandLine)
    524         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_CommandLine));
    525     else
    526         gActionPool->action(UIActionIndexRuntime_Simple_CommandLine)->setEnabled(false);
    527     /* Logging action: */
    528     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_Logging)
    529         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Logging));
    530     else
    531         gActionPool->action(UIActionIndexRuntime_Toggle_Logging)->setEnabled(false);
    532     /* Log Dialog action: */
    533     if (m_pSession->allowedActionsMenuDebugger() & RuntimeMenuDebuggerActionType_LogDialog)
    534         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_LogDialog));
    535     else
    536         gActionPool->action(UIActionIndex_Simple_LogDialog)->setEnabled(false);
    537 }
    538 #endif /* VBOX_WITH_DEBUGGER_GUI */
    539 
    540 void UIMachineMenuBar::prepareMenuHelp(QMenu *pMenu)
    541 {
    542     /* Do not prepare if ready: */
    543     if (!pMenu->isEmpty())
    544         return;
    545 
    546 
    547     /* Separator #1? */
    548     bool fSeparator1 = false;
    549 
    550     /* Contents action: */
    551     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_Contents)
    552     {
    553         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Contents));
    554         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_Contents), SIGNAL(triggered()),
    555                             &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    556         fSeparator1 = true;
    557     }
    558     else
    559         gActionPool->action(UIActionIndex_Simple_Contents)->setEnabled(false);
    560     /* Web Site action: */
    561     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_WebSite)
    562     {
    563         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_WebSite));
    564         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()),
    565                             &msgCenter(), SLOT(sltShowHelpWebDialog()));
    566         fSeparator1 = true;
    567     }
    568     else
    569         gActionPool->action(RuntimeMenuHelpActionType_WebSite)->setEnabled(false);
    570 
    571     /* Separator #1: */
    572     if (fSeparator1)
    573         pMenu->addSeparator();
    574 
    575 
    576     /* Separator #2? */
    577     bool fSeparator2 = false;
    578 
    579     /* Reset Warnings action: */
    580     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_ResetWarnings)
    581     {
    582         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_ResetWarnings));
    583         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
    584                             &msgCenter(), SLOT(sltResetSuppressedMessages()));
    585         fSeparator2 = true;
    586     }
    587     else
    588         gActionPool->action(UIActionIndex_Simple_ResetWarnings)->setEnabled(false);
    589 
    590     /* Separator #2: */
    591     if (fSeparator2)
    592         pMenu->addSeparator();
    593 
    594 
    595 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    596 # ifndef Q_WS_MAC
    597     /* Separator #3? */
    598     bool fSeparator3 = false;
    599 # endif /* !Q_WS_MAC */
    600 
    601     /* Reset Warnings action: */
    602     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_NetworkAccessManager)
    603     {
    604         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_NetworkAccessManager));
    605         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()),
    606                             gNetworkManager, SLOT(show()));
    607 # ifndef Q_WS_MAC
    608         fSeparator3 = true;
    609 # endif /* !Q_WS_MAC */
    610     }
    611     else
    612         gActionPool->action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(false);
    613 
    614 # ifndef Q_WS_MAC
    615     /* Separator #3: */
    616     if (fSeparator3)
    617         pMenu->addSeparator();
    618 # endif /* !Q_WS_MAC */
    619 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    620 
    621 
    622     /* About action: */
    623 #ifdef Q_WS_MAC
    624     if (m_pSession->allowedActionsMenuApplication() & RuntimeMenuApplicationActionType_About)
    625 #else /* !Q_WS_MAC */
    626     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_About)
    627 #endif /* Q_WS_MAC */
    628     {
    629         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_About));
    630         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
    631                             &msgCenter(), SLOT(sltShowHelpAboutDialog()));
    632     }
    633     else
    634         gActionPool->action(UIActionIndex_Simple_About)->setEnabled(false);
    635 
    636     /* Preferences action: */
    637 #ifdef Q_WS_MAC
    638     if (m_pSession->allowedActionsMenuApplication() & RuntimeMenuApplicationActionType_Preferences)
    639 #else /* !Q_WS_MAC */
    640     if (m_pSession->allowedActionsMenuHelp() & RuntimeMenuHelpActionType_Preferences)
    641 #endif /* Q_WS_MAC */
    642     {
    643         pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Preferences));
    644         VBoxGlobal::connect(gActionPool->action(UIActionIndex_Simple_Preferences), SIGNAL(triggered()),
    645                             m_pSession->machineLogic(), SLOT(sltShowGlobalPreferences()));
    646     }
    647     else
    648         gActionPool->action(UIActionIndex_Simple_Preferences)->setEnabled(false);
    649 }
    650 
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBar.h

    r52129 r52130  
    11/** @file
    2  * VBox Qt GUI - UIMachineMenuBar class declaration.
     2 * VBox Qt GUI - UIMenuBar class declaration.
    33 */
    44
    55/*
    6  * Copyright (C) 2010-2013 Oracle Corporation
     6 * Copyright (C) 2010-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 */
    1616
    17 #ifndef ___UIMachineMenuBar_h___
    18 #define ___UIMachineMenuBar_h___
     17#ifndef ___UIMenuBar_h___
     18#define ___UIMenuBar_h___
    1919
    2020/* Qt includes: */
    21 #include <QList>
    22 #include <QMenu>
    2321#include <QMenuBar>
    24 
    25 /* GUI includes: */
    26 #include "UIExtraDataDefs.h"
    27 
    28 /* Forward declarations: */
    29 class UISession;
    30 
    31 
    32 /** QMenu extension
    33   * which allows to highlight first menu item for popped up menu. */
    34 class QIMenu : public QMenu
    35 {
    36     Q_OBJECT;
    37 
    38 public:
    39 
    40     /** Constructor. */
    41     QIMenu(QWidget *pParent = 0);
    42 
    43 private slots:
    44 
    45     /** Highlights first menu action for popped up menu. */
    46     void sltHighlightFirstAction();
    47 };
    48 
    4922
    5023/** QMenuBar extension
     
    5629public:
    5730
    58     /** Constructor. */
     31    /** Constructor, passes @a pParent to the QMenuBar constructor. */
    5932    UIMenuBar(QWidget *pParent = 0);
    6033
     
    7043};
    7144
    72 
    73 /**
    74  * Menubar factory for virtual machine (Runtime UI).
    75  * Provides client with the new menu/menubar whenever it necessary.
    76  */
    77 class UIMachineMenuBar
    78 {
    79 public:
    80 
    81     /** Constructor. Stores UI session pointer for further needs. */
    82     UIMachineMenuBar(UISession *pSession);
    83 
    84     /** Provides client with new menu. */
    85     QMenu* createMenu(RuntimeMenuType fOptions = RuntimeMenuType_All);
    86     /** Provides client with new menubar. */
    87     QMenuBar* createMenuBar(RuntimeMenuType fOptions = RuntimeMenuType_All);
    88 
    89 private:
    90 
    91     /** Populates all the sub-menus client need. */
    92     QList<QMenu*> prepareSubMenus(RuntimeMenuType fOptions = RuntimeMenuType_All);
    93     /** Populates <b>Machine</b> sub-menu. */
    94     void prepareMenuMachine(QMenu *pMenu);
    95     /** Populates <b>View</b> sub-menu. */
    96     void prepareMenuView(QMenu *pMenu);
    97     /** Populates <b>Devices</b> sub-menu. */
    98     void prepareMenuDevices(QMenu *pMenu);
    99 #ifdef VBOX_WITH_DEBUGGER_GUI
    100     /** Populates <b>Debug</b> sub-menu. */
    101     void prepareMenuDebug(QMenu *pMenu);
    102 #endif /* VBOX_WITH_DEBUGGER_GUI */
    103     /** Populates <b>Help</b> sub-menu. */
    104     void prepareMenuHelp(QMenu *pMenu);
    105 
    106     /** Contains pointer to parent UI session. */
    107     UISession *m_pSession;
    108 };
    109 
    110 #endif /* !___UIMachineMenuBar_h___ */
    111 
     45#endif /* !___UIMenuBar_h___ */
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