VirtualBox

Changeset 85619 in vbox


Ignore:
Timestamp:
Aug 5, 2020 6:34:08 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139728
Message:

FE/Qt: bugref:9609: A bit of cleanup for action-pool stuff: Coding-style fixes; Make sure UIAction icon is always assigned if icon for at least initial state is set; A bit of paranoia for menu tool-tip setter.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

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

    r85613 r85619  
    196196void UIAction::updateIcon()
    197197{
    198     QAction::setIcon(m_icons.value(m_iState));
     198    QAction::setIcon(m_icons.value(m_iState, m_icons.value(0)));
    199199}
    200200
     
    264264void UIActionMenu::setShowToolTip(bool fShowToolTip)
    265265{
    266     qobject_cast<UIMenu*>(menu())->setShowToolTip(fShowToolTip);
     266    UIMenu *pMenu = qobject_cast<UIMenu*>(menu());
     267    AssertPtrReturnVoid(pMenu);
     268    pMenu->setShowToolTip(fShowToolTip);
    267269}
    268270
     
    421423void UIActionPolymorphicMenu::setShowToolTip(bool fShowToolTip)
    422424{
    423     qobject_cast<UIMenu*>(menu())->setShowToolTip(fShowToolTip);
     425    UIMenu *pMenu = qobject_cast<UIMenu*>(menu());
     426    if (pMenu)
     427        pMenu->setShowToolTip(fShowToolTip);
    424428}
    425429
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r85610 r85619  
    144144};
    145145
    146 /** Restriction levels. */
     146/** Action restriction levels. */
    147147enum UIActionRestrictionLevel
    148148{
     
    237237    /** Defines action @a strShortcutScope. */
    238238    void setShortcutScope(const QString &strShortcutScope) { m_strShortcutScope = strShortcutScope; }
     239
     240    /** Defines current keyboard shortcuts for this action. */
     241    void setShortcuts(const QList<QKeySequence> &shortcuts);
     242    /** Make action show keyboard shortcut. */
     243    void showShortcut();
     244    /** Make action hide keyboard shortcut. */
     245    void hideShortcut();
    239246
    240247    /** Returns action extra-data ID. */
     
    252259    virtual QKeySequence standardShortcut(UIActionPoolType) const { return QKeySequence(); }
    253260
    254     /** Defines current keyboard shortcuts for this action. */
    255     void setShortcuts(const QList<QKeySequence> &shortcuts);
    256     /** Make action show keyboard shortcut. */
    257     void showShortcut();
    258     /** Make action hide keyboard shortcut. */
    259     void hideShortcut();
    260 
    261261    /** Retranslates action. */
    262262    virtual void retranslateUi() = 0;
     
    286286
    287287    /** Holds the action type. */
    288     UIActionType  m_enmType;
     288    const UIActionType  m_enmType;
    289289    /** Holds whether this is machine-menu action. */
    290     bool          m_fMachineMenuAction;
     290    const bool          m_fMachineMenuAction;
    291291
    292292    /** Holds the reference to the action-pool this action belongs to. */
    293     UIActionPool     *m_pActionPool;
     293    UIActionPool           *m_pActionPool;
    294294    /** Holds the type of the action-pool this action belongs to. */
    295     UIActionPoolType  m_enmActionPoolType;
     295    const UIActionPoolType  m_enmActionPoolType;
    296296
    297297    /** Holds current action state. */
    298     int                  m_iState;
     298    int             m_iState;
    299299    /** Holds action icons. */
    300     QVector<QIcon>       m_icons;
     300    QVector<QIcon>  m_icons;
     301
    301302    /** Holds the action name. */
    302     QString              m_strName;
     303    QString  m_strName;
     304
    303305    /** Holds the action shortcut scope. */
    304306    QString              m_strShortcutScope;
     
    321323      * @param  strIconDisabled  Brings the disabled-icon name. */
    322324    UIActionMenu(UIActionPool *pParent,
    323                  const QString &strIcon = QString(),
    324                  const QString &strIconDisabled = QString());
     325                 const QString &strIcon = QString(), const QString &strIconDisabled = QString());
    325326    /** Constructs menu action passing @a pParent to the base-class.
    326327      * @param  strIconNormal          Brings the normal-icon name.
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