Changeset 52478 in vbox for trunk/src/VBox
- Timestamp:
- Aug 22, 2014 3:21:15 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95695
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 13 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r52459 r52478 302 302 src/runtime/UIMachineWindow.h \ 303 303 src/runtime/UIMachineView.h \ 304 src/runtime/UIMenuBarEditorWindow.h \ 304 305 src/runtime/UIMouseHandler.h \ 305 306 src/runtime/UIMultiScreenLayout.h \ … … 486 487 src/runtime/UIIndicatorsPool.cpp \ 487 488 src/runtime/UIMachine.cpp \ 489 src/runtime/UIMenuBarEditorWindow.cpp \ 488 490 src/runtime/UIStatusBarEditorWindow.cpp \ 489 491 src/selector/UIActionPoolSelector.cpp \ … … 580 582 src/runtime/UIMachineView.cpp \ 581 583 src/runtime/UIMachineWindow.cpp \ 584 src/runtime/UIMenuBarEditorWindow.cpp \ 582 585 src/runtime/UIMouseHandler.cpp \ 583 586 src/runtime/UIMultiScreenLayout.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r52186 r52478 193 193 <file alias="machine_warning_16px.png">images/machine_warning_16px.png</file> 194 194 <file alias="meditation_32px.png">images/meditation_32px.png</file> 195 <file alias="menubar_16px.png">images/menubar_16px.png</file> 196 <file alias="menubar_disabled_16px.png">images/menubar_disabled_16px.png</file> 197 <file alias="menubar_settings_16px.png">images/menubar_settings_16px.png</file> 198 <file alias="menubar_settings_disabled_16px.png">images/menubar_settings_disabled_16px.png</file> 195 199 <file alias="minimize_16px.png">images/minimize_16px.png</file> 196 200 <file alias="monitor.png">images/monitor.png</file> -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r52459 r52478 517 517 case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close: strResult = "Close"; break; 518 518 #endif /* !Q_WS_MAC */ 519 case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing: strResult = "Nothing"; break; 519 520 case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All: strResult = "All"; break; 520 521 default: … … 553 554 keys << "Close"; values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close; 554 555 #endif /* !Q_WS_MAC */ 556 keys << "Nothing"; values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing; 555 557 keys << "All"; values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All; 556 558 /* Invalid type for unknown words: */ … … 572 574 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize: strResult = "GuestAutoresize"; break; 573 575 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow: strResult = "AdjustWindow"; break; 576 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar: strResult = "MenuBar"; break; 577 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings: strResult = "MenuBarSettings"; break; 574 578 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar: strResult = "StatusBar"; break; 575 579 case UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBarSettings: strResult = "StatusBarSettings"; break; … … 598 602 keys << "GuestAutoresize"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize; 599 603 keys << "AdjustWindow"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow; 604 keys << "MenuBar"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar; 605 keys << "MenuBarSettings"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings; 600 606 keys << "StatusBar"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar; 601 607 keys << "StatusBarSettings"; values << UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBarSettings; … … 635 641 case UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_StartVideoCapture: strResult = "StartVideoCapture"; break; 636 642 case UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_InstallGuestTools: strResult = "InstallGuestTools"; break; 643 case UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing: strResult = "Nothing"; break; 637 644 case UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All: strResult = "All"; break; 638 645 default: … … 669 676 keys << "StartVideoCapture"; values << UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_StartVideoCapture; 670 677 keys << "InstallGuestTools"; values << UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_InstallGuestTools; 678 keys << "Nothing"; values << UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing; 671 679 keys << "All"; values << UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All; 672 680 /* Invalid type for unknown words: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r52460 r52478 350 350 RuntimeMenuMachineActionType_Close = RT_BIT(15), 351 351 #endif /* !RT_OS_DARWIN */ 352 RuntimeMenuMachineActionType_Nothing = RT_BIT(16), 352 353 RuntimeMenuMachineActionType_All = 0xFFFF 353 354 }; … … 362 363 RuntimeMenuViewActionType_GuestAutoresize = RT_BIT(3), 363 364 RuntimeMenuViewActionType_AdjustWindow = RT_BIT(4), 364 RuntimeMenuViewActionType_StatusBar = RT_BIT(5), 365 RuntimeMenuViewActionType_StatusBarSettings = RT_BIT(6), 366 RuntimeMenuViewActionType_ToggleStatusBar = RT_BIT(7), 367 RuntimeMenuViewActionType_Resize = RT_BIT(8), 368 RuntimeMenuViewActionType_Multiscreen = RT_BIT(9), 365 RuntimeMenuViewActionType_MenuBar = RT_BIT(5), 366 RuntimeMenuViewActionType_MenuBarSettings = RT_BIT(6), 367 RuntimeMenuViewActionType_StatusBar = RT_BIT(7), 368 RuntimeMenuViewActionType_StatusBarSettings = RT_BIT(8), 369 RuntimeMenuViewActionType_ToggleStatusBar = RT_BIT(9), 370 RuntimeMenuViewActionType_Resize = RT_BIT(10), 371 RuntimeMenuViewActionType_Multiscreen = RT_BIT(11), 369 372 RuntimeMenuViewActionType_All = 0xFFFF 370 373 }; … … 392 395 RuntimeMenuDevicesActionType_StartVideoCapture = RT_BIT(16), 393 396 RuntimeMenuDevicesActionType_InstallGuestTools = RT_BIT(17), 397 RuntimeMenuDevicesActionType_Nothing = RT_BIT(18), 394 398 RuntimeMenuDevicesActionType_All = 0xFFFF 395 399 }; -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r52467 r52478 2524 2524 const UIExtraDataMetaDefs::RuntimeMenuType enumValue = 2525 2525 static_cast<const UIExtraDataMetaDefs::RuntimeMenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2526 /* Skip RuntimeMenuType_All enum-value: */ 2527 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuType_All) 2526 /* Skip RuntimeMenuType_Invalid & RuntimeMenuType_All enum-values: */ 2527 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuType_Invalid || 2528 enumValue == UIExtraDataMetaDefs::RuntimeMenuType_All) 2528 2529 continue; 2529 2530 if (types & enumValue) … … 2571 2572 const UIExtraDataMetaDefs::MenuApplicationActionType enumValue = 2572 2573 static_cast<const UIExtraDataMetaDefs::MenuApplicationActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2573 /* Skip MenuApplicationActionType_All enum-value: */ 2574 if (enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_All) 2574 /* Skip MenuApplicationActionType_Invalid & MenuApplicationActionType_All enum-values: */ 2575 if (enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_Invalid || 2576 enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_All) 2575 2577 continue; 2576 2578 if (types & enumValue) … … 2591 2593 { 2592 2594 UIExtraDataMetaDefs::RuntimeMenuMachineActionType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(strValue); 2595 /* Since empty value has default restriction, we are supporting special 'Nothing' value: */ 2596 if (value == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing) 2597 { 2598 result = UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing; 2599 break; 2600 } 2593 2601 if (value != UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid) 2594 2602 result = static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(result | value); … … 2625 2633 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enumValue = 2626 2634 static_cast<const UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2627 /* Skip RuntimeMenuMachineActionType_All enum-value: */ 2628 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All) 2635 /* Skip RuntimeMenuMachineActionType_Invalid, RuntimeMenuMachineActionType_Nothing & RuntimeMenuMachineActionType_All enum-values: */ 2636 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid || 2637 enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing || 2638 enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All) 2629 2639 continue; 2630 2640 if (types & enumValue) … … 2632 2642 } 2633 2643 } 2644 /* Since empty value has default restriction, we are supporting special 'Nothing' value: */ 2645 if (result.isEmpty()) 2646 result << gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Nothing); 2634 2647 /* Save result: */ 2635 2648 setExtraDataStringList(GUI_RestrictedRuntimeMachineMenuActions, result, strID); … … 2671 2684 const UIExtraDataMetaDefs::RuntimeMenuViewActionType enumValue = 2672 2685 static_cast<const UIExtraDataMetaDefs::RuntimeMenuViewActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2673 /* Skip RuntimeMenuViewActionType_All enum-value: */ 2674 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_All) 2686 /* Skip RuntimeMenuViewActionType_Invalid & RuntimeMenuViewActionType_All enum-values: */ 2687 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid || 2688 enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_All) 2675 2689 continue; 2676 2690 if (types & enumValue) … … 2690 2704 { 2691 2705 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(strValue); 2706 /* Since empty value has default restriction, we are supporting special 'Nothing' value: */ 2707 if (value == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing) 2708 { 2709 result = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing; 2710 break; 2711 } 2692 2712 if (value != UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid) 2693 2713 result = static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(result | value); … … 2723 2743 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enumValue = 2724 2744 static_cast<const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2725 /* Skip RuntimeMenuDevicesActionType_All enum-value: */ 2726 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All) 2745 /* Skip RuntimeMenuDevicesActionType_Invalid, RuntimeMenuDevicesActionType_Nothing & RuntimeMenuDevicesActionType_All enum-values: */ 2746 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid || 2747 enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing || 2748 enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All) 2727 2749 continue; 2728 2750 if (types & enumValue) … … 2730 2752 } 2731 2753 } 2754 /* Since empty value has default restriction, we are supporting special 'Nothing' value: */ 2755 if (result.isEmpty()) 2756 result << gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Nothing); 2732 2757 /* Save result: */ 2733 2758 setExtraDataStringList(GUI_RestrictedRuntimeDevicesMenuActions, result, strID); … … 2770 2795 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enumValue = 2771 2796 static_cast<const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2772 /* Skip RuntimeMenuDebuggerActionType_All enum-value: */ 2773 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All) 2797 /* Skip RuntimeMenuDebuggerActionType_Invalid & RuntimeMenuDebuggerActionType_All enum-values: */ 2798 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid || 2799 enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All) 2774 2800 continue; 2775 2801 if (types & enumValue) … … 2817 2843 const UIExtraDataMetaDefs::MenuHelpActionType enumValue = 2818 2844 static_cast<const UIExtraDataMetaDefs::MenuHelpActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2819 /* Skip MenuHelpActionType_All enum-value: */ 2820 if (enumValue == UIExtraDataMetaDefs::MenuHelpActionType_All) 2845 /* Skip MenuHelpActionType_Invalid && MenuHelpActionType_All enum-values: */ 2846 if (enumValue == UIExtraDataMetaDefs::MenuHelpActionType_Invalid || 2847 enumValue == UIExtraDataMetaDefs::MenuHelpActionType_All) 2821 2848 continue; 2822 2849 if (types & enumValue) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r52470 r52478 785 785 setName(QApplication::translate("UIActionPool", "&Adjust Window Size")); 786 786 setStatusTip(QApplication::translate("UIActionPool", "Adjust window size and position to best fit the guest display")); 787 } 788 }; 789 790 class UIActionMenuMenuBar : public UIActionMenu 791 { 792 Q_OBJECT; 793 794 public: 795 796 UIActionMenuMenuBar(UIActionPool *pParent) 797 : UIActionMenu(pParent, ":/menubar_16px.png", ":/menubar_disabled_16px.png") {} 798 799 protected: 800 801 /** Returns action extra-data ID. */ 802 virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar; } 803 /** Returns action extra-data key. */ 804 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar); } 805 806 void retranslateUi() 807 { 808 setName(QApplication::translate("UIActionPool", "&Menu Bar")); 809 } 810 }; 811 812 class UIActionSimpleShowMenuBarSettingsWindow : public UIActionSimple 813 { 814 Q_OBJECT; 815 816 public: 817 818 UIActionSimpleShowMenuBarSettingsWindow(UIActionPool *pParent) 819 : UIActionSimple(pParent, ":/menubar_settings_16px.png", ":/menubar_settings_disabled_16px.png") {} 820 821 protected: 822 823 /** Returns action extra-data ID. */ 824 virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings; } 825 /** Returns action extra-data key. */ 826 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings); } 827 828 QString shortcutExtraDataID() const 829 { 830 return QString("MenuBarSettings"); 831 } 832 833 void retranslateUi() 834 { 835 setName(QApplication::translate("UIActionPool", "&Menu Bar Settings...")); 836 setStatusTip(QApplication::translate("UIActionPool", "Opens window to configure menu-bar")); 787 837 } 788 838 }; … … 1749 1799 m_pool[UIActionIndexRT_M_View_T_GuestAutoresize] = new UIActionToggleGuestAutoresize(this); 1750 1800 m_pool[UIActionIndexRT_M_View_S_AdjustWindow] = new UIActionSimplePerformWindowAdjust(this); 1801 m_pool[UIActionIndexRT_M_View_M_MenuBar] = new UIActionMenuMenuBar(this); 1802 m_pool[UIActionIndexRT_M_View_M_MenuBar_S_Settings] = new UIActionSimpleShowMenuBarSettingsWindow(this); 1751 1803 m_pool[UIActionIndexRT_M_View_M_StatusBar] = new UIActionMenuStatusBar(this); 1752 1804 m_pool[UIActionIndexRT_M_View_M_StatusBar_S_Settings] = new UIActionSimpleShowStatusBarSettingsWindow(this); … … 1796 1848 m_menuUpdateHandlers[UIActionIndexRT_M_View].ptfr = &UIActionPoolRuntime::updateMenuView; 1797 1849 m_menuUpdateHandlers[UIActionIndexRT_M_ViewPopup].ptfr = &UIActionPoolRuntime::updateMenuViewPopup; 1850 m_menuUpdateHandlers[UIActionIndexRT_M_View_M_MenuBar].ptfr = &UIActionPoolRuntime::updateMenuViewMenuBar; 1798 1851 m_menuUpdateHandlers[UIActionIndexRT_M_View_M_StatusBar].ptfr = &UIActionPoolRuntime::updateMenuViewStatusBar; 1799 1852 m_menuUpdateHandlers[UIActionIndexRT_M_Devices].ptfr = &UIActionPoolRuntime::updateMenuDevices; … … 2263 2316 bool fSeparator2 = false; 2264 2317 2318 /* 'Menu Bar' submenu: */ 2319 const bool fAllowToShowActionMenuBar = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar); 2320 action(UIActionIndexRT_M_View_M_MenuBar)->setEnabled(fAllowToShowActionMenuBar); 2321 if (fAllowToShowActionMenuBar) 2322 { 2323 pMenu->addAction(action(UIActionIndexRT_M_View_M_MenuBar)); 2324 fSeparator2 = true; 2325 } 2326 updateMenuViewMenuBar(); 2327 2265 2328 /* 'Status Bar' submenu: */ 2266 2329 const bool fAllowToShowActionStatusBar = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar); … … 2365 2428 /* Mark menu as valid: */ 2366 2429 m_invalidations.remove(UIActionIndexRT_M_ViewPopup); 2430 } 2431 2432 void UIActionPoolRuntime::updateMenuViewMenuBar() 2433 { 2434 /* Get corresponding menu: */ 2435 QMenu *pMenu = action(UIActionIndexRT_M_View_M_MenuBar)->menu(); 2436 AssertPtrReturnVoid(pMenu); 2437 /* Clear contents: */ 2438 pMenu->clear(); 2439 2440 /* 'Menu Bar Settings' action: */ 2441 const bool fAllowToShowActionMenuBarSettings = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBarSettings); 2442 action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(fAllowToShowActionMenuBarSettings); 2443 if (fAllowToShowActionMenuBarSettings) 2444 pMenu->addAction(action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)); 2445 2446 /* Mark menu as valid: */ 2447 m_invalidations.remove(UIActionIndexRT_M_View_M_MenuBar); 2367 2448 } 2368 2449 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r52469 r52478 68 68 UIActionIndexRT_M_View_S_AdjustWindow, 69 69 UIActionIndexRT_M_View_T_GuestAutoresize, 70 UIActionIndexRT_M_View_M_MenuBar, 71 UIActionIndexRT_M_View_M_MenuBar_S_Settings, 70 72 UIActionIndexRT_M_View_M_StatusBar, 71 73 UIActionIndexRT_M_View_M_StatusBar_S_Settings, … … 218 220 /** Update 'View' : 'Popup' menu routine. */ 219 221 void updateMenuViewPopup(); 222 /** Update 'View' : 'Menu Bar' menu routine. */ 223 void updateMenuViewMenuBar(); 220 224 /** Update 'View' : 'Status Bar' menu routine. */ 221 225 void updateMenuViewStatusBar(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r52275 r52478 866 866 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Machine_M_Mouse_T_Integration)); 867 867 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Machine_T_Pause)); 868 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar)); 869 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)); 868 870 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar)); 869 871 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings)); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp
r52395 r52478 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI StatusBarEditorWindow class implementation.3 * VBox Qt GUI - UIMenuBarEditorWindow class implementation. 4 4 */ 5 5 … … 17 17 18 18 /* Qt includes: */ 19 #include <QStylePainter>20 #include <QStyleOption>21 19 #include <QHBoxLayout> 22 20 #include <QPaintEvent> 23 #include <QM ouseEvent>24 #include <Q StatusBar>21 #include <QMetaEnum> 22 #include <QMenuBar> 25 23 #include <QPainter> 26 #include <QPixmap> 27 #include <QDrag> 28 #include <QList> 24 #include <QMenu> 29 25 #include <QMap> 30 26 31 27 /* GUI includes: */ 32 #include "UIStatusBarEditorWindow.h" 28 #include "UIMenuBarEditorWindow.h" 29 #include "UIActionPoolRuntime.h" 33 30 #include "UIExtraDataManager.h" 34 31 #include "UIMachineWindow.h" 35 32 #include "UIConverter.h" 36 33 #include "UIIconPool.h" 34 #include "UIToolBar.h" 37 35 #include "QIWithRetranslateUI.h" 38 36 #include "QIToolButton.h" … … 40 38 41 39 42 /** QWidget extension43 * used as status-bar editor button. */44 class UI StatusBarEditorButton : public QIWithRetranslateUI<QWidget>40 /** QWidget reimplementation 41 * used as menu-bar editor widget. */ 42 class UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget> 45 43 { 46 44 Q_OBJECT; … … 48 46 signals: 49 47 50 /** Notifies about click. */ 51 void sigClick(); 52 53 /** Notifies about drag-object destruction. */ 54 void sigDragObjectDestroy(); 48 /** Notifies about Cancel button click. */ 49 void sigCancelClicked(); 55 50 56 51 public: 57 52 58 /** Holds the mime-type for the D&D system. */ 59 static const QString MimeType; 60 61 /** Constructor for the button of passed @a type. */ 62 UIStatusBarEditorButton(IndicatorType type); 63 64 /** Returns button type. */ 65 IndicatorType type() const { return m_type; } 66 67 /** Returns button size-hint. */ 68 QSize sizeHint() const { return m_size; } 69 70 /** Defines whether button is @a fChecked. */ 71 void setChecked(bool fChecked); 53 /** Constructor, taking @a pActionPool argument. */ 54 UIMenuBarEditorWidget(UIActionPool *pActionPool); 55 56 /** Returns the action-pool reference. */ 57 const UIActionPool* actionPool() const { return m_pActionPool; } 58 59 private slots: 60 61 /** Handles configuration change. */ 62 void sltHandleConfigurationChange(); 63 64 /** Handles menu-bar menu click. */ 65 void sltHandleMenuBarMenuClick(); 72 66 73 67 private: 68 69 /** Prepare routine. */ 70 void prepare(); 71 #ifdef Q_WS_MAC 72 /** Prepare named menu routine. */ 73 QMenu* prepareNamedMenu(const QString &strName); 74 #endif /* Q_WS_MAC */ 75 /** Prepare copied menu routine. */ 76 QMenu* prepareCopiedMenu(const UIAction *pAction); 77 #if 0 78 /** Prepare copied sub-menu routine. */ 79 QMenu* prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction); 80 #endif 81 /** Prepare copied action routine. */ 82 QAction* prepareCopiedAction(QMenu *pMenu, const UIAction *pAction); 83 /** Prepare menus routine. */ 84 void prepareMenus(); 85 #ifdef Q_WS_MAC 86 /** Mac OS X: Prepare 'Application' menu routine. */ 87 void prepareMenuApplication(); 88 #endif /* Q_WS_MAC */ 89 /** Prepare 'Machine' menu routine. */ 90 void prepareMenuMachine(); 91 /** Prepare 'View' menu routine. */ 92 void prepareMenuView(); 93 /** Prepare 'Devices' menu routine. */ 94 void prepareMenuDevices(); 95 #ifdef VBOX_WITH_DEBUGGER_GUI 96 /** Prepare 'Debug' menu routine. */ 97 void prepareMenuDebug(); 98 #endif /* VBOX_WITH_DEBUGGER_GUI */ 99 /** Prepare 'Help' menu routine. */ 100 void prepareMenuHelp(); 101 102 /** Updates menus routine. */ 103 void updateMenus(); 104 /** Updates 'Machine' menu routine. */ 105 void updateMenuMachine(); 106 /** Updates 'View' menu routine. */ 107 void updateMenuView(); 108 /** Updates 'Devices' menu routine. */ 109 void updateMenuDevices(); 110 #ifdef VBOX_WITH_DEBUGGER_GUI 111 /** Updates 'Debug' menu routine. */ 112 void updateMenuDebug(); 113 #endif /* VBOX_WITH_DEBUGGER_GUI */ 114 /** Updates 'Help' menu routine. */ 115 void updateMenuHelp(); 74 116 75 117 /** Retranslation routine. */ 76 118 virtual void retranslateUi(); 77 119 78 /** Paint-event handler. */79 virtual void paintEvent(QPaintEvent *pEvent);80 81 /** Mouse-press event handler. */82 virtual void mousePressEvent(QMouseEvent *pEvent);83 /** Mouse-release event handler. */84 virtual void mouseReleaseEvent(QMouseEvent *pEvent);85 /** Mouse-enter event handler. */86 virtual void enterEvent(QEvent *pEvent);87 /** Mouse-leave event handler. */88 virtual void leaveEvent(QEvent *pEvent);89 /** Mouse-move event handler. */90 virtual void mouseMoveEvent(QMouseEvent *pEvent);91 92 /** Holds the button type. */93 IndicatorType m_type;94 /** Holds the button size. */95 QSize m_size;96 /** Holds the button pixmap. */97 QPixmap m_pixmap;98 /** Holds whether button is checked. */99 bool m_fChecked;100 /** Holds whether button is hovered. */101 bool m_fHovered;102 /** Holds the last mouse-press position. */103 QPoint m_mousePressPosition;104 };105 106 107 /** QWidget reimplementation108 * used as status-bar editor widget. */109 class UIStatusBarEditorWidget : public QIWithRetranslateUI2<QWidget>110 {111 Q_OBJECT;112 113 signals:114 115 /** Notifies about Cancel button click. */116 void sigCancelClicked();117 118 public:119 120 /** Constructor, passes @a pParent to the QWidget constructor.121 * @param rect is used to define initial cached parent geometry.122 * @param statusBarRect is used to define initial cached status-bar geometry. */123 UIStatusBarEditorWidget(QWidget *pParent = 0);124 125 private slots:126 127 /** Handles configuration change. */128 void sltHandleConfigurationChange();129 130 /** Handles button click. */131 void sltHandleButtonClick();132 133 /** Handles drag object destroy. */134 void sltHandleDragObjectDestroy();135 136 private:137 138 /** Prepare routine. */139 void prepare();140 /** Prepare status buttons routine. */141 void prepareStatusButtons();142 /** Prepare status button routine. */143 void prepareStatusButton(IndicatorType type);144 145 /** Updates status buttons. */146 void updateStatusButtons();147 148 /** Retranslation routine. */149 virtual void retranslateUi();150 151 120 /** Paint event handler. */ 152 121 virtual void paintEvent(QPaintEvent *pEvent); 153 122 154 /** Drag-enter event handler. */ 155 virtual void dragEnterEvent(QDragEnterEvent *pEvent); 156 /** Drag-move event handler. */ 157 virtual void dragMoveEvent(QDragMoveEvent *pEvent); 158 /** Drag-leave event handler. */ 159 virtual void dragLeaveEvent(QDragLeaveEvent *pEvent); 160 /** Drop event handler. */ 161 virtual void dropEvent(QDropEvent *pEvent); 162 163 /** Returns position for passed @a type. */ 164 int position(IndicatorType type) const; 123 /** @name General 124 * @{ */ 125 /** Holds the action-pool reference. */ 126 const UIActionPool *m_pActionPool; 127 /** @} */ 165 128 166 129 /** @name Contents … … 168 131 /** Holds the main-layout instance. */ 169 132 QHBoxLayout *m_pMainLayout; 170 /** Holds the button-layoutinstance. */171 QHBoxLayout *m_pButtonLayout;133 /** Holds the tool-bar instance. */ 134 UIToolBar *m_pToolBar; 172 135 /** Holds the close-button instance. */ 173 136 QIToolButton *m_pButtonClose; 174 /** Holds status-bar buttons. */ 175 QMap<IndicatorType, UIStatusBarEditorButton*> m_buttons; 176 /** @} */ 177 178 /** @name Contents: Restrictions 179 * @{ */ 180 /** Holds the cached status-bar button restrictions. */ 181 QList<IndicatorType> m_restrictions; 182 /** @} */ 183 184 /** @name Contents: Order 185 * @{ */ 186 /** Holds the cached status-bar button order. */ 187 QList<IndicatorType> m_order; 188 /** Holds the token-button to drop dragged-button nearby. */ 189 UIStatusBarEditorButton *m_pButtonDropToken; 190 /** Holds whether dragged-button should be dropped <b>after</b> the token-button. */ 191 bool m_fDropAfterTokenButton; 137 /** Holds tool-bar action references. */ 138 QMap<QString, QAction*> m_actions; 192 139 /** @} */ 193 140 }; 194 141 195 142 196 /* static */ 197 const QString UIStatusBarEditorButton::MimeType = QString("application/virtualbox;value=IndicatorType"); 198 199 UIStatusBarEditorButton::UIStatusBarEditorButton(IndicatorType type) 200 : m_type(type) 201 , m_fChecked(false) 202 , m_fHovered(false) 203 { 204 /* Track mouse events: */ 205 setMouseTracking(true); 206 207 /* Prepare icon for assigned type: */ 208 const QIcon icon = gpConverter->toIcon(m_type); 209 /* Cache button size-hint: */ 210 m_size = icon.availableSizes().first(); 211 /* Cache pixmap of same size: */ 212 m_pixmap = icon.pixmap(m_size); 213 214 /* Translate finally: */ 215 retranslateUi(); 216 } 217 218 void UIStatusBarEditorButton::setChecked(bool fChecked) 219 { 220 /* Update 'checked' state: */ 221 m_fChecked = fChecked; 222 /* Update: */ 223 update(); 224 } 225 226 void UIStatusBarEditorButton::retranslateUi() 227 { 228 /* Translate tool-tip: */ 229 setToolTip(tr("<nobr><b>Click</b> to toggle indicator presence.</nobr><br>" 230 "<nobr><b>Drag&Drop</b> to change indicator position.</nobr>")); 231 } 232 233 void UIStatusBarEditorButton::paintEvent(QPaintEvent*) 234 { 235 /* Create style-painter: */ 236 QStylePainter painter(this); 237 QStyleOption option; 238 option.initFrom(this); 239 option.rect = QRect(0, 0, width(), height()); 240 /* Remember checked-state: */ 241 if (m_fChecked) 242 option.state |= QStyle::State_On; 243 /* Draw check-box for hovered-state: */ 244 if (m_fHovered) 245 painter.drawPrimitive(QStyle::PE_IndicatorCheckBox, option); 246 /* Draw pixmap for unhovered-state: */ 247 else 248 painter.drawItemPixmap(option.rect, Qt::AlignCenter, m_pixmap); 249 } 250 251 void UIStatusBarEditorButton::mousePressEvent(QMouseEvent *pEvent) 252 { 253 /* We are interested in left button only: */ 254 if (pEvent->button() != Qt::LeftButton) 255 return; 256 257 /* Remember mouse-press position: */ 258 m_mousePressPosition = pEvent->globalPos(); 259 } 260 261 void UIStatusBarEditorButton::mouseReleaseEvent(QMouseEvent *pEvent) 262 { 263 /* We are interested in left button only: */ 264 if (pEvent->button() != Qt::LeftButton) 265 return; 266 267 /* Forget mouse-press position: */ 268 m_mousePressPosition = QPoint(); 269 270 /* Notify about click: */ 271 emit sigClick(); 272 } 273 274 void UIStatusBarEditorButton::enterEvent(QEvent*) 275 { 276 /* Make sure button isn't hovered: */ 277 if (m_fHovered) 278 return; 279 280 /* Invert hovered state: */ 281 m_fHovered = true; 282 /* Update: */ 283 update(); 284 } 285 286 void UIStatusBarEditorButton::leaveEvent(QEvent*) 287 { 288 /* Make sure button is hovered: */ 289 if (!m_fHovered) 290 return; 291 292 /* Invert hovered state: */ 293 m_fHovered = false; 294 /* Update: */ 295 update(); 296 } 297 298 void UIStatusBarEditorButton::mouseMoveEvent(QMouseEvent *pEvent) 299 { 300 /* Make sure item isn't already dragged: */ 301 if (m_mousePressPosition.isNull()) 302 return QWidget::mouseMoveEvent(pEvent); 303 304 /* Make sure item is really dragged: */ 305 if (QLineF(pEvent->globalPos(), m_mousePressPosition).length() < 306 QApplication::startDragDistance()) 307 return QWidget::mouseMoveEvent(pEvent); 308 309 /* Revoke hovered state: */ 310 m_fHovered = false; 311 /* Update: */ 312 update(); 313 314 /* Initialize dragging: */ 315 m_mousePressPosition = QPoint(); 316 QDrag *pDrag = new QDrag(this); 317 connect(pDrag, SIGNAL(destroyed(QObject*)), this, SIGNAL(sigDragObjectDestroy())); 318 QMimeData *pMimeData = new QMimeData; 319 pMimeData->setData(MimeType, gpConverter->toInternalString(m_type).toLatin1()); 320 pDrag->setMimeData(pMimeData); 321 pDrag->setPixmap(m_pixmap); 322 pDrag->exec(); 323 } 324 325 326 UIStatusBarEditorWidget::UIStatusBarEditorWidget(QWidget *pParent /* = 0 */) 327 : QIWithRetranslateUI2<QWidget>(pParent) 328 , m_pMainLayout(0), m_pButtonLayout(0) 143 UIMenuBarEditorWidget::UIMenuBarEditorWidget(UIActionPool *pActionPool) 144 : m_pActionPool(pActionPool) 145 , m_pMainLayout(0) 146 , m_pToolBar(0) 329 147 , m_pButtonClose(0) 330 , m_pButtonDropToken(0)331 , m_fDropAfterTokenButton(true)332 148 { 333 149 /* Prepare: */ … … 335 151 } 336 152 337 void UI StatusBarEditorWidget::sltHandleConfigurationChange()338 { 339 /* Update status buttons: */340 update StatusButtons();341 } 342 343 void UI StatusBarEditorWidget::sltHandleButtonClick()153 void UIMenuBarEditorWidget::sltHandleConfigurationChange() 154 { 155 /* Update menus: */ 156 updateMenus(); 157 } 158 159 void UIMenuBarEditorWidget::sltHandleMenuBarMenuClick() 344 160 { 345 161 /* Make sure sender is valid: */ 346 UIStatusBarEditorButton *pButton = qobject_cast<UIStatusBarEditorButton*>(sender()); 347 AssertPtrReturnVoid(pButton); 348 349 /* Get sender type: */ 350 const IndicatorType type = pButton->type(); 351 352 /* Load current status-bar indicator restrictions: */ 353 QList<IndicatorType> restrictions = 354 gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid()); 355 356 /* Invert restriction for sender type: */ 357 if (restrictions.contains(type)) 358 restrictions.removeAll(type); 359 else 360 restrictions.append(type); 361 362 /* Save updated status-bar indicator restrictions: */ 363 gEDataManager->setRestrictedStatusBarIndicators(restrictions, vboxGlobal().managedVMUuid()); 364 } 365 366 void UIStatusBarEditorWidget::sltHandleDragObjectDestroy() 367 { 368 /* Reset token: */ 369 m_pButtonDropToken = 0; 370 m_fDropAfterTokenButton = true; 371 /* Update: */ 372 update(); 373 } 374 375 void UIStatusBarEditorWidget::prepare() 376 { 377 /* Track D&D events: */ 378 setAcceptDrops(true); 379 162 QAction *pAction = qobject_cast<QAction*>(sender()); 163 AssertPtrReturnVoid(pAction); 164 165 /* Depending on triggered action class: */ 166 switch (pAction->property("class").toInt()) 167 { 168 case UIExtraDataMetaDefs::RuntimeMenuType_All: 169 { 170 /* Get sender type: */ 171 const UIExtraDataMetaDefs::RuntimeMenuType type = 172 static_cast<UIExtraDataMetaDefs::RuntimeMenuType>(pAction->property("type").toInt()); 173 /* Load current menu-bar restrictions: */ 174 UIExtraDataMetaDefs::RuntimeMenuType restrictions = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid()); 175 /* Invert restriction for sender type: */ 176 restrictions = (UIExtraDataMetaDefs::RuntimeMenuType)(restrictions ^ type); 177 /* Save updated menu-bar restrictions: */ 178 gEDataManager->setRestrictedRuntimeMenuTypes(restrictions, vboxGlobal().managedVMUuid()); 179 break; 180 } 181 case UIExtraDataMetaDefs::RuntimeMenuType_Machine: 182 { 183 /* Get sender type: */ 184 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType type = 185 static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(pAction->property("type").toInt()); 186 /* Load current menu-bar restrictions: */ 187 UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictions = gEDataManager->restrictedRuntimeMenuMachineActionTypes(vboxGlobal().managedVMUuid()); 188 /* Invert restriction for sender type: */ 189 restrictions = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(restrictions ^ type); 190 /* Save updated menu-bar restrictions: */ 191 gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(restrictions, vboxGlobal().managedVMUuid()); 192 break; 193 } 194 case UIExtraDataMetaDefs::RuntimeMenuType_View: 195 { 196 /* Get sender type: */ 197 const UIExtraDataMetaDefs::RuntimeMenuViewActionType type = 198 static_cast<UIExtraDataMetaDefs::RuntimeMenuViewActionType>(pAction->property("type").toInt()); 199 /* Load current menu-bar restrictions: */ 200 UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictions = gEDataManager->restrictedRuntimeMenuViewActionTypes(vboxGlobal().managedVMUuid()); 201 /* Invert restriction for sender type: */ 202 restrictions = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictions ^ type); 203 /* Save updated menu-bar restrictions: */ 204 gEDataManager->setRestrictedRuntimeMenuViewActionTypes(restrictions, vboxGlobal().managedVMUuid()); 205 break; 206 } 207 case UIExtraDataMetaDefs::RuntimeMenuType_Devices: 208 { 209 /* Get sender type: */ 210 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType type = 211 static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(pAction->property("type").toInt()); 212 /* Load current menu-bar restrictions: */ 213 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictions = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(vboxGlobal().managedVMUuid()); 214 /* Invert restriction for sender type: */ 215 restrictions = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictions ^ type); 216 /* Save updated menu-bar restrictions: */ 217 gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(restrictions, vboxGlobal().managedVMUuid()); 218 break; 219 } 220 #ifdef VBOX_WITH_DEBUGGER_GUI 221 case UIExtraDataMetaDefs::RuntimeMenuType_Debug: 222 { 223 /* Get sender type: */ 224 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType type = 225 static_cast<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(pAction->property("type").toInt()); 226 /* Load current menu-bar restrictions: */ 227 UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictions = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(vboxGlobal().managedVMUuid()); 228 /* Invert restriction for sender type: */ 229 restrictions = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(restrictions ^ type); 230 /* Save updated menu-bar restrictions: */ 231 gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(restrictions, vboxGlobal().managedVMUuid()); 232 break; 233 } 234 #endif /* VBOX_WITH_DEBUGGER_GUI */ 235 case UIExtraDataMetaDefs::RuntimeMenuType_Help: 236 { 237 /* Get sender type: */ 238 const UIExtraDataMetaDefs::MenuHelpActionType type = 239 static_cast<UIExtraDataMetaDefs::MenuHelpActionType>(pAction->property("type").toInt()); 240 /* Load current menu-bar restrictions: */ 241 UIExtraDataMetaDefs::MenuHelpActionType restrictions = gEDataManager->restrictedRuntimeMenuHelpActionTypes(vboxGlobal().managedVMUuid()); 242 /* Invert restriction for sender type: */ 243 restrictions = (UIExtraDataMetaDefs::MenuHelpActionType)(restrictions ^ type); 244 /* Save updated menu-bar restrictions: */ 245 gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(restrictions, vboxGlobal().managedVMUuid()); 246 break; 247 } 248 default: break; 249 } 250 } 251 252 void UIMenuBarEditorWidget::prepare() 253 { 380 254 /* Create main-layout: */ 381 255 m_pMainLayout = new QHBoxLayout(this); … … 385 259 #ifdef Q_WS_MAC 386 260 /* Standard margins on Mac OS X are too big: */ 387 m_pMainLayout->setContentsMargins(10, 10, 10, 5);261 m_pMainLayout->setContentsMargins(10, 5, 10, 10); 388 262 #else /* !Q_WS_MAC */ 389 263 /* Standard margins on Windows/X11: */ 390 264 int iLeft, iTop, iRight, iBottom; 391 265 m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 392 if (i Bottom>= 5)393 i Bottom-= 5;266 if (iTop >= 5) 267 iTop -= 5; 394 268 m_pMainLayout->setContentsMargins(iLeft, iTop, iRight, iBottom); 395 269 #endif /* !Q_WS_MAC */ 396 270 m_pMainLayout->setSpacing(0); 271 /* Create tool-bar: */ 272 m_pToolBar = new UIToolBar; 273 AssertPtrReturnVoid(m_pToolBar); 274 { 275 /* Prepare menus: */ 276 prepareMenus(); 277 /* Add tool-bar into main-layout: */ 278 m_pMainLayout->addWidget(m_pToolBar); 279 } 280 /* Insert stretch: */ 281 m_pMainLayout->addStretch(); 397 282 /* Create close-button: */ 398 283 m_pButtonClose = new QIToolButton; … … 408 293 m_pMainLayout->addWidget(m_pButtonClose); 409 294 } 410 /* Insert stretch: */411 m_pMainLayout->addStretch();412 /* Create button-layout: */413 m_pButtonLayout = new QHBoxLayout;414 AssertPtrReturnVoid(m_pButtonLayout);415 {416 /* Configure button-layout: */417 m_pButtonLayout->setContentsMargins(0, 0, 0, 0);418 m_pButtonLayout->setSpacing(5);419 /* Add button-layout into main-layout: */420 m_pMainLayout->addLayout(m_pButtonLayout);421 }422 /* Prepare status buttons: */423 prepareStatusButtons();424 295 } 425 296 … … 428 299 } 429 300 430 void UI StatusBarEditorWidget::prepareStatusButtons()431 { 432 /* Create status buttons: */433 for (int i = IndicatorType_Invalid; i < IndicatorType_Max; ++i) 434 {435 /* Get current type:*/436 const IndicatorType type = (IndicatorType)i;437 /* Skip inappropriate types: */438 if (type == IndicatorType_Invalid || type == IndicatorType_KeyboardExtension)439 continue; 440 /* Create status button: */441 prepareStatusButton(type); 442 }443 444 /* Listen for the status-bar configuration changes: */445 connect(gEDataManager, SIGNAL(sig StatusBarConfigurationChange()),301 void UIMenuBarEditorWidget::prepareMenus() 302 { 303 /* Create menus: */ 304 #ifdef Q_WS_MAC 305 prepareMenuApplication(); 306 #endif /* Q_WS_MAC */ 307 prepareMenuMachine(); 308 prepareMenuView(); 309 prepareMenuDevices(); 310 #ifdef VBOX_WITH_DEBUGGER_GUI 311 prepareMenuDebug(); 312 #endif /* VBOX_WITH_DEBUGGER_GUI */ 313 prepareMenuHelp(); 314 315 /* Listen for the menu-bar configuration changes: */ 316 connect(gEDataManager, SIGNAL(sigMenuBarConfigurationChange()), 446 317 this, SLOT(sltHandleConfigurationChange())); 447 /* Update status buttons: */ 448 updateStatusButtons(); 449 } 450 451 void UIStatusBarEditorWidget::prepareStatusButton(IndicatorType type) 452 { 453 /* Create status button: */ 454 UIStatusBarEditorButton *pButton = new UIStatusBarEditorButton(type); 455 AssertPtrReturnVoid(pButton); 456 { 457 /* Configure status button: */ 458 connect(pButton, SIGNAL(sigClick()), this, SLOT(sltHandleButtonClick())); 459 connect(pButton, SIGNAL(sigDragObjectDestroy()), this, SLOT(sltHandleDragObjectDestroy())); 460 /* Add status button into button-layout: */ 461 m_pButtonLayout->addWidget(pButton); 462 /* Insert status button into map: */ 463 m_buttons.insert(type, pButton); 464 } 465 } 466 467 void UIStatusBarEditorWidget::updateStatusButtons() 468 { 469 /* Recache status-bar configuration: */ 470 m_restrictions = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid()); 471 m_order = gEDataManager->statusBarIndicatorOrder(vboxGlobal().managedVMUuid()); 472 for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType) 473 if (iType != IndicatorType_Invalid && iType != IndicatorType_KeyboardExtension && 474 !m_order.contains((IndicatorType)iType)) 475 m_order << (IndicatorType)iType; 476 477 /* Update configuration for all the status buttons: */ 478 foreach (const IndicatorType &type, m_order) 479 { 480 /* Get button: */ 481 UIStatusBarEditorButton *pButton = m_buttons.value(type); 482 /* Update button 'checked' state: */ 483 pButton->setChecked(!m_restrictions.contains(type)); 484 /* Make sure it have valid position: */ 485 const int iWantedIndex = position(type); 486 const int iActualIndex = m_pButtonLayout->indexOf(pButton); 487 if (iActualIndex != iWantedIndex) 488 { 489 /* Re-inject button into main-layout at proper position: */ 490 m_pButtonLayout->removeWidget(pButton); 491 m_pButtonLayout->insertWidget(iWantedIndex, pButton); 492 } 493 } 494 } 495 496 void UIStatusBarEditorWidget::retranslateUi() 318 319 /* Update menus: */ 320 updateMenus(); 321 } 322 323 #ifdef Q_WS_MAC 324 QMenu* UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName) 325 { 326 /* Create named menu: */ 327 QMenu *pNamedMenu = new QMenu(strName, m_pToolBar); 328 AssertPtrReturn(pNamedMenu, 0); 329 { 330 /* Configure named menu: */ 331 pNamedMenu->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_Help); 332 /* Get named menu action: */ 333 QAction *pNamedMenuAction = pNamedMenu->menuAction(); 334 AssertPtrReturn(pNamedMenuAction, 0); 335 { 336 /* Add menu action into tool-bar: */ 337 m_pToolBar->addAction(pNamedMenuAction); 338 /* Get named menu tool-button: */ 339 QToolButton *pNamedMenuToolButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pNamedMenuAction)); 340 AssertPtrReturn(pNamedMenuToolButton, 0); 341 { 342 /* Configure named menu tool-button: */ 343 pNamedMenuToolButton->setPopupMode(QToolButton::MenuButtonPopup); 344 pNamedMenuToolButton->setAutoRaise(true); 345 /* Create spacing after named menu tool-button: */ 346 QWidget *pSpacing = new QWidget; 347 AssertPtrReturn(pSpacing, 0); 348 { 349 /* Configure spacing: */ 350 pSpacing->setFixedSize(5, 1); 351 /* Add spacing into tool-bar: */ 352 m_pToolBar->addWidget(pSpacing); 353 } 354 } 355 } 356 } 357 /* Return named menu: */ 358 return pNamedMenu; 359 } 360 #endif /* Q_WS_MAC */ 361 362 QMenu* UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction) 363 { 364 /* Create copied menu: */ 365 QMenu *pCopiedMenu = new QMenu(pAction->name(), m_pToolBar); 366 AssertPtrReturn(pCopiedMenu, 0); 367 { 368 /* Configure copied menu: */ 369 pCopiedMenu->setProperty("class", pAction->extraDataID()); 370 /* Get copied menu action: */ 371 QAction *pCopiedMenuAction = pCopiedMenu->menuAction(); 372 AssertPtrReturn(pCopiedMenuAction, 0); 373 { 374 /* Configure copied menu action: */ 375 pCopiedMenuAction->setCheckable(true); 376 pCopiedMenuAction->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_All); 377 pCopiedMenuAction->setProperty("type", pAction->extraDataID()); 378 connect(pCopiedMenuAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick())); 379 m_actions.insert(pAction->extraDataKey(), pCopiedMenuAction); 380 /* Add menu action into tool-bar: */ 381 m_pToolBar->addAction(pCopiedMenuAction); 382 /* Get copied menu tool-button: */ 383 QToolButton *pCopiedMenuToolButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pCopiedMenuAction)); 384 AssertPtrReturn(pCopiedMenuToolButton, 0); 385 { 386 /* Configure copied menu tool-button: */ 387 pCopiedMenuToolButton->setPopupMode(QToolButton::MenuButtonPopup); 388 pCopiedMenuToolButton->setAutoRaise(true); 389 /* Create spacing after copied menu tool-button: */ 390 QWidget *pSpacing = new QWidget; 391 AssertPtrReturn(pSpacing, 0); 392 { 393 /* Configure spacing: */ 394 pSpacing->setFixedSize(5, 1); 395 /* Add spacing into tool-bar: */ 396 m_pToolBar->addWidget(pSpacing); 397 } 398 } 399 } 400 } 401 /* Return copied menu: */ 402 return pCopiedMenu; 403 } 404 405 #if 0 406 QMenu* UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction) 407 { 408 /* Create copied sub-menu: */ 409 QMenu *pCopiedMenu = pMenu->addMenu(pAction->name()); 410 AssertPtrReturn(pCopiedMenu, 0); 411 { 412 /* Configure copied sub-menu: */ 413 pCopiedMenu->setProperty("class", pMenu->property("class")); 414 /* Get copied sub-menu action: */ 415 QAction *pCopiedMenuAction = pCopiedMenu->menuAction(); 416 AssertPtrReturn(pCopiedMenuAction, 0); 417 { 418 /* Configure copied sub-menu: */ 419 pCopiedMenuAction->setCheckable(true); 420 pCopiedMenuAction->setProperty("class", pCopiedMenu->property("class")); 421 pCopiedMenuAction->setProperty("type", pAction->extraDataID()); 422 connect(pCopiedMenuAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick())); 423 m_actions.insert(pAction->extraDataKey(), pCopiedMenuAction); 424 } 425 } 426 /* Return copied sub-menu: */ 427 return pCopiedMenu; 428 } 429 #endif 430 431 QAction* UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction) 432 { 433 /* Create copied action: */ 434 QAction *pCopiedAction = pMenu->addAction(pAction->name()); 435 AssertPtrReturn(pCopiedAction, 0); 436 { 437 /* Configure copied action: */ 438 pCopiedAction->setCheckable(true); 439 pCopiedAction->setProperty("class", pMenu->property("class")); 440 pCopiedAction->setProperty("type", pAction->extraDataID()); 441 connect(pCopiedAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick())); 442 m_actions.insert(pAction->extraDataKey(), pCopiedAction); 443 } 444 /* Return copied action: */ 445 return pCopiedAction; 446 } 447 448 #ifdef Q_WS_MAC 449 void UIMenuBarEditorWidget::prepareMenuApplication() 450 { 451 /* Copy menu: */ 452 QMenu *pMenu = prepareNamedMenu("VirtualBox"); 453 AssertPtrReturnVoid(pMenu); 454 { 455 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_About)); 456 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Preferences)); 457 } 458 } 459 #endif /* Q_WS_MAC */ 460 461 void UIMenuBarEditorWidget::prepareMenuMachine() 462 { 463 /* Copy menu: */ 464 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Machine)); 465 AssertPtrReturnVoid(pMenu); 466 { 467 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Settings)); 468 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_TakeSnapshot)); 469 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_TakeScreenshot)); 470 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_ShowInformation)); 471 pMenu->addSeparator(); 472 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_M_Keyboard_S_Settings)); 473 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_M_Mouse_T_Integration)); 474 pMenu->addSeparator(); 475 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_TypeCAD)); 476 #ifdef Q_WS_X11 477 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_TypeCABS)); 478 #endif /* Q_WS_X11 */ 479 pMenu->addSeparator(); 480 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_T_Pause)); 481 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Reset)); 482 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Save)); 483 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Shutdown)); 484 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_PowerOff)); 485 } 486 } 487 488 void UIMenuBarEditorWidget::prepareMenuView() 489 { 490 /* Copy menu: */ 491 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_View)); 492 AssertPtrReturnVoid(pMenu); 493 { 494 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen)); 495 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Seamless)); 496 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Scale)); 497 pMenu->addSeparator(); 498 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_S_AdjustWindow)); 499 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)); 500 pMenu->addSeparator(); 501 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_M_MenuBar)); 502 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_M_StatusBar)); 503 pMenu->addSeparator(); 504 // prepareCopiedAction(pMenu, Resize); 505 // prepareCopiedAction(pMenu, MultiScreen); 506 } 507 } 508 509 void UIMenuBarEditorWidget::prepareMenuDevices() 510 { 511 /* Copy menu: */ 512 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Devices)); 513 AssertPtrReturnVoid(pMenu); 514 { 515 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_HardDrives)); 516 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices)); 517 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices)); 518 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_Network)); 519 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_USBDevices)); 520 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_WebCams)); 521 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_SharedClipboard)); 522 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_DragAndDrop)); 523 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_SharedFolders)); 524 pMenu->addSeparator(); 525 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_T_VRDEServer)); 526 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_T_Start)); 527 pMenu->addSeparator(); 528 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_S_InstallGuestTools)); 529 } 530 } 531 532 #ifdef VBOX_WITH_DEBUGGER_GUI 533 void UIMenuBarEditorWidget::prepareMenuDebug() 534 { 535 /* Copy menu: */ 536 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Debug)); 537 AssertPtrReturnVoid(pMenu); 538 { 539 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_S_ShowStatistics)); 540 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_S_ShowCommandLine)); 541 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_T_Logging)); 542 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_LogDialog)); 543 } 544 } 545 #endif /* VBOX_WITH_DEBUGGER_GUI */ 546 547 void UIMenuBarEditorWidget::prepareMenuHelp() 548 { 549 /* Copy menu: */ 550 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_Menu_Help)); 551 AssertPtrReturnVoid(pMenu); 552 { 553 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Contents)); 554 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_WebSite)); 555 pMenu->addSeparator(); 556 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_ResetWarnings)); 557 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 558 pMenu->addSeparator(); 559 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_NetworkAccessManager)); 560 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 561 #ifndef Q_WS_MAC 562 pMenu->addSeparator(); 563 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_About)); 564 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Preferences)); 565 #endif /* !Q_WS_MAC */ 566 } 567 } 568 569 void UIMenuBarEditorWidget::updateMenus() 570 { 571 /* Recache menu-bar configuration: */ 572 const UIExtraDataMetaDefs::RuntimeMenuType restrictionsMenuBar = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid()); 573 /* Get static meta-object: */ 574 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 575 576 /* We have UIExtraDataMetaDefs::RuntimeMenuType enum registered, so we can enumerate it: */ 577 const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuType"); 578 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 579 /* Handle other enum-values: */ 580 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 581 { 582 /* Get iterated enum-value: */ 583 const UIExtraDataMetaDefs::RuntimeMenuType enumValue = 584 static_cast<const UIExtraDataMetaDefs::RuntimeMenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 585 /* Skip RuntimeMenuType_Invalid & RuntimeMenuType_All enum-value: */ 586 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuType_Invalid || 587 enumValue == UIExtraDataMetaDefs::RuntimeMenuType_All) 588 continue; 589 /* Which key required action registered under? */ 590 const QString strKey = gpConverter->toInternalString(enumValue); 591 if (!m_actions.contains(strKey)) 592 continue; 593 /* Update action 'checked' state: */ 594 m_actions.value(strKey)->setChecked(!(restrictionsMenuBar & enumValue)); 595 } 596 597 /* Update known menu-bar menus: */ 598 updateMenuMachine(); 599 updateMenuView(); 600 updateMenuDevices(); 601 #ifdef VBOX_WITH_DEBUGGER_GUI 602 updateMenuDebug(); 603 #endif /* VBOX_WITH_DEBUGGER_GUI */ 604 updateMenuHelp(); 605 } 606 607 void UIMenuBarEditorWidget::updateMenuMachine() 608 { 609 /* Recache menu-bar configuration: */ 610 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionsMenuMachine = gEDataManager->restrictedRuntimeMenuMachineActionTypes(vboxGlobal().managedVMUuid()); 611 /* Get static meta-object: */ 612 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 613 614 /* We have UIExtraDataMetaDefs::RuntimeMenuMachineActionType enum registered, so we can enumerate it: */ 615 const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuMachineActionType"); 616 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 617 /* Handle other enum-values: */ 618 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 619 { 620 /* Get iterated enum-value: */ 621 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enumValue = 622 static_cast<const UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 623 /* Skip RuntimeMenuMachineActionType_Invalid & RuntimeMenuMachineActionType_All enum-value: */ 624 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid || 625 enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All) 626 continue; 627 /* Which key required action registered under? */ 628 const QString strKey = gpConverter->toInternalString(enumValue); 629 if (!m_actions.contains(strKey)) 630 continue; 631 /* Update action 'checked' state: */ 632 m_actions.value(strKey)->setChecked(!(restrictionsMenuMachine & enumValue)); 633 } 634 } 635 636 void UIMenuBarEditorWidget::updateMenuView() 637 { 638 /* Recache menu-bar configuration: */ 639 const UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionsMenuView = gEDataManager->restrictedRuntimeMenuViewActionTypes(vboxGlobal().managedVMUuid()); 640 /* Get static meta-object: */ 641 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 642 643 /* We have UIExtraDataMetaDefs::RuntimeMenuViewActionType enum registered, so we can enumerate it: */ 644 const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuViewActionType"); 645 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 646 /* Handle other enum-values: */ 647 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 648 { 649 /* Get iterated enum-value: */ 650 const UIExtraDataMetaDefs::RuntimeMenuViewActionType enumValue = 651 static_cast<const UIExtraDataMetaDefs::RuntimeMenuViewActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 652 /* Skip RuntimeMenuViewActionType_Invalid & RuntimeMenuViewActionType_All enum-value: */ 653 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid || 654 enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_All) 655 continue; 656 /* Which key required action registered under? */ 657 const QString strKey = gpConverter->toInternalString(enumValue); 658 if (!m_actions.contains(strKey)) 659 continue; 660 /* Update action 'checked' state: */ 661 m_actions.value(strKey)->setChecked(!(restrictionsMenuView & enumValue)); 662 } 663 } 664 665 void UIMenuBarEditorWidget::updateMenuDevices() 666 { 667 /* Recache menu-bar configuration: */ 668 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionsMenuDevices = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(vboxGlobal().managedVMUuid()); 669 /* Get static meta-object: */ 670 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 671 672 /* We have UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enum registered, so we can enumerate it: */ 673 const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuDevicesActionType"); 674 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 675 /* Handle other enum-values: */ 676 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 677 { 678 /* Get iterated enum-value: */ 679 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enumValue = 680 static_cast<const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 681 /* Skip RuntimeMenuDevicesActionType_Invalid & RuntimeMenuDevicesActionType_All enum-value: */ 682 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid || 683 enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All) 684 continue; 685 /* Which key required action registered under? */ 686 const QString strKey = gpConverter->toInternalString(enumValue); 687 if (!m_actions.contains(strKey)) 688 continue; 689 /* Update action 'checked' state: */ 690 m_actions.value(strKey)->setChecked(!(restrictionsMenuDevices & enumValue)); 691 } 692 } 693 694 #ifdef VBOX_WITH_DEBUGGER_GUI 695 void UIMenuBarEditorWidget::updateMenuDebug() 696 { 697 /* Recache menu-bar configuration: */ 698 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictionsMenuDebug = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(vboxGlobal().managedVMUuid()); 699 /* Get static meta-object: */ 700 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 701 702 /* We have UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enum registered, so we can enumerate it: */ 703 const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuDebuggerActionType"); 704 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 705 /* Handle other enum-values: */ 706 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 707 { 708 /* Get iterated enum-value: */ 709 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enumValue = 710 static_cast<const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 711 /* Skip RuntimeMenuDebuggerActionType_Invalid & RuntimeMenuDebuggerActionType_All enum-value: */ 712 if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid || 713 enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All) 714 continue; 715 /* Which key required action registered under? */ 716 const QString strKey = gpConverter->toInternalString(enumValue); 717 if (!m_actions.contains(strKey)) 718 continue; 719 /* Update action 'checked' state: */ 720 m_actions.value(strKey)->setChecked(!(restrictionsMenuDebug & enumValue)); 721 } 722 } 723 #endif /* VBOX_WITH_DEBUGGER_GUI */ 724 725 void UIMenuBarEditorWidget::updateMenuHelp() 726 { 727 /* Recache menu-bar configuration: */ 728 const UIExtraDataMetaDefs::MenuHelpActionType restrictionsMenuHelp = gEDataManager->restrictedRuntimeMenuHelpActionTypes(vboxGlobal().managedVMUuid()); 729 /* Get static meta-object: */ 730 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 731 732 /* We have UIExtraDataMetaDefs::MenuHelpActionType enum registered, so we can enumerate it: */ 733 const int iEnumIndex = smo.indexOfEnumerator("MenuHelpActionType"); 734 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 735 /* Handle other enum-values: */ 736 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 737 { 738 /* Get iterated enum-value: */ 739 const UIExtraDataMetaDefs::MenuHelpActionType enumValue = 740 static_cast<const UIExtraDataMetaDefs::MenuHelpActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 741 /* Skip MenuHelpActionType_Invalid & MenuHelpActionType_All enum-value: */ 742 if (enumValue == UIExtraDataMetaDefs::MenuHelpActionType_Invalid || 743 enumValue == UIExtraDataMetaDefs::MenuHelpActionType_All) 744 continue; 745 /* Which key required action registered under? */ 746 const QString strKey = gpConverter->toInternalString(enumValue); 747 if (!m_actions.contains(strKey)) 748 continue; 749 /* Update action 'checked' state: */ 750 m_actions.value(strKey)->setChecked(!(restrictionsMenuHelp & enumValue)); 751 } 752 } 753 754 void UIMenuBarEditorWidget::retranslateUi() 497 755 { 498 756 /* Translate close-button: */ … … 500 758 } 501 759 502 void UI StatusBarEditorWidget::paintEvent(QPaintEvent*)760 void UIMenuBarEditorWidget::paintEvent(QPaintEvent*) 503 761 { 504 762 /* Prepare painter: */ … … 516 774 517 775 /* Left corner: */ 518 QRadialGradient grad1(QPointF(5, 5), 5);776 QRadialGradient grad1(QPointF(5, height() - 5), 5); 519 777 { 520 778 grad1.setColorAt(0, color2); … … 522 780 } 523 781 /* Right corner: */ 524 QRadialGradient grad2(QPointF(width() - 5, 5), 5);782 QRadialGradient grad2(QPointF(width() - 5, height() - 5), 5); 525 783 { 526 784 grad2.setColorAt(0, color2); 527 785 grad2.setColorAt(1, color1); 528 786 } 529 /* Topline: */530 QLinearGradient grad3(QPointF(5, 0), QPointF(5,5));787 /* Bottom line: */ 788 QLinearGradient grad3(QPointF(5, height()), QPointF(5, height() - 5)); 531 789 { 532 790 grad3.setColorAt(0, color1); … … 534 792 } 535 793 /* Left line: */ 536 QLinearGradient grad4(QPointF(0, 5), QPointF(5,5));794 QLinearGradient grad4(QPointF(0, height() - 5), QPointF(5, height() - 5)); 537 795 { 538 796 grad4.setColorAt(0, color1); … … 540 798 } 541 799 /* Right line: */ 542 QLinearGradient grad5(QPointF(width(), 5), QPointF(width() - 5,5));800 QLinearGradient grad5(QPointF(width(), height() - 5), QPointF(width() - 5, height() - 5)); 543 801 { 544 802 grad5.setColorAt(0, color1); … … 546 804 } 547 805 806 /* Paint shape/shadow: */ 807 painter.fillRect(QRect(5, 0, width() - 5 * 2, height() - 5), color0); // background 808 painter.fillRect(QRect(0, height() - 5, 5, 5), grad1); // left corner 809 painter.fillRect(QRect(width() - 5, height() - 5, 5, 5), grad2); // right corner 810 painter.fillRect(QRect(5, height() - 5, width() - 5 * 2, 5), grad3); // bottom line 811 painter.fillRect(QRect(0, 0, 5, height() - 5), grad4); // left line 812 painter.fillRect(QRect(width() - 5, 0, 5, height() - 5), grad5); // right line 813 814 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 548 815 /* Paint frames: */ 549 painter.fillRect(QRect(5, 5, width() - 5 * 2, height() - 5), color0);550 painter.fillRect(QRect(0, 0, 5, 5), grad1);551 painter.fillRect(QRect(width() - 5, 0, 5, 5), grad2);552 painter.fillRect(QRect(5, 0, width() - 5 * 2, 5), grad3);553 painter.fillRect(QRect(0, 5, 5, height() - 5), grad4);554 painter.fillRect(QRect(width() - 5, 5, 5, height() - 5), grad5);555 #if defined(Q_WS_WIN) || defined(Q_WS_X11)556 816 painter.save(); 557 817 painter.setPen(color3); 558 painter.drawLine(QLine(QPoint(5 + 1, 5 + 1), QPoint(width() - 1 - 5 - 1, 5 + 1))); 559 painter.drawLine(QLine(QPoint(width() - 1 - 5 - 1, 5 + 1), QPoint(width() - 1 - 5 - 1, height() - 1))); 560 painter.drawLine(QLine(QPoint(width() - 1 - 5 - 1, height() - 1), QPoint(5 + 1, height() - 1))); 561 painter.drawLine(QLine(QPoint(5 + 1, height() - 1), QPoint(5 + 1, 5 + 1))); 818 painter.drawLine(QLine(QPoint(5 + 1, 0), QPoint(5 + 1, height() - 1 - 5 - 1))); 819 painter.drawLine(QLine(QPoint(5 + 1, height() - 1 - 5 - 1), QPoint(width() - 1 - 5 - 1, height() - 1 - 5 - 1))); 820 painter.drawLine(QLine(QPoint(width() - 1 - 5 - 1, height() - 1 - 5 - 1), QPoint(width() - 1 - 5 - 1, 0))); 562 821 painter.restore(); 563 822 #endif /* Q_WS_WIN || Q_WS_X11 */ 564 565 /* Paint drop token: */ 566 if (m_pButtonDropToken) 567 { 568 QStyleOption option; 569 option.state |= QStyle::State_Horizontal; 570 const QRect geo = m_pButtonDropToken->geometry(); 571 option.rect = !m_fDropAfterTokenButton ? 572 QRect(geo.topLeft() - QPoint(5, 5), 573 geo.bottomLeft() + QPoint(0, 5)) : 574 QRect(geo.topRight() - QPoint(0, 5), 575 geo.bottomRight() + QPoint(5, 5)); 576 QApplication::style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, 577 &option, &painter); 578 } 579 } 580 581 void UIStatusBarEditorWidget::dragEnterEvent(QDragEnterEvent *pEvent) 582 { 583 /* Make sure event is valid: */ 584 AssertPtrReturnVoid(pEvent); 585 /* And mime-data is set: */ 586 const QMimeData *pMimeData = pEvent->mimeData(); 587 AssertPtrReturnVoid(pMimeData); 588 /* Make sure mime-data format is valid: */ 589 if (!pMimeData->hasFormat(UIStatusBarEditorButton::MimeType)) 590 return; 591 592 /* Accept drag-enter event: */ 593 pEvent->acceptProposedAction(); 594 } 595 596 void UIStatusBarEditorWidget::dragMoveEvent(QDragMoveEvent *pEvent) 597 { 598 /* Make sure event is valid: */ 599 AssertPtrReturnVoid(pEvent); 600 /* And mime-data is set: */ 601 const QMimeData *pMimeData = pEvent->mimeData(); 602 AssertPtrReturnVoid(pMimeData); 603 /* Make sure mime-data format is valid: */ 604 if (!pMimeData->hasFormat(UIStatusBarEditorButton::MimeType)) 605 return; 606 607 /* Reset token: */ 608 m_pButtonDropToken = 0; 609 m_fDropAfterTokenButton = true; 610 611 /* Get event position: */ 612 const QPoint pos = pEvent->pos(); 613 /* Search for most suitable button: */ 614 foreach (const IndicatorType &type, m_order) 615 { 616 m_pButtonDropToken = m_buttons.value(type); 617 const QRect geo = m_pButtonDropToken->geometry(); 618 if (pos.x() < geo.center().x()) 619 { 620 m_fDropAfterTokenButton = false; 621 break; 622 } 623 } 624 /* Update: */ 625 update(); 626 } 627 628 void UIStatusBarEditorWidget::dragLeaveEvent(QDragLeaveEvent*) 629 { 630 /* Reset token: */ 631 m_pButtonDropToken = 0; 632 m_fDropAfterTokenButton = true; 633 /* Update: */ 634 update(); 635 } 636 637 void UIStatusBarEditorWidget::dropEvent(QDropEvent *pEvent) 638 { 639 /* Make sure event is valid: */ 640 AssertPtrReturnVoid(pEvent); 641 /* And mime-data is set: */ 642 const QMimeData *pMimeData = pEvent->mimeData(); 643 AssertPtrReturnVoid(pMimeData); 644 /* Make sure mime-data format is valid: */ 645 if (!pMimeData->hasFormat(UIStatusBarEditorButton::MimeType)) 646 return; 647 648 /* Make sure token-button set: */ 649 if (!m_pButtonDropToken) 650 return; 651 652 /* Determine type of token-button: */ 653 const IndicatorType tokenType = m_pButtonDropToken->type(); 654 /* Determine type of dropped-button: */ 655 const QString strDroppedType = 656 QString::fromLatin1(pMimeData->data(UIStatusBarEditorButton::MimeType)); 657 const IndicatorType droppedType = 658 gpConverter->fromInternalString<IndicatorType>(strDroppedType); 659 660 /* Make sure these types are different: */ 661 if (droppedType == tokenType) 662 return; 663 664 /* Load current status-bar indicator order and make sure it's complete: */ 665 QList<IndicatorType> order = 666 gEDataManager->statusBarIndicatorOrder(vboxGlobal().managedVMUuid()); 667 for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType) 668 if (iType != IndicatorType_Invalid && iType != IndicatorType_KeyboardExtension && 669 !order.contains((IndicatorType)iType)) 670 order << (IndicatorType)iType; 671 672 /* Remove type of dropped-button: */ 673 order.removeAll(droppedType); 674 /* Insert type of dropped-button into position of token-button: */ 675 int iPosition = order.indexOf(tokenType); 676 if (m_fDropAfterTokenButton) 677 ++iPosition; 678 order.insert(iPosition, droppedType); 679 680 /* Save updated status-bar indicator order: */ 681 gEDataManager->setStatusBarIndicatorOrder(order, vboxGlobal().managedVMUuid()); 682 } 683 684 int UIStatusBarEditorWidget::position(IndicatorType type) const 685 { 686 int iPosition = 0; 687 foreach (const IndicatorType &iteratedType, m_order) 688 if (iteratedType == type) 689 return iPosition; 690 else 691 ++iPosition; 692 return iPosition; 693 } 694 695 696 UIStatusBarEditorWindow::UIStatusBarEditorWindow(UIMachineWindow *pParent) 697 : UISlidingToolBar(pParent, pParent->statusBar(), new UIStatusBarEditorWidget) 698 { 699 } 700 701 #include "UIStatusBarEditorWindow.moc" 702 823 } 824 825 826 UIMenuBarEditorWindow::UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool) 827 : UISlidingToolBar(pParent, pParent->menuBar(), new UIMenuBarEditorWidget(pActionPool), UISlidingToolBar::Position_Top) 828 { 829 } 830 831 #include "UIMenuBarEditorWindow.moc" 832 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.h
r52395 r52478 1 1 /** @file 2 * VBox Qt GUI - UI StatusBarEditorWindow class declaration.2 * VBox Qt GUI - UIMenuBarEditorWindow class declaration. 3 3 */ 4 4 … … 15 15 */ 16 16 17 #ifndef ___UI StatusBarEditorWindow_h___18 #define ___UI StatusBarEditorWindow_h___17 #ifndef ___UIMenuBarEditorWindow_h___ 18 #define ___UIMenuBarEditorWindow_h___ 19 19 20 20 /* Qt includes: */ … … 23 23 /* Forward declarations: */ 24 24 class UIMachineWindow; 25 class UIActionPool; 25 26 26 27 /** UISlidingToolBar wrapper 27 * providing user with possibility to edit status-bar layout. */28 class UI StatusBarEditorWindow : public UISlidingToolBar28 * providing user with possibility to edit menu-bar layout. */ 29 class UIMenuBarEditorWindow : public UISlidingToolBar 29 30 { 30 31 Q_OBJECT; … … 32 33 public: 33 34 34 /** Constructor, passes @a pParent to the UISlidingToolBar constructor. */ 35 UIStatusBarEditorWindow(UIMachineWindow *pParent); 35 /** Constructor, passes @a pParent to the UISlidingToolBar constructor. 36 * @param pActionPool brings the action-pool reference for internal use. */ 37 UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool); 36 38 }; 37 39 38 #endif /* !___UI StatusBarEditorWindow_h___ */40 #endif /* !___UIMenuBarEditorWindow_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r52459 r52478 465 465 (UIExtraDataMetaDefs::RuntimeMenuViewActionType) 466 466 (UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow | 467 UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar | 467 468 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar | 468 469 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize)); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r52344 r52478 26 26 #include "UIMachineLogicNormal.h" 27 27 #include "UIMachineWindow.h" 28 #include "UIMenuBarEditorWindow.h" 28 29 #include "UIStatusBarEditorWindow.h" 29 30 #include "UIExtraDataManager.h" … … 75 76 } 76 77 78 void UIMachineLogicNormal::sltOpenMenuBarSettings() 79 { 80 /* Do not process if window(s) missed! */ 81 AssertReturnVoid(isMachineWindowsCreated()); 82 83 /* Prevent user from opening another one editor: */ 84 actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(false); 85 /* Create menu-bar editor: */ 86 UIMenuBarEditorWindow *pMenuBarEditor = new UIMenuBarEditorWindow(activeMachineWindow(), actionPool()); 87 AssertPtrReturnVoid(pMenuBarEditor); 88 { 89 /* Configure menu-bar editor: */ 90 connect(pMenuBarEditor, SIGNAL(destroyed(QObject*)), 91 this, SLOT(sltMenuBarSettingsClosed())); 92 #ifdef Q_WS_MAC 93 connect(this, SIGNAL(sigNotifyAbout3DOverlayVisibilityChange(bool)), 94 pMenuBarEditor, SLOT(sltActivateWindow())); 95 #endif /* Q_WS_MAC */ 96 /* Show window: */ 97 pMenuBarEditor->show(); 98 } 99 } 100 101 void UIMachineLogicNormal::sltMenuBarSettingsClosed() 102 { 103 /* Allow user to open editor again: */ 104 actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(true); 105 } 106 77 107 void UIMachineLogicNormal::sltOpenStatusBarSettings() 78 108 { … … 164 194 connect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), SIGNAL(triggered(bool)), 165 195 this, SLOT(sltChangeVisualStateToScale())); 196 connect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings), SIGNAL(triggered(bool)), 197 this, SLOT(sltOpenMenuBarSettings())); 166 198 connect(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings), SIGNAL(triggered(bool)), 167 199 this, SLOT(sltOpenStatusBarSettings())); … … 228 260 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), SIGNAL(triggered(bool)), 229 261 this, SLOT(sltChangeVisualStateToScale())); 262 disconnect(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings), SIGNAL(triggered(bool)), 263 this, SLOT(sltOpenMenuBarSettings())); 230 264 disconnect(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings), SIGNAL(triggered(bool)), 231 265 this, SLOT(sltOpenStatusBarSettings())); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h
r52344 r52478 43 43 44 44 /* View menu functionality: */ 45 void sltOpenMenuBarSettings(); 46 void sltMenuBarSettingsClosed(); 45 47 void sltOpenStatusBarSettings(); 46 48 void sltStatusBarSettingsClosed(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp
r52459 r52478 78 78 (UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow | 79 79 UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize | 80 UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar | 80 81 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar | 81 82 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize)); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
r52459 r52478 211 211 (UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow | 212 212 UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize | 213 UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar | 213 214 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar | 214 215 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize));
Note:
See TracChangeset
for help on using the changeset viewer.