VirtualBox

Changeset 64254 in vbox


Ignore:
Timestamp:
Oct 13, 2016 2:51:50 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111264
Message:

FE/Qt: bugref:6899: Accessibility support (step 87): Preferences: Input page: Moving cache declaration to source file (doxy and encapsulation later).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/global
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r64180 r64254  
    4242/* Namespaces: */
    4343using namespace UIExtraDataDefs;
     44
     45
     46/* Global settings / Input page / Cache / Shortcut cache item: */
     47struct UIShortcutCacheItem
     48{
     49    UIShortcutCacheItem(const QString &strKey,
     50                        const QString &strDescription,
     51                        const QString &strCurrentSequence,
     52                        const QString &strDefaultSequence)
     53        : key(strKey)
     54        , description(strDescription)
     55        , currentSequence(strCurrentSequence)
     56        , defaultSequence(strDefaultSequence)
     57    {}
     58
     59    UIShortcutCacheItem(const UIShortcutCacheItem &other)
     60        : key(other.key)
     61        , description(other.description)
     62        , currentSequence(other.currentSequence)
     63        , defaultSequence(other.defaultSequence)
     64    {}
     65
     66    UIShortcutCacheItem& operator=(const UIShortcutCacheItem &other)
     67    {
     68        key = other.key;
     69        description = other.description;
     70        currentSequence = other.currentSequence;
     71        defaultSequence = other.defaultSequence;
     72        return *this;
     73    }
     74
     75    bool operator==(const UIShortcutCacheItem &other) const
     76    {
     77        return key == other.key;
     78    }
     79
     80    QString key;
     81    QString description;
     82    QString currentSequence;
     83    QString defaultSequence;
     84};
     85
     86/* Global settings / Input page / Cache / Shortcut cache: */
     87typedef QList<UIShortcutCacheItem> UIShortcutCache;
     88
     89/* Global settings / Input page / Cache: */
     90class UISettingsCacheGlobalInput : public QObject
     91{
     92    Q_OBJECT;
     93
     94public:
     95
     96    UISettingsCacheGlobalInput(QObject *pParent)
     97        : QObject(pParent)
     98        , m_fAutoCapture(false)
     99    {}
     100
     101    UIShortcutCache m_shortcuts;
     102    bool m_fAutoCapture;
     103};
    44104
    45105
     
    562622    , m_pSelectorFilterEditor(0), m_pSelectorModel(0), m_pSelectorTable(0)
    563623    , m_pMachineFilterEditor(0), m_pMachineModel(0), m_pMachineTable(0)
     624    , m_pCache(new UISettingsCacheGlobalInput(this))
    564625{
    565626    /* Apply UI decorations: */
     
    630691
    631692    /* Load host-combo shortcut to cache: */
    632     m_cache.m_shortcuts << UIShortcutCacheItem(UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"),  m_settings.hostCombo(), QString());
     693    m_pCache->m_shortcuts << UIShortcutCacheItem(UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"),  m_settings.hostCombo(), QString());
    633694    /* Load all other shortcuts to cache: */
    634695    const QMap<QString, UIShortcut>& shortcuts = gShortcutPool->shortcuts();
     
    637698    {
    638699        const UIShortcut &shortcut = shortcuts[strShortcutKey];
    639         m_cache.m_shortcuts << UIShortcutCacheItem(strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()),
     700        m_pCache->m_shortcuts << UIShortcutCacheItem(strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()),
    640701                                                   shortcut.sequence().toString(QKeySequence::NativeText),
    641702                                                   shortcut.defaultSequence().toString(QKeySequence::NativeText));
    642703    }
    643704    /* Load other things to cache: */
    644     m_cache.m_fAutoCapture = m_settings.autoCapture();
     705    m_pCache->m_fAutoCapture = m_settings.autoCapture();
    645706
    646707    /* Upload properties & settings to data: */
     
    653714{
    654715    /* Fetch from cache: */
    655     m_pSelectorModel->load(m_cache.m_shortcuts);
    656     m_pMachineModel->load(m_cache.m_shortcuts);
    657     m_pEnableAutoGrabCheckbox->setChecked(m_cache.m_fAutoCapture);
     716    m_pSelectorModel->load(m_pCache->m_shortcuts);
     717    m_pMachineModel->load(m_pCache->m_shortcuts);
     718    m_pEnableAutoGrabCheckbox->setChecked(m_pCache->m_fAutoCapture);
    658719
    659720    /* Revalidate: */
     
    666727{
    667728    /* Upload to cache: */
    668     m_pSelectorModel->save(m_cache.m_shortcuts);
    669     m_pMachineModel->save(m_cache.m_shortcuts);
    670     m_cache.m_fAutoCapture = m_pEnableAutoGrabCheckbox->isChecked();
     729    m_pSelectorModel->save(m_pCache->m_shortcuts);
     730    m_pMachineModel->save(m_pCache->m_shortcuts);
     731    m_pCache->m_fAutoCapture = m_pEnableAutoGrabCheckbox->isChecked();
    671732}
    672733
     
    680741    /* Save host-combo shortcut from cache: */
    681742    UIShortcutCacheItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
    682     int iIndexOfHostComboItem = m_cache.m_shortcuts.indexOf(fakeHostComboItem);
     743    int iIndexOfHostComboItem = m_pCache->m_shortcuts.indexOf(fakeHostComboItem);
    683744    if (iIndexOfHostComboItem != -1)
    684         m_settings.setHostCombo(m_cache.m_shortcuts[iIndexOfHostComboItem].currentSequence);
     745        m_settings.setHostCombo(m_pCache->m_shortcuts[iIndexOfHostComboItem].currentSequence);
    685746    /* Iterate over cached shortcuts: */
    686747    QMap<QString, QString> sequences;
    687     foreach (const UIShortcutCacheItem &item, m_cache.m_shortcuts)
     748    foreach (const UIShortcutCacheItem &item, m_pCache->m_shortcuts)
    688749        sequences.insert(item.key, item.currentSequence);
    689750    /* Save shortcut sequences from cache: */
    690751    gShortcutPool->setOverrides(sequences);
    691752    /* Save other things from cache: */
    692     m_settings.setAutoCapture(m_cache.m_fAutoCapture);
     753    m_settings.setAutoCapture(m_pCache->m_fAutoCapture);
    693754
    694755    /* Upload properties & settings to data: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.h

    r64170 r64254  
    3131class QTabWidget;
    3232class QLineEdit;
     33class UISettingsCacheGlobalInput;
    3334class UIHotKeyTableModel;
    3435class UIHotKeyTable;
    35 
    36 /* Global settings / Input page / Cache / Shortcut cache item: */
    37 struct UIShortcutCacheItem
    38 {
    39     UIShortcutCacheItem(const QString &strKey,
    40                         const QString &strDescription,
    41                         const QString &strCurrentSequence,
    42                         const QString &strDefaultSequence)
    43         : key(strKey)
    44         , description(strDescription)
    45         , currentSequence(strCurrentSequence)
    46         , defaultSequence(strDefaultSequence)
    47     {}
    48 
    49     UIShortcutCacheItem(const UIShortcutCacheItem &other)
    50         : key(other.key)
    51         , description(other.description)
    52         , currentSequence(other.currentSequence)
    53         , defaultSequence(other.defaultSequence)
    54     {}
    55 
    56     UIShortcutCacheItem& operator=(const UIShortcutCacheItem &other)
    57     {
    58         key = other.key;
    59         description = other.description;
    60         currentSequence = other.currentSequence;
    61         defaultSequence = other.defaultSequence;
    62         return *this;
    63     }
    64 
    65     bool operator==(const UIShortcutCacheItem &other) const
    66     {
    67         return key == other.key;
    68     }
    69 
    70     QString key;
    71     QString description;
    72     QString currentSequence;
    73     QString defaultSequence;
    74 };
    75 
    76 /* Global settings / Input page / Cache / Shortcut cache: */
    77 typedef QList<UIShortcutCacheItem> UIShortcutCache;
    78 
    79 /* Global settings / Input page / Cache: */
    80 struct UISettingsCacheGlobalInput
    81 {
    82     UIShortcutCache m_shortcuts;
    83     bool m_fAutoCapture;
    84 };
    8536
    8637/* Global settings / Input page: */
     
    13182    void prepareValidation();
    13283
    133     /* Cache: */
    134     UISettingsCacheGlobalInput m_cache;
    13584    QTabWidget *m_pTabWidget;
    13685    QLineEdit *m_pSelectorFilterEditor;
     
    14089    UIHotKeyTableModel *m_pMachineModel;
    14190    UIHotKeyTable *m_pMachineTable;
     91
     92    /** Holds the cache instance. */
     93    UISettingsCacheGlobalInput *m_pCache;
    14294};
    14395
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