VirtualBox

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


Ignore:
Timestamp:
Nov 13, 2013 12:29:44 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Menu/menubar factory cleanup/rework.

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

Legend:

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

    r49333 r49462  
    11/* $Id$ */
    22/** @file
    3  *
    4  * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIMachineMenuBar class implementation
     3 * VBox Qt GUI - UIMachineMenuBar class implementation.
    64 */
    75
     
    3028#include "VBoxGlobal.h"
    3129#include "UIMessageCenter.h"
    32 #include "UIExtraDataEventHandler.h"
    3330#include "UIImageTools.h"
    3431#include "UINetworkManager.h"
    35 #include "VBoxGlobal.h"
    36 #include "UISession.h"
    3732
    3833/* COM includes: */
    3934#include "CMachine.h"
    4035
    41 /* Helper QMenu reimplementation which allows
    42  * to highlight first menu item for popped up menu: */
     36
     37/**
     38 * QMenu sub-class with extended functionality.
     39 * Allows to highlight first menu item for popped up menu.
     40 */
    4341class QIMenu : public QMenu
    4442{
     
    4745public:
    4846
     47    /** Constructor. */
    4948    QIMenu() : QMenu(0) {}
    5049
    5150private slots:
    5251
    53     void sltSelectFirstAction()
     52    /** Highlights first menu action for popped up menu. */
     53    void sltHighlightFirstAction()
    5454    {
    5555#ifdef Q_WS_WIN
    5656        activateWindow();
    57 #endif
     57#endif /* Q_WS_WIN */
    5858        QMenu::focusNextChild();
    5959    }
    6060};
    6161
     62
     63/**
     64 * QMenuBar sub-class with extended functionality.
     65 * Reflects BETA label when necessary.
     66 */
    6267class UIMenuBar: public QMenuBar
    6368{
     69    Q_OBJECT;
     70
    6471public:
    6572
     73    /** Constructor. */
    6674    UIMenuBar(QWidget *pParent = 0)
    67       : QMenuBar(pParent)
    68       , m_fShowBetaLabel(false)
    69     {
    70         /* Check for beta versions */
     75        : QMenuBar(pParent)
     76        , m_fShowBetaLabel(false)
     77    {
     78        /* Check for beta versions: */
    7179        if (vboxGlobal().isBeta())
    7280            m_fShowBetaLabel = true;
     
    7583protected:
    7684
     85    /** Paint-event reimplementation. */
    7786    void paintEvent(QPaintEvent *pEvent)
    7887    {
     
    96105private:
    97106
    98     /* Private member vars */
     107    /** Reflects whether we should show BETA label or not. */
    99108    bool m_fShowBetaLabel;
    100109};
    101110
    102 UIMachineMenuBar::UIMachineMenuBar(UISession *pSession, const CMachine &machine)
    103     /* On the Mac we add some items only the first time, cause otherwise they
    104      * will be merged more than once to the application menu by Qt. */
     111
     112UIMachineMenuBar::UIMachineMenuBar(UISession *pSession)
    105113    : m_pSession(pSession)
    106     , m_machine(machine)
    107114{
    108115}
     
    167174    if (fOptions & RuntimeMenuType_Debug)
    168175    {
    169         CMachine machine; /** @todo we should try get the machine here. But we'll
    170                            *        probably be fine with the cached values. */
     176        CMachine machine = m_pSession->session().GetMachine();
    171177        if (vboxGlobal().isDebuggerEnabled(machine))
    172178        {
     
    176182        }
    177183    }
    178 #endif
     184#endif /* VBOX_WITH_DEBUGGER_GUI */
    179185
    180186    /* Help submenu: */
     
    198204    /* Machine submenu: */
    199205    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    200     if (vboxGlobal().shouldWeAllowSnapshotOperations(m_machine))
     206    if (m_pSession->isSnapshotOperationsAllowed())
    201207        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
    202208    else
     
    210216#ifdef Q_WS_X11
    211217    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));
    212 #endif
     218#endif /* Q_WS_X11 */
    213219    pMenu->addSeparator();
    214220    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
     
    228234
    229235    /* View submenu: */
    230     bool fIsAllowedFullscreen = uisession()->isVisualStateAllowedFullscreen();
    231     bool fIsAllowedSeamless = uisession()->isVisualStateAllowedSeamless();
    232     bool fIsAllowedScale = uisession()->isVisualStateAllowedScale();
     236    bool fIsAllowedFullscreen = m_pSession->isVisualStateAllowedFullscreen();
     237    bool fIsAllowedSeamless = m_pSession->isVisualStateAllowedSeamless();
     238    bool fIsAllowedScale = m_pSession->isVisualStateAllowedScale();
    233239    gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->setEnabled(fIsAllowedFullscreen);
    234240    if (fIsAllowedFullscreen)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h

    r47478 r49462  
    11/** @file
    2  *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    4  * UIMachineMenuBar class declaration
     2 * VBox Qt GUI - UIMachineMenuBar class declaration.
    53 */
    64
    75/*
    8  * Copyright (C) 2010-2011 Oracle Corporation
     6 * Copyright (C) 2010-2013 Oracle Corporation
    97 *
    108 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1715 */
    1816
    19 #ifndef __UIMachineMenuBar_h__
    20 #define __UIMachineMenuBar_h__
     17#ifndef ___UIMachineMenuBar_h___
     18#define ___UIMachineMenuBar_h___
    2119
    22 /* Local includes */
     20/* Qt includes: */
     21#include <QList>
     22
     23/* GUI includes: */
    2324#include "UIDefs.h"
    2425
    25 /* Global includes */
    26 #include <QList>
    27 
    28 /* COM includes: */
    29 #include "COMEnums.h"
    30 #include "CMachine.h"
    31 
    32 /* Global forwards */
     26/* Forward declarations: */
    3327class QMenu;
    3428class QMenuBar;
    3529class UISession;
    3630
     31/**
     32 * Menubar factory for virtual machine (Runtime UI).
     33 * Provides client with the new menu/menubar whenever it necessary.
     34 */
    3735class UIMachineMenuBar
    3836{
    3937public:
    4038
    41     UIMachineMenuBar(UISession *pSession, const CMachine &machine);
     39    /** Constructor. Stores UI session pointer for further needs. */
     40    UIMachineMenuBar(UISession *pSession);
    4241
     42    /** Provides client with new menu. */
    4343    QMenu* createMenu(RuntimeMenuType fOptions = RuntimeMenuType_All);
     44    /** Provides client with new menubar. */
    4445    QMenuBar* createMenuBar(RuntimeMenuType fOptions = RuntimeMenuType_All);
    4546
    46 protected:
     47private:
    4748
     49    /** Populates all the sub-menus client need. */
    4850    QList<QMenu*> prepareSubMenus(RuntimeMenuType fOptions = RuntimeMenuType_All);
     51    /** Populates <b>Machine</b> sub-menu. */
    4952    void prepareMenuMachine(QMenu *pMenu);
     53    /** Populates <b>View</b> sub-menu. */
    5054    void prepareMenuView(QMenu *pMenu);
     55    /** Populates <b>Devices</b> sub-menu. */
    5156    void prepareMenuDevices(QMenu *pMenu);
    5257#ifdef VBOX_WITH_DEBUGGER_GUI
     58    /** Populates <b>Debug</b> sub-menu. */
    5359    void prepareMenuDebug(QMenu *pMenu);
    54 #endif
     60#endif /* VBOX_WITH_DEBUGGER_GUI */
     61    /** Populates <b>Help</b> sub-menu. */
    5562    void prepareMenuHelp(QMenu *pMenu);
    5663
    57     /* Helper: UI session stuff: */
    58     UISession* uisession() const { return m_pSession; }
    59 
    60     /* Variables: */
     64    /** Contains pointer to parent UI session. */
    6165    UISession *m_pSession;
    62     CMachine m_machine;
    6366};
    6467
    65 #endif /* __UIMachineMenuBar_h__ */
     68#endif /* !___UIMachineMenuBar_h___ */
    6669
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r49340 r49462  
    132132    , m_pWatchdogDisplayChange(0)
    133133#endif /* Q_WS_MAC */
     134    , m_fSnapshotOperationsAllowed(true)
    134135    /* Common flags: */
    135136    , m_fIsFirstTimeStarted(false)
     
    10541055void UISession::prepareMenuPool()
    10551056{
    1056     m_pMenuPool = new UIMachineMenuBar(this, session().GetMachine());
     1057    m_pMenuPool = new UIMachineMenuBar(this);
    10571058}
    10581059
     
    10851086        m_fReconfigurable = VBoxGlobal::shouldWeAllowMachineReconfiguration(machine);
    10861087        updateSessionSettings();
     1088
     1089        /* Should we allow snapshot operations? */
     1090        m_fSnapshotOperationsAllowed = vboxGlobal().shouldWeAllowSnapshotOperations(machine);
    10871091
    10881092#if 0 /* Disabled for now! */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r49177 r49462  
    105105    QCursor cursor() const { return m_cursor; }
    106106
     107    /** @name Snapshot Operations configuration stuff.
     108     * @{ */
     109    /** Returns whether we should allow snapshot operations. */
     110    bool isSnapshotOperationsAllowed() const { return m_fSnapshotOperationsAllowed; }
     111    /** @} */
     112
    107113    /* API: Visual-state stuff: */
    108114    bool isVisualStateAllowedFullscreen() const;
     
    298304    KMachineState m_machineState;
    299305    QCursor m_cursor;
     306
    300307#if defined(Q_WS_WIN)
    301308    HCURSOR m_alphaCursor;
    302309#endif
     310
    303311#ifdef Q_WS_MAC
    304312    /** @name MacOS X: Display reconfiguration variables.
     
    311319#endif /* Q_WS_MAC */
    312320
     321    /** @name Snapshot Operations configuration variables.
     322     * @{ */
     323    /** Determines whether we should allow snapshot operations. */
     324    bool m_fSnapshotOperationsAllowed;
     325    /** @} */
     326
    313327    /* Common flags: */
    314328    bool m_fIsFirstTimeStarted : 1;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r49177 r49462  
    5858    {
    5959        m_pMainMenu->popup(geometry().center());
    60         QTimer::singleShot(0, m_pMainMenu, SLOT(sltSelectFirstAction()));
     60        QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction()));
    6161    }
    6262}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r46797 r49462  
    5050    {
    5151        m_pMainMenu->popup(geometry().center());
    52         QTimer::singleShot(0, m_pMainMenu, SLOT(sltSelectFirstAction()));
     52        QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction()));
    5353    }
    5454}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r49291 r49462  
    6767    {
    6868        m_pMainMenu->popup(geometry().center());
    69         QTimer::singleShot(0, m_pMainMenu, SLOT(sltSelectFirstAction()));
     69        QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction()));
    7070    }
    7171}
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