Changeset 49462 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 13, 2013 12:29:44 PM (11 years ago)
- 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 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIMachineMenuBar class implementation 3 * VBox Qt GUI - UIMachineMenuBar class implementation. 6 4 */ 7 5 … … 30 28 #include "VBoxGlobal.h" 31 29 #include "UIMessageCenter.h" 32 #include "UIExtraDataEventHandler.h"33 30 #include "UIImageTools.h" 34 31 #include "UINetworkManager.h" 35 #include "VBoxGlobal.h"36 #include "UISession.h"37 32 38 33 /* COM includes: */ 39 34 #include "CMachine.h" 40 35 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 */ 43 41 class QIMenu : public QMenu 44 42 { … … 47 45 public: 48 46 47 /** Constructor. */ 49 48 QIMenu() : QMenu(0) {} 50 49 51 50 private slots: 52 51 53 void sltSelectFirstAction() 52 /** Highlights first menu action for popped up menu. */ 53 void sltHighlightFirstAction() 54 54 { 55 55 #ifdef Q_WS_WIN 56 56 activateWindow(); 57 #endif 57 #endif /* Q_WS_WIN */ 58 58 QMenu::focusNextChild(); 59 59 } 60 60 }; 61 61 62 63 /** 64 * QMenuBar sub-class with extended functionality. 65 * Reflects BETA label when necessary. 66 */ 62 67 class UIMenuBar: public QMenuBar 63 68 { 69 Q_OBJECT; 70 64 71 public: 65 72 73 /** Constructor. */ 66 74 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: */ 71 79 if (vboxGlobal().isBeta()) 72 80 m_fShowBetaLabel = true; … … 75 83 protected: 76 84 85 /** Paint-event reimplementation. */ 77 86 void paintEvent(QPaintEvent *pEvent) 78 87 { … … 96 105 private: 97 106 98 /* Private member vars*/107 /** Reflects whether we should show BETA label or not. */ 99 108 bool m_fShowBetaLabel; 100 109 }; 101 110 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 112 UIMachineMenuBar::UIMachineMenuBar(UISession *pSession) 105 113 : m_pSession(pSession) 106 , m_machine(machine)107 114 { 108 115 } … … 167 174 if (fOptions & RuntimeMenuType_Debug) 168 175 { 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(); 171 177 if (vboxGlobal().isDebuggerEnabled(machine)) 172 178 { … … 176 182 } 177 183 } 178 #endif 184 #endif /* VBOX_WITH_DEBUGGER_GUI */ 179 185 180 186 /* Help submenu: */ … … 198 204 /* Machine submenu: */ 199 205 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)); 200 if ( vboxGlobal().shouldWeAllowSnapshotOperations(m_machine))206 if (m_pSession->isSnapshotOperationsAllowed()) 201 207 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)); 202 208 else … … 210 216 #ifdef Q_WS_X11 211 217 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS)); 212 #endif 218 #endif /* Q_WS_X11 */ 213 219 pMenu->addSeparator(); 214 220 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause)); … … 228 234 229 235 /* 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(); 233 239 gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->setEnabled(fIsAllowedFullscreen); 234 240 if (fIsAllowedFullscreen) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h
r47478 r49462 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIMachineMenuBar class declaration 2 * VBox Qt GUI - UIMachineMenuBar class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2010-201 1Oracle Corporation6 * Copyright (C) 2010-2013 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ UIMachineMenuBar_h__20 #define __ UIMachineMenuBar_h__17 #ifndef ___UIMachineMenuBar_h___ 18 #define ___UIMachineMenuBar_h___ 21 19 22 /* Local includes */ 20 /* Qt includes: */ 21 #include <QList> 22 23 /* GUI includes: */ 23 24 #include "UIDefs.h" 24 25 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: */ 33 27 class QMenu; 34 28 class QMenuBar; 35 29 class UISession; 36 30 31 /** 32 * Menubar factory for virtual machine (Runtime UI). 33 * Provides client with the new menu/menubar whenever it necessary. 34 */ 37 35 class UIMachineMenuBar 38 36 { 39 37 public: 40 38 41 UIMachineMenuBar(UISession *pSession, const CMachine &machine); 39 /** Constructor. Stores UI session pointer for further needs. */ 40 UIMachineMenuBar(UISession *pSession); 42 41 42 /** Provides client with new menu. */ 43 43 QMenu* createMenu(RuntimeMenuType fOptions = RuntimeMenuType_All); 44 /** Provides client with new menubar. */ 44 45 QMenuBar* createMenuBar(RuntimeMenuType fOptions = RuntimeMenuType_All); 45 46 46 pr otected:47 private: 47 48 49 /** Populates all the sub-menus client need. */ 48 50 QList<QMenu*> prepareSubMenus(RuntimeMenuType fOptions = RuntimeMenuType_All); 51 /** Populates <b>Machine</b> sub-menu. */ 49 52 void prepareMenuMachine(QMenu *pMenu); 53 /** Populates <b>View</b> sub-menu. */ 50 54 void prepareMenuView(QMenu *pMenu); 55 /** Populates <b>Devices</b> sub-menu. */ 51 56 void prepareMenuDevices(QMenu *pMenu); 52 57 #ifdef VBOX_WITH_DEBUGGER_GUI 58 /** Populates <b>Debug</b> sub-menu. */ 53 59 void prepareMenuDebug(QMenu *pMenu); 54 #endif 60 #endif /* VBOX_WITH_DEBUGGER_GUI */ 61 /** Populates <b>Help</b> sub-menu. */ 55 62 void prepareMenuHelp(QMenu *pMenu); 56 63 57 /* Helper: UI session stuff: */ 58 UISession* uisession() const { return m_pSession; } 59 60 /* Variables: */ 64 /** Contains pointer to parent UI session. */ 61 65 UISession *m_pSession; 62 CMachine m_machine;63 66 }; 64 67 65 #endif /* __UIMachineMenuBar_h__ */68 #endif /* !___UIMachineMenuBar_h___ */ 66 69 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r49340 r49462 132 132 , m_pWatchdogDisplayChange(0) 133 133 #endif /* Q_WS_MAC */ 134 , m_fSnapshotOperationsAllowed(true) 134 135 /* Common flags: */ 135 136 , m_fIsFirstTimeStarted(false) … … 1054 1055 void UISession::prepareMenuPool() 1055 1056 { 1056 m_pMenuPool = new UIMachineMenuBar(this , session().GetMachine());1057 m_pMenuPool = new UIMachineMenuBar(this); 1057 1058 } 1058 1059 … … 1085 1086 m_fReconfigurable = VBoxGlobal::shouldWeAllowMachineReconfiguration(machine); 1086 1087 updateSessionSettings(); 1088 1089 /* Should we allow snapshot operations? */ 1090 m_fSnapshotOperationsAllowed = vboxGlobal().shouldWeAllowSnapshotOperations(machine); 1087 1091 1088 1092 #if 0 /* Disabled for now! */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r49177 r49462 105 105 QCursor cursor() const { return m_cursor; } 106 106 107 /** @name Snapshot Operations configuration stuff. 108 * @{ */ 109 /** Returns whether we should allow snapshot operations. */ 110 bool isSnapshotOperationsAllowed() const { return m_fSnapshotOperationsAllowed; } 111 /** @} */ 112 107 113 /* API: Visual-state stuff: */ 108 114 bool isVisualStateAllowedFullscreen() const; … … 298 304 KMachineState m_machineState; 299 305 QCursor m_cursor; 306 300 307 #if defined(Q_WS_WIN) 301 308 HCURSOR m_alphaCursor; 302 309 #endif 310 303 311 #ifdef Q_WS_MAC 304 312 /** @name MacOS X: Display reconfiguration variables. … … 311 319 #endif /* Q_WS_MAC */ 312 320 321 /** @name Snapshot Operations configuration variables. 322 * @{ */ 323 /** Determines whether we should allow snapshot operations. */ 324 bool m_fSnapshotOperationsAllowed; 325 /** @} */ 326 313 327 /* Common flags: */ 314 328 bool m_fIsFirstTimeStarted : 1; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r49177 r49462 58 58 { 59 59 m_pMainMenu->popup(geometry().center()); 60 QTimer::singleShot(0, m_pMainMenu, SLOT(slt SelectFirstAction()));60 QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction())); 61 61 } 62 62 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp
r46797 r49462 50 50 { 51 51 m_pMainMenu->popup(geometry().center()); 52 QTimer::singleShot(0, m_pMainMenu, SLOT(slt SelectFirstAction()));52 QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction())); 53 53 } 54 54 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp
r49291 r49462 67 67 { 68 68 m_pMainMenu->popup(geometry().center()); 69 QTimer::singleShot(0, m_pMainMenu, SLOT(slt SelectFirstAction()));69 QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction())); 70 70 } 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.