Changeset 52215 in vbox
- Timestamp:
- Jul 28, 2014 6:24:57 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95278
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r52190 r52215 70 70 template<> bool canConvert<SizeSuffix>(); 71 71 template<> bool canConvert<StorageSlot>(); 72 template<> bool canConvert<MenuHelpActionType>(); 72 73 template<> bool canConvert<RuntimeMenuType>(); 73 74 #ifdef Q_WS_MAC … … 80 81 template<> bool canConvert<RuntimeMenuDebuggerActionType>(); 81 82 #endif /* VBOX_WITH_DEBUGGER_GUI */ 82 template<> bool canConvert<RuntimeMenuHelpActionType>();83 83 template<> bool canConvert<UIVisualStateType>(); 84 84 template<> bool canConvert<DetailsElementType>(); … … 123 123 template<> QString toString(const StorageSlot &storageSlot); 124 124 template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot); 125 template<> QString toInternalString(const MenuHelpActionType &menuHelpActionType); 126 template<> MenuHelpActionType fromInternalString<MenuHelpActionType>(const QString &strMenuHelpActionType); 125 127 template<> QString toInternalString(const RuntimeMenuType &runtimeMenuType); 126 128 template<> RuntimeMenuType fromInternalString<RuntimeMenuType>(const QString &strRuntimeMenuType); … … 139 141 template<> RuntimeMenuDebuggerActionType fromInternalString<RuntimeMenuDebuggerActionType>(const QString &strRuntimeMenuDebuggerActionType); 140 142 #endif /* VBOX_WITH_DEBUGGER_GUI */ 141 template<> QString toInternalString(const RuntimeMenuHelpActionType &runtimeMenuHelpActionType);142 template<> RuntimeMenuHelpActionType fromInternalString<RuntimeMenuHelpActionType>(const QString &strRuntimeMenuHelpActionType);143 143 template<> QString toInternalString(const UIVisualStateType &visualStateType); 144 144 template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r52203 r52215 34 34 template<> bool canConvert<SizeSuffix>() { return true; } 35 35 template<> bool canConvert<StorageSlot>() { return true; } 36 template<> bool canConvert<MenuHelpActionType>() { return true; } 36 37 template<> bool canConvert<RuntimeMenuType>() { return true; } 37 38 #ifdef Q_WS_MAC … … 44 45 template<> bool canConvert<RuntimeMenuDebuggerActionType>() { return true; } 45 46 #endif /* VBOX_WITH_DEBUGGER_GUI */ 46 template<> bool canConvert<RuntimeMenuHelpActionType>() { return true; }47 47 template<> bool canConvert<UIVisualStateType>() { return true; } 48 48 template<> bool canConvert<DetailsElementType>() { return true; } … … 355 355 } 356 356 return result; 357 } 358 359 /* QString <= MenuHelpActionType: */ 360 template<> QString toInternalString(const MenuHelpActionType &menuHelpActionType) 361 { 362 QString strResult; 363 switch (menuHelpActionType) 364 { 365 case MenuHelpActionType_Contents: strResult = "Contents"; break; 366 case MenuHelpActionType_WebSite: strResult = "WebSite"; break; 367 case MenuHelpActionType_ResetWarnings: strResult = "ResetWarnings"; break; 368 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 369 case MenuHelpActionType_NetworkAccessManager: strResult = "NetworkAccessManager"; break; 370 case MenuHelpActionType_CheckForUpdates: strResult = "CheckForUpdates"; break; 371 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 372 #ifndef Q_WS_MAC 373 case MenuHelpActionType_About: strResult = "About"; break; 374 case MenuHelpActionType_Preferences: strResult = "Preferences"; break; 375 #endif /* !Q_WS_MAC */ 376 case MenuHelpActionType_All: strResult = "All"; break; 377 default: 378 { 379 AssertMsgFailed(("No text for action type=%d", menuHelpActionType)); 380 break; 381 } 382 } 383 return strResult; 384 } 385 386 /* MenuHelpActionType <= QString: */ 387 template<> MenuHelpActionType fromInternalString<MenuHelpActionType>(const QString &strMenuHelpActionType) 388 { 389 /* Here we have some fancy stuff allowing us 390 * to search through the keys using 'case-insensitive' rule: */ 391 QStringList keys; QList<MenuHelpActionType> values; 392 keys << "Contents"; values << MenuHelpActionType_Contents; 393 keys << "WebSite"; values << MenuHelpActionType_WebSite; 394 keys << "ResetWarnings"; values << MenuHelpActionType_ResetWarnings; 395 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 396 keys << "NetworkAccessManager"; values << MenuHelpActionType_NetworkAccessManager; 397 keys << "CheckForUpdates"; values << MenuHelpActionType_CheckForUpdates; 398 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 399 #ifndef Q_WS_MAC 400 keys << "About"; values << MenuHelpActionType_About; 401 keys << "Preferences"; values << MenuHelpActionType_Preferences; 402 #endif /* !Q_WS_MAC */ 403 keys << "All"; values << MenuHelpActionType_All; 404 /* Invalid type for unknown words: */ 405 if (!keys.contains(strMenuHelpActionType, Qt::CaseInsensitive)) 406 return MenuHelpActionType_Invalid; 407 /* Corresponding type for known words: */ 408 return values.at(keys.indexOf(QRegExp(strMenuHelpActionType, Qt::CaseInsensitive))); 357 409 } 358 410 … … 663 715 #endif /* VBOX_WITH_DEBUGGER_GUI */ 664 716 665 /* QString <= RuntimeMenuHelpActionType: */666 template<> QString toInternalString(const RuntimeMenuHelpActionType &runtimeMenuHelpActionType)667 {668 QString strResult;669 switch (runtimeMenuHelpActionType)670 {671 case RuntimeMenuHelpActionType_Contents: strResult = "Contents"; break;672 case RuntimeMenuHelpActionType_WebSite: strResult = "WebSite"; break;673 case RuntimeMenuHelpActionType_ResetWarnings: strResult = "ResetWarnings"; break;674 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER675 case RuntimeMenuHelpActionType_NetworkAccessManager: strResult = "NetworkAccessManager"; break;676 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */677 #ifndef Q_WS_MAC678 case RuntimeMenuHelpActionType_About: strResult = "About"; break;679 case RuntimeMenuHelpActionType_Preferences: strResult = "Preferences"; break;680 #endif /* !Q_WS_MAC */681 case RuntimeMenuHelpActionType_All: strResult = "All"; break;682 default:683 {684 AssertMsgFailed(("No text for action type=%d", runtimeMenuHelpActionType));685 break;686 }687 }688 return strResult;689 }690 691 /* RuntimeMenuHelpActionType <= QString: */692 template<> RuntimeMenuHelpActionType fromInternalString<RuntimeMenuHelpActionType>(const QString &strRuntimeMenuHelpActionType)693 {694 /* Here we have some fancy stuff allowing us695 * to search through the keys using 'case-insensitive' rule: */696 QStringList keys; QList<RuntimeMenuHelpActionType> values;697 keys << "Contents"; values << RuntimeMenuHelpActionType_Contents;698 keys << "WebSite"; values << RuntimeMenuHelpActionType_WebSite;699 keys << "ResetWarnings"; values << RuntimeMenuHelpActionType_ResetWarnings;700 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER701 keys << "NetworkAccessManager"; values << RuntimeMenuHelpActionType_NetworkAccessManager;702 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */703 #ifndef Q_WS_MAC704 keys << "About"; values << RuntimeMenuHelpActionType_About;705 keys << "Preferences"; values << RuntimeMenuHelpActionType_Preferences;706 #endif /* !Q_WS_MAC */707 keys << "All"; values << RuntimeMenuHelpActionType_All;708 /* Invalid type for unknown words: */709 if (!keys.contains(strRuntimeMenuHelpActionType, Qt::CaseInsensitive))710 return RuntimeMenuHelpActionType_Invalid;711 /* Corresponding type for known words: */712 return values.at(keys.indexOf(QRegExp(strRuntimeMenuHelpActionType, Qt::CaseInsensitive)));713 }714 715 717 /* QString <= UIVisualStateType: */ 716 718 template<> QString toInternalString(const UIVisualStateType &visualStateType) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r52203 r52215 360 360 361 361 362 /** Menu "Help": Action types. */ 363 enum MenuHelpActionType 364 { 365 MenuHelpActionType_Invalid = 0, 366 MenuHelpActionType_Contents = RT_BIT(0), 367 MenuHelpActionType_WebSite = RT_BIT(1), 368 MenuHelpActionType_ResetWarnings = RT_BIT(2), 369 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 370 MenuHelpActionType_NetworkAccessManager = RT_BIT(3), 371 MenuHelpActionType_CheckForUpdates = RT_BIT(4), 372 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 373 #ifndef Q_WS_MAC 374 MenuHelpActionType_About = RT_BIT(5), 375 MenuHelpActionType_Preferences = RT_BIT(6), 376 #endif /* !Q_WS_MAC */ 377 MenuHelpActionType_All = 0xFFFF 378 }; 379 362 380 /** Runtime UI: Menu types. */ 363 381 enum RuntimeMenuType … … 467 485 #endif /* VBOX_WITH_DEBUGGER_GUI */ 468 486 469 /** Runtime UI: Menu "Help": Action types. */470 enum RuntimeMenuHelpActionType471 {472 RuntimeMenuHelpActionType_Invalid = 0,473 RuntimeMenuHelpActionType_Contents = RT_BIT(0),474 RuntimeMenuHelpActionType_WebSite = RT_BIT(1),475 RuntimeMenuHelpActionType_ResetWarnings = RT_BIT(2),476 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER477 RuntimeMenuHelpActionType_NetworkAccessManager = RT_BIT(3),478 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */479 #ifndef Q_WS_MAC480 RuntimeMenuHelpActionType_About = RT_BIT(4),481 RuntimeMenuHelpActionType_Preferences = RT_BIT(5),482 #endif /* !Q_WS_MAC */483 RuntimeMenuHelpActionType_All = 0xFFFF484 };485 486 487 /** Runtime UI: Visual-state types. */ 487 488 enum UIVisualStateType -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r52202 r52215 2582 2582 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2583 2583 2584 RuntimeMenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID)2584 MenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID) 2585 2585 { 2586 2586 /* Prepare result: */ 2587 RuntimeMenuHelpActionType result = RuntimeMenuHelpActionType_Invalid;2587 MenuHelpActionType result = MenuHelpActionType_Invalid; 2588 2588 /* Get restricted runtime-help-menu action-types: */ 2589 2589 foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeHelpMenuActions, strID)) 2590 2590 { 2591 RuntimeMenuHelpActionType value = gpConverter->fromInternalString<RuntimeMenuHelpActionType>(strValue);2592 if (value != RuntimeMenuHelpActionType_Invalid)2593 result = static_cast< RuntimeMenuHelpActionType>(result | value);2591 MenuHelpActionType value = gpConverter->fromInternalString<MenuHelpActionType>(strValue); 2592 if (value != MenuHelpActionType_Invalid) 2593 result = static_cast<MenuHelpActionType>(result | value); 2594 2594 } 2595 2595 /* Return result: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r52190 r52215 301 301 #endif /* VBOX_WITH_DEBUGGER_GUI */ 302 302 /** Returns restricted Runtime UI action types for Help menu. */ 303 RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID);303 MenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID); 304 304 305 305 /** Returns restricted Runtime UI visual-states. */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r52203 r52215 27 27 #include "UIIconPool.h" 28 28 #include "VBoxGlobal.h" 29 #include "UIMessageCenter.h" 30 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 31 # include "UIExtraDataManager.h" 32 # include "UINetworkManager.h" 33 # include "UIUpdateManager.h" 34 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 29 35 30 36 … … 602 608 } 603 609 610 bool UIActionPool::isAllowedInMenuHelp(MenuHelpActionType type) const 611 { 612 foreach (const MenuHelpActionType &restriction, m_restrictedActionsMenuHelp.values()) 613 if (restriction & type) 614 return false; 615 return true; 616 } 617 618 void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel level, MenuHelpActionType restriction) 619 { 620 m_restrictedActionsMenuHelp[level] = restriction; 621 updateMenuHelp(); 622 } 623 604 624 void UIActionPool::prepare() 605 625 { … … 630 650 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 631 651 m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this); 652 653 /* Retranslate finally: */ 654 retranslateUi(); 632 655 } 633 656 … … 680 703 } 681 704 705 void UIActionPool::updateConfiguration() 706 { 707 /* Recache common action restrictions: */ 708 // Nothing here for now.. 709 710 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 711 /* Recache update action restrictions: */ 712 bool fUpdateAllowed = gEDataManager->applicationUpdateEnabled(); 713 if (!fUpdateAllowed) 714 { 715 m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] = (MenuHelpActionType) 716 (m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] | MenuHelpActionType_CheckForUpdates); 717 } 718 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 719 720 /* Update menus: */ 721 updateMenus(); 722 } 723 724 void UIActionPool::updateMenuHelp() 725 { 726 /* Get corresponding menu: */ 727 QMenu *pMenu = action(UIActionIndex_Menu_Help)->menu(); 728 AssertPtrReturnVoid(pMenu); 729 /* Clear contents: */ 730 pMenu->clear(); 731 732 733 /* Separator #1? */ 734 bool fSeparator1 = false; 735 736 /* 'Contents' action: */ 737 const bool fAllowToShowActionContents = isAllowedInMenuHelp(MenuHelpActionType_Contents); 738 action(UIActionIndex_Simple_Contents)->setEnabled(fAllowToShowActionContents); 739 if (fAllowToShowActionContents) 740 { 741 pMenu->addAction(action(UIActionIndex_Simple_Contents)); 742 connect(action(UIActionIndex_Simple_Contents), SIGNAL(triggered()), 743 &msgCenter(), SLOT(sltShowHelpHelpDialog()), Qt::UniqueConnection); 744 fSeparator1 = true; 745 } 746 747 /* 'Web Site' action: */ 748 const bool fAllowToShowActionWebSite = isAllowedInMenuHelp(MenuHelpActionType_WebSite); 749 action(MenuHelpActionType_WebSite)->setEnabled(fAllowToShowActionWebSite); 750 if (fAllowToShowActionWebSite) 751 { 752 pMenu->addAction(action(UIActionIndex_Simple_WebSite)); 753 connect(action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()), 754 &msgCenter(), SLOT(sltShowHelpWebDialog()), Qt::UniqueConnection); 755 fSeparator1 = true; 756 } 757 758 /* Separator #1: */ 759 if (fSeparator1) 760 pMenu->addSeparator(); 761 762 763 /* Separator #2? */ 764 bool fSeparator2 = false; 765 766 /* 'Reset Warnings' action: */ 767 const bool fAllowToShowActionResetWarnings = isAllowedInMenuHelp(MenuHelpActionType_ResetWarnings); 768 action(UIActionIndex_Simple_ResetWarnings)->setEnabled(fAllowToShowActionResetWarnings); 769 if (fAllowToShowActionResetWarnings) 770 { 771 pMenu->addAction(action(UIActionIndex_Simple_ResetWarnings)); 772 connect(action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()), 773 &msgCenter(), SLOT(sltResetSuppressedMessages()), Qt::UniqueConnection); 774 fSeparator2 = true; 775 } 776 777 /* Separator #2: */ 778 if (fSeparator2) 779 pMenu->addSeparator(); 780 781 782 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 783 # ifndef Q_WS_MAC 784 /* Separator #3? */ 785 bool fSeparator3 = false; 786 # endif /* !Q_WS_MAC */ 787 788 /* 'Network Manager' action: */ 789 const bool fAllowToShowActionNetworkManager = isAllowedInMenuHelp(MenuHelpActionType_NetworkAccessManager); 790 action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionNetworkManager); 791 if (fAllowToShowActionNetworkManager) 792 { 793 pMenu->addAction(action(UIActionIndex_Simple_NetworkAccessManager)); 794 connect(action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()), 795 gNetworkManager, SLOT(show()), Qt::UniqueConnection); 796 # ifndef Q_WS_MAC 797 fSeparator3 = true; 798 # endif /* !Q_WS_MAC */ 799 } 800 801 /* Only for Selector pool: */ 802 if (type() == UIActionPoolType_Selector) 803 { 804 /* 'Check for Updates' action: */ 805 const bool fAllowToShowActionCheckForUpdates = isAllowedInMenuHelp(MenuHelpActionType_CheckForUpdates); 806 action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionCheckForUpdates); 807 if (fAllowToShowActionCheckForUpdates) 808 { 809 pMenu->addAction(action(UIActionIndex_Simple_CheckForUpdates)); 810 connect(action(UIActionIndex_Simple_CheckForUpdates), SIGNAL(triggered()), 811 gUpdateManager, SLOT(sltForceCheck()), Qt::UniqueConnection); 812 # ifndef Q_WS_MAC 813 fSeparator3 = true; 814 # endif /* !Q_WS_MAC */ 815 } 816 } 817 818 # ifndef Q_WS_MAC 819 /* Separator #3: */ 820 if (fSeparator3) 821 pMenu->addSeparator(); 822 # endif /* !Q_WS_MAC */ 823 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 824 825 826 /* 'About' action: */ 827 const bool fAllowToShowActionAbout = 828 #ifdef Q_WS_MAC 829 isAllowedInMenuApplication(RuntimeMenuApplicationActionType_About); 830 #else /* !Q_WS_MAC */ 831 isAllowedInMenuHelp(MenuHelpActionType_About); 832 #endif /* Q_WS_MAC */ 833 action(UIActionIndex_Simple_About)->setEnabled(fAllowToShowActionAbout); 834 if (fAllowToShowActionAbout) 835 { 836 pMenu->addAction(action(UIActionIndex_Simple_About)); 837 connect(action(UIActionIndex_Simple_About), SIGNAL(triggered()), 838 &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection); 839 } 840 841 /* Only for Runtime pool: */ 842 if (type() == UIActionPoolType_Runtime) 843 { 844 /* 'Preferences' action: */ 845 const bool fAllowToShowActionPreferences = 846 #ifdef Q_WS_MAC 847 isAllowedInMenuApplication(RuntimeMenuApplicationActionType_Preferences); 848 #else /* !Q_WS_MAC */ 849 isAllowedInMenuHelp(MenuHelpActionType_Preferences); 850 #endif /* Q_WS_MAC */ 851 action(UIActionIndex_Simple_Preferences)->setEnabled(fAllowToShowActionPreferences); 852 if (fAllowToShowActionPreferences) 853 pMenu->addAction(action(UIActionIndex_Simple_Preferences)); 854 } 855 } 856 857 void UIActionPool::retranslateUi() 858 { 859 /* Translate all the actions: */ 860 foreach (const int iActionPoolKey, m_pool.keys()) 861 m_pool[iActionPoolKey]->retranslateUi(); 862 /* Update shortcuts: */ 863 updateShortcuts(); 864 } 865 682 866 bool UIActionPool::event(QEvent *pEvent) 683 867 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r52202 r52215 24 24 /* GUI includes: */ 25 25 #include "QIWithRetranslateUI.h" 26 #include "UIExtraDataDefs.h" 26 27 27 28 /* Forward declarations: */ … … 301 302 /** Returns all the actions action-pool contains. */ 302 303 QList<UIAction*> actions() const { return m_pool.values(); } 304 305 /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */ 306 bool isAllowedInMenuHelp(MenuHelpActionType type) const; 307 /** Defines 'Help' menu @a restriction for passed @a level. */ 308 void setRestrictionForMenuHelp(UIActionRestrictionLevel level, MenuHelpActionType restriction); 303 309 304 310 /** Hot-key processing delegate. */ … … 335 341 336 342 /** Update configuration routine. */ 337 virtual void updateConfiguration() = 0; 343 virtual void updateConfiguration(); 344 345 /** Update menus routine. */ 346 virtual void updateMenus() = 0; 347 /** Update 'Help' menu routine. */ 348 virtual void updateMenuHelp(); 349 338 350 /** Update shortcuts. */ 339 351 virtual void updateShortcuts(); 352 353 /** Translation handler. */ 354 virtual void retranslateUi(); 340 355 341 356 /** General event handler. */ … … 348 363 /** Holds all the actions action-pool contains. */ 349 364 QMap<int, UIAction*> m_pool; 365 366 /** Holds restricted action types of the Help menu. */ 367 QMap<UIActionRestrictionLevel, MenuHelpActionType> m_restrictedActionsMenuHelp; 350 368 }; 351 369 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r52203 r52215 19 19 #include "UIActionPoolRuntime.h" 20 20 #include "UIExtraDataManager.h" 21 #include "UIMessageCenter.h"22 21 #include "UIShortcutPool.h" 23 22 #include "VBoxGlobal.h" 24 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER25 # include "UINetworkManager.h"26 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */27 23 28 24 /* COM includes: */ … … 1356 1352 #endif /* VBOX_WITH_DEBUGGER_GUI */ 1357 1353 1358 bool UIActionPoolRuntime::isAllowedInMenuHelp(RuntimeMenuHelpActionType type) const1359 {1360 foreach (const RuntimeMenuHelpActionType &restriction, m_restrictedActionsMenuHelp.values())1361 if (restriction & type)1362 return false;1363 return true;1364 }1365 1366 void UIActionPoolRuntime::setRestrictionForMenuHelp(UIActionRestrictionLevel level, RuntimeMenuHelpActionType restriction)1367 {1368 m_restrictedActionsMenuHelp[level] = restriction;1369 updateMenuHelp();1370 }1371 1372 1354 void UIActionPoolRuntime::setCurrentFrameBufferSizes(const QList<QSize> &sizes, bool fUpdateMenu /* = false */) 1373 1355 { … … 1403 1385 void UIActionPoolRuntime::preparePool() 1404 1386 { 1405 /* Call to base-class: */1406 UIActionPool::preparePool();1407 1408 1387 /* 'Machine' actions: */ 1409 1388 m_pool[UIActionIndexRT_M_Machine] = new UIActionMenuMachineRuntime(this); … … 1476 1455 #endif /* Q_WS_MAC */ 1477 1456 1478 /* Retranslate finally: */1479 retranslateUi();1457 /* Call to base-class: */ 1458 UIActionPool::preparePool(); 1480 1459 } 1481 1460 … … 1575 1554 } 1576 1555 1577 /* Update menus: */1578 updateMenus();1556 /* Call to base-class: */ 1557 UIActionPool::updateConfiguration(); 1579 1558 } 1580 1559 … … 2300 2279 #endif /* VBOX_WITH_DEBUGGER_GUI */ 2301 2280 2302 void UIActionPoolRuntime::updateMenuHelp()2303 {2304 /* Get corresponding menu: */2305 QMenu *pMenu = action(UIActionIndex_Menu_Help)->menu();2306 AssertPtrReturnVoid(pMenu);2307 /* Clear contents: */2308 pMenu->clear();2309 2310 2311 /* Separator #1? */2312 bool fSeparator1 = false;2313 2314 /* 'Contents' action: */2315 const bool fAllowToShowActionContents = isAllowedInMenuHelp(RuntimeMenuHelpActionType_Contents);2316 action(UIActionIndex_Simple_Contents)->setEnabled(fAllowToShowActionContents);2317 if (fAllowToShowActionContents)2318 {2319 pMenu->addAction(action(UIActionIndex_Simple_Contents));2320 VBoxGlobal::connect(action(UIActionIndex_Simple_Contents), SIGNAL(triggered()),2321 &msgCenter(), SLOT(sltShowHelpHelpDialog()), Qt::UniqueConnection);2322 fSeparator1 = true;2323 }2324 2325 /* 'Web Site' action: */2326 const bool fAllowToShowActionWebSite = isAllowedInMenuHelp(RuntimeMenuHelpActionType_WebSite);2327 action(RuntimeMenuHelpActionType_WebSite)->setEnabled(fAllowToShowActionWebSite);2328 if (fAllowToShowActionWebSite)2329 {2330 pMenu->addAction(action(UIActionIndex_Simple_WebSite));2331 VBoxGlobal::connect(action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()),2332 &msgCenter(), SLOT(sltShowHelpWebDialog()), Qt::UniqueConnection);2333 fSeparator1 = true;2334 }2335 2336 /* Separator #1: */2337 if (fSeparator1)2338 pMenu->addSeparator();2339 2340 2341 /* Separator #2? */2342 bool fSeparator2 = false;2343 2344 /* 'Reset Warnings' action: */2345 const bool fAllowToShowActionResetWarnings = isAllowedInMenuHelp(RuntimeMenuHelpActionType_ResetWarnings);2346 action(UIActionIndex_Simple_ResetWarnings)->setEnabled(fAllowToShowActionResetWarnings);2347 if (fAllowToShowActionResetWarnings)2348 {2349 pMenu->addAction(action(UIActionIndex_Simple_ResetWarnings));2350 VBoxGlobal::connect(action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),2351 &msgCenter(), SLOT(sltResetSuppressedMessages()), Qt::UniqueConnection);2352 fSeparator2 = true;2353 }2354 2355 /* Separator #2: */2356 if (fSeparator2)2357 pMenu->addSeparator();2358 2359 2360 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER2361 # ifndef Q_WS_MAC2362 /* Separator #3? */2363 bool fSeparator3 = false;2364 # endif /* !Q_WS_MAC */2365 2366 /* 'Network Manager' action: */2367 const bool fAllowToShowActionNetworkManager = isAllowedInMenuHelp(RuntimeMenuHelpActionType_NetworkAccessManager);2368 action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionNetworkManager);2369 if (fAllowToShowActionNetworkManager)2370 {2371 pMenu->addAction(action(UIActionIndex_Simple_NetworkAccessManager));2372 VBoxGlobal::connect(action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()),2373 gNetworkManager, SLOT(show()), Qt::UniqueConnection);2374 # ifndef Q_WS_MAC2375 fSeparator3 = true;2376 # endif /* !Q_WS_MAC */2377 }2378 2379 # ifndef Q_WS_MAC2380 /* Separator #3: */2381 if (fSeparator3)2382 pMenu->addSeparator();2383 # endif /* !Q_WS_MAC */2384 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */2385 2386 2387 /* 'About' action: */2388 const bool fAllowToShowActionAbout =2389 #ifdef Q_WS_MAC2390 isAllowedInMenuApplication(RuntimeMenuApplicationActionType_About);2391 #else /* !Q_WS_MAC */2392 isAllowedInMenuHelp(RuntimeMenuHelpActionType_About);2393 #endif /* Q_WS_MAC */2394 action(UIActionIndex_Simple_About)->setEnabled(fAllowToShowActionAbout);2395 if (fAllowToShowActionAbout)2396 {2397 pMenu->addAction(action(UIActionIndex_Simple_About));2398 VBoxGlobal::connect(action(UIActionIndex_Simple_About), SIGNAL(triggered()),2399 &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection);2400 }2401 2402 /* 'Preferences' action: */2403 const bool fAllowToShowActionPreferences =2404 #ifdef Q_WS_MAC2405 isAllowedInMenuApplication(RuntimeMenuApplicationActionType_Preferences);2406 #else /* !Q_WS_MAC */2407 isAllowedInMenuHelp(RuntimeMenuHelpActionType_Preferences);2408 #endif /* Q_WS_MAC */2409 action(UIActionIndex_Simple_Preferences)->setEnabled(fAllowToShowActionPreferences);2410 if (fAllowToShowActionPreferences)2411 pMenu->addAction(action(UIActionIndex_Simple_Preferences));2412 }2413 2414 2281 void UIActionPoolRuntime::retranslateUi() 2415 2282 { 2416 /* Translate all the actions: */ 2417 foreach (const int iActionPoolKey, m_pool.keys()) 2418 m_pool[iActionPoolKey]->retranslateUi(); 2419 /* Update Runtime UI shortcuts: */ 2420 updateShortcuts(); 2283 /* Call to base-class: */ 2284 UIActionPool::retranslateUi(); 2421 2285 /* Create temporary Selector UI pool to do the same: */ 2422 2286 if (!m_fTemporary) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r52203 r52215 156 156 #endif /* VBOX_WITH_DEBUGGER_GUI */ 157 157 158 /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */159 bool isAllowedInMenuHelp(RuntimeMenuHelpActionType type) const;160 /** Defines 'Help' menu @a restriction for passed @a level. */161 void setRestrictionForMenuHelp(UIActionRestrictionLevel level, RuntimeMenuHelpActionType restriction);162 163 158 /** Defines current frame-buffer sizes 164 159 * for menus which uses such arguments to build content. */ … … 219 214 void updateMenuDebug(); 220 215 #endif /* VBOX_WITH_DEBUGGER_GUI */ 221 /** Update 'Help' menu routine. */222 void updateMenuHelp();223 216 224 217 /** Translation handler. */ … … 236 229 QList<QMenu*> m_mainMenus; 237 230 238 /** Holds restricted menu s. */231 /** Holds restricted menu types. */ 239 232 QMap<UIActionRestrictionLevel, RuntimeMenuType> m_restrictedMenus; 240 233 #ifdef Q_WS_MAC 241 /** Holds restricted action s of the Application menu. */234 /** Holds restricted action types of the Application menu. */ 242 235 QMap<UIActionRestrictionLevel, RuntimeMenuApplicationActionType> m_restrictedActionsMenuApplication; 243 236 #endif /* Q_WS_MAC */ 244 /** Holds restricted action s of the Machine menu. */237 /** Holds restricted action types of the Machine menu. */ 245 238 QMap<UIActionRestrictionLevel, RuntimeMenuMachineActionType> m_restrictedActionsMenuMachine; 246 /** Holds restricted action s of the View menu. */239 /** Holds restricted action types of the View menu. */ 247 240 QMap<UIActionRestrictionLevel, RuntimeMenuViewActionType> m_restrictedActionsMenuView; 248 /** Holds restricted action s of the Devices menu. */241 /** Holds restricted action types of the Devices menu. */ 249 242 QMap<UIActionRestrictionLevel, RuntimeMenuDevicesActionType> m_restrictedActionsMenuDevices; 250 243 #ifdef VBOX_WITH_DEBUGGER_GUI 251 /** Holds restricted action s of the Debugger menu. */244 /** Holds restricted action types of the Debugger menu. */ 252 245 QMap<UIActionRestrictionLevel, RuntimeMenuDebuggerActionType> m_restrictedActionsMenuDebug; 253 246 #endif /* VBOX_WITH_DEBUGGER_GUI */ 254 /** Holds restricted actions of the Help menu. */255 QMap<UIActionRestrictionLevel, RuntimeMenuHelpActionType> m_restrictedActionsMenuHelp;256 247 257 248 /** Defines current frame-buffer sizes -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp
r52202 r52215 894 894 void UIActionPoolSelector::preparePool() 895 895 { 896 /* Call to base-class: */897 UIActionPool::preparePool();898 899 896 /* 'File' actions: */ 900 897 m_pool[UIActionIndexST_M_File] = new UIActionMenuFile(this); … … 947 944 m_pool[UIActionIndexST_M_Machine_S_SortParent] = new UIActionSimpleMachineSortParent(this); 948 945 949 /* Retranslate finally: */950 retranslateUi();946 /* Call to base-class: */ 947 UIActionPool::preparePool(); 951 948 } 952 949 … … 957 954 } 958 955 959 void UIActionPoolSelector::updateConfiguration() 960 { 961 // TODO: Make it proper way.. 956 void UIActionPoolSelector::updateMenus() 957 { 958 /* 'Help' menu: */ 959 updateMenuHelp(); 962 960 } 963 961 964 962 void UIActionPoolSelector::retranslateUi() 965 963 { 966 /* Translate all the actions: */ 967 foreach (const int iActionPoolKey, m_pool.keys()) 968 m_pool[iActionPoolKey]->retranslateUi(); 969 /* Update Selector UI shortcuts: */ 970 updateShortcuts(); 964 /* Call to base-class: */ 965 UIActionPool::retranslateUi(); 971 966 /* Create temporary Runtime UI pool to do the same: */ 972 967 if (!m_fTemporary) -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h
r52202 r52215 102 102 virtual void prepareConnections(); 103 103 104 /** Update configurationroutine. */105 virtual void update Configuration();104 /** Update menus routine. */ 105 virtual void updateMenus(); 106 106 107 107 /** Translation handler. */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r52202 r52215 1124 1124 1125 1125 /* Prepare Help-menu: */ 1126 prepareMenuHelp(actionPool()->action(UIActionIndex_Menu_Help)->menu());1127 1126 menuBar()->addMenu(actionPool()->action(UIActionIndex_Menu_Help)->menu()); 1128 1127 … … 1275 1274 } 1276 1275 1277 void UISelectorWindow::prepareMenuHelp(QMenu *pMenu)1278 {1279 /* Do not touch if filled already: */1280 if (!pMenu->isEmpty())1281 return;1282 1283 /* Populate Help-menu: */1284 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_Contents));1285 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_WebSite));1286 pMenu->addSeparator();1287 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_ResetWarnings));1288 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER1289 pMenu->addSeparator();1290 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_NetworkAccessManager));1291 if (gEDataManager->applicationUpdateEnabled())1292 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_CheckForUpdates));1293 else1294 actionPool()->action(UIActionIndex_Simple_CheckForUpdates)->setEnabled(false);1295 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */1296 #ifndef Q_WS_MAC1297 pMenu->addSeparator();1298 #endif /* !Q_WS_MAC */1299 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_About));1300 }1301 1302 1276 void UISelectorWindow::prepareStatusBar() 1303 1277 { … … 1429 1403 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffAction())); 1430 1404 1431 /* 'Help' menu connections: */1432 connect(actionPool()->action(UIActionIndex_Simple_Contents), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));1433 connect(actionPool()->action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpWebDialog()));1434 connect(actionPool()->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()), &msgCenter(), SLOT(sltResetSuppressedMessages()));1435 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER1436 connect(actionPool()->action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()), gNetworkManager, SLOT(show()));1437 connect(actionPool()->action(UIActionIndex_Simple_CheckForUpdates), SIGNAL(triggered()), gUpdateManager, SLOT(sltForceCheck()));1438 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */1439 connect(actionPool()->action(UIActionIndex_Simple_About), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpAboutDialog()));1440 1441 1405 /* Status-bar connections: */ 1442 1406 connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)), -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r52202 r52215 129 129 void prepareMenuGroupClose(QMenu *pMenu); 130 130 void prepareMenuMachineClose(QMenu *pMenu); 131 void prepareMenuHelp(QMenu *pMenu);132 131 void prepareStatusBar(); 133 132 void prepareWidgets();
Note:
See TracChangeset
for help on using the changeset viewer.