1 | /* $Id: UIMachineMenuBar.cpp 26919 2010-03-01 15:07:03Z 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 |
|
---|
34 | UIMachineMenuBar::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 |
|
---|
41 | QMenuBar* UIMachineMenuBar::createMenuBar(UISession *pSession)
|
---|
42 | {
|
---|
43 | QMenuBar *pMenuBar = new QMenuBar(0);
|
---|
44 |
|
---|
45 | UIActionsPool *pActionsPool = pSession->actionsPool();
|
---|
46 |
|
---|
47 | /* Machine submenu: */
|
---|
48 | QMenu *pMenuMachine = pActionsPool->action(UIActionIndex_Menu_Machine)->menu();
|
---|
49 | prepareMenuMachine(pMenuMachine, pActionsPool);
|
---|
50 | pMenuBar->addMenu(pMenuMachine);
|
---|
51 |
|
---|
52 | /* Devices submenu: */
|
---|
53 | QMenu *pMenuDevices = pActionsPool->action(UIActionIndex_Menu_Devices)->menu();
|
---|
54 | prepareMenuDevices(pMenuDevices, pActionsPool);
|
---|
55 | pMenuBar->addMenu(pMenuDevices);
|
---|
56 |
|
---|
57 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
58 | if (vboxGlobal().isDebuggerEnabled())
|
---|
59 | {
|
---|
60 | QMenu *pMenuDebug = pActionsPool->action(UIActionIndex_Menu_Debug)->menu();
|
---|
61 | prepareMenuDebug(pMenuDebug, pActionsPool);
|
---|
62 | pMenuBar->addMenu(pMenuDebug);
|
---|
63 | }
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | /* Help submenu: */
|
---|
67 | QMenu *pMenuHelp = pActionsPool->action(UIActionIndex_Menu_Help)->menu();
|
---|
68 | prepareMenuHelp(pMenuHelp, pActionsPool);
|
---|
69 | pMenuBar->addMenu(pMenuHelp);
|
---|
70 |
|
---|
71 | /* Because this connections are done to VBoxGlobal, they are needed once
|
---|
72 | * only. Otherwise we will get the slots called more than once. */
|
---|
73 | if (m_fIsFirstTime)
|
---|
74 | {
|
---|
75 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Help), SIGNAL(triggered()),
|
---|
76 | &vboxProblem(), SLOT(showHelpHelpDialog()));
|
---|
77 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Web), SIGNAL(triggered()),
|
---|
78 | &vboxProblem(), SLOT(showHelpWebDialog()));
|
---|
79 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
|
---|
80 | &vboxProblem(), SLOT(resetSuppressedMessages()));
|
---|
81 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Register), SIGNAL(triggered()),
|
---|
82 | &vboxGlobal(), SLOT(showRegistrationDialog()));
|
---|
83 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Update), SIGNAL(triggered()),
|
---|
84 | &vboxGlobal(), SLOT(showUpdateDialog()));
|
---|
85 | VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
|
---|
86 | &vboxProblem(), SLOT(showHelpAboutDialog()));
|
---|
87 |
|
---|
88 | VBoxGlobal::connect(&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
|
---|
89 | pActionsPool->action(UIActionIndex_Simple_Register), SLOT(setEnabled(bool)));
|
---|
90 | VBoxGlobal::connect(&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
|
---|
91 | pActionsPool->action(UIActionIndex_Simple_Update), SLOT(setEnabled(bool)));
|
---|
92 |
|
---|
93 | m_fIsFirstTime = false;
|
---|
94 | }
|
---|
95 |
|
---|
96 | return pMenuBar;
|
---|
97 | }
|
---|
98 |
|
---|
99 | void UIMachineMenuBar::prepareMenuMachine(QMenu *pMenu, UIActionsPool *pActionsPool)
|
---|
100 | {
|
---|
101 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Fullscreen));
|
---|
102 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Seamless));
|
---|
103 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_GuestAutoresize));
|
---|
104 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_AdjustWindow));
|
---|
105 | pMenu->addSeparator();
|
---|
106 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_MouseIntegration));
|
---|
107 | pMenu->addSeparator();
|
---|
108 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TypeCAD));
|
---|
109 | #ifdef Q_WS_X11
|
---|
110 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TypeCABS));
|
---|
111 | #endif
|
---|
112 | pMenu->addSeparator();
|
---|
113 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TakeSnapshot));
|
---|
114 | pMenu->addSeparator();
|
---|
115 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InformationDialog));
|
---|
116 | pMenu->addSeparator();
|
---|
117 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Pause));
|
---|
118 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Reset));
|
---|
119 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Shutdown));
|
---|
120 | #ifndef Q_WS_MAC
|
---|
121 | pMenu->addSeparator();
|
---|
122 | #else /* Q_WS_MAC */
|
---|
123 | if (m_fIsFirstTime)
|
---|
124 | #endif /* !Q_WS_MAC */
|
---|
125 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Close));
|
---|
126 | }
|
---|
127 |
|
---|
128 | void UIMachineMenuBar::prepareMenuDevices(QMenu *pMenu, UIActionsPool *pActionsPool)
|
---|
129 | {
|
---|
130 | /* Devices submenu */
|
---|
131 | pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_OpticalDevices)->menu());
|
---|
132 | pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_FloppyDevices)->menu());
|
---|
133 | pMenu->addMenu(pActionsPool->action(UIActionIndex_Menu_USBDevices)->menu());
|
---|
134 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_NetworkAdaptersDialog));
|
---|
135 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_SharedFoldersDialog));
|
---|
136 | pMenu->addSeparator();
|
---|
137 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_VRDP));
|
---|
138 | pMenu->addSeparator();
|
---|
139 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InstallGuestTools));
|
---|
140 | }
|
---|
141 |
|
---|
142 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
143 | void UIMachineMenuBar::prepareMenuDebug(QMenu *pMenu, UIActionsPool *pActionsPool)
|
---|
144 | {
|
---|
145 | /* Debug submenu */
|
---|
146 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Statistics));
|
---|
147 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_CommandLine));
|
---|
148 | pMenu->addAction(pActionsPool->action(UIActionIndex_Toggle_Logging));
|
---|
149 | }
|
---|
150 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
151 |
|
---|
152 | void UIMachineMenuBar::prepareMenuHelp(QMenu *pMenu, UIActionsPool *pActionsPool)
|
---|
153 | {
|
---|
154 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Help));
|
---|
155 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Web));
|
---|
156 | pMenu->addSeparator();
|
---|
157 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_ResetWarnings));
|
---|
158 | pMenu->addSeparator();
|
---|
159 |
|
---|
160 | #ifdef VBOX_WITH_REGISTRATION
|
---|
161 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Register));
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #ifdef Q_WS_MAC
|
---|
165 | if (m_fIsFirstTime)
|
---|
166 | #endif /* Q_WS_MAC */
|
---|
167 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Update));
|
---|
168 |
|
---|
169 | #ifndef Q_WS_MAC
|
---|
170 | pMenu->addSeparator();
|
---|
171 | #else /* Q_WS_MAC */
|
---|
172 | if (m_fIsFirstTime)
|
---|
173 | #endif /* !Q_WS_MAC */
|
---|
174 | pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_About));
|
---|
175 | }
|
---|
176 |
|
---|