- Timestamp:
- Mar 30, 2018 3:46:47 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r71027 r71582 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 26 26 /* GUI includes: */ 27 # include "VBoxGlobal.h" 27 28 # include "UIActionPool.h" 28 29 # include "UIActionPoolSelector.h" 29 30 # include "UIActionPoolRuntime.h" 30 # include "UIShortcutPool.h"31 31 # include "UIConverter.h" 32 32 # include "UIIconPool.h" 33 # include "VBoxGlobal.h"34 33 # include "UIMessageCenter.h" 34 # include "UIShortcutPool.h" 35 35 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 36 36 # include "UIExtraDataManager.h" … … 42 42 43 43 44 45 44 /** QEvent extension 46 45 * representing action-activation event. */ … … 49 48 public: 50 49 51 /** Construct or. */50 /** Constructs @a pAction event. */ 52 51 ActivateActionEvent(QAction *pAction) 53 52 : QEvent((QEvent::Type)ActivateActionEventType) 54 , m_pAction(pAction) {} 55 56 /** Returns the action this event corresponding to. */ 57 QAction* action() const { return m_pAction; } 53 , m_pAction(pAction) 54 {} 55 56 /** Returns the action this event corresponds to. */ 57 QAction *action() const { return m_pAction; } 58 58 59 59 private: 60 60 61 /** Ho 0lds the action this event correspondingto. */61 /** Holds the action this event corresponds to. */ 62 62 QAction *m_pAction; 63 63 }; 64 64 65 65 66 /********************************************************************************************************************************* 67 * Class UIMenu implementation. * 68 *********************************************************************************************************************************/ 69 66 70 UIMenu::UIMenu() 67 71 : m_fShowToolTip(false) … … 69 73 , m_fConsumable(false) 70 74 , m_fConsumed(false) 71 #endif /* VBOX_WS_MAC */75 #endif 72 76 { 73 77 } … … 98 102 99 103 100 UIAction::UIAction(UIActionPool *pParent, UIActionType type) 104 /********************************************************************************************************************************* 105 * Class UIAction implementation. * 106 *********************************************************************************************************************************/ 107 108 UIAction::UIAction(UIActionPool *pParent, UIActionType enmType) 101 109 : QAction(pParent) 102 , m_ type(type)110 , m_enmType(enmType) 103 111 , m_pActionPool(pParent) 104 , m_ actionPoolType(pParent->type())112 , m_enmActionPoolType(pParent->type()) 105 113 , m_fShortcutHidden(false) 106 114 { … … 116 124 } 117 125 118 UIMenu *UIAction::menu() const126 UIMenu *UIAction::menu() const 119 127 { 120 128 return QAction::menu() ? qobject_cast<UIMenu*>(QAction::menu()) : 0; 121 129 } 122 130 123 UIActionPolymorphic *UIAction::toActionPolymorphic()131 UIActionPolymorphic *UIAction::toActionPolymorphic() 124 132 { 125 133 return qobject_cast<UIActionPolymorphic*>(this); 126 134 } 127 135 128 UIActionPolymorphicMenu *UIAction::toActionPolymorphicMenu()136 UIActionPolymorphicMenu *UIAction::toActionPolymorphicMenu() 129 137 { 130 138 return qobject_cast<UIActionPolymorphicMenu*>(this); … … 142 150 { 143 151 /* Only for selector's action-pool: */ 144 if (m_ actionPoolType == UIActionPoolType_Selector)152 if (m_enmActionPoolType == UIActionPoolType_Selector) 145 153 { 146 154 /* If shortcut is visible: */ … … 172 180 { 173 181 /* Action-name format depends on action-pool type: */ 174 switch (m_ actionPoolType)182 switch (m_enmActionPoolType) 175 183 { 176 184 /* Unchanged name for Selector UI: */ … … 186 194 { 187 195 /* Action-text format depends on action-pool type: */ 188 switch (m_ actionPoolType)196 switch (m_enmActionPoolType) 189 197 { 190 198 /* The same as menu name for Selector UI: */ … … 201 209 202 210 211 /********************************************************************************************************************************* 212 * Class UIActionMenu implementation. * 213 *********************************************************************************************************************************/ 214 203 215 UIActionMenu::UIActionMenu(UIActionPool *pParent, 204 const QString &strIcon, const QString &strIconDis )216 const QString &strIcon, const QString &strIconDisabled) 205 217 : UIAction(pParent, UIActionType_Menu) 206 218 { 207 219 if (!strIcon.isNull()) 208 setIcon(UIIconPool::iconSet(strIcon, strIconDis ));220 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled)); 209 221 prepare(); 210 222 } … … 241 253 } 242 254 255 256 /********************************************************************************************************************************* 257 * Class UIActionSimple implementation. * 258 *********************************************************************************************************************************/ 243 259 244 260 UIActionSimple::UIActionSimple(UIActionPool *pParent, … … 259 275 260 276 UIActionSimple::UIActionSimple(UIActionPool *pParent, 261 const QIcon &icon)277 const QIcon &icon) 262 278 : UIAction(pParent, UIActionType_Simple) 263 279 { … … 265 281 } 266 282 283 284 /********************************************************************************************************************************* 285 * Class UIActionToggle implementation. * 286 *********************************************************************************************************************************/ 267 287 268 288 UIActionToggle::UIActionToggle(UIActionPool *pParent, … … 298 318 } 299 319 320 321 /********************************************************************************************************************************* 322 * Class UIActionPolymorphic implementation. * 323 *********************************************************************************************************************************/ 300 324 301 325 UIActionPolymorphic::UIActionPolymorphic(UIActionPool *pParent, … … 326 350 } 327 351 352 353 /********************************************************************************************************************************* 354 * Class UIActionPolymorphicMenu implementation. * 355 *********************************************************************************************************************************/ 328 356 329 357 UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent, … … 409 437 410 438 439 /** Menu action extension, used as 'Application' menu class. */ 411 440 class UIActionMenuApplication : public UIActionMenu 412 441 { … … 415 444 public: 416 445 446 /** Constructs action passing @a pParent to the base-class. */ 417 447 UIActionMenuApplication(UIActionPool *pParent) 418 448 : UIActionMenu(pParent) 419 449 { 420 #ifdef RT_OS_DARWIN450 #ifdef VBOX_WS_MAC 421 451 menu()->setConsumable(true); 422 #endif /* RT_OS_DARWIN */452 #endif 423 453 retranslateUi(); 424 454 } … … 433 463 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Application); } 434 464 435 void retranslateUi() 436 { 437 #ifdef RT_OS_DARWIN 465 /** Handles translation event. */ 466 virtual void retranslateUi() /* override */ 467 { 468 #ifdef VBOX_WS_MAC 438 469 setName(QApplication::translate("UIActionPool", "&VirtualBox")); 439 #else /* !RT_OS_DARWIN */470 #else 440 471 setName(QApplication::translate("UIActionPool", "&File")); 441 #endif /* !RT_OS_DARWIN */472 #endif 442 473 } 443 474 }; 444 475 476 477 /** Simple action extension, used as 'Close' action class. */ 445 478 class UIActionSimplePerformClose : public UIActionSimple 446 479 { … … 449 482 public: 450 483 484 /** Constructs action passing @a pParent to the base-class. */ 451 485 UIActionSimplePerformClose(UIActionPool *pParent) 452 486 : UIActionSimple(pParent, ":/exit_16px.png") … … 464 498 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Close); } 465 499 500 /** Returns shortcut extra-data ID. */ 466 501 QString shortcutExtraDataID() const 467 502 { … … 469 504 } 470 505 506 /** Returns default shortcut. */ 471 507 QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const 472 508 { … … 479 515 } 480 516 481 void retranslateUi() 517 /** Handles translation event. */ 518 virtual void retranslateUi() /* override */ 482 519 { 483 520 setName(QApplication::translate("UIActionPool", "&Close...")); … … 486 523 }; 487 524 488 #ifdef RT_OS_DARWIN 525 #ifdef VBOX_WS_MAC 526 /** Menu action extension, used as 'Window' menu class. */ 489 527 class UIActionMenuWindow : public UIActionMenu 490 528 { … … 493 531 public: 494 532 533 /** Constructs action passing @a pParent to the base-class. */ 495 534 UIActionMenuWindow(UIActionPool *pParent) 496 : UIActionMenu(pParent) {} 535 : UIActionMenu(pParent) 536 {} 497 537 498 538 protected: … … 505 545 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Window); } 506 546 507 void retranslateUi() 547 /** Handles translation event. */ 548 virtual void retranslateUi() /* override */ 508 549 { 509 550 setName(QApplication::translate("UIActionPool", "&Window")); … … 511 552 }; 512 553 554 555 /** Simple action extension, used as 'Minimize' action class. */ 513 556 class UIActionSimpleMinimize : public UIActionSimple 514 557 { … … 517 560 public: 518 561 562 /** Constructs action passing @a pParent to the base-class. */ 519 563 UIActionSimpleMinimize(UIActionPool *pParent) 520 : UIActionSimple(pParent) {} 564 : UIActionSimple(pParent) 565 {} 521 566 522 567 protected: … … 529 574 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); } 530 575 576 /** Returns shortcut extra-data ID. */ 531 577 QString shortcutExtraDataID() const 532 578 { … … 534 580 } 535 581 536 void retranslateUi() 582 /** Handles translation event. */ 583 virtual void retranslateUi() /* override */ 537 584 { 538 585 setName(QApplication::translate("UIActionPool", "&Minimize")); … … 540 587 } 541 588 }; 542 #endif /* RT_OS_DARWIN */ 543 589 #endif /* VBOX_WS_MAC */ 590 591 592 /** Menu action extension, used as 'Help' menu class. */ 544 593 class UIActionMenuHelp : public UIActionMenu 545 594 { … … 548 597 public: 549 598 599 /** Constructs action passing @a pParent to the base-class. */ 550 600 UIActionMenuHelp(UIActionPool *pParent) 551 601 : UIActionMenu(pParent) … … 563 613 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Help); } 564 614 565 void retranslateUi() 615 /** Handles translation event. */ 616 virtual void retranslateUi() /* override */ 566 617 { 567 618 setName(QApplication::translate("UIActionPool", "&Help")); … … 569 620 }; 570 621 622 623 /** Simple action extension, used as 'Contents' action class. */ 571 624 class UIActionSimpleContents : public UIActionSimple 572 625 { … … 575 628 public: 576 629 630 /** Constructs action passing @a pParent to the base-class. */ 577 631 UIActionSimpleContents(UIActionPool *pParent) 578 632 : UIActionSimple(pParent, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogHelp)) … … 590 644 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Contents); } 591 645 646 /** Returns shortcut extra-data ID. */ 592 647 QString shortcutExtraDataID() const 593 648 { … … 595 650 } 596 651 652 /** Returns default shortcut. */ 597 653 QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const 598 654 { … … 605 661 } 606 662 607 void retranslateUi() 663 /** Handles translation event. */ 664 virtual void retranslateUi() /* override */ 608 665 { 609 666 setName(QApplication::translate("UIActionPool", "&Contents...")); … … 612 669 }; 613 670 671 672 /** Simple action extension, used as 'Web Site' action class. */ 614 673 class UIActionSimpleWebSite : public UIActionSimple 615 674 { … … 618 677 public: 619 678 679 /** Constructs action passing @a pParent to the base-class. */ 620 680 UIActionSimpleWebSite(UIActionPool *pParent) 621 681 : UIActionSimple(pParent, ":/site_16px.png") … … 633 693 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_WebSite); } 634 694 695 /** Returns shortcut extra-data ID. */ 635 696 QString shortcutExtraDataID() const 636 697 { … … 638 699 } 639 700 640 void retranslateUi() 701 /** Handles translation event. */ 702 virtual void retranslateUi() /* override */ 641 703 { 642 704 setName(QApplication::translate("UIActionPool", "&VirtualBox Web Site...")); … … 645 707 }; 646 708 709 710 /** Simple action extension, used as 'Bug Tracker' action class. */ 647 711 class UIActionSimpleBugTracker : public UIActionSimple 648 712 { … … 651 715 public: 652 716 717 /** Constructs action passing @a pParent to the base-class. */ 653 718 UIActionSimpleBugTracker(UIActionPool *pParent) 654 719 : UIActionSimple(pParent, ":/site_bugtracker_16px.png") … … 666 731 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_BugTracker); } 667 732 733 /** Returns shortcut extra-data ID. */ 668 734 QString shortcutExtraDataID() const 669 735 { … … 671 737 } 672 738 673 void retranslateUi() 739 /** Handles translation event. */ 740 virtual void retranslateUi() /* override */ 674 741 { 675 742 setName(QApplication::translate("UIActionPool", "&VirtualBox Bug Tracker...")); … … 678 745 }; 679 746 747 748 /** Simple action extension, used as 'Forums' action class. */ 680 749 class UIActionSimpleForums : public UIActionSimple 681 750 { … … 684 753 public: 685 754 755 /** Constructs action passing @a pParent to the base-class. */ 686 756 UIActionSimpleForums(UIActionPool *pParent) 687 757 : UIActionSimple(pParent, ":/site_forum_16px.png") … … 699 769 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Forums); } 700 770 771 /** Returns shortcut extra-data ID. */ 701 772 QString shortcutExtraDataID() const 702 773 { … … 704 775 } 705 776 706 void retranslateUi() 777 /** Handles translation event. */ 778 virtual void retranslateUi() /* override */ 707 779 { 708 780 setName(QApplication::translate("UIActionPool", "&VirtualBox Forums...")); … … 711 783 }; 712 784 785 786 /** Simple action extension, used as 'Oracle' action class. */ 713 787 class UIActionSimpleOracle : public UIActionSimple 714 788 { … … 717 791 public: 718 792 793 /** Constructs action passing @a pParent to the base-class. */ 719 794 UIActionSimpleOracle(UIActionPool *pParent) 720 795 : UIActionSimple(pParent, ":/site_oracle_16px.png") … … 732 807 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Oracle); } 733 808 809 /** Returns shortcut extra-data ID. */ 734 810 QString shortcutExtraDataID() const 735 811 { … … 737 813 } 738 814 739 void retranslateUi() 815 /** Handles translation event. */ 816 virtual void retranslateUi() /* override */ 740 817 { 741 818 setName(QApplication::translate("UIActionPool", "&Oracle Web Site...")); … … 744 821 }; 745 822 823 824 /** Simple action extension, used as 'Reset Warnings' action class. */ 746 825 class UIActionSimpleResetWarnings : public UIActionSimple 747 826 { … … 750 829 public: 751 830 831 /** Constructs action passing @a pParent to the base-class. */ 752 832 UIActionSimpleResetWarnings(UIActionPool *pParent) 753 833 : UIActionSimple(pParent, ":/reset_warnings_16px.png") … … 766 846 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_ResetWarnings); } 767 847 848 /** Returns shortcut extra-data ID. */ 768 849 QString shortcutExtraDataID() const 769 850 { … … 771 852 } 772 853 773 void retranslateUi() 854 /** Handles translation event. */ 855 virtual void retranslateUi() /* override */ 774 856 { 775 857 setName(QApplication::translate("UIActionPool", "&Reset All Warnings")); … … 778 860 }; 779 861 862 780 863 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 864 /** Simple action extension, used as 'Network Access Manager' action class. */ 781 865 class UIActionSimpleNetworkAccessManager : public UIActionSimple 782 866 { … … 785 869 public: 786 870 871 /** Constructs action passing @a pParent to the base-class. */ 787 872 UIActionSimpleNetworkAccessManager(UIActionPool *pParent) 788 873 : UIActionSimple(pParent, ":/download_manager_16px.png") … … 801 886 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_NetworkAccessManager); } 802 887 888 /** Returns shortcut extra-data ID. */ 803 889 QString shortcutExtraDataID() const 804 890 { … … 806 892 } 807 893 808 void retranslateUi() 894 /** Handles translation event. */ 895 virtual void retranslateUi() /* override */ 809 896 { 810 897 setName(QApplication::translate("UIActionPool", "&Network Operations Manager...")); … … 813 900 }; 814 901 902 903 /** Simple action extension, used as 'Check for Updates' action class. */ 815 904 class UIActionSimpleCheckForUpdates : public UIActionSimple 816 905 { … … 819 908 public: 820 909 910 /** Constructs action passing @a pParent to the base-class. */ 821 911 UIActionSimpleCheckForUpdates(UIActionPool *pParent) 822 912 : UIActionSimple(pParent, ":/refresh_16px.png", ":/refresh_disabled_16px.png") … … 835 925 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates); } 836 926 927 /** Returns shortcut extra-data ID. */ 837 928 QString shortcutExtraDataID() const 838 929 { … … 840 931 } 841 932 842 void retranslateUi() 933 /** Handles translation event. */ 934 virtual void retranslateUi() /* override */ 843 935 { 844 936 setName(QApplication::translate("UIActionPool", "C&heck for Updates...")); … … 848 940 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 849 941 942 943 /** Simple action extension, used as 'About' action class. */ 850 944 class UIActionSimpleAbout : public UIActionSimple 851 945 { … … 854 948 public: 855 949 950 /** Constructs action passing @a pParent to the base-class. */ 856 951 UIActionSimpleAbout(UIActionPool *pParent) 857 952 : UIActionSimple(pParent, ":/about_16px.png") … … 866 961 virtual int extraDataID() const 867 962 { 868 #ifdef RT_OS_DARWIN963 #ifdef VBOX_WS_MAC 869 964 return UIExtraDataMetaDefs::MenuApplicationActionType_About; 870 #else /* !RT_OS_DARWIN */965 #else 871 966 return UIExtraDataMetaDefs::MenuHelpActionType_About; 872 #endif /* !RT_OS_DARWIN */967 #endif 873 968 } 874 969 /** Returns action extra-data key. */ 875 970 virtual QString extraDataKey() const 876 971 { 877 #ifdef RT_OS_DARWIN972 #ifdef VBOX_WS_MAC 878 973 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_About); 879 #else /* !RT_OS_DARWIN */974 #else 880 975 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_About); 881 #endif /* !RT_OS_DARWIN */976 #endif 882 977 } 883 978 /** Returns whether action is allowed. */ 884 979 virtual bool isAllowed() const 885 980 { 886 #ifdef RT_OS_DARWIN981 #ifdef VBOX_WS_MAC 887 982 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_About); 888 #else /* !RT_OS_DARWIN */983 #else 889 984 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_About); 890 #endif /* !RT_OS_DARWIN */ 891 } 892 985 #endif 986 } 987 988 /** Returns shortcut extra-data ID. */ 893 989 QString shortcutExtraDataID() const 894 990 { … … 896 992 } 897 993 898 void retranslateUi() 994 /** Handles translation event. */ 995 virtual void retranslateUi() /* override */ 899 996 { 900 997 setName(QApplication::translate("UIActionPool", "&About VirtualBox...")); … … 903 1000 }; 904 1001 1002 1003 /** Simple action extension, used as 'Preferences' action class. */ 905 1004 class UIActionSimplePreferences : public UIActionSimple 906 1005 { … … 909 1008 public: 910 1009 1010 /** Constructs action passing @a pParent to the base-class. */ 911 1011 UIActionSimplePreferences(UIActionPool *pParent) 912 1012 : UIActionSimple(pParent, ":/global_settings_16px.png") … … 925 1025 virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences); } 926 1026 1027 /** Returns shortcut extra-data ID. */ 927 1028 QString shortcutExtraDataID() const 928 1029 { … … 930 1031 } 931 1032 1033 /** Returns default shortcut. */ 932 1034 QKeySequence defaultShortcut(UIActionPoolType) const 933 1035 { … … 940 1042 } 941 1043 942 void retranslateUi() 1044 /** Handles translation event. */ 1045 virtual void retranslateUi() /* override */ 943 1046 { 944 1047 setName(QApplication::translate("UIActionPool", "&Preferences...", "global preferences window")); … … 948 1051 949 1052 1053 /********************************************************************************************************************************* 1054 * Class UIActionPool implementation. * 1055 *********************************************************************************************************************************/ 1056 950 1057 /* static */ 951 UIActionPool * UIActionPool::create(UIActionPoolType type)1058 UIActionPool *UIActionPool::create(UIActionPoolType enmType) 952 1059 { 953 1060 UIActionPool *pActionPool = 0; 954 switch ( type)1061 switch (enmType) 955 1062 { 956 1063 case UIActionPoolType_Selector: pActionPool = new UIActionPoolSelector; break; … … 972 1079 973 1080 /* static */ 974 void UIActionPool::createTemporary(UIActionPoolType type)1081 void UIActionPool::createTemporary(UIActionPoolType enmType) 975 1082 { 976 1083 UIActionPool *pActionPool = 0; 977 switch ( type)1084 switch (enmType) 978 1085 { 979 1086 case UIActionPoolType_Selector: pActionPool = new UIActionPoolSelector(true); break; … … 987 1094 } 988 1095 989 UIActionPool::UIActionPool(UIActionPoolType type, bool fTemporary /* = false */)990 : m_ type(type)1096 UIActionPool::UIActionPool(UIActionPoolType enmType, bool fTemporary /* = false */) 1097 : m_enmType(enmType) 991 1098 , m_fTemporary(fTemporary) 992 1099 { 993 1100 } 994 1101 995 UIActionPoolRuntime *UIActionPool::toRuntime()1102 UIActionPoolRuntime *UIActionPool::toRuntime() 996 1103 { 997 1104 return qobject_cast<UIActionPoolRuntime*>(this); 998 1105 } 999 1106 1000 UIActionPoolSelector *UIActionPool::toSelector()1107 UIActionPoolSelector *UIActionPool::toSelector() 1001 1108 { 1002 1109 return qobject_cast<UIActionPoolSelector*>(this); 1003 1110 } 1004 1111 1005 bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const1006 { 1007 foreach (const UIExtraDataMetaDefs::MenuType & restriction, m_restrictedMenus.values())1008 if ( restriction & type)1112 bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType enmType) const 1113 { 1114 foreach (const UIExtraDataMetaDefs::MenuType &enmRestriction, m_restrictedMenus.values()) 1115 if (enmRestriction & enmType) 1009 1116 return false; 1010 1117 return true; 1011 1118 } 1012 1119 1013 void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction)1014 { 1015 m_restrictedMenus[ level] = restriction;1120 void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuType enmRestriction) 1121 { 1122 m_restrictedMenus[enmLevel] = enmRestriction; 1016 1123 updateMenus(); 1017 1124 } 1018 1125 1019 bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const1020 { 1021 foreach (const UIExtraDataMetaDefs::MenuApplicationActionType & restriction, m_restrictedActionsMenuApplication.values())1022 if ( restriction & type)1126 bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType enmType) const 1127 { 1128 foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &enmRestriction, m_restrictedActionsMenuApplication.values()) 1129 if (enmRestriction & enmType) 1023 1130 return false; 1024 1131 return true; 1025 1132 } 1026 1133 1027 void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction)1028 { 1029 m_restrictedActionsMenuApplication[ level] = restriction;1134 void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction) 1135 { 1136 m_restrictedActionsMenuApplication[enmLevel] = enmRestriction; 1030 1137 m_invalidations << UIActionIndex_M_Application; 1031 1138 } 1032 1139 1033 1140 #ifdef VBOX_WS_MAC 1034 bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const1035 { 1036 foreach (const UIExtraDataMetaDefs::MenuWindowActionType & restriction, m_restrictedActionsMenuWindow.values())1037 if ( restriction & type)1141 bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType enmType) const 1142 { 1143 foreach (const UIExtraDataMetaDefs::MenuWindowActionType &enmRestriction, m_restrictedActionsMenuWindow.values()) 1144 if (enmRestriction & enmType) 1038 1145 return false; 1039 1146 return true; 1040 1147 } 1041 1148 1042 void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction)1043 { 1044 m_restrictedActionsMenuWindow[ level] = restriction;1149 void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction) 1150 { 1151 m_restrictedActionsMenuWindow[enmLevel] = enmRestriction; 1045 1152 m_invalidations << UIActionIndex_M_Window; 1046 1153 } 1047 1154 #endif /* VBOX_WS_MAC */ 1048 1155 1049 bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const1050 { 1051 foreach (const UIExtraDataMetaDefs::MenuHelpActionType & restriction, m_restrictedActionsMenuHelp.values())1052 if ( restriction & type)1156 bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const 1157 { 1158 foreach (const UIExtraDataMetaDefs::MenuHelpActionType &enmRestriction, m_restrictedActionsMenuHelp.values()) 1159 if (enmRestriction & enmType) 1053 1160 return false; 1054 1161 return true; 1055 1162 } 1056 1163 1057 void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction)1058 { 1059 m_restrictedActionsMenuHelp[ level] = restriction;1164 void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction) 1165 { 1166 m_restrictedActionsMenuHelp[enmLevel] = enmRestriction; 1060 1167 m_invalidations << UIActionIndex_Menu_Help; 1061 1168 } … … 1111 1218 /* Create 'Application' actions: */ 1112 1219 m_pool[UIActionIndex_M_Application] = new UIActionMenuApplication(this); 1113 #ifdef RT_OS_DARWIN1220 #ifdef VBOX_WS_MAC 1114 1221 m_pool[UIActionIndex_M_Application_S_About] = new UIActionSimpleAbout(this); 1115 #endif /* RT_OS_DARWIN */1222 #endif 1116 1223 m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this); 1117 1224 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1118 1225 m_pool[UIActionIndex_M_Application_S_NetworkAccessManager] = new UIActionSimpleNetworkAccessManager(this); 1119 1226 m_pool[UIActionIndex_M_Application_S_CheckForUpdates] = new UIActionSimpleCheckForUpdates(this); 1120 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */1227 #endif 1121 1228 m_pool[UIActionIndex_M_Application_S_ResetWarnings] = new UIActionSimpleResetWarnings(this); 1122 1229 m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this); 1123 1230 1124 #ifdef RT_OS_DARWIN1231 #ifdef VBOX_WS_MAC 1125 1232 /* Create 'Window' actions: */ 1126 1233 m_pool[UIActionIndex_M_Window] = new UIActionMenuWindow(this); 1127 1234 m_pool[UIActionIndex_M_Window_S_Minimize] = new UIActionSimpleMinimize(this); 1128 #endif /* RT_OS_DARWIN */1235 #endif 1129 1236 1130 1237 /* Create 'Help' actions: */ … … 1135 1242 m_pool[UIActionIndex_Simple_Forums] = new UIActionSimpleForums(this); 1136 1243 m_pool[UIActionIndex_Simple_Oracle] = new UIActionSimpleOracle(this); 1137 #ifndef RT_OS_DARWIN1244 #ifndef VBOX_WS_MAC 1138 1245 m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this); 1139 #endif /* !RT_OS_DARWIN */1246 #endif 1140 1247 1141 1248 /* Prepare update-handlers for known menus: */ 1142 #ifdef RT_OS_DARWIN1249 #ifdef VBOX_WS_MAC 1143 1250 m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication; 1144 1251 m_menuUpdateHandlers[UIActionIndex_M_Window].ptf = &UIActionPool::updateMenuWindow; 1145 #endif /* RT_OS_DARWIN */1252 #endif 1146 1253 m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp; 1147 1254 … … 1156 1263 { 1157 1264 /* 'Application' menu connections: */ 1158 #ifdef RT_OS_DARWIN1265 #ifdef VBOX_WS_MAC 1159 1266 connect(action(UIActionIndex_M_Application_S_About), &UIAction::triggered, 1160 1267 &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection); 1161 #endif /* RT_OS_DARWIN */1268 #endif 1162 1269 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1163 1270 connect(action(UIActionIndex_M_Application_S_NetworkAccessManager), &UIAction::triggered, … … 1165 1272 connect(action(UIActionIndex_M_Application_S_CheckForUpdates), &UIAction::triggered, 1166 1273 gUpdateManager, &UIUpdateManager::sltForceCheck, Qt::UniqueConnection); 1167 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */1274 #endif 1168 1275 connect(action(UIActionIndex_M_Application_S_ResetWarnings), &UIAction::triggered, 1169 1276 &msgCenter(), &UIMessageCenter::sltResetSuppressedMessages, Qt::UniqueConnection); … … 1180 1287 connect(action(UIActionIndex_Simple_Oracle), &UIAction::triggered, 1181 1288 &msgCenter(), &UIMessageCenter::sltShowOracle, Qt::UniqueConnection); 1182 #ifndef RT_OS_DARWIN1289 #ifndef VBOX_WS_MAC 1183 1290 connect(action(UIActionIndex_Simple_About), &UIAction::triggered, 1184 1291 &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection); 1185 #endif /* !RT_OS_DARWIN */1292 #endif 1186 1293 } 1187 1294 … … 1265 1372 UIMenu *pMenu = action(UIActionIndex_M_Application)->menu(); 1266 1373 AssertPtrReturnVoid(pMenu); 1267 #ifdef RT_OS_DARWIN1374 #ifdef VBOX_WS_MAC 1268 1375 AssertReturnVoid(pMenu->isConsumable()); 1269 #endif /* RT_OS_DARWIN */1376 #endif 1270 1377 /* Clear contents: */ 1271 #ifdef RT_OS_DARWIN1378 #ifdef VBOX_WS_MAC 1272 1379 if (!pMenu->isConsumed()) 1273 #endif /* RT_OS_DARWIN */1380 #endif 1274 1381 pMenu->clear(); 1275 1382 … … 1277 1384 bool fSeparator = false; 1278 1385 1279 #ifdef RT_OS_DARWIN1386 #ifdef VBOX_WS_MAC 1280 1387 /* 'About' action: */ 1281 1388 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_About)) || fSeparator; 1282 #endif /* RT_OS_DARWIN */1389 #endif 1283 1390 1284 1391 /* 'Preferences' action: */ 1285 1392 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_Preferences)) || fSeparator; 1286 1393 1287 #ifndef RT_OS_DARWIN1394 #ifndef VBOX_WS_MAC 1288 1395 /* Separator: */ 1289 1396 if (fSeparator) … … 1292 1399 fSeparator = false; 1293 1400 } 1294 #endif /* !RT_OS_DARWIN */1401 #endif 1295 1402 1296 1403 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1297 1404 /* 'Network Manager' action: */ 1298 1405 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_NetworkAccessManager)) || fSeparator; 1299 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */1406 #endif 1300 1407 /* 'Reset Warnings' action: */ 1301 1408 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_ResetWarnings)) || fSeparator; 1302 1409 1303 #ifndef RT_OS_DARWIN1410 #ifndef VBOX_WS_MAC 1304 1411 /* Separator: */ 1305 1412 if (fSeparator) … … 1308 1415 fSeparator = false; 1309 1416 } 1310 #endif /* !RT_OS_DARWIN */1417 #endif 1311 1418 1312 1419 /* 'Close' action: */ … … 1317 1424 } 1318 1425 1319 #ifdef RT_OS_DARWIN1426 #ifdef VBOX_WS_MAC 1320 1427 void UIActionPool::updateMenuWindow() 1321 1428 { … … 1341 1448 /* This menu always remains invalid.. */ 1342 1449 } 1343 #endif /* RT_OS_DARWIN*/1450 #endif /* VBOX_WS_MAC */ 1344 1451 1345 1452 void UIActionPool::updateMenuHelp() … … 1372 1479 } 1373 1480 1374 #ifndef RT_OS_DARWIN1481 #ifndef VBOX_WS_MAC 1375 1482 /* 'About' action: */ 1376 1483 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_About)) || fSeparator;; 1377 #endif /* !RT_OS_DARWIN */1484 #endif 1378 1485 1379 1486 /* Mark menu as valid: */ … … 1415 1522 const bool fIsActionAllowed = pAction->isAllowed(); 1416 1523 1417 #ifdef RT_OS_DARWIN1524 #ifdef VBOX_WS_MAC 1418 1525 /* Check if menu is consumable: */ 1419 1526 const bool fIsMenuConsumable = pMenu->isConsumable(); 1420 1527 /* Check if menu is NOT yet consumed: */ 1421 1528 const bool fIsMenuConsumed = pMenu->isConsumed(); 1422 #endif /* RT_OS_DARWIN */1529 #endif 1423 1530 1424 1531 /* Make this action visible … … 1426 1533 pAction->setVisible(fIsActionAllowed); 1427 1534 1428 #ifdef RT_OS_DARWIN1535 #ifdef VBOX_WS_MAC 1429 1536 /* If menu is consumable: */ 1430 1537 if (fIsMenuConsumable) … … 1436 1543 /* If menu is NOT consumable: */ 1437 1544 else 1438 #endif /* RT_OS_DARWIN */1545 #endif 1439 1546 { 1440 1547 /* Add action only if is allowed: */ … … 1455 1562 UIMenu *pMenu = pAction->menu(); 1456 1563 1457 #ifdef RT_OS_DARWIN1564 #ifdef VBOX_WS_MAC 1458 1565 /* Check if menu is consumable: */ 1459 1566 const bool fIsMenuConsumable = pMenu->isConsumable(); 1460 1567 /* Check if menu is NOT yet consumed: */ 1461 1568 const bool fIsMenuConsumed = pMenu->isConsumed(); 1462 #endif /* RT_OS_DARWIN */1569 #endif 1463 1570 1464 1571 /* Make this action visible 1465 1572 * depending on clearance state. */ 1466 1573 pAction->setVisible( fIsActionAllowed 1467 #ifdef RT_OS_DARWIN1574 #ifdef VBOX_WS_MAC 1468 1575 && !fIsMenuConsumable 1469 #endif /* RT_OS_DARWIN */1576 #endif 1470 1577 ); 1471 1578 1472 #ifdef RT_OS_DARWIN1579 #ifdef VBOX_WS_MAC 1473 1580 /* If menu is consumable: */ 1474 1581 if (fIsMenuConsumable) … … 1480 1587 /* If menu is NOT consumable: */ 1481 1588 else 1482 #endif /* RT_OS_DARWIN */1589 #endif 1483 1590 { 1484 1591 /* Add action only if is allowed: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r71027 r71582 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 29 29 /* Forward declarations: */ 30 class QKeySequence; 31 class QString; 30 32 class UIActionPolymorphic; 31 33 class UIActionPolymorphicMenu; … … 57 59 /* 'Application' menu actions: */ 58 60 UIActionIndex_M_Application, 59 #ifdef RT_OS_DARWIN61 #ifdef VBOX_WS_MAC 60 62 UIActionIndex_M_Application_S_About, 61 #endif /* RT_OS_DARWIN */63 #endif 62 64 UIActionIndex_M_Application_S_Preferences, 63 65 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER … … 68 70 UIActionIndex_M_Application_S_Close, 69 71 70 #ifdef RT_OS_DARWIN72 #ifdef VBOX_WS_MAC 71 73 /* 'Window' menu actions: */ 72 74 UIActionIndex_M_Window, 73 75 UIActionIndex_M_Window_S_Minimize, 74 #endif /* RT_OS_DARWIN */76 #endif 75 77 76 78 /* 'Help' menu actions: */ … … 81 83 UIActionIndex_Simple_Forums, 82 84 UIActionIndex_Simple_Oracle, 83 #ifndef RT_OS_DARWIN85 #ifndef VBOX_WS_MAC 84 86 UIActionIndex_Simple_About, 85 #endif /* !RT_OS_DARWIN */87 #endif 86 88 87 89 /* Maximum index: */ … … 105 107 public: 106 108 107 /** Construct or. */109 /** Constructs menu. */ 108 110 UIMenu(); 109 111 … … 125 127 protected: 126 128 127 /** General event handler. */129 /** Handles any Qt @a pEvent. */ 128 130 virtual bool event(QEvent *pEvent); 129 131 … … 150 152 151 153 /** Returns action type. */ 152 UIActionType type() const { return m_ type; }154 UIActionType type() const { return m_enmType; } 153 155 154 156 /** Returns menu contained by this action. */ 155 UIMenu *menu() const;157 UIMenu *menu() const; 156 158 157 159 /** Returns action-pool this action belongs to. */ 158 UIActionPool *actionPool() const { return m_pActionPool; }160 UIActionPool *actionPool() const { return m_pActionPool; } 159 161 160 162 /** Casts action to polymorphic-action. */ 161 UIActionPolymorphic *toActionPolymorphic();163 UIActionPolymorphic *toActionPolymorphic(); 162 164 /** Casts action to polymorphic-menu-action. */ 163 UIActionPolymorphicMenu *toActionPolymorphicMenu();165 UIActionPolymorphicMenu *toActionPolymorphicMenu(); 164 166 165 167 /** Returns current action name. */ 166 const QString &name() const { return m_strName; }168 const QString &name() const { return m_strName; } 167 169 /** Defines current action name. */ 168 170 void setName(const QString &strName); … … 189 191 /** Retranslates action. */ 190 192 virtual void retranslateUi() = 0; 191 virtual ~UIAction() { delete menu(); } 192 193 protected: 194 195 /** Constructor. */ 196 UIAction(UIActionPool *pParent, UIActionType type); 193 virtual ~UIAction() /* override */ { delete menu(); } 194 195 protected: 196 197 /** Constructs action passing @a pParent to the base-class. 198 * @param enmType Brings the action type. */ 199 UIAction(UIActionPool *pParent, UIActionType enmType); 197 200 198 201 /** Returns current action name in menu. */ … … 205 208 206 209 /** Holds the action type. */ 207 UIActionType m_type;210 UIActionType m_enmType; 208 211 209 212 /** Holds the reference to the action-pool this action belongs to. */ 210 UIActionPool *m_pActionPool;213 UIActionPool *m_pActionPool; 211 214 /** Holds the type of the action-pool this action belongs to. */ 212 UIActionPoolType m_actionPoolType;215 UIActionPoolType m_enmActionPoolType; 213 216 214 217 /** Holds the action name. */ 215 QString m_strName;218 QString m_strName; 216 219 /** Holds the action shortcut. */ 217 QKeySequence m_shortcut;220 QKeySequence m_shortcut; 218 221 /** Holds whether action shortcut hidden. */ 219 bool m_fShortcutHidden;222 bool m_fShortcutHidden; 220 223 }; 221 224 … … 228 231 protected: 229 232 230 /** Constructor, taking normal icon name and name for disabled analog. */ 233 /** Constructs menu action passing @a pParent to the base-class. 234 * @param strIcon Brings the normal-icon name. 235 * @param strIconDisabled Brings the disabled-icon name. */ 231 236 UIActionMenu(UIActionPool *pParent, 232 const QString &strIcon = QString(), const QString &strIconDis = QString()); 233 /** Constructor, taking copy of existing icon. */ 237 const QString &strIcon = QString(), 238 const QString &strIconDisabled = QString()); 239 /** Constructs menu action passing @a pParent to the base-class. 240 * @param icon Brings the icon. */ 234 241 UIActionMenu(UIActionPool *pParent, 235 242 const QIcon &icon); … … 255 262 protected: 256 263 257 /** Constructor, taking normal icon name and name for disabled analog. */ 264 /** Constructs simple action passing @a pParent to the base-class. 265 * @param strIcon Brings the normal-icon name. 266 * @param strIconDisabled Brings the disabled-icon name. */ 258 267 UIActionSimple(UIActionPool *pParent, 259 const QString &strIcon = QString(), const QString &strIconDisabled = QString()); 260 /** Constructor, taking normal, small icon names and names for disabled analogs. */ 268 const QString &strIcon = QString(), 269 const QString &strIconDisabled = QString()); 270 /** Constructs simple action passing @a pParent to the base-class. 271 * @param strIconNormal Brings the normal-icon name. 272 * @param strIconSmall Brings the small-icon name. 273 * @param strIconNormalDisabled Brings the normal-disabled-icon name. 274 * @param strIconSmallDisabled Brings the small-disabled-icon name. */ 261 275 UIActionSimple(UIActionPool *pParent, 262 276 const QString &strIconNormal, const QString &strIconSmall, 263 277 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled); 264 /** Constructor, taking copy of existing icon. */ 278 /** Constructs simple action passing @a pParent to the base-class. 279 * @param icon Brings the icon. */ 265 280 UIActionSimple(UIActionPool *pParent, 266 281 const QIcon& icon); … … 275 290 protected: 276 291 277 /** Constructor, taking normal icon name and name for disabled analog. */ 292 /** Constructs toggle action passing @a pParent to the base-class. 293 * @param strIcon Brings the normal-icon name. 294 * @param strIconDisabled Brings the disabled-icon name. */ 278 295 UIActionToggle(UIActionPool *pParent, 279 296 const QString &strIcon = QString(), const QString &strIconDisabled = QString()); 280 /** Constructor, taking normal on/off icon names and names for disabled analogs. */ 297 /** Constructs toggle action passing @a pParent to the base-class. 298 * @param strIconOn Brings the on-icon name. 299 * @param strIconOff Brings the off-icon name. 300 * @param strIconOnDisabled Brings the on-disabled-icon name. 301 * @param strIconOffDisabled Brings the off-disabled-icon name. */ 281 302 UIActionToggle(UIActionPool *pParent, 282 303 const QString &strIconOn, const QString &strIconOff, 283 304 const QString &strIconOnDisabled, const QString &strIconOffDisabled); 284 /** Constructor, taking copy of existing icon. */ 305 /** Constructs toggle action passing @a pParent to the base-class. 306 * @param icon Brings the icon. */ 285 307 UIActionToggle(UIActionPool *pParent, 286 308 const QIcon &icon); … … 307 329 protected: 308 330 309 /** Constructor, taking normal icon name and name for disabled analog. */ 331 /** Constructs polymorphic action passing @a pParent to the base-class. 332 * @param strIcon Brings the normal-icon name. 333 * @param strIconDisabled Brings the disabled-icon name. */ 310 334 UIActionPolymorphic(UIActionPool *pParent, 311 const QString &strIcon = QString(), const QString &strIconDisabled = QString()); 312 /** Constructor, taking normal, small icon names and names for disabled analogs. */ 335 const QString &strIcon = QString(), const QString &strIconDisabled = QString()); 336 /** Constructs polymorphic action passing @a pParent to the base-class. 337 * @param strIconNormal Brings the normal-icon name. 338 * @param strIconSmall Brings the small-icon name. 339 * @param strIconNormalDisabled Brings the normal-disabled-icon name. 340 * @param strIconSmallDisabled Brings the small-disabled-icon name. */ 313 341 UIActionPolymorphic(UIActionPool *pParent, 314 const QString &strIconNormal, const QString &strIconSmall, 315 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled); 316 /** Constructor, taking copy of existing icon. */ 342 const QString &strIconNormal, const QString &strIconSmall, 343 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled); 344 /** Constructs polymorphic action passing @a pParent to the base-class. 345 * @param icon Brings the icon. */ 317 346 UIActionPolymorphic(UIActionPool *pParent, 318 const QIcon& icon);347 const QIcon& icon); 319 348 320 349 private: … … 339 368 protected: 340 369 341 /** Constructor, taking normal icon name and name for disabled analog. */ 370 /** Constructs polymorphic menu action passing @a pParent to the base-class. 371 * @param strIcon Brings the normal-icon name. 372 * @param strIconDisabled Brings the disabled-icon name. */ 342 373 UIActionPolymorphicMenu(UIActionPool *pParent, 343 const QString &strIcon = QString(), const QString &strIconDis = QString()); 344 /** Constructor, taking normal, small icon names and names for disabled analogs. */ 374 const QString &strIcon = QString(), const QString &strIconDisabled = QString()); 375 /** Constructs polymorphic menu action passing @a pParent to the base-class. 376 * @param strIconNormal Brings the normal-icon name. 377 * @param strIconSmall Brings the small-icon name. 378 * @param strIconNormalDisabled Brings the normal-disabled-icon name. 379 * @param strIconSmallDisabled Brings the small-disabled-icon name. */ 345 380 UIActionPolymorphicMenu(UIActionPool *pParent, 346 381 const QString &strIconNormal, const QString &strIconSmall, 347 382 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled); 348 /** Constructor, taking copy of existing icon. */ 383 /** Constructs polymorphic menu action passing @a pParent to the base-class. 384 * @param icon Brings the icon. */ 349 385 UIActionPolymorphicMenu(UIActionPool *pParent, 350 386 const QIcon &icon); 351 387 352 /** Destruct or. */388 /** Destructs polymorphic menu action. */ 353 389 ~UIActionPolymorphicMenu(); 354 390 … … 374 410 UIMenu *m_pMenu; 375 411 /** Holds current action state. */ 376 int m_iState;412 int m_iState; 377 413 }; 378 414 … … 403 439 /** Notifies about @a pAction hovered. */ 404 440 void sigActionHovered(UIAction *pAction); 405 #endif /* VBOX_WS_MAC */441 #endif 406 442 407 443 public: 408 444 409 /** Static factory constructor. */410 static UIActionPool * create(UIActionPoolType type);411 /** Static factory destructor. */445 /** Creates singleton instance. */ 446 static UIActionPool *create(UIActionPoolType enmType); 447 /** Destroys singleton instance. */ 412 448 static void destroy(UIActionPool *pActionPool); 413 449 414 /** Static factory constructor (temporary),415 * used to initialize shortcuts-pool from action-pool of passed @a type. */416 static void createTemporary(UIActionPoolType type);450 /** Creates temporary singleton instance, 451 * used to initialize shortcuts-pool from action-pool of passed @a enmType. */ 452 static void createTemporary(UIActionPoolType enmType); 417 453 418 454 /** Cast action-pool to Runtime one. */ 419 UIActionPoolRuntime *toRuntime();455 UIActionPoolRuntime *toRuntime(); 420 456 /** Cast action-pool to Selector one. */ 421 UIActionPoolSelector *toSelector();457 UIActionPoolSelector *toSelector(); 422 458 423 459 /** Returns action-pool type. */ 424 UIActionPoolType type() const { return m_ type; }460 UIActionPoolType type() const { return m_enmType; } 425 461 426 462 /** Returns the action for the passed @a iIndex. */ 427 UIAction *action(int iIndex) const { return m_pool.value(iIndex); }463 UIAction *action(int iIndex) const { return m_pool.value(iIndex); } 428 464 /** Returns all the actions action-pool contains. */ 429 465 QList<UIAction*> actions() const { return m_pool.values(); } … … 431 467 /** Returns whether the menu with passed @a type is allowed in menu-bar. */ 432 468 bool isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const; 433 /** Defines menu-bar @a restriction for passed @a level. */434 void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction);469 /** Defines menu-bar @a enmRestriction for passed @a level. */ 470 void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType enmRestriction); 435 471 436 472 /** Returns whether the action with passed @a type is allowed in the 'Application' menu. */ 437 473 bool isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const; 438 /** Defines 'Application' menu @a restriction for passed @a level. */439 void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction);474 /** Defines 'Application' menu @a enmRestriction for passed @a level. */ 475 void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction); 440 476 441 477 #ifdef VBOX_WS_MAC 442 478 /** Mac OS X: Returns whether the action with passed @a type is allowed in the 'Window' menu. */ 443 479 bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const; 444 /** Mac OS X: Defines 'Window' menu @a restriction for passed @a level. */445 void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction);480 /** Mac OS X: Defines 'Window' menu @a enmRestriction for passed @a level. */ 481 void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction); 446 482 #endif /* VBOX_WS_MAC */ 447 483 448 484 /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */ 449 bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const;450 /** Defines 'Help' menu @a restriction for passed @a level. */451 void setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction);485 bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const; 486 /** Defines 'Help' menu @a enmRestriction for passed @a level. */ 487 void setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction); 452 488 453 489 /** Hot-key processing delegate. */ … … 477 513 protected: 478 514 479 /** Construct or of the action-pool of passed @a type. */480 UIActionPool(UIActionPoolType type, bool fTemporary = false);481 482 /** Prepare routine. */515 /** Constructs probably @a fTemporary action-pool of passed @a enmType. */ 516 UIActionPool(UIActionPoolType enmType, bool fTemporary = false); 517 518 /** Prepares all. */ 483 519 void prepare(); 484 /** Prepare pool routine. */520 /** Prepares pool. */ 485 521 virtual void preparePool(); 486 /** Prepare connections routine. */522 /** Prepares connections. */ 487 523 virtual void prepareConnections(); 488 /** Cleanup connections routine. */524 /** Cleanups connections. */ 489 525 virtual void cleanupConnections() {} 490 /** Cleanup pool routine. */526 /** Cleanups pool. */ 491 527 virtual void cleanupPool(); 492 /** Cleanup routine. */528 /** Cleanups all. */ 493 529 void cleanup(); 494 530 495 /** Update configuration routine. */531 /** Updates configuration. */ 496 532 virtual void updateConfiguration(); 497 533 498 /** Update menu routine. */534 /** Updates menu with certain @a iIndex. */ 499 535 virtual void updateMenu(int iIndex); 500 /** Update menus routine. */536 /** Updates menus. */ 501 537 virtual void updateMenus() = 0; 502 /** Update 'Application' menu routine. */538 /** Updates 'Application' menu. */ 503 539 virtual void updateMenuApplication(); 504 #ifdef RT_OS_DARWIN505 /** Mac OS X: Update 'Window' menu routine. */540 #ifdef VBOX_WS_MAC 541 /** Mac OS X: Updates 'Window' menu. */ 506 542 virtual void updateMenuWindow(); 507 #endif /* RT_OS_DARWIN */508 /** Update 'Help' menu routine. */543 #endif 544 /** Updates 'Help' menu. */ 509 545 virtual void updateMenuHelp(); 510 546 511 /** Update shortcuts. */547 /** Updates shortcuts. */ 512 548 virtual void updateShortcuts(); 513 549 514 /** Translation handler. */515 virtual void retranslateUi() ;516 517 /** General event handler.*/518 virtual bool event(QEvent *pEvent) ;550 /** Hadles translation event. */ 551 virtual void retranslateUi() /* override */; 552 553 /** Handles any Qt @a pEvent */ 554 virtual bool event(QEvent *pEvent) /* override */; 519 555 520 556 /** Adds action into corresponding menu. */ … … 524 560 525 561 /** Holds the action-pool type. */ 526 const UIActionPoolType m_type;562 const UIActionPoolType m_enmType; 527 563 /** Holds whether this action-pool is temporary. */ 528 const bool m_fTemporary;564 const bool m_fTemporary; 529 565 530 566 /** Holds the map of actions. */ 531 QMap<int, UIAction*> m_pool;567 QMap<int, UIAction*> m_pool; 532 568 /** Holds the map of validation handlers. */ 533 QMap<int, PointerToFunction> m_menuUpdateHandlers;569 QMap<int, PointerToFunction> m_menuUpdateHandlers; 534 570 /** Holds the set of invalidated action indexes. */ 535 QSet<int> m_invalidations;571 QSet<int> m_invalidations; 536 572 537 573 /** Holds restricted menu types. */ 538 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus;574 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus; 539 575 /** Holds restricted action types of the 'Application' menu. */ 540 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication;576 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication; 541 577 #ifdef VBOX_WS_MAC 542 578 /** Mac OS X: Holds restricted action types of the 'Window' menu. */ 543 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow;544 #endif /* VBOX_WS_MAC */579 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow; 580 #endif 545 581 /** Holds restricted action types of the Help menu. */ 546 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp; 547 }; 582 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp; 583 }; 584 548 585 549 586 #endif /* !___UIActionPool_h___ */ 587
Note:
See TracChangeset
for help on using the changeset viewer.