VirtualBox

Ignore:
Timestamp:
Sep 11, 2020 2:31:56 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9827: Cleanup for Global properties / General page.

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

    r86094 r86096  
    2424#include "UICommon.h"
    2525#include "UIErrorString.h"
    26 #include "UIExtraDataManager.h"
    2726#include "UIFilePathSelector.h"
    2827#include "UIGlobalSettingsGeneral.h"
     
    5251    bool operator!=(const UIDataSettingsGlobalGeneral &other) const { return !equal(other); }
    5352
    54     /** Holds the default machine folder path. */
     53    /** Holds the 'default machine folder' path. */
    5554    QString m_strDefaultMachineFolder;
    56     /** Holds the VRDE authentication library name. */
     55    /** Holds the 'VRDE auth library' name. */
    5756    QString m_strVRDEAuthLibrary;
    5857};
     
    6160UIGlobalSettingsGeneral::UIGlobalSettingsGeneral()
    6261    : m_pCache(0)
    63     , m_pLabelMachineFolder(0)
    64     , m_pSelectorMachineFolder(0)
    65     , m_pLabelVRDPLibraryName(0)
    66     , m_pSelectorVRDPLibraryName(0)
    67 {
    68     /* Prepare: */
     62    , m_pLabelDefaultMachineFolder(0)
     63    , m_pSelectorDefaultMachineFolder(0)
     64    , m_pLabelVRDEAuthLibrary(0)
     65    , m_pSelectorVRDEAuthLibrary(0)
     66{
    6967    prepare();
    7068}
     
    7270UIGlobalSettingsGeneral::~UIGlobalSettingsGeneral()
    7371{
    74     /* Cleanup: */
    7572    cleanup();
    7673}
     
    8481    m_pCache->clear();
    8582
    86     /* Prepare old general data: */
    87     UIDataSettingsGlobalGeneral oldGeneralData;
    88 
    89     /* Gather old general data: */
    90     oldGeneralData.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
    91     oldGeneralData.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
    92 
    93     /* Cache old general data: */
    94     m_pCache->cacheInitialData(oldGeneralData);
     83    /* Cache old data: */
     84    UIDataSettingsGlobalGeneral oldData;
     85    oldData.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
     86    oldData.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
     87    m_pCache->cacheInitialData(oldData);
    9588
    9689    /* Upload properties to data: */
     
    10093void UIGlobalSettingsGeneral::getFromCache()
    10194{
    102     /* Get old general data from the cache: */
    103     const UIDataSettingsGlobalGeneral &oldGeneralData = m_pCache->base();
    104 
    105     /* Load old general data from the cache: */
    106     m_pSelectorMachineFolder->setPath(oldGeneralData.m_strDefaultMachineFolder);
    107     m_pSelectorVRDPLibraryName->setPath(oldGeneralData.m_strVRDEAuthLibrary);
     95    /* Load old data from cache: */
     96    const UIDataSettingsGlobalGeneral &oldData = m_pCache->base();
     97    m_pSelectorDefaultMachineFolder->setPath(oldData.m_strDefaultMachineFolder);
     98    m_pSelectorVRDEAuthLibrary->setPath(oldData.m_strVRDEAuthLibrary);
    10899}
    109100
    110101void UIGlobalSettingsGeneral::putToCache()
    111102{
    112     /* Prepare new general data: */
    113     UIDataSettingsGlobalGeneral newGeneralData = m_pCache->base();
    114 
    115     /* Gather new general data: */
    116     newGeneralData.m_strDefaultMachineFolder = m_pSelectorMachineFolder->path();
    117     newGeneralData.m_strVRDEAuthLibrary = m_pSelectorVRDPLibraryName->path();
    118 
    119     /* Cache new general data: */
    120     m_pCache->cacheCurrentData(newGeneralData);
     103    /* Prepare new data: */
     104    UIDataSettingsGlobalGeneral newData = m_pCache->base();
     105
     106    /* Cache new data: */
     107    newData.m_strDefaultMachineFolder = m_pSelectorDefaultMachineFolder->path();
     108    newData.m_strVRDEAuthLibrary = m_pSelectorVRDEAuthLibrary->path();
     109    m_pCache->cacheCurrentData(newData);
    121110}
    122111
     
    126115    UISettingsPageGlobal::fetchData(data);
    127116
    128     /* Update general data and failing state: */
     117    /* Update data and failing state: */
    129118    setFailed(!saveGeneralData());
    130119
     
    135124void UIGlobalSettingsGeneral::retranslateUi()
    136125{
    137     m_pLabelMachineFolder->setText(tr("Default &Machine Folder:"));
    138     m_pSelectorMachineFolder->setWhatsThis(tr("Holds the path to the default virtual machine folder. This folder is used, "
    139                                               "if not explicitly specified otherwise, when creating new virtual machines."));
    140     m_pLabelVRDPLibraryName->setText(tr("V&RDP Authentication Library:"));
    141     m_pSelectorVRDPLibraryName->setWhatsThis(tr("Holds the path to the library that provides authentication for Remote Display (VRDP) clients."));
     126    m_pLabelDefaultMachineFolder->setText(tr("Default &Machine Folder:"));
     127    m_pSelectorDefaultMachineFolder->setWhatsThis(tr("Holds the path to the default virtual machine folder. This folder is used, "
     128                                                     "if not explicitly specified otherwise, when creating new virtual machines."));
     129    m_pLabelVRDEAuthLibrary->setText(tr("V&RDP Authentication Library:"));
     130    m_pSelectorVRDEAuthLibrary->setWhatsThis(tr("Holds the path to the library that provides "
     131                                                "authentication for Remote Display (VRDP) clients."));
    142132}
    143133
     
    164154        pLayoutMain->setRowStretch(3, 1);
    165155
    166         /* Prepare machine folder label: */
    167         m_pLabelMachineFolder = new QLabel(this);
    168         if (m_pLabelMachineFolder)
    169         {
    170             m_pLabelMachineFolder->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    171             pLayoutMain->addWidget(m_pLabelMachineFolder, 0, 0);
    172         }
    173         /* Prepare machine folder selector: */
    174         m_pSelectorMachineFolder = new UIFilePathSelector(this);
    175         if (m_pSelectorMachineFolder)
    176         {
    177             if (m_pLabelMachineFolder)
    178                 m_pLabelMachineFolder->setBuddy(m_pSelectorMachineFolder);
    179             m_pSelectorMachineFolder->setHomeDir(uiCommon().homeFolder());
    180 
    181             pLayoutMain->addWidget(m_pSelectorMachineFolder, 0, 1, 1, 2);
    182         }
    183 
    184         /* Prepare VRDP library name label: */
    185         m_pLabelVRDPLibraryName = new QLabel(this);
    186         if (m_pLabelVRDPLibraryName)
    187         {
    188             m_pLabelVRDPLibraryName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    189             pLayoutMain->addWidget(m_pLabelVRDPLibraryName, 1, 0);
    190         }
    191         /* Prepare VRDP library name selector: */
    192         m_pSelectorVRDPLibraryName = new UIFilePathSelector(this);
    193         if (m_pSelectorVRDPLibraryName)
    194         {
    195             if (m_pLabelVRDPLibraryName)
    196                 m_pLabelVRDPLibraryName->setBuddy(m_pSelectorVRDPLibraryName);
    197             m_pSelectorVRDPLibraryName->setHomeDir(uiCommon().homeFolder());
    198             m_pSelectorVRDPLibraryName->setMode(UIFilePathSelector::Mode_File_Open);
    199 
    200             pLayoutMain->addWidget(m_pSelectorVRDPLibraryName, 1, 1, 1, 2);
     156        /* Prepare 'default machine folder' label: */
     157        m_pLabelDefaultMachineFolder = new QLabel(this);
     158        if (m_pLabelDefaultMachineFolder)
     159        {
     160            m_pLabelDefaultMachineFolder->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     161            pLayoutMain->addWidget(m_pLabelDefaultMachineFolder, 0, 0);
     162        }
     163        /* Prepare 'default machine folder' editor: */
     164        m_pSelectorDefaultMachineFolder = new UIFilePathSelector(this);
     165        if (m_pSelectorDefaultMachineFolder)
     166        {
     167            if (m_pLabelDefaultMachineFolder)
     168                m_pLabelDefaultMachineFolder->setBuddy(m_pSelectorDefaultMachineFolder);
     169            m_pSelectorDefaultMachineFolder->setHomeDir(uiCommon().homeFolder());
     170
     171            pLayoutMain->addWidget(m_pSelectorDefaultMachineFolder, 0, 1, 1, 2);
     172        }
     173
     174        /* Prepare 'VRDE auth library' label: */
     175        m_pLabelVRDEAuthLibrary = new QLabel(this);
     176        if (m_pLabelVRDEAuthLibrary)
     177        {
     178            m_pLabelVRDEAuthLibrary->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     179            pLayoutMain->addWidget(m_pLabelVRDEAuthLibrary, 1, 0);
     180        }
     181        /* Prepare 'VRDE auth library' editor: */
     182        m_pSelectorVRDEAuthLibrary = new UIFilePathSelector(this);
     183        if (m_pSelectorVRDEAuthLibrary)
     184        {
     185            if (m_pLabelVRDEAuthLibrary)
     186                m_pLabelVRDEAuthLibrary->setBuddy(m_pSelectorVRDEAuthLibrary);
     187            m_pSelectorVRDEAuthLibrary->setHomeDir(uiCommon().homeFolder());
     188            m_pSelectorVRDEAuthLibrary->setMode(UIFilePathSelector::Mode_File_Open);
     189
     190            pLayoutMain->addWidget(m_pSelectorVRDEAuthLibrary, 1, 1, 1, 2);
    201191        }
    202192    }
     
    214204    /* Prepare result: */
    215205    bool fSuccess = true;
    216     /* Save general settings from the cache: */
     206    /* Save settings from cache: */
    217207    if (fSuccess && m_pCache->wasChanged())
    218208    {
    219         /* Get old general data from the cache: */
    220         const UIDataSettingsGlobalGeneral &oldGeneralData = m_pCache->base();
    221         /* Get new general data from the cache: */
    222         const UIDataSettingsGlobalGeneral &newGeneralData = m_pCache->data();
    223 
    224         /* Save default machine folder: */
     209        /* Get old data from cache: */
     210        const UIDataSettingsGlobalGeneral &oldData = m_pCache->base();
     211        /* Get new data from cache: */
     212        const UIDataSettingsGlobalGeneral &newData = m_pCache->data();
     213
     214        /* Save 'default machine folder': */
    225215        if (   fSuccess
    226             && newGeneralData.m_strDefaultMachineFolder != oldGeneralData.m_strDefaultMachineFolder)
    227         {
    228             m_properties.SetDefaultMachineFolder(newGeneralData.m_strDefaultMachineFolder);
     216            && newData.m_strDefaultMachineFolder != oldData.m_strDefaultMachineFolder)
     217        {
     218            m_properties.SetDefaultMachineFolder(newData.m_strDefaultMachineFolder);
    229219            fSuccess = m_properties.isOk();
    230220        }
    231         /* Save VRDE auth library: */
     221        /* Save 'VRDE auth library': */
    232222        if (   fSuccess
    233             && newGeneralData.m_strVRDEAuthLibrary != oldGeneralData.m_strVRDEAuthLibrary)
    234         {
    235             m_properties.SetVRDEAuthLibrary(newGeneralData.m_strVRDEAuthLibrary);
     223            && newData.m_strVRDEAuthLibrary != oldData.m_strVRDEAuthLibrary)
     224        {
     225            m_properties.SetVRDEAuthLibrary(newData.m_strVRDEAuthLibrary);
    236226            fSuccess = m_properties.isOk();
    237227        }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.h

    r86095 r86096  
    3838public:
    3939
    40     /** Constructs General settings page. */
     40    /** Constructs settings page. */
    4141    UIGlobalSettingsGeneral();
    42     /** Destructs General settings page. */
    43     ~UIGlobalSettingsGeneral();
     42    /** Destructs settings page. */
     43    virtual ~UIGlobalSettingsGeneral() /* override */;
    4444
    4545protected:
     
    7171    void cleanup();
    7272
    73     /** Saves existing general data from the cache. */
     73    /** Saves existing data from cache. */
    7474    bool saveGeneralData();
    7575
     
    7979    /** @name Widgets
    8080     * @{ */
    81         /** Holds machine folder label instance. */
    82         QLabel             *m_pLabelMachineFolder;
    83         /** Holds machine folder selector instance. */
    84         UIFilePathSelector *m_pSelectorMachineFolder;
    85         /** Holds VRDP library name label instance. */
    86         QLabel             *m_pLabelVRDPLibraryName;
    87         /** Holds VRDP library name selector instance. */
    88         UIFilePathSelector *m_pSelectorVRDPLibraryName;
     81        /** Holds 'default machine folder' label instance. */
     82        QLabel             *m_pLabelDefaultMachineFolder;
     83        /** Holds 'default machine folder' selector instance. */
     84        UIFilePathSelector *m_pSelectorDefaultMachineFolder;
     85        /** Holds 'VRDE auth library' label instance. */
     86        QLabel             *m_pLabelVRDEAuthLibrary;
     87        /** Holds 'VRDE auth library' selector instance. */
     88        UIFilePathSelector *m_pSelectorVRDEAuthLibrary;
    8989    /** @} */
    9090};
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