Changeset 65688 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 8, 2017 4:06:25 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp
r65678 r65688 59 59 UISettingsPageGlobal::fetchData(data); 60 60 61 /* Load to cache: */ 61 /* Clear cache initially: */ 62 m_cache.clear(); 63 64 /* Prepare old data: */ 65 UIDataSettingsGlobalProxy oldData; 66 67 /* Gather old data: */ 62 68 UIProxyManager proxyManager(m_settings.proxySettings()); 63 m_cache.m_enmProxyState = proxyManager.proxyState(); 64 m_cache.m_strProxyHost = proxyManager.proxyHost(); 65 m_cache.m_strProxyPort = proxyManager.proxyPort(); 69 oldData.m_enmProxyState = proxyManager.proxyState(); 70 oldData.m_strProxyHost = proxyManager.proxyHost(); 71 oldData.m_strProxyPort = proxyManager.proxyPort(); 72 73 /* Cache old data: */ 74 m_cache.cacheInitialData(oldData); 66 75 67 76 /* Upload properties & settings to data: */ … … 71 80 void UIGlobalSettingsProxy::getFromCache() 72 81 { 73 /* Fetch from cache: */ 74 switch (m_cache.m_enmProxyState) 82 /* Get old data from cache: */ 83 const UIDataSettingsGlobalProxy &oldData = m_cache.base(); 84 85 /* Load old data from cache: */ 86 switch (oldData.m_enmProxyState) 75 87 { 76 88 case UIProxyManager::ProxyState_Auto: m_pRadioProxyAuto->setChecked(true); break; … … 78 90 case UIProxyManager::ProxyState_Enabled: m_pRadioProxyEnabled->setChecked(true); break; 79 91 } 80 m_pHostEditor->setText( m_cache.m_strProxyHost);81 m_pPortEditor->setText( m_cache.m_strProxyPort);92 m_pHostEditor->setText(oldData.m_strProxyHost); 93 m_pPortEditor->setText(oldData.m_strProxyPort); 82 94 sltProxyToggled(); 83 95 … … 88 100 void UIGlobalSettingsProxy::putToCache() 89 101 { 90 /* Upload to cache: */ 91 m_cache.m_enmProxyState = m_pRadioProxyEnabled->isChecked() ? UIProxyManager::ProxyState_Enabled : 102 /* Prepare new data: */ 103 UIDataSettingsGlobalProxy newData = m_cache.base(); 104 105 /* Gather new data: */ 106 newData.m_enmProxyState = m_pRadioProxyEnabled->isChecked() ? UIProxyManager::ProxyState_Enabled : 92 107 m_pRadioProxyDisabled->isChecked() ? UIProxyManager::ProxyState_Disabled : 93 108 UIProxyManager::ProxyState_Auto; 94 m_cache.m_strProxyHost = m_pHostEditor->text(); 95 m_cache.m_strProxyPort = m_pPortEditor->text(); 109 newData.m_strProxyHost = m_pHostEditor->text(); 110 newData.m_strProxyPort = m_pPortEditor->text(); 111 112 /* Cache new data: */ 113 m_cache.cacheCurrentData(newData); 96 114 } 97 115 … … 101 119 UISettingsPageGlobal::fetchData(data); 102 120 103 /* Save from cache: */ 104 UIProxyManager proxyManager; 105 proxyManager.setProxyState(m_cache.m_enmProxyState); 106 proxyManager.setProxyHost(m_cache.m_strProxyHost); 107 proxyManager.setProxyPort(m_cache.m_strProxyPort); 108 m_settings.setProxySettings(proxyManager.toString()); 121 /* Save new data from cache: */ 122 if (m_cache.wasChanged()) 123 { 124 UIProxyManager proxyManager; 125 proxyManager.setProxyState(m_cache.data().m_enmProxyState); 126 proxyManager.setProxyHost(m_cache.data().m_strProxyHost); 127 proxyManager.setProxyPort(m_cache.data().m_strProxyPort); 128 m_settings.setProxySettings(proxyManager.toString()); 129 } 109 130 110 131 /* Upload properties & settings to data: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h
r65678 r65688 25 25 26 26 27 /** Global settings: Proxy page cachestructure. */28 struct UI SettingsCacheGlobalProxy27 /** Global settings: Proxy page data structure. */ 28 struct UIDataSettingsGlobalProxy 29 29 { 30 30 /** Constructs data. */ 31 UI SettingsCacheGlobalProxy()31 UIDataSettingsGlobalProxy() 32 32 : m_enmProxyState(UIProxyManager::ProxyState_Auto) 33 33 , m_strProxyHost(QString()) 34 34 , m_strProxyPort(QString()) 35 35 {} 36 37 /** Returns whether the @a other passed data is equal to this one. */ 38 bool equal(const UIDataSettingsGlobalProxy &other) const 39 { 40 return true 41 && (m_enmProxyState == other.m_enmProxyState) 42 && (m_strProxyHost == other.m_strProxyHost) 43 && (m_strProxyPort == other.m_strProxyPort) 44 ; 45 } 46 47 /** Returns whether the @a other passed data is equal to this one. */ 48 bool operator==(const UIDataSettingsGlobalProxy &other) const { return equal(other); } 49 /** Returns whether the @a other passed data is different from this one. */ 50 bool operator!=(const UIDataSettingsGlobalProxy &other) const { return !equal(other); } 36 51 37 52 /** Holds the proxy state. */ … … 42 57 QString m_strProxyPort; 43 58 }; 59 typedef UISettingsCache<UIDataSettingsGlobalProxy> UISettingsCacheGlobalProxy; 44 60 45 61
Note:
See TracChangeset
for help on using the changeset viewer.