VirtualBox

Ignore:
Timestamp:
Mar 24, 2015 2:29:53 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings Serializer: Cleanup rework to prepare to the encryption settings integration (step 4): Moving save/load functionality to the base-class.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
4 edited

Legend:

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

    r52730 r54921  
    3535# include "QIWidgetValidator.h"
    3636# include "VBoxSettingsSelector.h"
     37# include "UISettingsSerializer.h"
    3738# include "UISettingsPage.h"
    3839# include "UIToolBar.h"
     
    158159{
    159160    /* Load data: */
    160     loadData();
     161    loadOwnData();
    161162
    162163    /* Execute dialog and wait for completion: */
     
    165166
    166167    /* Save data: */
    167     saveData();
     168    saveOwnData();
    168169}
    169170
     
    197198void UISettingsDialog::sltMarkLoaded()
    198199{
     200    /* Mark as loaded: */
    199201    m_fLoaded = true;
    200202}
     
    202204void UISettingsDialog::sltMarkSaved()
    203205{
     206    /* Mark as saved: */
    204207    m_fSaved = true;
    205208}
     
    223226}
    224227
    225 void UISettingsDialog::loadData()
    226 {
     228void UISettingsDialog::loadData(QVariant &data)
     229{
     230    /* Mark as not loaded: */
    227231    m_fLoaded = false;
    228 }
    229 
    230 void UISettingsDialog::saveData()
    231 {
     232
     233    /* Create settings loader: */
     234    UISettingsSerializer *pSettingsLoader = new UISettingsSerializer(this,
     235                                                                     UISettingsSerializer::Load,
     236                                                                     QVariant::fromValue(data),
     237                                                                     m_pSelector->settingPages());
     238    connect(pSettingsLoader, SIGNAL(destroyed(QObject*)), this, SLOT(sltMarkLoaded()));
     239    /* Ask to raise required page priority: */
     240    pSettingsLoader->raisePriorityOfPage(m_pSelector->currentId());
     241    /* Start loader: */
     242    pSettingsLoader->start();
     243
     244    /* Upload data finally: */
     245    data = pSettingsLoader->data();
     246}
     247
     248void UISettingsDialog::saveData(QVariant &data)
     249{
     250    /* Mark as not saved: */
    232251    m_fSaved = false;
     252
     253    /* Create settings saver: */
     254    UISettingsSerializer *pSettingsSaver = new UISettingsSerializer(this,
     255                                                                    UISettingsSerializer::Save,
     256                                                                    QVariant::fromValue(data),
     257                                                                    m_pSelector->settingPages());
     258    /* Start saver: */
     259    pSettingsSaver->start();
     260
     261    /* Upload data finally: */
     262    data = pSettingsSaver->data();
    233263}
    234264
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r52727 r54921  
    6666protected:
    6767
    68     /* Save/load API: */
    69     virtual void loadData();
    70     virtual void saveData();
     68    /** Loads the @a data. */
     69    void loadData(QVariant &data);
     70    /** Wrapper for the method above.
     71      * Loads the data from the corresponding source. */
     72    virtual void loadOwnData() = 0;
     73
     74    /** Saves the @a data. */
     75    void saveData(QVariant &data);
     76    /** Wrapper for the method above.
     77      * Saves the data to the corresponding source. */
     78    virtual void saveOwnData() = 0;
    7179
    7280    /* UI translator: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r54919 r54921  
    206206}
    207207
    208 void UISettingsDialogGlobal::loadData()
    209 {
    210     /* Call to base-class: */
    211     UISettingsDialog::loadData();
    212 
     208void UISettingsDialogGlobal::loadOwnData()
     209{
    213210    /* Get properties and settings: */
    214211    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
     
    217214    qRegisterMetaType<UISettingsDataGlobal>();
    218215    UISettingsDataGlobal data(properties, settings);
    219     /* Create global settings loader: */
    220     UISettingsSerializer *pGlobalSettingsLoader = new UISettingsSerializer(this,
    221                                                                            UISettingsSerializer::Load,
    222                                                                            QVariant::fromValue(data),
    223                                                                            m_pSelector->settingPages());
    224     connect(pGlobalSettingsLoader, SIGNAL(destroyed(QObject*)), this, SLOT(sltMarkLoaded()));
    225     /* Start loader: */
    226     pGlobalSettingsLoader->start();
    227 }
    228 
    229 void UISettingsDialogGlobal::saveData()
    230 {
     216    QVariant varData = QVariant::fromValue(data);
     217
    231218    /* Call to base-class: */
    232     UISettingsDialog::saveData();
    233 
     219    UISettingsDialog::loadData(varData);
     220}
     221
     222void UISettingsDialogGlobal::saveOwnData()
     223{
    234224    /* Get properties and settings: */
    235225    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
     
    238228    qRegisterMetaType<UISettingsDataGlobal>();
    239229    UISettingsDataGlobal data(properties, settings);
    240     /* Create global settings saver: */
    241     UISettingsSerializer *pGlobalSettingsSaver = new UISettingsSerializer(this,
    242                                                                           UISettingsSerializer::Save,
    243                                                                           QVariant::fromValue(data),
    244                                                                           m_pSelector->settingPages());
    245     /* Start saver: */
    246     pGlobalSettingsSaver->start();
     230    QVariant varData = QVariant::fromValue(data);
     231
     232    /* Call to base-class: */
     233    UISettingsDialog::saveData(varData);
    247234
    248235    /* Get updated properties & settings: */
    249     CSystemProperties newProperties = pGlobalSettingsSaver->data().value<UISettingsDataGlobal>().m_properties;
    250     VBoxGlobalSettings newSettings = pGlobalSettingsSaver->data().value<UISettingsDataGlobal>().m_settings;
     236    CSystemProperties newProperties = varData.value<UISettingsDataGlobal>().m_properties;
     237    VBoxGlobalSettings newSettings = varData.value<UISettingsDataGlobal>().m_settings;
    251238    /* If properties are not OK => show the error: */
    252239    if (!newProperties.isOk())
     
    506493}
    507494
    508 void UISettingsDialogMachine::loadData()
     495void UISettingsDialogMachine::loadOwnData()
    509496{
    510497    /* Check that session is NOT created: */
    511498    if (!m_session.isNull())
    512499        return;
    513 
    514     /* Call to base-class: */
    515     UISettingsDialog::loadData();
    516500
    517501    /* Disconnect global VBox events from this dialog: */
     
    532516    qRegisterMetaType<UISettingsDataMachine>();
    533517    UISettingsDataMachine data(m_machine, m_console);
    534     /* Create machine settings loader: */
    535     UISettingsSerializer *pMachineSettingsLoader = new UISettingsSerializer(this,
    536                                                                             UISettingsSerializer::Load,
    537                                                                             QVariant::fromValue(data),
    538                                                                             m_pSelector->settingPages());
    539     connect(pMachineSettingsLoader, SIGNAL(destroyed(QObject*)), this, SLOT(sltMarkLoaded()));
    540     connect(pMachineSettingsLoader, SIGNAL(sigNotifyAboutPagesProcessed()), this, SLOT(sltSetFirstRunFlag()));
    541     /* Ask to raise required page priority: */
    542     pMachineSettingsLoader->raisePriorityOfPage(m_pSelector->currentId());
    543     /* Start page loader: */
    544     pMachineSettingsLoader->start();
    545 }
    546 
    547 void UISettingsDialogMachine::saveData()
     518    QVariant varData = QVariant::fromValue(data);
     519
     520    /* Call to base-class: */
     521    UISettingsDialog::loadData(varData);
     522}
     523
     524void UISettingsDialogMachine::saveOwnData()
    548525{
    549526    /* Check that session is NOT created: */
    550527    if (!m_session.isNull())
    551528        return;
    552 
    553     /* Call to base-class: */
    554     UISettingsDialog::saveData();
    555529
    556530    /* Disconnect global VBox events from this dialog: */
     
    571545    qRegisterMetaType<UISettingsDataMachine>();
    572546    UISettingsDataMachine data(m_machine, m_console);
    573     /* Create machine settings saver: */
    574     UISettingsSerializer *pMachineSettingsSaver = new UISettingsSerializer(this,
    575                                                                            UISettingsSerializer::Save,
    576                                                                            QVariant::fromValue(data),
    577                                                                            m_pSelector->settingPages());
    578     /* Start saver: */
    579     pMachineSettingsSaver->start();
     547    QVariant varData = QVariant::fromValue(data);
     548
     549    /* Call to base-class: */
     550    UISettingsDialog::saveData(varData);
    580551
    581552    /* Get updated machine: */
    582     m_machine = pMachineSettingsSaver->data().value<UISettingsDataMachine>().m_machine;
     553    m_machine = varData.value<UISettingsDataMachine>().m_machine;
    583554    /* If machine is OK => perform final operations: */
    584555    if (m_machine.isOk())
     
    743714    UISettingsDialog::sltMarkLoaded();
    744715
     716    sltSetFirstRunFlag();
     717
    745718    /* Unlock the session if exists: */
    746719    if (!m_session.isNull())
     
    821794
    822795    /* Reload data: */
    823     loadData();
     796    loadOwnData();
    824797}
    825798
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h

    r52727 r54921  
    4141protected:
    4242
    43     void loadData();
    44     void saveData();
     43    /** Loads the data from the corresponding source. */
     44    void loadOwnData();
     45    /** Saves the data to the corresponding source. */
     46    void saveOwnData();
    4547
    4648    void retranslateUi();
     
    6668protected:
    6769
    68     void loadData();
    69     void saveData();
     70    /** Loads the data from the corresponding source. */
     71    void loadOwnData();
     72    /** Saves the data to the corresponding source. */
     73    void saveOwnData();
    7074
    7175    void retranslateUi();
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