VirtualBox

Changeset 44586 in vbox


Ignore:
Timestamp:
Feb 7, 2013 1:52:35 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6065: Saving overridden shortcuts at shortcut-pool cleanup.

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

Legend:

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

    r44585 r44586  
    210210}
    211211
     212void UIShortcutPool::cleanup()
     213{
     214    /* Save overrides: */
     215    saveOverrides();
     216}
     217
    212218void UIShortcutPool::loadDefaults()
    213219{
     
    253259            /* Get corresponding value: */
    254260            UIShortcut &shortcut = m_shortcuts[strShortcutKey];
    255             /* Check if corresponding shortcut overriden by value: */
     261            /* Check if corresponding shortcut overridden by value: */
    256262            if (shortcut.toString().compare(strShortcutSequence, Qt::CaseInsensitive) != 0)
    257263            {
     
    267273}
    268274
     275void UIShortcutPool::saveOverrides()
     276{
     277    /* Load selector overrides: */
     278    saveOverridesFor(GUI_Input_SelectorShortcuts);
     279    /* Load machine overrides: */
     280    saveOverridesFor(GUI_Input_MachineShortcuts);
     281}
     282
     283void UIShortcutPool::saveOverridesFor(const QString &strPoolExtraDataID)
     284{
     285    /* Compose shortcut prefix: */
     286    const QString strShortcutPrefix(m_strShortcutKeyTemplate.arg(strPoolExtraDataID, QString()));
     287    /* Populate the list of all the known overrides: */
     288    QStringList overrides;
     289    const QList<QString> shortcutKeys = m_shortcuts.keys();
     290    foreach (const QString &strShortcutKey, shortcutKeys)
     291    {
     292        /* Check if the key starts from the proper prefix: */
     293        if (!strShortcutKey.startsWith(strShortcutPrefix))
     294            continue;
     295        /* Get corresponding shortcut: */
     296        const UIShortcut &shortcut = m_shortcuts[strShortcutKey];
     297        /* Check if the sequence for that shortcut differs from default: */
     298        if (shortcut.sequence() == shortcut.defaultSequence())
     299            continue;
     300        /* Add the shortcut sequence into overrides list: */
     301        overrides << QString("%1=%2").arg(QString(strShortcutKey).remove(strShortcutPrefix),
     302                                          shortcut.sequence().toString());
     303    }
     304    /* Save overrides into the extra-data: */
     305    vboxGlobal().virtualBox().SetExtraDataStringList(strPoolExtraDataID, overrides);
     306}
     307
    269308UIShortcut& UIShortcutPool::shortcut(const QString &strShortcutKey)
    270309{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.h

    r44585 r44586  
    115115
    116116    /* Helper: Cleanup stuff: */
    117     void cleanup() {}
     117    void cleanup();
    118118
    119119    /* Helpers: Shortcuts stuff: */
     
    121121    void loadOverrides();
    122122    void loadOverridesFor(const QString &strPoolExtraDataID);
     123    void saveOverrides();
     124    void saveOverridesFor(const QString &strPoolExtraDataID);
    123125
    124126    /* Helper: Shortcut stuff: */
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