Changeset 54272 in vbox
- Timestamp:
- Feb 18, 2015 4:45:36 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r52937 r54272 80 80 template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(); 81 81 #endif /* VBOX_WITH_DEBUGGER_GUI */ 82 #ifdef Q_WS_MAC 83 template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>(); 84 #endif /* Q_WS_MAC */ 82 85 template<> bool canConvert<UIVisualStateType>(); 83 86 template<> bool canConvert<DetailsElementType>(); … … 125 128 template<> UIExtraDataMetaDefs::MenuType fromInternalString<UIExtraDataMetaDefs::MenuType>(const QString &strMenuType); 126 129 #ifdef Q_WS_MAC 127 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType & runtimeMenuApplicationActionType);128 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &str RuntimeMenuApplicationActionType);130 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &menuApplicationActionType); 131 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strMenuApplicationActionType); 129 132 #endif /* Q_WS_MAC */ 130 133 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuHelpActionType &menuHelpActionType); … … 142 145 template<> UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType fromInternalString<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(const QString &strRuntimeMenuDebuggerActionType); 143 146 #endif /* VBOX_WITH_DEBUGGER_GUI */ 147 #ifdef Q_WS_MAC 148 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuWindowActionType &menuWindowActionType); 149 template<> UIExtraDataMetaDefs::MenuWindowActionType fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(const QString &strMenuWindowActionType); 150 #endif /* Q_WS_MAC */ 144 151 template<> QString toInternalString(const UIVisualStateType &visualStateType); 145 152 template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r54228 r54272 51 51 template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>() { return true; } 52 52 #endif /* VBOX_WITH_DEBUGGER_GUI */ 53 #ifdef Q_WS_MAC 54 template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>() { return true; } 55 #endif /* Q_WS_MAC */ 53 56 template<> bool canConvert<UIVisualStateType>() { return true; } 54 57 template<> bool canConvert<DetailsElementType>() { return true; } … … 379 382 case UIExtraDataMetaDefs::MenuType_Debug: strResult = "Debug"; break; 380 383 #endif /* VBOX_WITH_DEBUGGER_GUI */ 384 #ifdef RT_OS_DARWIN 385 case UIExtraDataMetaDefs::MenuType_Window: strResult = "Window"; break; 386 #endif /* RT_OS_DARWIN */ 381 387 case UIExtraDataMetaDefs::MenuType_Help: strResult = "Help"; break; 382 388 case UIExtraDataMetaDefs::MenuType_All: strResult = "All"; break; … … 406 412 keys << "Debug"; values << UIExtraDataMetaDefs::MenuType_Debug; 407 413 #endif /* VBOX_WITH_DEBUGGER_GUI */ 414 #ifdef RT_OS_DARWIN 415 keys << "Window"; values << UIExtraDataMetaDefs::MenuType_Window; 416 #endif /* RT_OS_DARWIN */ 408 417 keys << "Help"; values << UIExtraDataMetaDefs::MenuType_Help; 409 418 keys << "All"; values << UIExtraDataMetaDefs::MenuType_All; … … 417 426 #ifdef Q_WS_MAC 418 427 /* QString <= UIExtraDataMetaDefs::MenuApplicationActionType: */ 419 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType & runtimeMenuApplicationActionType)420 { 421 QString strResult; 422 switch ( runtimeMenuApplicationActionType)428 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &menuApplicationActionType) 429 { 430 QString strResult; 431 switch (menuApplicationActionType) 423 432 { 424 433 case UIExtraDataMetaDefs::MenuApplicationActionType_About: strResult = "About"; break; … … 428 437 default: 429 438 { 430 AssertMsgFailed(("No text for action type=%d", runtimeMenuApplicationActionType));439 AssertMsgFailed(("No text for action type=%d", menuApplicationActionType)); 431 440 break; 432 441 } … … 436 445 437 446 /* UIExtraDataMetaDefs::MenuApplicationActionType <= QString: */ 438 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &str RuntimeMenuApplicationActionType)447 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strMenuApplicationActionType) 439 448 { 440 449 /* Here we have some fancy stuff allowing us … … 446 455 keys << "All"; values << UIExtraDataMetaDefs::MenuApplicationActionType_All; 447 456 /* Invalid type for unknown words: */ 448 if (!keys.contains(str RuntimeMenuApplicationActionType, Qt::CaseInsensitive))457 if (!keys.contains(strMenuApplicationActionType, Qt::CaseInsensitive)) 449 458 return UIExtraDataMetaDefs::MenuApplicationActionType_Invalid; 450 459 /* Corresponding type for known words: */ 451 return values.at(keys.indexOf(QRegExp(str RuntimeMenuApplicationActionType, Qt::CaseInsensitive)));460 return values.at(keys.indexOf(QRegExp(strMenuApplicationActionType, Qt::CaseInsensitive))); 452 461 } 453 462 #endif /* Q_WS_MAC */ … … 773 782 #endif /* VBOX_WITH_DEBUGGER_GUI */ 774 783 784 #ifdef Q_WS_MAC 785 /* QString <= UIExtraDataMetaDefs::MenuWindowActionType: */ 786 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuWindowActionType &menuWindowActionType) 787 { 788 QString strResult; 789 switch (menuWindowActionType) 790 { 791 case UIExtraDataMetaDefs::MenuWindowActionType_Minimize: strResult = "Minimize"; break; 792 case UIExtraDataMetaDefs::MenuWindowActionType_Switch: strResult = "Switch"; break; 793 case UIExtraDataMetaDefs::MenuWindowActionType_All: strResult = "All"; break; 794 default: 795 { 796 AssertMsgFailed(("No text for action type=%d", menuWindowActionType)); 797 break; 798 } 799 } 800 return strResult; 801 } 802 803 /* UIExtraDataMetaDefs::MenuWindowActionType <= QString: */ 804 template<> UIExtraDataMetaDefs::MenuWindowActionType fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(const QString &strMenuWindowActionType) 805 { 806 /* Here we have some fancy stuff allowing us 807 * to search through the keys using 'case-insensitive' rule: */ 808 QStringList keys; QList<UIExtraDataMetaDefs::MenuWindowActionType> values; 809 keys << "Minimize"; values << UIExtraDataMetaDefs::MenuWindowActionType_Minimize; 810 keys << "Switch"; values << UIExtraDataMetaDefs::MenuWindowActionType_Switch; 811 keys << "All"; values << UIExtraDataMetaDefs::MenuWindowActionType_All; 812 /* Invalid type for unknown words: */ 813 if (!keys.contains(strMenuWindowActionType, Qt::CaseInsensitive)) 814 return UIExtraDataMetaDefs::MenuWindowActionType_Invalid; 815 /* Corresponding type for known words: */ 816 return values.at(keys.indexOf(QRegExp(strMenuWindowActionType, Qt::CaseInsensitive))); 817 } 818 #endif /* Q_WS_MAC */ 819 775 820 /* QString <= UIVisualStateType: */ 776 821 template<> QString toInternalString(const UIVisualStateType &visualStateType) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r53447 r54272 100 100 const char* UIExtraDataDefs::GUI_RestrictedRuntimeDebuggerMenuActions = "GUI/RestrictedRuntimeDebuggerMenuActions"; 101 101 #endif /* VBOX_WITH_DEBUGGER_GUI */ 102 #ifdef Q_WS_MAC 103 const char* UIExtraDataDefs::GUI_RestrictedRuntimeWindowMenuActions = "GUI/RestrictedRuntimeWindowMenuActions"; 104 #endif /* Q_WS_MAC */ 102 105 const char* UIExtraDataDefs::GUI_RestrictedRuntimeHelpMenuActions = "GUI/RestrictedRuntimeHelpMenuActions"; 103 106 const char* UIExtraDataDefs::GUI_RestrictedVisualStates = "GUI/RestrictedVisualStates"; -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r54228 r54272 153 153 extern const char* GUI_RestrictedRuntimeMenus; 154 154 #ifdef Q_WS_MAC 155 /** Mac OS X: Holds restricted Runtime UI action types for Applicationmenu. */155 /** Mac OS X: Holds restricted Runtime UI action types for 'Application' menu. */ 156 156 extern const char* GUI_RestrictedRuntimeApplicationMenuActions; 157 157 #endif /* Q_WS_MAC */ … … 168 168 extern const char* GUI_RestrictedRuntimeDebuggerMenuActions; 169 169 #endif /* VBOX_WITH_DEBUGGER_GUI */ 170 #ifdef Q_WS_MAC 171 /** Mac OS X: Holds restricted Runtime UI action types for 'Window' menu. */ 172 extern const char* GUI_RestrictedRuntimeWindowMenuActions; 173 #endif /* Q_WS_MAC */ 170 174 /** Holds restricted Runtime UI action types for Help menu. */ 171 175 extern const char* GUI_RestrictedRuntimeHelpMenuActions; … … 298 302 Q_ENUMS(RuntimeMenuDebuggerActionType); 299 303 #endif /* VBOX_WITH_DEBUGGER_GUI */ 304 #ifdef RT_OS_DARWIN 305 Q_ENUMS(MenuWindowActionType); 306 #endif /* RT_OS_DARWIN */ 300 307 301 308 public: … … 315 322 MenuType_Debug = RT_BIT(5), 316 323 #endif /* VBOX_WITH_DEBUGGER_GUI */ 317 MenuType_Help = RT_BIT(6), 324 #ifdef RT_OS_DARWIN 325 MenuType_Window = RT_BIT(6), 326 #endif /* RT_OS_DARWIN */ 327 MenuType_Help = RT_BIT(7), 318 328 MenuType_All = 0xFF 319 329 }; … … 443 453 }; 444 454 #endif /* VBOX_WITH_DEBUGGER_GUI */ 455 456 #ifdef RT_OS_DARWIN 457 /** Menu "Window": Action types. */ 458 enum MenuWindowActionType 459 { 460 MenuWindowActionType_Invalid = 0, 461 MenuWindowActionType_Minimize = RT_BIT(0), 462 MenuWindowActionType_Switch = RT_BIT(1), 463 MenuWindowActionType_All = 0xFFFF 464 }; 465 #endif /* RT_OS_DARWIN */ 445 466 }; 446 467 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r54151 r54272 1766 1766 << GUI_RestrictedRuntimeDebuggerMenuActions 1767 1767 #endif /* VBOX_WITH_DEBUGGER_GUI */ 1768 #ifdef Q_WS_MAC 1769 << GUI_RestrictedRuntimeWindowMenuActions 1770 #endif /* Q_WS_MAC */ 1768 1771 << GUI_RestrictedRuntimeHelpMenuActions 1769 1772 << GUI_RestrictedVisualStates … … 2884 2887 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2885 2888 2889 #ifdef Q_WS_MAC 2890 UIExtraDataMetaDefs::MenuWindowActionType UIExtraDataManager::restrictedRuntimeMenuWindowActionTypes(const QString &strID) 2891 { 2892 /* Prepare result: */ 2893 UIExtraDataMetaDefs::MenuWindowActionType result = UIExtraDataMetaDefs::MenuWindowActionType_Invalid; 2894 /* Get restricted runtime-window-menu action-types: */ 2895 foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeWindowMenuActions, strID)) 2896 { 2897 UIExtraDataMetaDefs::MenuWindowActionType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(strValue); 2898 if (value != UIExtraDataMetaDefs::MenuWindowActionType_Invalid) 2899 result = static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(result | value); 2900 } 2901 /* Return result: */ 2902 return result; 2903 } 2904 2905 void UIExtraDataManager::setRestrictedRuntimeMenuWindowActionTypes(UIExtraDataMetaDefs::MenuWindowActionType types, const QString &strID) 2906 { 2907 /* We have MenuWindowActionType enum registered, so we can enumerate it: */ 2908 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 2909 const int iEnumIndex = smo.indexOfEnumerator("MenuWindowActionType"); 2910 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 2911 2912 /* Prepare result: */ 2913 QStringList result; 2914 /* Handle MenuWindowActionType_All enum-value: */ 2915 if (types == UIExtraDataMetaDefs::MenuWindowActionType_All) 2916 result << gpConverter->toInternalString(types); 2917 else 2918 { 2919 /* Handle other enum-values: */ 2920 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 2921 { 2922 /* Get iterated enum-value: */ 2923 const UIExtraDataMetaDefs::MenuWindowActionType enumValue = 2924 static_cast<const UIExtraDataMetaDefs::MenuWindowActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 2925 /* Skip MenuWindowActionType_Invalid & MenuWindowActionType_All enum-values: */ 2926 if (enumValue == UIExtraDataMetaDefs::MenuWindowActionType_Invalid || 2927 enumValue == UIExtraDataMetaDefs::MenuWindowActionType_All) 2928 continue; 2929 if (types & enumValue) 2930 result << gpConverter->toInternalString(enumValue); 2931 } 2932 } 2933 /* Save result: */ 2934 setExtraDataStringList(GUI_RestrictedRuntimeWindowMenuActions, result, strID); 2935 } 2936 #endif /* Q_WS_MAC */ 2937 2886 2938 UIExtraDataMetaDefs::MenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID) 2887 2939 { … … 3586 3638 strKey == GUI_RestrictedRuntimeDebuggerMenuActions || 3587 3639 #endif /* VBOX_WITH_DEBUGGER_GUI */ 3640 #ifdef Q_WS_MAC 3641 strKey == GUI_RestrictedRuntimeWindowMenuActions || 3642 #endif /* Q_WS_MAC */ 3588 3643 strKey == GUI_RestrictedRuntimeHelpMenuActions) 3589 3644 emit sigMenuBarConfigurationChange(strMachineID); -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r53861 r54272 344 344 #endif /* VBOX_WITH_DEBUGGER_GUI */ 345 345 346 #ifdef Q_WS_MAC 347 /** Mac OS X: Returns restricted Runtime UI action types for Window menu. */ 348 UIExtraDataMetaDefs::MenuWindowActionType restrictedRuntimeMenuWindowActionTypes(const QString &strID); 349 /** Mac OS X: Defines restricted Runtime UI action types for Window menu. */ 350 void setRestrictedRuntimeMenuWindowActionTypes(UIExtraDataMetaDefs::MenuWindowActionType types, const QString &strID); 351 #endif /* Q_WS_MAC */ 352 346 353 /** Returns restricted Runtime UI action types for Help menu. */ 347 354 UIExtraDataMetaDefs::MenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r53305 r54272 382 382 } 383 383 }; 384 385 class UIActionMenuWindow : public UIActionMenu 386 { 387 Q_OBJECT; 388 389 public: 390 391 UIActionMenuWindow(UIActionPool *pParent) 392 : UIActionMenu(pParent) {} 393 394 protected: 395 396 /** Returns action extra-data ID. */ 397 virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Window; } 398 /** Returns action extra-data key. */ 399 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Window); } 400 /** Returns whether action is allowed. */ 401 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Window); } 402 403 void retranslateUi() 404 { 405 setName(QApplication::translate("UIActionPool", "&Window")); 406 } 407 }; 408 409 class UIActionSimpleMinimize : public UIActionSimple 410 { 411 Q_OBJECT; 412 413 public: 414 415 UIActionSimpleMinimize(UIActionPool *pParent) 416 : UIActionSimple(pParent) {} 417 418 protected: 419 420 /** Returns action extra-data ID. */ 421 virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuWindowActionType_Minimize; } 422 /** Returns action extra-data key. */ 423 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); } 424 /** Returns whether action is allowed. */ 425 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); } 426 427 QString shortcutExtraDataID() const 428 { 429 return QString("Minimize"); 430 } 431 432 void retranslateUi() 433 { 434 setName(QApplication::translate("UIActionPool", "&Minimize")); 435 setStatusTip(QApplication::translate("UIActionPool", "Minimize active machine-window")); 436 } 437 }; 384 438 #endif /* RT_OS_DARWIN */ 385 439 … … 792 846 m_restrictedActionsMenuApplication[level] = restriction; 793 847 m_invalidations << UIActionIndex_M_Application; 848 } 849 850 bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const 851 { 852 foreach (const UIExtraDataMetaDefs::MenuWindowActionType &restriction, m_restrictedActionsMenuWindow.values()) 853 if (restriction & type) 854 return false; 855 return true; 856 } 857 858 void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction) 859 { 860 m_restrictedActionsMenuWindow[level] = restriction; 861 m_invalidations << UIActionIndex_M_Window; 794 862 } 795 863 #endif /* Q_WS_MAC */ … … 848 916 m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this); 849 917 m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this); 918 919 /* Create 'Window' actions: */ 920 m_pool[UIActionIndex_M_Window] = new UIActionMenuWindow(this); 921 m_pool[UIActionIndex_M_Window_S_Minimize] = new UIActionSimpleMinimize(this); 850 922 #endif /* RT_OS_DARWIN */ 851 923 … … 867 939 #ifdef RT_OS_DARWIN 868 940 m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication; 941 m_menuUpdateHandlers[UIActionIndex_M_Window].ptf = &UIActionPool::updateMenuWindow; 869 942 #endif /* RT_OS_DARWIN */ 870 943 m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp; … … 995 1068 m_invalidations.remove(UIActionIndex_M_Application); 996 1069 } 1070 1071 void UIActionPool::updateMenuWindow() 1072 { 1073 /* Get corresponding menu: */ 1074 UIMenu *pMenu = action(UIActionIndex_M_Window)->menu(); 1075 AssertPtrReturnVoid(pMenu); 1076 /* Clear contents: */ 1077 pMenu->clear(); 1078 1079 /* Separator: */ 1080 bool fSeparator = false; 1081 1082 /* 'Minimize' action: */ 1083 fSeparator = addAction(pMenu, action(UIActionIndex_M_Window_S_Minimize)) || fSeparator; 1084 1085 /* Separator: */ 1086 if (fSeparator) 1087 { 1088 pMenu->addSeparator(); 1089 fSeparator = false; 1090 } 1091 1092 /* This menu always remains invalid.. */ 1093 } 997 1094 #endif /* RT_OS_DARWIN */ 998 1095 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r52589 r54272 58 58 UIActionIndex_M_Application_S_Preferences, 59 59 UIActionIndex_M_Application_S_Close, 60 61 /* 'Window' menu actions: */ 62 UIActionIndex_M_Window, 63 UIActionIndex_M_Window_S_Minimize, 60 64 #endif /* RT_OS_DARWIN */ 61 65 … … 367 371 /** Defines 'Application' menu @a restriction for passed @a level. */ 368 372 void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction); 373 374 /** Returns whether the action with passed @a type is allowed in the 'Window' menu. */ 375 bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const; 376 /** Defines 'Window' menu @a restriction for passed @a level. */ 377 void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction); 369 378 #endif /* Q_WS_MAC */ 370 379 … … 419 428 /** Update 'Application' menu routine. */ 420 429 virtual void updateMenuApplication(); 430 /** Update 'Window' menu routine. */ 431 virtual void updateMenuWindow(); 421 432 #endif /* RT_OS_DARWIN */ 422 433 /** Update 'Help' menu routine. */ … … 452 463 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus; 453 464 #ifdef Q_WS_MAC 454 /** Holds restricted action types of the Applicationmenu. */465 /** Holds restricted action types of the 'Application' menu. */ 455 466 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication; 467 /** Holds restricted action types of the 'Window' menu. */ 468 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow; 456 469 #endif /* Q_WS_MAC */ 457 470 /** Holds restricted action types of the Help menu. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r53406 r54272 2125 2125 m_restrictedActionsMenuDebug[UIActionRestrictionLevel_Base] = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(strMachineID); 2126 2126 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2127 #ifdef Q_WS_MAC 2128 m_restrictedActionsMenuWindow[UIActionRestrictionLevel_Base] = gEDataManager->restrictedRuntimeMenuWindowActionTypes(strMachineID); 2129 #endif /* Q_WS_MAC */ 2127 2130 m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] = gEDataManager->restrictedRuntimeMenuHelpActionTypes(strMachineID); 2128 2131 … … 2248 2251 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2249 2252 2253 #ifdef RT_OS_DARWIN 2254 /* 'Window' menu: */ 2255 addMenu(m_mainMenus, action(UIActionIndex_M_Window)); 2256 updateMenuWindow(); 2257 #endif /* RT_OS_DARWIN */ 2258 2250 2259 /* 'Help' menu: */ 2251 2260 addMenu(m_mainMenus, action(UIActionIndex_Menu_Help)); … … 2365 2374 const bool fAllowToShowActionResize = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize); 2366 2375 const bool fAllowToShowActionMultiscreen = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Multiscreen); 2367 if (fAllowToShowActionResize && session())2368 { 2369 for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)2376 if (fAllowToShowActionResize && uisession()) 2377 { 2378 for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex) 2370 2379 { 2371 2380 /* Add 'Virtual Screen %1' menu: */ … … 2379 2388 { 2380 2389 /* Only for multi-screen host case: */ 2381 if ( session()->hostScreens().size() > 1)2390 if (uisession()->hostScreens().size() > 1) 2382 2391 { 2383 for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)2392 for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex) 2384 2393 { 2385 2394 /* Add 'Virtual Screen %1' menu: */ … … 2425 2434 /* Do we have to show resize menu? */ 2426 2435 const bool fAllowToShowActionResize = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize); 2427 if (fAllowToShowActionResize && session())2428 { 2429 for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)2436 if (fAllowToShowActionResize && uisession()) 2437 { 2438 for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex) 2430 2439 { 2431 2440 /* Add 'Virtual Screen %1' menu: */ … … 2527 2536 { 2528 2537 /* Make sure UI session defined: */ 2529 AssertPtrReturnVoid( session());2538 AssertPtrReturnVoid(uisession()); 2530 2539 2531 2540 /* Clear contents: */ … … 2548 2557 /* Get corresponding screen index and frame-buffer size: */ 2549 2558 const int iGuestScreenIndex = pMenu->property("Guest Screen Index").toInt(); 2550 const UIFrameBuffer* pFrameBuffer = session()->frameBuffer(iGuestScreenIndex);2559 const UIFrameBuffer* pFrameBuffer = uisession()->frameBuffer(iGuestScreenIndex); 2551 2560 const QSize screenSize = QSize(pFrameBuffer->width(), pFrameBuffer->height()); 2552 const bool fScreenEnabled = session()->isScreenVisible(iGuestScreenIndex);2561 const bool fScreenEnabled = uisession()->isScreenVisible(iGuestScreenIndex); 2553 2562 2554 2563 /* For non-primary screens: */ … … 2561 2570 { 2562 2571 /* Configure 'toggle' action: */ 2563 pToggleAction->setEnabled( session()->isGuestSupportsGraphics());2572 pToggleAction->setEnabled(uisession()->isGuestSupportsGraphics()); 2564 2573 pToggleAction->setProperty("Guest Screen Index", iGuestScreenIndex); 2565 2574 pToggleAction->setCheckable(true); … … 2585 2594 { 2586 2595 /* Configure exclusive 'resize' action: */ 2587 pAction->setEnabled( session()->isGuestSupportsGraphics() && fScreenEnabled);2596 pAction->setEnabled(uisession()->isGuestSupportsGraphics() && fScreenEnabled); 2588 2597 pAction->setProperty("Guest Screen Index", iGuestScreenIndex); 2589 2598 pAction->setProperty("Requested Size", size); … … 2619 2628 /* Configure exclusive action-group: */ 2620 2629 pActionGroup->setExclusive(true); 2621 for (int iHostScreenIndex = 0; iHostScreenIndex < session()->hostScreens().size(); ++iHostScreenIndex)2630 for (int iHostScreenIndex = 0; iHostScreenIndex < uisession()->hostScreens().size(); ++iHostScreenIndex) 2622 2631 { 2623 2632 QAction *pAction = pActionGroup->addAction(UIMultiScreenLayout::tr("Use Host Screen %1") -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r53406 r54272 144 144 void setSession(UISession *pSession); 145 145 /** Returns UI session object reference. */ 146 UISession* session() const { return m_pSession; }146 UISession* uisession() const { return m_pSession; } 147 147 148 148 /** Defines UI multi-screen layout object reference. -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r54223 r54272 956 956 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_S_Settings)); 957 957 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Devices_S_InstallGuestTools)); 958 #ifdef Q_WS_MAC 959 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndex_M_Window)); 960 m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndex_M_Window_S_Minimize)); 961 #endif /* Q_WS_MAC */ 958 962 959 963 /* Move actions into running-n-paused-n-stucked actions group: */ … … 1039 1043 #endif /* VBOX_WITH_DEBUGGER_GUI */ 1040 1044 1045 #ifdef Q_WS_MAC 1046 /* 'Window' action connections: */ 1047 connect(actionPool()->action(UIActionIndex_M_Window_S_Minimize), SIGNAL(triggered()), 1048 this, SLOT(sltMinimizeActiveMachineWindow())); 1049 #endif /* Q_WS_MAC */ 1050 1041 1051 /* 'Help' actions connections: */ 1042 1052 #ifdef RT_OS_DARWIN … … 1062 1072 m_menuUpdateHandlers[UIActionIndexRT_M_Debug] = &UIMachineLogic::updateMenuDebug; 1063 1073 #endif /* VBOX_WITH_DEBUGGER_GUI */ 1074 #ifdef Q_WS_MAC 1075 m_menuUpdateHandlers[UIActionIndex_M_Window] = &UIMachineLogic::updateMenuWindow; 1076 #endif /* Q_WS_MAC */ 1064 1077 1065 1078 /* Create keyboard/mouse handlers: */ … … 1921 1934 1922 1935 #ifdef Q_WS_MAC 1936 void UIMachineLogic::sltMinimizeActiveMachineWindow() 1937 { 1938 /* Minimize active machine-window: */ 1939 AssertPtrReturnVoid(activeMachineWindow()); 1940 activeMachineWindow()->showMinimized(); 1941 } 1942 1943 void UIMachineLogic::sltSwitchToMachineWindow() 1944 { 1945 /* Acquire appropriate sender action: */ 1946 const QAction *pSender = qobject_cast<QAction*>(sender()); 1947 AssertReturnVoid(pSender); 1948 { 1949 /* Determine sender action index: */ 1950 const int iIndex = pSender->data().toInt(); 1951 AssertReturnVoid(iIndex >= 0 && iIndex < machineWindows().size()); 1952 { 1953 /* Raise appropriate machine-window: */ 1954 UIMachineWindow *pMachineWindow = machineWindows().at(iIndex); 1955 AssertPtrReturnVoid(pMachineWindow); 1956 { 1957 pMachineWindow->show(); 1958 pMachineWindow->raise(); 1959 pMachineWindow->activateWindow(); 1960 } 1961 } 1962 } 1963 } 1964 1923 1965 void UIMachineLogic::sltDockPreviewModeChanged(QAction *pAction) 1924 1966 { … … 2271 2313 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2272 2314 2315 #ifdef Q_WS_MAC 2316 void UIMachineLogic::updateMenuWindow(QMenu *pMenu) 2317 { 2318 /* Make sure 'Switch' action(s) are allowed: */ 2319 AssertPtrReturnVoid(actionPool()); 2320 if (actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Switch)) 2321 { 2322 /* Append menu with actions to switch to machine-window(s): */ 2323 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 2324 { 2325 /* Create machine-window action: */ 2326 AssertPtrReturnVoid(pMachineWindow); 2327 QAction *pMachineWindowAction = pMenu->addAction(pMachineWindow->windowTitle(), 2328 this, SLOT(sltSwitchToMachineWindow())); 2329 AssertPtrReturnVoid(pMachineWindowAction); 2330 { 2331 pMachineWindowAction->setCheckable(true); 2332 pMachineWindowAction->setChecked(activeMachineWindow() == pMachineWindow); 2333 pMachineWindowAction->setData((int)pMachineWindow->screenId()); 2334 } 2335 } 2336 } 2337 } 2338 #endif /* Q_WS_MAC */ 2339 2273 2340 void UIMachineLogic::showGlobalPreferences(const QString &strCategory /* = QString() */, const QString &strControl /* = QString() */) 2274 2341 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r54151 r54272 286 286 287 287 #ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */ 288 /* "Window" menu functionality: */ 289 void sltMinimizeActiveMachineWindow(); 290 void sltSwitchToMachineWindow(); 291 292 /* "Dock" menu functionality: */ 288 293 void sltDockPreviewModeChanged(QAction *pAction); 289 294 void sltDockPreviewMonitorChanged(QAction *pAction); … … 317 322 void updateMenuDebug(QMenu *pMenu); 318 323 #endif /* VBOX_WITH_DEBUGGER_GUI */ 324 #ifdef Q_WS_MAC 325 /** Update 'Window' menu routine. */ 326 void updateMenuWindow(QMenu *pMenu); 327 #endif /* Q_WS_MAC */ 319 328 320 329 /** Show Global Preferences on the page defined by @a strCategory and tab defined by @a strControl. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp
r54079 r54272 189 189 } 190 190 #endif /* VBOX_WITH_DEBUGGER_GUI */ 191 #ifdef Q_WS_MAC 192 case UIExtraDataMetaDefs::MenuType_Window: 193 { 194 /* Get sender type: */ 195 const UIExtraDataMetaDefs::MenuWindowActionType type = 196 static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(pAction->property("type").toInt()); 197 /* Load current menu-bar restrictions: */ 198 UIExtraDataMetaDefs::MenuWindowActionType restrictions = gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()); 199 /* Invert restriction for sender type: */ 200 restrictions = (UIExtraDataMetaDefs::MenuWindowActionType)(restrictions ^ type); 201 /* Save updated menu-bar restrictions: */ 202 gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(restrictions, machineID()); 203 break; 204 } 205 #endif /* Q_WS_MAC */ 191 206 case UIExtraDataMetaDefs::MenuType_Help: 192 207 { … … 281 296 prepareMenuDebug(); 282 297 #endif /* VBOX_WITH_DEBUGGER_GUI */ 298 #ifdef Q_WS_MAC 299 prepareMenuWindow(); 300 #endif /* Q_WS_MAC */ 283 301 prepareMenuHelp(); 284 302 … … 541 559 #endif /* VBOX_WITH_DEBUGGER_GUI */ 542 560 561 #ifdef Q_WS_MAC 562 void UIMenuBarEditorWidget::prepareMenuWindow() 563 { 564 /* Copy menu: */ 565 QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_M_Window)); 566 AssertPtrReturnVoid(pMenu); 567 { 568 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Window_S_Minimize)); 569 prepareNamedAction(pMenu, tr("Switch"), 570 UIExtraDataMetaDefs::MenuWindowActionType_Switch, 571 gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Switch)); 572 } 573 } 574 #endif /* Q_WS_MAC */ 575 543 576 void UIMenuBarEditorWidget::prepareMenuHelp() 544 577 { … … 602 635 updateMenuDebug(); 603 636 #endif /* VBOX_WITH_DEBUGGER_GUI */ 637 #ifdef Q_WS_MAC 638 updateMenuWindow(); 639 #endif /* Q_WS_MAC */ 604 640 updateMenuHelp(); 605 641 } … … 782 818 } 783 819 #endif /* VBOX_WITH_DEBUGGER_GUI */ 820 821 #ifdef Q_WS_MAC 822 void UIMenuBarEditorWidget::updateMenuWindow() 823 { 824 /* Recache menu-bar configuration: */ 825 const UIExtraDataMetaDefs::MenuWindowActionType restrictionsMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()); 826 /* Get static meta-object: */ 827 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject; 828 829 /* We have UIExtraDataMetaDefs::MenuWindowActionType enum registered, so we can enumerate it: */ 830 const int iEnumIndex = smo.indexOfEnumerator("MenuWindowActionType"); 831 QMetaEnum metaEnum = smo.enumerator(iEnumIndex); 832 /* Handle other enum-values: */ 833 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex) 834 { 835 /* Get iterated enum-value: */ 836 const UIExtraDataMetaDefs::MenuWindowActionType enumValue = 837 static_cast<const UIExtraDataMetaDefs::MenuWindowActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex))); 838 /* Skip MenuWindowActionType_Invalid & MenuWindowActionType_All enum-value: */ 839 if (enumValue == UIExtraDataMetaDefs::MenuWindowActionType_Invalid || 840 enumValue == UIExtraDataMetaDefs::MenuWindowActionType_All) 841 continue; 842 /* Which key required action registered under? */ 843 const QString strKey = gpConverter->toInternalString(enumValue); 844 if (!m_actions.contains(strKey)) 845 continue; 846 /* Update action 'checked' state: */ 847 m_actions.value(strKey)->setChecked(!(restrictionsMenuWindow & enumValue)); 848 } 849 } 850 #endif /* Q_WS_MAC */ 784 851 785 852 void UIMenuBarEditorWidget::updateMenuHelp() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.h
r53321 r54272 128 128 void prepareMenuDebug(); 129 129 #endif /* VBOX_WITH_DEBUGGER_GUI */ 130 #ifdef Q_WS_MAC 131 /** Mac OS X: Prepare 'Window' menu routine. */ 132 void prepareMenuWindow(); 133 #endif /* Q_WS_MAC */ 130 134 /** Prepare 'Help' menu routine. */ 131 135 void prepareMenuHelp(); … … 149 153 void updateMenuDebug(); 150 154 #endif /* VBOX_WITH_DEBUGGER_GUI */ 155 #ifdef Q_WS_MAC 156 /** Mac OS X: Updates 'Window' menu routine. */ 157 void updateMenuWindow(); 158 #endif /* Q_WS_MAC */ 151 159 /** Updates 'Help' menu routine. */ 152 160 void updateMenuHelp(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r54160 r54272 458 458 UIMachineLogic* UISession::machineLogic() const 459 459 { 460 return uimachine() ->machineLogic();460 return uimachine() ? uimachine()->machineLogic() : 0; 461 461 } 462 462 463 463 QWidget* UISession::mainMachineWindow() const 464 464 { 465 return machineLogic() ->mainMachineWindow();465 return machineLogic() ? machineLogic()->mainMachineWindow() : 0; 466 466 } 467 467 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r54160 r54272 474 474 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar | 475 475 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize)); 476 #ifdef Q_WS_MAC 477 /* Restrict 'Window' menu: */ 478 actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic, 479 UIExtraDataMetaDefs::MenuType_Window); 480 #endif /* Q_WS_MAC */ 476 481 477 482 /* Take care of view-action toggle state: */ … … 666 671 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic, 667 672 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid); 673 #ifdef Q_WS_MAC 674 /* Allow 'Window' menu: */ 675 actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic, 676 UIExtraDataMetaDefs::MenuType_Invalid); 677 #endif /* Q_WS_MAC */ 668 678 669 679 /* Call to base-class: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
r54160 r54272 220 220 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar | 221 221 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize)); 222 #ifdef Q_WS_MAC 223 /* Restrict 'Window' menu: */ 224 actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic, 225 UIExtraDataMetaDefs::MenuType_Window); 226 #endif /* Q_WS_MAC */ 222 227 223 228 /* Take care of view-action toggle state: */ … … 346 351 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic, 347 352 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid); 353 #ifdef Q_WS_MAC 354 /* Allow 'Window' menu: */ 355 actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic, 356 UIExtraDataMetaDefs::MenuType_Invalid); 357 #endif /* Q_WS_MAC */ 348 358 349 359 /* Call to base-class: */
Note:
See TracChangeset
for help on using the changeset viewer.