VirtualBox

Changeset 66600 in vbox for trunk/src


Ignore:
Timestamp:
Apr 18, 2017 9:25:33 AM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Global preferences: Error handling (settings save) for all pages except Network for now.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r66593 r66600  
    10671067          tr("Failed to set global VirtualBox properties."),
    10681068          formatErrorInfo(properties));
     1069}
     1070
     1071void UIMessageCenter::cannotSaveDisplaySettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1072{
     1073    error(pParent, MessageType_Error,
     1074          tr("Cannot save display settings."),
     1075          formatErrorInfo(comProperties));
     1076}
     1077
     1078void UIMessageCenter::cannotSaveGeneralSettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1079{
     1080    error(pParent, MessageType_Error,
     1081          tr("Cannot save general settings."),
     1082          formatErrorInfo(comProperties));
     1083}
     1084
     1085void UIMessageCenter::cannotSaveInputSettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1086{
     1087    error(pParent, MessageType_Error,
     1088          tr("Cannot save input settings."),
     1089          formatErrorInfo(comProperties));
     1090}
     1091
     1092void UIMessageCenter::cannotSaveLanguageSettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1093{
     1094    error(pParent, MessageType_Error,
     1095          tr("Cannot save language settings."),
     1096          formatErrorInfo(comProperties));
     1097}
     1098
     1099void UIMessageCenter::cannotSaveProxySettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1100{
     1101    error(pParent, MessageType_Error,
     1102          tr("Cannot save proxy settings."),
     1103          formatErrorInfo(comProperties));
     1104}
     1105
     1106void UIMessageCenter::cannotSaveUpdateSettings(const CSystemProperties &comProperties, QWidget *pParent /* = 0 */)
     1107{
     1108    error(pParent, MessageType_Error,
     1109          tr("Cannot save update settings."),
     1110          formatErrorInfo(comProperties));
    10691111}
    10701112
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r66593 r66600  
    229229    void cannotRemoveHostInterface(const CProgress &progress, const QString &strInterfaceName, QWidget *pParent = 0);
    230230    void cannotSetSystemProperties(const CSystemProperties &properties, QWidget *pParent = 0) const;
     231    void cannotSaveDisplaySettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     232    void cannotSaveGeneralSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     233    void cannotSaveInputSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     234    void cannotSaveLanguageSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     235    void cannotSaveProxySettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     236    void cannotSaveUpdateSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
    231237
    232238    /* API: Machine settings warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp

    r66593 r66600  
    2323# include "UIExtraDataManager.h"
    2424# include "UIGlobalSettingsDisplay.h"
     25# include "UIMessageCenter.h"
    2526
    2627#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    133134    UISettingsPageGlobal::fetchData(data);
    134135
    135     /* Make sure display data was changed: */
    136     if (m_pCache->wasChanged())
    137     {
    138         /* Save new display data from the cache: */
    139         if (   m_pCache->data().m_enmMaxGuestResolution != m_pCache->base().m_enmMaxGuestResolution
    140             || m_pCache->data().m_maxGuestResolution != m_pCache->base().m_maxGuestResolution)
    141             gEDataManager->setMaxGuestScreenResolution(m_pCache->data().m_enmMaxGuestResolution, m_pCache->data().m_maxGuestResolution);
    142         if (m_pCache->data().m_fActivateHoveredMachineWindow != m_pCache->base().m_fActivateHoveredMachineWindow)
    143             gEDataManager->setActivateHoveredMachineWindow(m_pCache->data().m_fActivateHoveredMachineWindow);
    144     }
     136    /* Update display data and failing state: */
     137    setFailed(!saveDisplayData());
    145138
    146139    /* Upload properties to data: */
     
    245238}
    246239
     240bool UIGlobalSettingsDisplay::saveDisplayData()
     241{
     242    /* Prepare result: */
     243    bool fSuccess = true;
     244    /* Save display settings from the cache: */
     245    if (fSuccess && m_pCache->wasChanged())
     246    {
     247        /* Get old display data from the cache: */
     248        const UIDataSettingsGlobalDisplay &oldDisplayData = m_pCache->base();
     249        /* Get new display data from the cache: */
     250        const UIDataSettingsGlobalDisplay &newDisplayData = m_pCache->data();
     251
     252        // Here could go changes for m_properties.
     253
     254        /* Show error message if necessary: */
     255        if (!fSuccess)
     256            msgCenter().cannotSaveDisplaySettings(m_properties, this);
     257
     258        /* Save maximum guest resolution policy and/or value: */
     259        if (   fSuccess
     260            && (   newDisplayData.m_enmMaxGuestResolution != oldDisplayData.m_enmMaxGuestResolution
     261                || newDisplayData.m_maxGuestResolution != oldDisplayData.m_maxGuestResolution))
     262            gEDataManager->setMaxGuestScreenResolution(newDisplayData.m_enmMaxGuestResolution, newDisplayData.m_maxGuestResolution);
     263        /* Save whether hovered machine-window should be activated automatically: */
     264        if (fSuccess && newDisplayData.m_fActivateHoveredMachineWindow != oldDisplayData.m_fActivateHoveredMachineWindow)
     265            gEDataManager->setActivateHoveredMachineWindow(newDisplayData.m_fActivateHoveredMachineWindow);
     266    }
     267    /* Return result: */
     268    return fSuccess;
     269}
     270
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h

    r66290 r66600  
    7575    void reloadMaximumGuestScreenSizePolicyComboBox();
    7676
     77    /** Saves existing display data from the cache. */
     78    bool saveDisplayData();
     79
    7780    /** Holds the page data cache instance. */
    7881    UISettingsCacheGlobalDisplay *m_pCache;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp

    r66593 r66600  
    2626# include "UIGlobalSettingsGeneral.h"
    2727# include "UIExtraDataManager.h"
     28# include "UIMessageCenter.h"
    2829# include "VBoxGlobal.h"
    2930
     
    131132    UISettingsPageGlobal::fetchData(data);
    132133
    133     /* Make sure general data was changed: */
    134     if (m_pCache->wasChanged())
    135     {
    136         /* Save new general data from the cache: */
    137         if (   m_properties.isOk()
    138             && m_pCache->data().m_strDefaultMachineFolder != m_pCache->base().m_strDefaultMachineFolder)
    139             m_properties.SetDefaultMachineFolder(m_pCache->data().m_strDefaultMachineFolder);
    140         if (   m_properties.isOk()
    141             && m_pCache->data().m_strVRDEAuthLibrary != m_pCache->base().m_strVRDEAuthLibrary)
    142             m_properties.SetVRDEAuthLibrary(m_pCache->data().m_strVRDEAuthLibrary);
    143         if (m_pCache->data().m_fHostScreenSaverDisabled != m_pCache->base().m_fHostScreenSaverDisabled)
    144             gEDataManager->setHostScreenSaverDisabled(m_pCache->data().m_fHostScreenSaverDisabled);
    145     }
     134    /* Update general data and failing state: */
     135    setFailed(!saveGeneralData());
    146136
    147137    /* Upload properties to data: */
     
    192182}
    193183
     184bool UIGlobalSettingsGeneral::saveGeneralData()
     185{
     186    /* Prepare result: */
     187    bool fSuccess = true;
     188    /* Save general settings from the cache: */
     189    if (fSuccess && m_pCache->wasChanged())
     190    {
     191        /* Get old general data from the cache: */
     192        const UIDataSettingsGlobalGeneral &oldGeneralData = m_pCache->base();
     193        /* Get new general data from the cache: */
     194        const UIDataSettingsGlobalGeneral &newGeneralData = m_pCache->data();
     195
     196        /* Save default machine folder: */
     197        if (   fSuccess
     198            && newGeneralData.m_strDefaultMachineFolder != oldGeneralData.m_strDefaultMachineFolder)
     199        {
     200            m_properties.SetDefaultMachineFolder(newGeneralData.m_strDefaultMachineFolder);
     201            fSuccess = m_properties.isOk();
     202        }
     203        /* Save VRDE auth library: */
     204        if (   fSuccess
     205            && newGeneralData.m_strVRDEAuthLibrary != oldGeneralData.m_strVRDEAuthLibrary)
     206        {
     207            m_properties.SetVRDEAuthLibrary(newGeneralData.m_strVRDEAuthLibrary);
     208            fSuccess = m_properties.isOk();
     209        }
     210
     211        /* Show error message if necessary: */
     212        if (!fSuccess)
     213            msgCenter().cannotSaveGeneralSettings(m_properties, this);
     214
     215        /* Save new general data from the cache: */
     216        if (newGeneralData.m_fHostScreenSaverDisabled != oldGeneralData.m_fHostScreenSaverDisabled)
     217            gEDataManager->setHostScreenSaverDisabled(newGeneralData.m_fHostScreenSaverDisabled);
     218    }
     219    /* Return result: */
     220    return fSuccess;
     221}
     222
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.h

    r66290 r66600  
    6767    void cleanup();
    6868
     69    /** Saves existing general data from the cache. */
     70    bool saveGeneralData();
     71
    6972    /** Holds the page data cache instance. */
    7073    UISettingsCacheGlobalGeneral *m_pCache;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r66593 r66600  
    3636# include "UIShortcutPool.h"
    3737# include "UIExtraDataManager.h"
     38# include "UIMessageCenter.h"
    3839
    3940#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    947948    UISettingsPageGlobal::fetchData(data);
    948949
    949     /* Make sure input data was changed: */
    950     if (m_pCache->wasChanged())
    951     {
    952         /* Save new host-combo shortcut from the cache: */
    953         const UIDataShortcutRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
    954         const int iHostComboItemBase = UIFunctorFindShortcut(UIFunctorFindShortcut::Base)(m_pCache->base().shortcuts(), fakeHostComboItem);
    955         const int iHostComboItemData = UIFunctorFindShortcut(UIFunctorFindShortcut::Base)(m_pCache->data().shortcuts(), fakeHostComboItem);
    956         const QString strHostComboBase = iHostComboItemBase != -1 ? m_pCache->base().shortcuts().at(iHostComboItemBase).currentSequence() : QString();
    957         const QString strHostComboData = iHostComboItemData != -1 ? m_pCache->data().shortcuts().at(iHostComboItemData).currentSequence() : QString();
    958         if (strHostComboData != strHostComboBase)
    959             gEDataManager->setHostKeyCombination(strHostComboData);
    960 
    961         /* Save other new shortcuts from the cache: */
    962         QMap<QString, QString> sequencesBase;
    963         QMap<QString, QString> sequencesData;
    964         foreach (const UIDataShortcutRow &item, m_pCache->base().shortcuts())
    965             sequencesBase.insert(item.key(), item.currentSequence());
    966         foreach (const UIDataShortcutRow &item, m_pCache->data().shortcuts())
    967             sequencesData.insert(item.key(), item.currentSequence());
    968         if (sequencesData != sequencesBase)
    969             gShortcutPool->setOverrides(sequencesData);
    970 
    971         /* Save other new things from the cache: */
    972         if (m_pCache->data().autoCapture() != m_pCache->base().autoCapture())
    973             gEDataManager->setAutoCaptureEnabled(m_pCache->data().autoCapture());
    974     }
     950    /* Update input data and failing state: */
     951    setFailed(!saveInputData());
    975952
    976953    /* Upload properties to data: */
     
    11701147}
    11711148
     1149bool UIGlobalSettingsInput::saveInputData()
     1150{
     1151    /* Prepare result: */
     1152    bool fSuccess = true;
     1153    /* Save input settings from the cache: */
     1154    if (fSuccess && m_pCache->wasChanged())
     1155    {
     1156        /* Get old input data from the cache: */
     1157        const UIDataSettingsGlobalInput &oldInputData = m_pCache->base();
     1158        /* Get new input data from the cache: */
     1159        const UIDataSettingsGlobalInput &newInputData = m_pCache->data();
     1160
     1161        // Here could go changes for m_properties.
     1162
     1163        /* Show error message if necessary: */
     1164        if (!fSuccess)
     1165            msgCenter().cannotSaveInputSettings(m_properties, this);
     1166
     1167        /* Save new host-combo shortcut from the cache: */
     1168        const UIDataShortcutRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
     1169        const int iHostComboItemBase = UIFunctorFindShortcut(UIFunctorFindShortcut::Base)(oldInputData.shortcuts(), fakeHostComboItem);
     1170        const int iHostComboItemData = UIFunctorFindShortcut(UIFunctorFindShortcut::Base)(newInputData.shortcuts(), fakeHostComboItem);
     1171        const QString strHostComboBase = iHostComboItemBase != -1 ? oldInputData.shortcuts().at(iHostComboItemBase).currentSequence() : QString();
     1172        const QString strHostComboData = iHostComboItemData != -1 ? newInputData.shortcuts().at(iHostComboItemData).currentSequence() : QString();
     1173        if (strHostComboData != strHostComboBase)
     1174            gEDataManager->setHostKeyCombination(strHostComboData);
     1175
     1176        /* Save other new shortcuts from the cache: */
     1177        QMap<QString, QString> sequencesBase;
     1178        QMap<QString, QString> sequencesData;
     1179        foreach (const UIDataShortcutRow &item, oldInputData.shortcuts())
     1180            sequencesBase.insert(item.key(), item.currentSequence());
     1181        foreach (const UIDataShortcutRow &item, newInputData.shortcuts())
     1182            sequencesData.insert(item.key(), item.currentSequence());
     1183        if (sequencesData != sequencesBase)
     1184            gShortcutPool->setOverrides(sequencesData);
     1185
     1186        /* Save other new things from the cache: */
     1187        if (newInputData.autoCapture() != oldInputData.autoCapture())
     1188            gEDataManager->setAutoCaptureEnabled(newInputData.autoCapture());
     1189    }
     1190    /* Return result: */
     1191    return fSuccess;
     1192}
     1193
    11721194# include "UIGlobalSettingsInput.moc"
    11731195
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.h

    r66343 r66600  
    8686    void cleanup();
    8787
     88    /** Saves existing input data from the cache. */
     89    bool saveInputData();
     90
    8891    /** Holds the tab-widget instance. */
    8992    QTabWidget         *m_pTabWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.cpp

    r66593 r66600  
    2929# include "UIGlobalSettingsLanguage.h"
    3030# include "UIExtraDataManager.h"
     31# include "UIMessageCenter.h"
    3132# include "VBoxGlobal.h"
    3233
     
    269270    UISettingsPageGlobal::fetchData(data);
    270271
    271     /* Make sure language data was changed: */
    272     if (m_pCache->wasChanged())
    273     {
    274         /* Save new language data from the cache: */
    275         if (m_pCache->data().m_strLanguageId != m_pCache->base().m_strLanguageId)
    276             gEDataManager->setLanguageId(m_pCache->data().m_strLanguageId);
    277     }
     272    /* Update language data and failing state: */
     273    setFailed(!saveLanguageData());
    278274
    279275    /* Upload properties to data: */
     
    449445}
    450446
     447bool UIGlobalSettingsLanguage::saveLanguageData()
     448{
     449    /* Prepare result: */
     450    bool fSuccess = true;
     451    /* Save language settings from the cache: */
     452    if (fSuccess && m_pCache->wasChanged())
     453    {
     454        /* Get old language data from the cache: */
     455        const UIDataSettingsGlobalLanguage &oldLanguageData = m_pCache->base();
     456        /* Get new language data from the cache: */
     457        const UIDataSettingsGlobalLanguage &newLanguageData = m_pCache->data();
     458
     459        // Here could go changes for m_properties.
     460
     461        /* Show error message if necessary: */
     462        if (!fSuccess)
     463            msgCenter().cannotSaveLanguageSettings(m_properties, this);
     464
     465        /* Save new language data from the cache: */
     466        if (newLanguageData.m_strLanguageId != oldLanguageData.m_strLanguageId)
     467            gEDataManager->setLanguageId(newLanguageData.m_strLanguageId);
     468    }
     469    /* Return result: */
     470    return fSuccess;
     471}
     472
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.h

    r66290 r66600  
    8383    void reloadLanguageTree(const QString &strLanguageId);
    8484
     85    /** Saves existing language data from the cache. */
     86    bool saveLanguageData();
     87
    8588    /** Holds whether the page is polished. */
    8689    bool m_fPolished;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r66593 r66600  
    2727# include "UIGlobalSettingsProxy.h"
    2828# include "UIExtraDataManager.h"
     29# include "UIMessageCenter.h"
    2930# include "VBoxUtils.h"
    3031
     
    144145    UISettingsPageGlobal::fetchData(data);
    145146
    146     /* Make sure proxy data was changed: */
    147     if (m_pCache->wasChanged())
    148     {
    149         /* Save new proxy data from the cache: */
    150         UIProxyManager proxyManager;
    151         proxyManager.setProxyState(m_pCache->data().m_enmProxyState);
    152         proxyManager.setProxyHost(m_pCache->data().m_strProxyHost);
    153         proxyManager.setProxyPort(m_pCache->data().m_strProxyPort);
    154         gEDataManager->setProxySettings(proxyManager.toString());
    155     }
     147    /* Update proxy data and failing state: */
     148    setFailed(!saveProxyData());
    156149
    157150    /* Upload properties to data: */
     
    259252}
    260253
     254bool UIGlobalSettingsProxy::saveProxyData()
     255{
     256    /* Prepare result: */
     257    bool fSuccess = true;
     258    /* Save proxy settings from the cache: */
     259    if (fSuccess && m_pCache->wasChanged())
     260    {
     261        /* Get old proxy data from the cache: */
     262        //const UIDataSettingsGlobalProxy &oldProxyData = m_pCache->base();
     263        /* Get new proxy data from the cache: */
     264        const UIDataSettingsGlobalProxy &newProxyData = m_pCache->data();
     265
     266        // Here could go changes for m_properties.
     267
     268        /* Show error message if necessary: */
     269        if (!fSuccess)
     270            msgCenter().cannotSaveProxySettings(m_properties, this);
     271
     272        /* Save new proxy data from the cache: */
     273        UIProxyManager proxyManager;
     274        proxyManager.setProxyState(newProxyData.m_enmProxyState);
     275        proxyManager.setProxyHost(newProxyData.m_strProxyHost);
     276        proxyManager.setProxyPort(newProxyData.m_strProxyPort);
     277        gEDataManager->setProxySettings(proxyManager.toString());
     278    }
     279    /* Return result: */
     280    return fSuccess;
     281}
     282
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r66290 r66600  
    7676    void cleanup();
    7777
     78    /** Saves existing proxy data from the cache. */
     79    bool saveProxyData();
     80
    7881    /** Holds the page data cache instance. */
    7982    UISettingsCacheGlobalProxy *m_pCache;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.cpp

    r66593 r66600  
    2323# include "UIGlobalSettingsUpdate.h"
    2424# include "UIExtraDataManager.h"
     25# include "UIMessageCenter.h"
    2526# include "VBoxGlobal.h"
    2627
     
    144145    UISettingsPageGlobal::fetchData(data);
    145146
    146     /* Make sure update data was changed: */
    147     if (m_pCache->wasChanged())
    148     {
    149         /* Save new update data from the cache: */
    150         const VBoxUpdateData newData(m_pCache->data().m_periodIndex, m_pCache->data().m_branchIndex);
    151         gEDataManager->setApplicationUpdateData(newData.data());
    152     }
     147    /* Update update data and failing state: */
     148    setFailed(!saveUpdateData());
    153149
    154150    /* Upload properties to data: */
     
    251247}
    252248
     249bool UIGlobalSettingsUpdate::saveUpdateData()
     250{
     251    /* Prepare result: */
     252    bool fSuccess = true;
     253    /* Save update settings from the cache: */
     254    if (fSuccess && m_pCache->wasChanged())
     255    {
     256        /* Get old update data from the cache: */
     257        //const UIDataSettingsGlobalUpdate &oldUpdateData = m_pCache->base();
     258        /* Get new update data from the cache: */
     259        const UIDataSettingsGlobalUpdate &newUpdateData = m_pCache->data();
     260
     261        // Here could go changes for m_properties.
     262
     263        /* Show error message if necessary: */
     264        if (!fSuccess)
     265            msgCenter().cannotSaveUpdateSettings(m_properties, this);
     266
     267        /* Save new update data from the cache: */
     268        const VBoxUpdateData newData(newUpdateData.m_periodIndex, newUpdateData.m_branchIndex);
     269        gEDataManager->setApplicationUpdateData(newData.data());
     270    }
     271    /* Return result: */
     272    return fSuccess;
     273}
     274
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h

    r66290 r66600  
    8383    VBoxUpdateData::BranchType branchType() const;
    8484
     85    /** Saves existing update data from the cache. */
     86    bool saveUpdateData();
     87
    8588    /** Holds the last checked button reference. */
    8689    QRadioButton *m_pLastChosenRadio;
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