VirtualBox

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


Ignore:
Timestamp:
May 27, 2021 2:23:11 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9827: Cleanup in Global Preferences pages; Mostly to comply with coding-style standards around.

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

Legend:

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

    r86978 r89323  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4141    bool equal(const UIDataSettingsGlobalDisplay &other) const
    4242    {
    43         return true
     43        return    true
    4444               && (m_guiMaximumGuestScreenSizeValue == other.m_guiMaximumGuestScreenSizeValue)
    4545               && (m_fActivateHoveredMachineWindow == other.m_fActivateHoveredMachineWindow)
    4646               && (m_scaleFactors == other.m_scaleFactors)
    47                ;
     47                  ;
    4848    }
    4949
     
    6161};
    6262
     63
     64/*********************************************************************************************************************************
     65*   Class UIGlobalSettingsDisplay implementation.                                                                                *
     66*********************************************************************************************************************************/
    6367
    6468UIGlobalSettingsDisplay::UIGlobalSettingsDisplay()
     
    129133
    130134    /* Update data and failing state: */
    131     setFailed(!saveDisplayData());
     135    setFailed(!saveData());
    132136
    133137    /* Upload properties to data: */
     
    240244}
    241245
    242 bool UIGlobalSettingsDisplay::saveDisplayData()
     246bool UIGlobalSettingsDisplay::saveData()
    243247{
    244248    /* Prepare result: */
    245249    bool fSuccess = true;
    246250    /* Save display settings from cache: */
    247     if (fSuccess && m_pCache->wasChanged())
     251    if (   fSuccess
     252        && m_pCache->wasChanged())
    248253    {
    249254        /* Get old data from cache: */
     
    253258
    254259        /* Save maximum guest screen size and policy: */
    255         if (fSuccess && newData.m_guiMaximumGuestScreenSizeValue != oldData.m_guiMaximumGuestScreenSizeValue)
    256             gEDataManager->setMaxGuestScreenResolution(newData.m_guiMaximumGuestScreenSizeValue.m_enmPolicy,
    257                                                        newData.m_guiMaximumGuestScreenSizeValue.m_size);
     260        if (   fSuccess
     261            && newData.m_guiMaximumGuestScreenSizeValue != oldData.m_guiMaximumGuestScreenSizeValue)
     262            /* fSuccess = */ gEDataManager->setMaxGuestScreenResolution(newData.m_guiMaximumGuestScreenSizeValue.m_enmPolicy,
     263                                                                        newData.m_guiMaximumGuestScreenSizeValue.m_size);
    258264        /* Save whether hovered machine-window should be activated automatically: */
    259         if (fSuccess && newData.m_fActivateHoveredMachineWindow != oldData.m_fActivateHoveredMachineWindow)
    260             gEDataManager->setActivateHoveredMachineWindow(newData.m_fActivateHoveredMachineWindow);
     265        if (   fSuccess
     266            && newData.m_fActivateHoveredMachineWindow != oldData.m_fActivateHoveredMachineWindow)
     267            /* fSuccess = */ gEDataManager->setActivateHoveredMachineWindow(newData.m_fActivateHoveredMachineWindow);
    261268        /* Save guest-screen scale-factor: */
    262         if (fSuccess && newData.m_scaleFactors != oldData.m_scaleFactors)
    263             gEDataManager->setScaleFactors(newData.m_scaleFactors, UIExtraDataManager::GlobalID);
     269        if (   fSuccess
     270            && newData.m_scaleFactors != oldData.m_scaleFactors)
     271            /* fSuccess = */ gEDataManager->setScaleFactors(newData.m_scaleFactors, UIExtraDataManager::GlobalID);
    264272    }
    265273    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h

    r86978 r89323  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7373    void cleanup();
    7474
    75     /** Saves existing data from the cache. */
    76     bool saveDisplayData();
     75    /** Saves existing data from cache. */
     76    bool saveData();
    7777
    7878    /** Holds the page data cache instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp

    r86122 r89323  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5858
    5959
     60/*********************************************************************************************************************************
     61*   Class UIGlobalSettingsGeneral implementation.                                                                                *
     62*********************************************************************************************************************************/
     63
    6064UIGlobalSettingsGeneral::UIGlobalSettingsGeneral()
    6165    : m_pCache(0)
     
    196200    bool fSuccess = true;
    197201    /* Save settings from cache: */
    198     if (fSuccess && m_pCache->wasChanged())
     202    if (   fSuccess
     203        && m_pCache->wasChanged())
    199204    {
    200205        /* Get old data from cache: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r86124 r89323  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5959};
    6060
     61
     62/*********************************************************************************************************************************
     63*   Class UIGlobalSettingsInput implementation.                                                                                  *
     64*********************************************************************************************************************************/
    6165
    6266UIGlobalSettingsInput::UIGlobalSettingsInput()
     
    234238    bool fSuccess = true;
    235239    /* Save settings from cache: */
    236     if (fSuccess && m_pCache->wasChanged())
     240    if (   fSuccess
     241        && m_pCache->wasChanged())
    237242    {
    238243        /* Get old data from cache: */
     
    242247
    243248        /* Save new host-combo shortcut from cache: */
    244         const UIShortcutConfigurationItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString(), QString());
    245         const int iHostComboItemBase = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(oldData.m_shortcuts, fakeHostComboItem);
    246         const int iHostComboItemData = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(newData.m_shortcuts, fakeHostComboItem);
    247         const QString strHostComboBase = iHostComboItemBase != -1 ? oldData.m_shortcuts.at(iHostComboItemBase).currentSequence() : QString();
    248         const QString strHostComboData = iHostComboItemData != -1 ? newData.m_shortcuts.at(iHostComboItemData).currentSequence() : QString();
    249         if (strHostComboData != strHostComboBase)
    250             gEDataManager->setHostKeyCombination(strHostComboData);
     249        if (fSuccess)
     250        {
     251            const UIShortcutConfigurationItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString(), QString());
     252            const int iHostComboItemBase = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(oldData.m_shortcuts, fakeHostComboItem);
     253            const int iHostComboItemData = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(newData.m_shortcuts, fakeHostComboItem);
     254            const QString strHostComboBase = iHostComboItemBase != -1 ? oldData.m_shortcuts.at(iHostComboItemBase).currentSequence() : QString();
     255            const QString strHostComboData = iHostComboItemData != -1 ? newData.m_shortcuts.at(iHostComboItemData).currentSequence() : QString();
     256            if (strHostComboData != strHostComboBase)
     257                /* fSuccess = */ gEDataManager->setHostKeyCombination(strHostComboData);
     258        }
    251259
    252260        /* Save other new shortcuts from cache: */
    253         QMap<QString, QString> sequencesBase;
    254         QMap<QString, QString> sequencesData;
    255         foreach (const UIShortcutConfigurationItem &item, oldData.m_shortcuts)
    256             sequencesBase.insert(item.key(), item.currentSequence());
    257         foreach (const UIShortcutConfigurationItem &item, newData.m_shortcuts)
    258             sequencesData.insert(item.key(), item.currentSequence());
    259         if (sequencesData != sequencesBase)
    260             gShortcutPool->setOverrides(sequencesData);
     261        if (fSuccess)
     262        {
     263            QMap<QString, QString> sequencesBase;
     264            QMap<QString, QString> sequencesData;
     265            foreach (const UIShortcutConfigurationItem &item, oldData.m_shortcuts)
     266                sequencesBase.insert(item.key(), item.currentSequence());
     267            foreach (const UIShortcutConfigurationItem &item, newData.m_shortcuts)
     268                sequencesData.insert(item.key(), item.currentSequence());
     269            if (sequencesData != sequencesBase)
     270                /* fSuccess = */ gShortcutPool->setOverrides(sequencesData);
     271        }
    261272
    262273        /* Save other new things from cache: */
    263         if (newData.m_fAutoCapture != oldData.m_fAutoCapture)
    264             gEDataManager->setAutoCaptureEnabled(newData.m_fAutoCapture);
     274        if (   fSuccess
     275            && newData.m_fAutoCapture != oldData.m_fAutoCapture)
     276            /* fSuccess = */ gEDataManager->setAutoCaptureEnabled(newData.m_fAutoCapture);
    265277    }
    266278    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.cpp

    r86976 r89323  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3636    bool equal(const UIDataSettingsGlobalLanguage &other) const
    3737    {
    38         return true
     38        return    true
    3939               && (m_strLanguageId == other.m_strLanguageId)
    40                ;
     40                  ;
    4141    }
    4242
     
    5050};
    5151
     52
     53/*********************************************************************************************************************************
     54*   Class UIGlobalSettingsLanguage implementation.                                                                               *
     55*********************************************************************************************************************************/
    5256
    5357UIGlobalSettingsLanguage::UIGlobalSettingsLanguage()
     
    151155    bool fSuccess = true;
    152156    /* Save settings from cache: */
    153     if (fSuccess && m_pCache->wasChanged())
     157    if (   fSuccess
     158        && m_pCache->wasChanged())
    154159    {
    155160        /* Get old data from cache: */
     
    159164
    160165        /* Save new data from cache: */
    161         if (newData.m_strLanguageId != oldData.m_strLanguageId)
    162             gEDataManager->setLanguageId(newData.m_strLanguageId);
     166        if (   fSuccess
     167            && newData.m_strLanguageId != oldData.m_strLanguageId)
     168            /* fSuccess = */ gEDataManager->setLanguageId(newData.m_strLanguageId);
    163169    }
    164170    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r86020 r89323  
    55
    66/*
    7  * Copyright (C) 2011-2020 Oracle Corporation
     7 * Copyright (C) 2011-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4848    bool equal(const UIDataSettingsGlobalProxy &other) const
    4949    {
    50         return true
     50        return    true
    5151               && (m_enmProxyMode == other.m_enmProxyMode)
    5252               && (m_strProxyHost == other.m_strProxyHost)
    53                ;
     53                  ;
    5454    }
    5555
     
    6565};
    6666
     67
     68/*********************************************************************************************************************************
     69*   Class UIGlobalSettingsProxy implementation.                                                                                  *
     70*********************************************************************************************************************************/
    6771
    6872UIGlobalSettingsProxy::UIGlobalSettingsProxy()
     
    7680    , m_pEditorHost(0)
    7781{
    78     /* Prepare: */
    7982    prepare();
    8083}
     
    8285UIGlobalSettingsProxy::~UIGlobalSettingsProxy()
    8386{
    84     /* Cleanup: */
    8587    cleanup();
    8688}
     
    9496    m_pCache->clear();
    9597
    96     /* Prepare old proxy data: */
    97     UIDataSettingsGlobalProxy oldProxyData;
    98 
    99     /* Gather old proxy data: */
    100     oldProxyData.m_enmProxyMode = m_properties.GetProxyMode();
    101     oldProxyData.m_strProxyHost = m_properties.GetProxyURL();
    102 
    103     /* Cache old proxy data: */
    104     m_pCache->cacheInitialData(oldProxyData);
     98    /* Cache old data: */
     99    UIDataSettingsGlobalProxy oldData;
     100    oldData.m_enmProxyMode = m_properties.GetProxyMode();
     101    oldData.m_strProxyHost = m_properties.GetProxyURL();
     102    m_pCache->cacheInitialData(oldData);
    105103
    106104    /* Upload properties to data: */
     
    110108void UIGlobalSettingsProxy::getFromCache()
    111109{
    112     /* Get old proxy data from the cache: */
    113     const UIDataSettingsGlobalProxy &oldProxyData = m_pCache->base();
    114 
    115     /* Load old proxy data from the cache: */
    116     switch (oldProxyData.m_enmProxyMode)
     110    /* Load old data from cache: */
     111    const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
     112    switch (oldData.m_enmProxyMode)
    117113    {
    118114        case KProxyMode_System:  m_pRadioButtonProxyAuto->setChecked(true); break;
     
    121117        case KProxyMode_Max:     break; /* (compiler warnings) */
    122118    }
    123     m_pEditorHost->setText(oldProxyData.m_strProxyHost);
     119    m_pEditorHost->setText(oldData.m_strProxyHost);
    124120    sltHandleProxyToggle();
    125121
     
    130126void UIGlobalSettingsProxy::putToCache()
    131127{
    132     /* Prepare new proxy data: */
    133     UIDataSettingsGlobalProxy newProxyData = m_pCache->base();
    134 
    135     /* Gather new proxy data: */
    136     newProxyData.m_enmProxyMode = m_pRadioButtonProxyEnabled->isChecked()  ? KProxyMode_Manual
    137                                 : m_pRadioButtonProxyDisabled->isChecked() ? KProxyMode_NoProxy : KProxyMode_System;
    138     newProxyData.m_strProxyHost = m_pEditorHost->text();
    139 
    140     /* Cache new proxy data: */
    141     m_pCache->cacheCurrentData(newProxyData);
     128    /* Prepare new data: */
     129    UIDataSettingsGlobalProxy newData = m_pCache->base();
     130
     131    /* Cache new data: */
     132    newData.m_enmProxyMode = m_pRadioButtonProxyEnabled->isChecked()
     133                           ? KProxyMode_Manual : m_pRadioButtonProxyDisabled->isChecked()
     134                           ? KProxyMode_NoProxy : KProxyMode_System;
     135    newData.m_strProxyHost = m_pEditorHost->text();
     136    m_pCache->cacheCurrentData(newData);
    142137}
    143138
     
    147142    UISettingsPageGlobal::fetchData(data);
    148143
    149     /* Update proxy data and failing state: */
    150     setFailed(!saveProxyData());
     144    /* Update data and failing state: */
     145    setFailed(!saveData());
    151146
    152147    /* Upload properties to data: */
     
    335330}
    336331
    337 bool UIGlobalSettingsProxy::saveProxyData()
     332bool UIGlobalSettingsProxy::saveData()
    338333{
    339334    /* Prepare result: */
    340335    bool fSuccess = true;
    341     /* Save proxy settings from the cache: */
    342     if (fSuccess && m_pCache->wasChanged())
    343     {
    344         /* Get old proxy data from the cache: */
    345         //const UIDataSettingsGlobalProxy &oldProxyData = m_pCache->base();
    346         /* Get new proxy data from the cache: */
    347         const UIDataSettingsGlobalProxy &newProxyData = m_pCache->data();
    348 
    349         /* Save new proxy data from the cache: */
    350         m_properties.SetProxyMode(newProxyData.m_enmProxyMode);
    351         fSuccess &= m_properties.isOk();
    352         m_properties.SetProxyURL(newProxyData.m_strProxyHost);
    353         fSuccess &= m_properties.isOk();
     336    /* Save settings from cache: */
     337    if (   fSuccess
     338        && m_pCache->wasChanged())
     339    {
     340        /* Get old data from cache: */
     341        //const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
     342        /* Get new data from cache: */
     343        const UIDataSettingsGlobalProxy &newData = m_pCache->data();
     344
     345        /* Save new data from cache: */
     346        if (fSuccess)
     347        {
     348            m_properties.SetProxyMode(newData.m_enmProxyMode);
     349            fSuccess &= m_properties.isOk();
     350        }
     351        if (fSuccess)
     352        {
     353            m_properties.SetProxyURL(newData.m_strProxyHost);
     354            fSuccess &= m_properties.isOk();
     355        }
    354356
    355357        /* Drop the old extra data setting if still around: */
    356         if (fSuccess && !gEDataManager->proxySettings().isEmpty())
    357             gEDataManager->setProxySettings(QString());
     358        if (   fSuccess
     359            && !gEDataManager->proxySettings().isEmpty())
     360            /* fSuccess = */ gEDataManager->setProxySettings(QString());
    358361    }
    359362    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r86095 r89323  
    55
    66/*
    7  * Copyright (C) 2011-2020 Oracle Corporation
     7 * Copyright (C) 2011-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8484    void cleanup();
    8585
    86     /** Saves existing proxy data from the cache. */
    87     bool saveProxyData();
     86    /** Saves existing proxy data from cache. */
     87    bool saveData();
    8888
    8989    /** Holds the page data cache instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.cpp

    r86128 r89323  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5050};
    5151
     52
     53/*********************************************************************************************************************************
     54*   Class UIGlobalSettingsUpdate implementation.                                                                                 *
     55*********************************************************************************************************************************/
    5256
    5357UIGlobalSettingsUpdate::UIGlobalSettingsUpdate()
     
    151155    bool fSuccess = true;
    152156    /* Save update settings from cache: */
    153     if (fSuccess && m_pCache->wasChanged())
     157    if (   fSuccess
     158        && m_pCache->wasChanged())
    154159    {
    155160        /* Get old data from cache: */
     
    161166        if (   fSuccess
    162167            && newData != oldData)
    163             gEDataManager->setApplicationUpdateData(newData.m_guiUpdateData.data());
     168            /* fSuccess = */ gEDataManager->setApplicationUpdateData(newData.m_guiUpdateData.data());
    164169    }
    165170    /* Return result: */
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