VirtualBox

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

Last change on this file since 50165 was 50165, checked in by vboxsync, 11 years ago

FE/Qt: 7036: Runtime UI: Devices menu: Network sub-menu: Stuff to connect/disconnect network adapter cable.

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

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