VirtualBox

Changeset 85620 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 5, 2020 6:39:14 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139729
Message:

FE/Qt: bugref:9609: A bit of cleanup for action-pool stuff: No need for state management stuff in UIActionPolymorphicMenu class since it's already present in UIAction base class.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r85619 r85620  
    125125}
    126126
    127 UIActionPolymorphicMenu *UIAction::toActionPolymorphicMenu()
    128 {
    129     return qobject_cast<UIActionPolymorphicMenu*>(this);
     127void UIAction::setState(int iState)
     128{
     129    m_iState = iState;
     130    updateIcon();
     131    retranslateUi();
    130132}
    131133
     
    382384    : UIAction(pParent, UIActionType_PolymorphicMenu)
    383385    , m_pMenu(0)
    384     , m_iState(0)
    385386{
    386387    if (!strIcon.isNull())
     
    394395    : UIAction(pParent, UIActionType_PolymorphicMenu)
    395396    , m_pMenu(0)
    396     , m_iState(0)
    397397{
    398398    if (!strIconNormal.isNull())
     
    405405    : UIAction(pParent, UIActionType_PolymorphicMenu)
    406406    , m_pMenu(0)
    407     , m_iState(0)
    408407{
    409408    if (!icon.isNull())
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r85619 r85620  
    215215    UIActionPool *actionPool() const { return m_pActionPool; }
    216216
    217     /** Casts action to polymorphic-menu-action. */
    218     UIActionPolymorphicMenu *toActionPolymorphicMenu();
    219 
    220217    /** Returns current action state. */
    221218    int state() const { return m_iState; }
    222219    /** Defines current action @a iState. */
    223     void setState(int iState) { m_iState = iState; updateIcon(); retranslateUi(); }
     220    void setState(int iState);
    224221
    225222    /** Defines @a icon for certain @a iState. */
     
    282279      * @note Used to simplify action names for tool-tip needs. */
    283280    static QString simplifyText(QString strText);
    284 
    285 private:
    286281
    287282    /** Holds the action type. */
     
    434429    Q_OBJECT;
    435430
    436 public:
    437 
    438     /** Returns current action state. */
    439     int state() const { return m_iState; }
    440     /** Defines current action state. */
    441     void setState(int iState) { m_iState = iState; retranslateUi(); }
    442 
    443431protected:
    444432
     
    484472    /** Holds the menu instance. */
    485473    UIMenu *m_pMenu;
    486     /** Holds current action state. */
    487     int     m_iState;
    488474};
    489475
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r85597 r85620  
    30283028            || pItem->itemType() == UIVirtualMachineItemType_CloudReal))
    30293029    {
    3030         actionPool()->action(UIActionIndexMN_M_Group_S_Discard)->toActionPolymorphicMenu()->setState(1);
    3031         actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)->toActionPolymorphicMenu()->setState(1);
     3030        actionPool()->action(UIActionIndexMN_M_Group_S_Discard)->setState(1);
     3031        actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)->setState(1);
    30323032    }
    30333033    else
    30343034    {
    3035         actionPool()->action(UIActionIndexMN_M_Group_S_Discard)->toActionPolymorphicMenu()->setState(0);
    3036         actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)->toActionPolymorphicMenu()->setState(0);
     3035        actionPool()->action(UIActionIndexMN_M_Group_S_Discard)->setState(0);
     3036        actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)->setState(0);
    30373037    }
    30383038
     
    30403040    if (pItem && pItem->accessible())
    30413041    {
    3042         actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(pItem->isItemPoweredOff() ? 0 : 1);
    3043         actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(pItem->isItemPoweredOff() ? 0 : 1);
     3042        actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)->setState(pItem->isItemPoweredOff() ? 0 : 1);
     3043        actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)->setState(pItem->isItemPoweredOff() ? 0 : 1);
    30443044        /// @todo Hmm, fix it?
    30453045//        QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)));
     
    30493049    else
    30503050    {
    3051         actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(0);
    3052         actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(0);
     3051        actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)->setState(0);
     3052        actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)->setState(0);
    30533053        /// @todo Hmm, fix it?
    30543054//        QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette