VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp@ 27335

Last change on this file since 27335 was 27335, checked in by vboxsync, 15 years ago

FE/Qt4: new core: added multi monitor support in fullscreen and (partly) seamless

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1/* $Id: UIMachineMenuBar.cpp 27335 2010-03-12 16:20:29Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * UIMachineMenuBar class implementation
6 */
7
8/*
9 * Copyright (C) 2010 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24/* Local includes */
25#include "UIMachineMenuBar.h"
26#include "UISession.h"
27#include "UIActionsPool.h"
28#include "VBoxGlobal.h"
29#include "VBoxProblemReporter.h"
30
31/* Global includes */
32#include <QMenuBar>
33
34UIMachineMenuBar::UIMachineMenuBar()
35 /* On the Mac we add some items only the first time, cause otherwise they
36 * will be merged more than once to the application menu by Qt. */
37 : m_fIsFirstTime(true)
38{
39}
40
41QMenu* UIMachineMenuBar::createMenu(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
42{
43 /* Create empty menu: */
44 QMenu *pMenu = new QMenu;
45
46 /* Fill menu with prepared items: */
47 foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool, fOptions))
48 pMenu->addMenu(pSubMenu);
49
50 /* Return filled menu: */
51 return pMenu;
52}
53
54QMenuBar* UIMachineMenuBar::createMenuBar(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
55{
56 /* Create empty menubar: */
57 QMenuBar *pMenuBar = new QMenuBar;
58
59 /* Fill menubar with prepared items: */
60 foreach (QMenu *pSubMenu, prepareSubMenus(pActionsPool, fOptions))
61 pMenuBar->addMenu(pSubMenu);
62
63 /* Return filled menubar: */
64 return pMenuBar;
65}
66
67QList<QMenu*> UIMachineMenuBar::prepareSubMenus(UIActionsPool *pActionsPool, UIMainMenuType fOptions /* = UIMainMenuType_All */)
68{
69 /* Create empty submenu list: */
70 QList<QMenu*> preparedSubMenus;
71
72 /* Machine submenu: */
73 if (fOptions & UIMainMenuType_Machine)
74 {
75 QMenu *pMenuMachine = pActionsPool->action(UIActionIndex_Menu_Machine)->menu();
76 prepareMenuMachine(pMenuMachine, pActionsPool);
77 preparedSubMenus << pMenuMachine;
78 }
79
80 /* View submenu: */
81 if (fOptions & UIMainMenuType_View)
82 {
83 QMenu *pMenuView = pActionsPool->action(UIActionIndex_Menu_View)->menu();
84 preparedSubMenus << pMenuView;
85 }
86
87 /* Devices submenu: */
88 if (fOptions & UIMainMenuType_Devices)
89 {
90 QMenu *pMenuDevices = pActionsPool->action(UIActionIndex_Menu_Devices)->menu();
91 prepareMenuDevices(pMenuDevices, pActionsPool);
92 preparedSubMenus << pMenuDevices;
93 }
94
95#ifdef VBOX_WITH_DEBUGGER_GUI
96 /* Debug submenu: */
97 if ( fOptions & UIMainMenuType_Debug
98 && vboxGlobal().isDebuggerEnabled())
99 {
100 QMenu *pMenuDebug = pActionsPool->action(UIActionIndex_Menu_Debug)->menu();
101 prepareMenuDebug(pMenuDebug, pActionsPool);
102 preparedSubMenus << pMenuDebug;
103 }
104#endif
105
106 /* Help submenu: */
107 if (fOptions & UIMainMenuType_Help)
108 {
109 QMenu *pMenuHelp = pActionsPool->action(UIActionIndex_Menu_Help)->menu();
110 prepareMenuHelp(pMenuHelp, pActionsPool);
111 preparedSubMenus << pMenuHelp;
112 }
113
114 /* Return a list of prepared submenus: */
115 return preparedSubMenus;
116}
117
118void UIMachineMenuBar::prepareMenuMachine(QMenu *pMenu, UIActionsPool *pActionsPool)
119{
120 /* Do not prepare if ready: */
121 if (!pMenu->isEmpty())
122 return;
123
124 /* Machine submenu: */
125 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Fullscreen));
126 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Seamless));
127 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_GuestAutoresize));
128 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_AdjustWindow));
129 pMenu->addSeparator();
130 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_MouseIntegration));
131 pMenu->addSeparator();
132 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TypeCAD));
133#ifdef Q_WS_X11
134 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TypeCABS));
135#endif
136 pMenu->addSeparator();
137 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TakeSnapshot));
138 pMenu->addSeparator();
139 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InformationDialog));
140 pMenu->addSeparator();
141 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Pause));
142 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Reset));
143 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Shutdown));
144#ifndef Q_WS_MAC
145 pMenu->addSeparator();
146#else /* Q_WS_MAC */
147 if (m_fIsFirstTime)
148#endif /* !Q_WS_MAC */
149 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Close));
150}
151
152void UIMachineMenuBar::prepareMenuDevices(QMenu *pMenu, UIActionsPool *pActionsPool)
153{
154 /* Do not prepare if ready: */
155 if (!pMenu->isEmpty())
156 return;
157
158 /* Devices submenu: */
159 pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_OpticalDevices)->menu());
160 pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_FloppyDevices)->menu());
161 pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_USBDevices)->menu());
162 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_NetworkAdaptersDialog));
163 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_SharedFoldersDialog));
164 pMenu->addSeparator();
165 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_VRDP));
166 pMenu->addSeparator();
167 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InstallGuestTools));
168}
169
170#ifdef VBOX_WITH_DEBUGGER_GUI
171void UIMachineMenuBar::prepareMenuDebug(QMenu *pMenu, UIActionsPool *pActionsPool)
172{
173 /* Do not prepare if ready: */
174 if (!pMenu->isEmpty())
175 return;
176
177 /* Debug submenu: */
178 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Statistics));
179 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_CommandLine));
180 pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Logging));
181}
182#endif /* VBOX_WITH_DEBUGGER_GUI */
183
184void UIMachineMenuBar::prepareMenuHelp(QMenu *pMenu, UIActionsPool *pActionsPool)
185{
186 /* Do not prepare if ready: */
187 if (!pMenu->isEmpty())
188 return;
189
190 /* Help submenu: */
191 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Help));
192 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Web));
193 pMenu->addSeparator();
194 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_ResetWarnings));
195 pMenu->addSeparator();
196
197#ifdef VBOX_WITH_REGISTRATION
198 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Register));
199#endif
200
201#ifdef Q_WS_MAC
202 if (m_fIsFirstTime)
203#endif /* Q_WS_MAC */
204 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Update));
205
206#ifndef Q_WS_MAC
207 pMenu->addSeparator();
208#else /* Q_WS_MAC */
209 if (m_fIsFirstTime)
210#endif /* !Q_WS_MAC */
211 pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_About));
212
213 /* Because this connections are done to VBoxGlobal, they are needed once only.
214 * Otherwise we will get the slots called more than once. */
215 if (m_fIsFirstTime)
216 {
217 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Help), SIGNAL(triggered()),
218 &vboxProblem(), SLOT(showHelpHelpDialog()));
219 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Web), SIGNAL(triggered()),
220 &vboxProblem(), SLOT(showHelpWebDialog()));
221 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
222 &vboxProblem(), SLOT(resetSuppressedMessages()));
223 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Register), SIGNAL(triggered()),
224 &vboxGlobal(), SLOT(showRegistrationDialog()));
225 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Update), SIGNAL(triggered()),
226 &vboxGlobal(), SLOT(showUpdateDialog()));
227 VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
228 &vboxProblem(), SLOT(showHelpAboutDialog()));
229
230 VBoxGlobal::connect(&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
231 pActionsPool->action(UIActionIndex_Simple_Register), SLOT(setEnabled(bool)));
232 VBoxGlobal::connect(&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
233 pActionsPool->action(UIActionIndex_Simple_Update), SLOT(setEnabled(bool)));
234
235 m_fIsFirstTime = false;
236 }
237}
238
Note: See TracBrowser for help on using the repository browser.

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