VirtualBox

Changeset 82187 in vbox for trunk/src


Ignore:
Timestamp:
Nov 25, 2019 5:18:11 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9609: Rework UIShortcut interface to support standard shortcut sequence; Update code accordingly to handle both default and standard sequences simultaneously.

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

Legend:

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

    r82186 r82187  
    247247    /** Returns default keyboard shortcut for this action. */
    248248    virtual QKeySequence defaultShortcut(UIActionPoolType) const { return QKeySequence(); }
     249    /** Returns standard keyboard shortcut for this action. */
     250    virtual QKeySequence standardShortcut(UIActionPoolType) const { return QKeySequence(); }
    249251
    250252    /** Defines current keyboard shortcuts for this action. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.cpp

    r82186 r82187  
    7171}
    7272
     73void UIShortcut::setStandardSequence(const QKeySequence &standardSequence)
     74{
     75    m_standardSequence = standardSequence;
     76}
     77
     78const QKeySequence &UIShortcut::standardSequence() const
     79{
     80    return m_standardSequence;
     81}
     82
    7383QString UIShortcut::primaryToNativeText() const
    7484{
     
    130140    newShortcut.setDescription(pAction->name());
    131141    const QKeySequence &defaultSequence = pAction->defaultShortcut(pActionPool->type());
    132     newShortcut.setSequences(QList<QKeySequence>() << defaultSequence);
     142    const QKeySequence &standardSequence = pAction->standardShortcut(pActionPool->type());
     143    newShortcut.setSequences(QList<QKeySequence>() << defaultSequence << standardSequence);
    133144    newShortcut.setDefaultSequence(defaultSequence);
     145    newShortcut.setStandardSequence(standardSequence);
    134146    return newShortcut;
    135147}
     
    181193            pAction->setShortcuts(existingShortcut.sequences());
    182194            pAction->retranslateUi();
    183             /* Copy default sequence from the action to the shortcut: */
     195            /* Copy default and standard sequences from the action to the shortcut: */
    184196            existingShortcut.setDefaultSequence(pAction->defaultShortcut(pActionPool->type()));
     197            existingShortcut.setStandardSequence(pAction->standardShortcut(pActionPool->type()));
    185198        }
    186199        /* If shortcut key is NOT known yet: */
     
    191204            /* Copy the action's default sequence to both the shortcut & the action: */
    192205            const QKeySequence &defaultSequence = pAction->defaultShortcut(pActionPool->type());
    193             newShortcut.setSequences(QList<QKeySequence>() << defaultSequence);
     206            const QKeySequence &standardSequence = pAction->standardShortcut(pActionPool->type());
     207            newShortcut.setSequences(QList<QKeySequence>() << defaultSequence << standardSequence);
    194208            newShortcut.setDefaultSequence(defaultSequence);
     209            newShortcut.setStandardSequence(standardSequence);
    195210            pAction->setShortcuts(newShortcut.sequences());
    196211            pAction->retranslateUi();
     
    299314                                      QApplication::translate("UIActionPool", "Popup Menu"),
    300315                                      QList<QKeySequence>() << QString("Home"),
    301                                       QString("Home")));
     316                                      QString("Home"),
     317                                      QString()));
    302318    }
    303319}
     
    340356                                          QString(),
    341357                                          QList<QKeySequence>() << strShortcutSequence,
     358                                          QString(),
    342359                                          QString()));
    343360        else
     
    381398        /* Get corresponding shortcut: */
    382399        const UIShortcut &shortcut = m_shortcuts[strShortcutKey];
    383         /* Check if the sequence for that shortcut differs from default: */
    384         if (shortcut.sequences().contains(shortcut.defaultSequence()))
     400        /* Check if the sequence for that shortcut differs from default or standard: */
     401        if (   shortcut.sequences().contains(shortcut.defaultSequence())
     402            || shortcut.sequences().contains(shortcut.standardSequence()))
    385403            continue;
    386404        /* Add the shortcut sequence into overrides list: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.h

    r82186 r82187  
    4747        , m_sequences(QList<QKeySequence>())
    4848        , m_defaultSequence(QKeySequence())
     49        , m_standardSequence(QKeySequence())
    4950    {}
    5051    /** Constructs shortcut descriptor.
     
    5253      * @param  strDescription    Brings the shortcut description.
    5354      * @param  sequences         Brings the shortcut sequences.
    54       * @param  defaultSequence   Brings the default shortcut sequence. */
     55      * @param  defaultSequence   Brings the default shortcut sequence.
     56      * @param  standardSequence  Brings the standard shortcut sequence. */
    5557    UIShortcut(const QString &strScope,
    5658               const QString &strDescription,
    5759               const QList<QKeySequence> &sequences,
    58                const QKeySequence &defaultSequence)
     60               const QKeySequence &defaultSequence,
     61               const QKeySequence &standardSequence)
    5962        : m_strScope(strScope)
    6063        , m_strDescription(strDescription)
    6164        , m_sequences(sequences)
    6265        , m_defaultSequence(defaultSequence)
     66        , m_standardSequence(standardSequence)
    6367    {}
    6468
     
    8286    /** Returns the default shortcut sequence. */
    8387    const QKeySequence &defaultSequence() const;
     88
     89    /** Defines the standard shortcut @a sequence. */
     90    void setStandardSequence(const QKeySequence &sequence);
     91    /** Returns the standard shortcut sequence. */
     92    const QKeySequence &standardSequence() const;
    8493
    8594    /** Converts primary shortcut sequence to native text. */
     
    98107    /** Holds the default shortcut sequence. */
    99108    QKeySequence         m_defaultSequence;
     109    /** Holds the standard shortcut sequence. */
     110    QKeySequence         m_standardSequence;
    100111};
    101112
Note: See TracChangeset for help on using the changeset viewer.

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