Changeset 85642 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 7, 2020 11:33:29 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r85641 r85642 208 208 { 209 209 case UIActionType_Menu: 210 case UIActionType_PolymorphicMenu:211 210 { 212 211 /* For menu types it's very easy: */ … … 255 254 const QString &strIcon, const QString &strIconDisabled) 256 255 : UIAction(pParent, UIActionType_Menu) 256 , m_pMenu(0) 257 257 { 258 258 if (!strIcon.isNull()) … … 265 265 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled) 266 266 : UIAction(pParent, UIActionType_Menu) 267 , m_pMenu(0) 267 268 { 268 269 if (!strIconNormal.isNull()) … … 274 275 const QIcon &icon) 275 276 : UIAction(pParent, UIActionType_Menu) 277 , m_pMenu(0) 276 278 { 277 279 if (!icon.isNull()) … … 280 282 } 281 283 284 UIActionMenu::~UIActionMenu() 285 { 286 /* Hide menu: */ 287 hideMenu(); 288 /* Delete menu: */ 289 delete m_pMenu; 290 m_pMenu = 0; 291 } 292 282 293 void UIActionMenu::setShowToolTip(bool fShowToolTip) 283 294 { 284 UIMenu *pMenu = qobject_cast<UIMenu*>(menu()); 285 AssertPtrReturnVoid(pMenu); 286 pMenu->setShowToolTip(fShowToolTip); 295 AssertPtrReturnVoid(m_pMenu); 296 m_pMenu->setShowToolTip(fShowToolTip); 297 } 298 299 void UIActionMenu::showMenu() 300 { 301 /* Show menu if necessary: */ 302 if (!menu()) 303 setMenu(m_pMenu); 304 } 305 306 void UIActionMenu::hideMenu() 307 { 308 /* Hide menu if necessary: */ 309 if (menu()) 310 setMenu(0); 287 311 } 288 312 … … 290 314 { 291 315 /* Create menu: */ 292 setMenu(new UIMenu);293 AssertPtrReturnVoid(m enu());316 m_pMenu = new UIMenu; 317 AssertPtrReturnVoid(m_pMenu); 294 318 { 295 319 /* Prepare menu: */ 296 connect(m enu(), &UIMenu::aboutToShow,320 connect(m_pMenu, &UIMenu::aboutToShow, 297 321 actionPool(), &UIActionPool::sltHandleMenuPrepare); 322 /* Show menu: */ 323 showMenu(); 298 324 } 299 325 } … … 384 410 { 385 411 setCheckable(true); 386 }387 388 389 /*********************************************************************************************************************************390 * Class UIActionPolymorphicMenu implementation. *391 *********************************************************************************************************************************/392 393 UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,394 const QString &strIcon, const QString &strIconDisabled)395 : UIAction(pParent, UIActionType_PolymorphicMenu)396 , m_pMenu(0)397 {398 if (!strIcon.isNull())399 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));400 prepare();401 }402 403 UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,404 const QString &strIconNormal, const QString &strIconSmall,405 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled)406 : UIAction(pParent, UIActionType_PolymorphicMenu)407 , m_pMenu(0)408 {409 if (!strIconNormal.isNull())410 setIcon(UIIconPool::iconSetFull(strIconNormal, strIconSmall, strIconNormalDisabled, strIconSmallDisabled));411 prepare();412 }413 414 UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,415 const QIcon &icon)416 : UIAction(pParent, UIActionType_PolymorphicMenu)417 , m_pMenu(0)418 {419 if (!icon.isNull())420 setIcon(icon);421 prepare();422 }423 424 UIActionPolymorphicMenu::~UIActionPolymorphicMenu()425 {426 /* Hide menu: */427 hideMenu();428 /* Delete menu: */429 delete m_pMenu;430 m_pMenu = 0;431 }432 433 void UIActionPolymorphicMenu::setShowToolTip(bool fShowToolTip)434 {435 UIMenu *pMenu = qobject_cast<UIMenu*>(menu());436 if (pMenu)437 pMenu->setShowToolTip(fShowToolTip);438 }439 440 void UIActionPolymorphicMenu::showMenu()441 {442 /* Show menu if necessary: */443 if (!menu())444 setMenu(m_pMenu);445 }446 447 void UIActionPolymorphicMenu::hideMenu()448 {449 /* Hide menu if necessary: */450 if (menu())451 setMenu(0);452 }453 454 void UIActionPolymorphicMenu::prepare()455 {456 /* Create menu: */457 m_pMenu = new UIMenu;458 AssertPtrReturnVoid(m_pMenu);459 {460 /* Prepare menu: */461 connect(m_pMenu, &UIMenu::aboutToShow,462 actionPool(), &UIActionPool::sltHandleMenuPrepare);463 /* Show menu: */464 showMenu();465 }466 412 } 467 413 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r85641 r85642 52 52 UIActionType_Menu, 53 53 UIActionType_Simple, 54 UIActionType_Toggle, 55 UIActionType_PolymorphicMenu 54 UIActionType_Toggle 56 55 }; 57 56 … … 329 328 const QIcon &icon); 330 329 330 /** Destructs menu action. */ 331 virtual ~UIActionMenu() /* override */; 332 331 333 /** Defines whether tool-tip should be shown. */ 332 334 void setShowToolTip(bool fShowToolTip); 333 335 336 /** Shows menu. */ 337 void showMenu(); 338 /** Hides menu. */ 339 void hideMenu(); 340 334 341 private: 335 342 336 343 /** Prepares all. */ 337 344 void prepare(); 345 346 /** Holds the menu instance. */ 347 UIMenu *m_pMenu; 338 348 }; 339 349 … … 415 425 /** Prepares all. */ 416 426 void prepare(); 417 };418 419 420 /** Abstract UIAction extension for 'Polymorphic Menu' action type. */421 class SHARED_LIBRARY_STUFF UIActionPolymorphicMenu : public UIAction422 {423 Q_OBJECT;424 425 protected:426 427 /** Constructs polymorphic menu action passing @a pParent to the base-class.428 * @param strIcon Brings the normal-icon name.429 * @param strIconDisabled Brings the disabled-icon name. */430 UIActionPolymorphicMenu(UIActionPool *pParent,431 const QString &strIcon = QString(), const QString &strIconDisabled = QString());432 /** Constructs polymorphic menu action passing @a pParent to the base-class.433 * @param strIconNormal Brings the normal-icon name.434 * @param strIconSmall Brings the small-icon name.435 * @param strIconNormalDisabled Brings the normal-disabled-icon name.436 * @param strIconSmallDisabled Brings the small-disabled-icon name. */437 UIActionPolymorphicMenu(UIActionPool *pParent,438 const QString &strIconNormal, const QString &strIconSmall,439 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);440 /** Constructs polymorphic menu action passing @a pParent to the base-class.441 * @param icon Brings the icon. */442 UIActionPolymorphicMenu(UIActionPool *pParent,443 const QIcon &icon);444 445 /** Destructs polymorphic menu action. */446 virtual ~UIActionPolymorphicMenu() /* override */;447 448 /** Defines whether tool-tip should be shown. */449 void setShowToolTip(bool fShowToolTip);450 451 /** Shows menu. */452 void showMenu();453 /** Hides menu. */454 void hideMenu();455 456 private:457 458 /** Prepares all. */459 void prepare();460 461 private:462 463 /** Holds the menu instance. */464 UIMenu *m_pMenu;465 427 }; 466 428 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r85634 r85642 923 923 924 924 /** Menu action extension, used as 'Start or Show' menu class. */ 925 class UIActionStateManagerCommonStartOrShow : public UIAction PolymorphicMenu925 class UIActionStateManagerCommonStartOrShow : public UIActionMenu 926 926 { 927 927 Q_OBJECT; … … 931 931 /** Constructs action passing @a pParent to the base-class. */ 932 932 UIActionStateManagerCommonStartOrShow(UIActionPool *pParent) 933 : UIAction PolymorphicMenu(pParent,934 935 933 : UIActionMenu(pParent, 934 ":/vm_start_32px.png", ":/vm_start_16px.png", 935 ":/vm_start_disabled_32px.png", ":/vm_start_disabled_16px.png") 936 936 {} 937 937
Note:
See TracChangeset
for help on using the changeset viewer.