VirtualBox

Changeset 65684 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Feb 8, 2017 3:42:47 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Global preferences: General page: Integrate settings caching.

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

Legend:

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

    r65678 r65684  
    5353    UISettingsPageGlobal::fetchData(data);
    5454
    55     /* Load to cache: */
    56     m_cache.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
    57     m_cache.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
    58     m_cache.m_fHostScreenSaverDisabled = m_settings.hostScreenSaverDisabled();
     55    /* Clear cache initially: */
     56    m_cache.clear();
     57
     58    /* Prepare old data: */
     59    UIDataSettingsGlobalGeneral oldData;
     60
     61    /* Gather old data: */
     62    oldData.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
     63    oldData.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
     64    oldData.m_fHostScreenSaverDisabled = m_settings.hostScreenSaverDisabled();
     65
     66    /* Cache old data: */
     67    m_cache.cacheInitialData(oldData);
    5968
    6069    /* Upload properties & settings to data: */
     
    6473void UIGlobalSettingsGeneral::getFromCache()
    6574{
    66     /* Fetch from cache: */
    67     m_pSelectorMachineFolder->setPath(m_cache.m_strDefaultMachineFolder);
    68     m_pSelectorVRDPLibName->setPath(m_cache.m_strVRDEAuthLibrary);
    69     m_pCheckBoxHostScreenSaver->setChecked(m_cache.m_fHostScreenSaverDisabled);
     75    /* Get old data from cache: */
     76    const UIDataSettingsGlobalGeneral &oldData = m_cache.base();
     77
     78    /* Load old data from cache: */
     79    m_pSelectorMachineFolder->setPath(oldData.m_strDefaultMachineFolder);
     80    m_pSelectorVRDPLibName->setPath(oldData.m_strVRDEAuthLibrary);
     81    m_pCheckBoxHostScreenSaver->setChecked(oldData.m_fHostScreenSaverDisabled);
    7082}
    7183
    7284void UIGlobalSettingsGeneral::putToCache()
    7385{
    74     /* Upload to cache: */
    75     m_cache.m_strDefaultMachineFolder = m_pSelectorMachineFolder->path();
    76     m_cache.m_strVRDEAuthLibrary = m_pSelectorVRDPLibName->path();
    77     m_cache.m_fHostScreenSaverDisabled = m_pCheckBoxHostScreenSaver->isChecked();
     86    /* Prepare new data: */
     87    UIDataSettingsGlobalGeneral newData = m_cache.base();
     88
     89    /* Gather new data: */
     90    newData.m_strDefaultMachineFolder = m_pSelectorMachineFolder->path();
     91    newData.m_strVRDEAuthLibrary = m_pSelectorVRDPLibName->path();
     92    newData.m_fHostScreenSaverDisabled = m_pCheckBoxHostScreenSaver->isChecked();
     93
     94    /* Cache new data: */
     95    m_cache.cacheCurrentData(newData);
    7896}
    7997
     
    83101    UISettingsPageGlobal::fetchData(data);
    84102
    85     /* Save from cache: */
    86     if (m_properties.isOk() && m_pSelectorMachineFolder->isModified())
    87         m_properties.SetDefaultMachineFolder(m_cache.m_strDefaultMachineFolder);
    88     if (m_properties.isOk() && m_pSelectorVRDPLibName->isModified())
    89         m_properties.SetVRDEAuthLibrary(m_cache.m_strVRDEAuthLibrary);
    90     m_settings.setHostScreenSaverDisabled(m_cache.m_fHostScreenSaverDisabled);
     103    /* Save new data from cache: */
     104    if (m_cache.wasChanged())
     105    {
     106        if (   m_properties.isOk()
     107            && m_cache.data().m_strDefaultMachineFolder != m_cache.base().m_strDefaultMachineFolder)
     108            m_properties.SetDefaultMachineFolder(m_cache.data().m_strDefaultMachineFolder);
     109        if (   m_properties.isOk()
     110            && m_cache.data().m_strVRDEAuthLibrary != m_cache.base().m_strVRDEAuthLibrary)
     111            m_properties.SetVRDEAuthLibrary(m_cache.data().m_strVRDEAuthLibrary);
     112        if (m_cache.data().m_fHostScreenSaverDisabled != m_cache.base().m_fHostScreenSaverDisabled)
     113            m_settings.setHostScreenSaverDisabled(m_cache.data().m_fHostScreenSaverDisabled);
     114    }
    91115
    92116    /* Upload properties & settings to data: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.h

    r65678 r65684  
    2424
    2525
    26 /** Global settings: General page cache structure. */
    27 struct UISettingsCacheGlobalGeneral
     26/** Global settings: General page data structure. */
     27struct UIDataSettingsGlobalGeneral
    2828{
     29    /** Constructs data. */
     30    UIDataSettingsGlobalGeneral()
     31        : m_strDefaultMachineFolder(QString())
     32        , m_strVRDEAuthLibrary(QString())
     33        , m_fHostScreenSaverDisabled(false)
     34    {}
     35
     36    /** Returns whether the @a other passed data is equal to this one. */
     37    bool equal(const UIDataSettingsGlobalGeneral &other) const
     38    {
     39        return true
     40               && (m_strDefaultMachineFolder == other.m_strDefaultMachineFolder)
     41               && (m_strVRDEAuthLibrary == other.m_strVRDEAuthLibrary)
     42               && (m_fHostScreenSaverDisabled == other.m_fHostScreenSaverDisabled)
     43               ;
     44    }
     45
     46    /** Returns whether the @a other passed data is equal to this one. */
     47    bool operator==(const UIDataSettingsGlobalGeneral &other) const { return equal(other); }
     48    /** Returns whether the @a other passed data is different from this one. */
     49    bool operator!=(const UIDataSettingsGlobalGeneral &other) const { return !equal(other); }
     50
    2951    /** Holds the default machine folder path. */
    3052    QString m_strDefaultMachineFolder;
     
    3456    bool m_fHostScreenSaverDisabled;
    3557};
     58typedef UISettingsCache<UIDataSettingsGlobalGeneral> UISettingsCacheGlobalGeneral;
    3659
    3760
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