Changeset 52558 in vbox
- Timestamp:
- Sep 1, 2014 5:02:01 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r52555 r52558 422 422 }; 423 423 424 #ifdef RT_OS_DARWIN 425 class UIActionMenuApplication : public UIActionMenu 426 { 427 Q_OBJECT; 428 429 public: 430 431 UIActionMenuApplication(UIActionPool *pParent) 432 : UIActionMenu(pParent) 433 { 434 menu()->setConsumable(true); 435 retranslateUi(); 436 } 437 438 protected: 439 440 /** Returns action extra-data ID. */ 441 virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Application; } 442 /** Returns action extra-data key. */ 443 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Application); } 444 445 void retranslateUi() 446 { 447 setName(QApplication::translate("UIActionPool", "&VirtualBox")); 448 } 449 }; 450 451 class UIActionSimplePerformClose : public UIActionSimple 452 { 453 Q_OBJECT; 454 455 public: 456 457 UIActionSimplePerformClose(UIActionPool *pParent) 458 : UIActionSimple(pParent, ":/exit_16px.png") 459 { 460 setMenuRole(QAction::QuitRole); 461 } 462 463 protected: 464 465 /** Returns action extra-data ID. */ 466 virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuApplicationActionType_Close; } 467 /** Returns action extra-data key. */ 468 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_Close); } 469 470 QString shortcutExtraDataID() const 471 { 472 return QString("Close"); 473 } 474 475 QKeySequence defaultShortcut(UIActionPoolType) const 476 { 477 return QKeySequence("Q"); 478 } 479 480 void retranslateUi() 481 { 482 setName(QApplication::translate("UIActionPool", "&Close...")); 483 setStatusTip(QApplication::translate("UIActionPool", "Close the virtual machine")); 484 } 485 }; 486 #endif /* RT_OS_DARWIN */ 487 424 488 class UIActionMenuHelp : public UIActionMenu 425 489 { … … 743 807 { 744 808 m_restrictedActionsMenuApplication[level] = restriction; 745 m_invalidations << UIActionIndex_M enu_Help;809 m_invalidations << UIActionIndex_M_Application; 746 810 } 747 811 #endif /* Q_WS_MAC */ … … 781 845 { 782 846 /* Create various actions: */ 783 m_pool[UIActionIndex_Simple_Preferences] = new UIActionSimplePreferences(this);784 847 m_pool[UIActionIndex_Simple_LogDialog] = new UIActionSimpleLogDialog(this); 848 849 #ifdef RT_OS_DARWIN 850 /* Create 'Application' actions: */ 851 m_pool[UIActionIndex_M_Application] = new UIActionMenuApplication(this); 852 m_pool[UIActionIndex_M_Application_S_About] = new UIActionSimpleAbout(this); 853 m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this); 854 m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this); 855 #endif /* RT_OS_DARWIN */ 785 856 786 857 /* Create 'Help' actions: */ … … 793 864 m_pool[UIActionIndex_Simple_CheckForUpdates] = new UIActionSimpleCheckForUpdates(this); 794 865 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 866 #ifndef RT_OS_DARWIN 795 867 m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this); 868 m_pool[UIActionIndex_Simple_Preferences] = new UIActionSimplePreferences(this); 869 #endif /* !RT_OS_DARWIN */ 796 870 797 871 /* Prepare update-handlers for known menus: */ 872 #ifdef RT_OS_DARWIN 873 m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication; 874 #endif /* RT_OS_DARWIN */ 798 875 m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp; 799 876 … … 879 956 } 880 957 958 #ifdef RT_OS_DARWIN 959 void UIActionPool::updateMenuApplication() 960 { 961 /* Get corresponding menu: */ 962 UIMenu *pMenu = action(UIActionIndex_M_Application)->menu(); 963 AssertReturnVoid(pMenu && pMenu->isConsumable()); 964 /* Clear contents: */ 965 if (!pMenu->isConsumed()) 966 pMenu->clear(); 967 968 /* 'About' action: */ 969 const bool fAllowToShowActionAbout = isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_About); 970 action(UIActionIndex_M_Application_S_About)->setEnabled(fAllowToShowActionAbout); 971 action(UIActionIndex_M_Application_S_About)->setVisible(fAllowToShowActionAbout); 972 if (!pMenu->isConsumed()) 973 { 974 pMenu->addAction(action(UIActionIndex_M_Application_S_About)); 975 connect(action(UIActionIndex_M_Application_S_About), SIGNAL(triggered()), 976 &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection); 977 } 978 979 /* Only for Runtime pool: */ 980 if (type() == UIActionPoolType_Runtime) 981 { 982 /* 'Preferences' action: */ 983 const bool fAllowToShowActionPreferences = isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences); 984 action(UIActionIndex_M_Application_S_Preferences)->setEnabled(fAllowToShowActionPreferences); 985 action(UIActionIndex_M_Application_S_Preferences)->setVisible(fAllowToShowActionPreferences); 986 if (!pMenu->isConsumed()) 987 pMenu->addAction(action(UIActionIndex_M_Application_S_Preferences)); 988 } 989 990 /* Close action: */ 991 const bool fAllowToShowActionClose = isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Close); 992 action(UIActionIndex_M_Application_S_Close)->setEnabled(fAllowToShowActionClose); 993 if (!pMenu->isConsumed()) 994 pMenu->addAction(action(UIActionIndex_M_Application_S_Close)); 995 996 /* Mark menu as valid: */ 997 m_invalidations.remove(UIActionIndex_M_Application); 998 } 999 #endif /* RT_OS_DARWIN */ 1000 881 1001 void UIActionPool::updateMenuHelp() 882 1002 { … … 981 1101 982 1102 1103 #ifndef RT_OS_DARWIN 983 1104 /* 'About' action: */ 984 const bool fAllowToShowActionAbout = 985 #ifdef Q_WS_MAC 986 isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_About); 987 #else /* !Q_WS_MAC */ 988 isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_About); 989 #endif /* Q_WS_MAC */ 1105 const bool fAllowToShowActionAbout = isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_About); 990 1106 action(UIActionIndex_Simple_About)->setEnabled(fAllowToShowActionAbout); 991 1107 if (fAllowToShowActionAbout) … … 1000 1116 { 1001 1117 /* 'Preferences' action: */ 1002 const bool fAllowToShowActionPreferences = 1003 #ifdef Q_WS_MAC 1004 isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences); 1005 #else /* !Q_WS_MAC */ 1006 isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Preferences); 1007 #endif /* Q_WS_MAC */ 1118 const bool fAllowToShowActionPreferences = isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Preferences); 1008 1119 action(UIActionIndex_Simple_Preferences)->setEnabled(fAllowToShowActionPreferences); 1009 1120 if (fAllowToShowActionPreferences) 1010 1121 pMenu->addAction(action(UIActionIndex_Simple_Preferences)); 1011 1122 } 1123 #endif /* !RT_OS_DARWIN */ 1012 1124 1013 1125 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r52555 r52558 53 53 { 54 54 /* Various actions: */ 55 UIActionIndex_Simple_Preferences,56 55 UIActionIndex_Simple_LogDialog, 56 57 #ifdef RT_OS_DARWIN 58 /* 'Application' menu actions: */ 59 UIActionIndex_M_Application, 60 UIActionIndex_M_Application_S_About, 61 UIActionIndex_M_Application_S_Preferences, 62 UIActionIndex_M_Application_S_Close, 63 #endif /* RT_OS_DARWIN */ 57 64 58 65 /* 'Help' menu actions: */ … … 65 72 UIActionIndex_Simple_CheckForUpdates, 66 73 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 74 #ifndef RT_OS_DARWIN 67 75 UIActionIndex_Simple_About, 76 UIActionIndex_Simple_Preferences, 77 #endif /* !RT_OS_DARWIN */ 68 78 69 79 /* Maximum index: */ … … 402 412 /** Update menus routine. */ 403 413 virtual void updateMenus() = 0; 414 #ifdef RT_OS_DARWIN 415 /** Update 'Application' menu routine. */ 416 virtual void updateMenuApplication(); 417 #endif /* RT_OS_DARWIN */ 404 418 /** Update 'Help' menu routine. */ 405 419 virtual void updateMenuHelp(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r52478 r52558 524 524 }; 525 525 526 #ifndef RT_OS_DARWIN 526 527 class UIActionSimplePerformClose : public UIActionSimple 527 528 { … … 539 540 540 541 /** Returns action extra-data ID. */ 541 virtual int extraDataID() const 542 { 543 #ifdef Q_WS_MAC 544 return UIExtraDataMetaDefs::MenuApplicationActionType_Close; 545 #else /* !Q_WS_MAC */ 546 return UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close; 547 #endif /* !Q_WS_MAC */ 548 } 549 /** Returns action extra-data key. */ 550 virtual QString extraDataKey() const 551 { 552 #ifdef Q_WS_MAC 553 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_Close); 554 #else /* !Q_WS_MAC */ 555 return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close); 556 #endif /* !Q_WS_MAC */ 557 } 542 virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close;} 543 /** Returns action extra-data key. */ 544 virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close);} 558 545 559 546 QString shortcutExtraDataID() const … … 573 560 } 574 561 }; 562 #endif /* !RT_OS_DARWIN */ 575 563 576 564 class UIActionMenuView : public UIActionMenu … … 1789 1777 m_pool[UIActionIndexRT_M_Machine_S_Shutdown] = new UIActionSimplePerformShutdown(this); 1790 1778 m_pool[UIActionIndexRT_M_Machine_S_PowerOff] = new UIActionSimplePerformPowerOff(this); 1779 #ifndef RT_OS_DARWIN 1791 1780 m_pool[UIActionIndexRT_M_Machine_S_Close] = new UIActionSimplePerformClose(this); 1781 #endif /* !RT_OS_DARWIN */ 1792 1782 1793 1783 /* 'View' actions: */ … … 1980 1970 m_mainMenus.clear(); 1981 1971 1972 #ifdef RT_OS_DARWIN 1973 /* 'Application' menu: */ 1974 action(UIActionIndex_M_Application)->setVisible(false); 1975 m_mainMenus << action(UIActionIndex_M_Application)->menu(); 1976 updateMenuApplication(); 1977 #endif /* RT_OS_DARWIN */ 1978 1982 1979 /* 'Machine' menu: */ 1983 1980 const bool fAllowToShowMenuMachine = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_Machine); … … 2202 2199 2203 2200 2201 #ifndef Q_WS_MAC 2204 2202 /* Close action: */ 2205 const bool fAllowToShowActionClose = 2206 #ifdef Q_WS_MAC 2207 isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Close); 2208 #else /* !Q_WS_MAC */ 2209 isAllowedInMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close); 2210 #endif /* !Q_WS_MAC */ 2203 const bool fAllowToShowActionClose = isAllowedInMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Close); 2211 2204 pMenu->addAction(action(UIActionIndexRT_M_Machine_S_Close)); 2212 2205 action(UIActionIndexRT_M_Machine_S_Close)->setEnabled(fAllowToShowActionClose); 2206 #endif /* !Q_WS_MAC */ 2213 2207 2214 2208 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r52478 r52558 58 58 UIActionIndexRT_M_Machine_S_Shutdown, 59 59 UIActionIndexRT_M_Machine_S_PowerOff, 60 #ifndef RT_OS_DARWIN 60 61 UIActionIndexRT_M_Machine_S_Close, 62 #endif /* !RT_OS_DARWIN */ 61 63 62 64 /* 'View' menu actions: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r52516 r52558 925 925 connect(actionPool()->action(UIActionIndexRT_M_Machine_S_PowerOff), SIGNAL(triggered()), 926 926 this, SLOT(sltPowerOff())); 927 #ifdef RT_OS_DARWIN 928 connect(actionPool()->action(UIActionIndex_M_Application_S_Close), SIGNAL(triggered()), 929 this, SLOT(sltClose())); 930 #else /* !RT_OS_DARWIN */ 927 931 connect(actionPool()->action(UIActionIndexRT_M_Machine_S_Close), SIGNAL(triggered()), 928 932 this, SLOT(sltClose())); 933 #endif /* !RT_OS_DARWIN */ 929 934 930 935 /* 'View' actions connections: */ … … 966 971 967 972 /* 'Help' actions connections: */ 973 #ifdef RT_OS_DARWIN 974 connect(actionPool()->action(UIActionIndex_M_Application_S_Preferences), SIGNAL(triggered()), 975 this, SLOT(sltShowGlobalPreferences()), Qt::UniqueConnection); 976 #else /* !RT_OS_DARWIN */ 968 977 connect(actionPool()->action(UIActionIndex_Simple_Preferences), SIGNAL(triggered()), 969 978 this, SLOT(sltShowGlobalPreferences()), Qt::UniqueConnection); 979 #endif /* !RT_OS_DARWIN */ 970 980 } 971 981 … … 2239 2249 return; 2240 2250 2251 #ifdef RT_OS_DARWIN 2252 /* Check that we do NOT handling that already: */ 2253 if (actionPool()->action(UIActionIndex_M_Application_S_Preferences)->data().toBool()) 2254 return; 2255 /* Remember that we handling that already: */ 2256 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(true); 2257 #else /* !RT_OS_DARWIN */ 2241 2258 /* Check that we do NOT handling that already: */ 2242 2259 if (actionPool()->action(UIActionIndex_Simple_Preferences)->data().toBool()) … … 2244 2261 /* Remember that we handling that already: */ 2245 2262 actionPool()->action(UIActionIndex_Simple_Preferences)->setData(true); 2263 #endif /* !RT_OS_DARWIN */ 2246 2264 2247 2265 /* Create and execute global settings window: */ … … 2252 2270 delete pDialog; 2253 2271 2272 #ifdef RT_OS_DARWIN 2273 /* Remember that we do NOT handling that already: */ 2274 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(false); 2275 #else /* !RT_OS_DARWIN */ 2254 2276 /* Remember that we do NOT handling that already: */ 2255 2277 actionPool()->action(UIActionIndex_Simple_Preferences)->setData(false); 2278 #endif /* !RT_OS_DARWIN */ 2256 2279 } 2257 2280 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp
r52557 r52558 474 474 AssertPtrReturnVoid(pMenu); 475 475 { 476 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_ Simple_About));477 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_ Simple_Preferences));476 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_About)); 477 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 478 478 } 479 479 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r52472 r52558 1280 1280 m_pMenuBar->clear(); 1281 1281 foreach (QMenu *pMenu, actionPool()->menus()) 1282 m_pMenuBar->addMenu(pMenu); 1282 { 1283 UIMenu *pMenuUI = qobject_cast<UIMenu*>(pMenu); 1284 if (!pMenuUI->isConsumable() || !pMenuUI->isConsumed()) 1285 m_pMenuBar->addMenu(pMenuUI); 1286 if (pMenuUI->isConsumable() && !pMenuUI->isConsumed()) 1287 pMenuUI->setConsumed(true); 1288 } 1283 1289 } 1284 1290 #endif /* Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r52472 r52558 32 32 /* Forward declarations: */ 33 33 class QMenu; 34 class QMenuBar;35 34 class UIFrameBuffer; 36 35 class UIMachine; … … 41 40 class CNetworkAdapter; 42 41 class CMediumAttachment; 43 #ifndef Q_WS_MAC 42 #ifdef Q_WS_MAC 43 class QMenuBar; 44 #else /* !Q_WS_MAC */ 44 45 class QIcon; 45 class QMenuBar;46 46 #endif /* !Q_WS_MAC */ 47 47 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r52515 r52558 235 235 connect(m_pMiniToolBar, SIGNAL(sigExitAction()), 236 236 actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SLOT(trigger())); 237 #ifdef RT_OS_DARWIN 238 connect(m_pMiniToolBar, SIGNAL(sigCloseAction()), 239 actionPool()->action(UIActionIndex_M_Application_S_Close), SLOT(trigger())); 240 #else /* !RT_OS_DARWIN */ 237 241 connect(m_pMiniToolBar, SIGNAL(sigCloseAction()), 238 242 actionPool()->action(UIActionIndexRT_M_Machine_S_Close), SLOT(trigger())); 243 #endif /* !RT_OS_DARWIN */ 239 244 connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutFocusStolen()), this, SLOT(sltRevokeFocus())); 240 245 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r52215 r52558 321 321 void UISelectorWindow::sltShowPreferencesDialog() 322 322 { 323 #ifdef RT_OS_DARWIN 324 /* Check that we do NOT handling that already: */ 325 if (actionPool()->action(UIActionIndex_M_Application_S_Preferences)->data().toBool()) 326 return; 327 /* Remember that we handling that already: */ 328 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(true); 329 #else /* !RT_OS_DARWIN */ 323 330 /* Check that we do NOT handling that already: */ 324 331 if (actionPool()->action(UIActionIndex_Simple_Preferences)->data().toBool()) … … 326 333 /* Remember that we handling that already: */ 327 334 actionPool()->action(UIActionIndex_Simple_Preferences)->setData(true); 335 #endif /* !RT_OS_DARWIN */ 328 336 329 337 /* Don't show the inaccessible warning … … 335 343 dialog.execute(); 336 344 345 #ifdef RT_OS_DARWIN 346 /* Remember that we do NOT handling that already: */ 347 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(false); 348 #else /* !RT_OS_DARWIN */ 337 349 /* Remember that we do NOT handling that already: */ 338 350 actionPool()->action(UIActionIndex_Simple_Preferences)->setData(false); 351 #endif /* !RT_OS_DARWIN */ 339 352 } 340 353 … … 1146 1159 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager)); 1147 1160 #endif /* DEBUG */ 1161 #ifdef RT_OS_DARWIN 1162 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 1163 #else /* !RT_OS_DARWIN */ 1148 1164 pMenu->addAction(actionPool()->action(UIActionIndex_Simple_Preferences)); 1165 #endif /* !RT_OS_DARWIN */ 1149 1166 #ifndef Q_WS_MAC 1150 1167 pMenu->addSeparator(); … … 1367 1384 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager), SIGNAL(triggered()), this, SLOT(sltOpenExtraDataManagerWindow())); 1368 1385 #endif /* DEBUG */ 1386 #ifdef RT_OS_DARWIN 1387 connect(actionPool()->action(UIActionIndex_M_Application_S_Preferences), SIGNAL(triggered()), this, SLOT(sltShowPreferencesDialog())); 1388 #else /* !RT_OS_DARWIN */ 1369 1389 connect(actionPool()->action(UIActionIndex_Simple_Preferences), SIGNAL(triggered()), this, SLOT(sltShowPreferencesDialog())); 1390 #endif /* !RT_OS_DARWIN */ 1370 1391 connect(actionPool()->action(UIActionIndexST_M_File_S_Close), SIGNAL(triggered()), this, SLOT(sltPerformExit())); 1371 1392
Note:
See TracChangeset
for help on using the changeset viewer.