Changeset 65681 in vbox
- Timestamp:
- Feb 8, 2017 2:42:11 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/UIGlobalSettingsDisplay.cpp
r65678 r65681 53 53 UISettingsPageGlobal::fetchData(data); 54 54 55 /* Load to cache: */ 56 m_cache.m_strMaxGuestResolution = m_settings.maxGuestRes(); 57 m_cache.m_fActivateHoveredMachineWindow = gEDataManager->activateHoveredMachineWindow(); 55 /* Clear cache initially: */ 56 m_cache.clear(); 57 58 /* Prepare old data: */ 59 UIDataSettingsGlobalDisplay oldData; 60 61 /* Gather old data: */ 62 oldData.m_strMaxGuestResolution = m_settings.maxGuestRes(); 63 oldData.m_fActivateHoveredMachineWindow = gEDataManager->activateHoveredMachineWindow(); 64 65 /* Cache old data: */ 66 m_cache.cacheInitialData(oldData); 58 67 59 68 /* Upload properties & settings to data: */ … … 63 72 void UIGlobalSettingsDisplay::getFromCache() 64 73 { 65 /* Fetch from cache: */ 66 if ((m_cache.m_strMaxGuestResolution.isEmpty()) || 67 (m_cache.m_strMaxGuestResolution == "auto")) 74 /* Get old data from cache: */ 75 const UIDataSettingsGlobalDisplay &oldData = m_cache.base(); 76 77 /* Load old data from cache: */ 78 if ((oldData.m_strMaxGuestResolution.isEmpty()) || 79 (oldData.m_strMaxGuestResolution == "auto")) 68 80 { 69 81 /* Switch combo-box item: */ 70 82 m_pMaxResolutionCombo->setCurrentIndex(m_pMaxResolutionCombo->findData("auto")); 71 83 } 72 else if ( m_cache.m_strMaxGuestResolution == "any")84 else if (oldData.m_strMaxGuestResolution == "any") 73 85 { 74 86 /* Switch combo-box item: */ … … 80 92 m_pMaxResolutionCombo->setCurrentIndex(m_pMaxResolutionCombo->findData("fixed")); 81 93 /* Trying to parse text into 2 sections by ',' symbol: */ 82 int iWidth = m_cache.m_strMaxGuestResolution.section(',', 0, 0).toInt();83 int iHeight = m_cache.m_strMaxGuestResolution.section(',', 1, 1).toInt();94 int iWidth = oldData.m_strMaxGuestResolution.section(',', 0, 0).toInt(); 95 int iHeight = oldData.m_strMaxGuestResolution.section(',', 1, 1).toInt(); 84 96 /* And set values if they are present: */ 85 97 m_pResolutionWidthSpin->setValue(iWidth); 86 98 m_pResolutionHeightSpin->setValue(iHeight); 87 99 } 88 m_pCheckBoxActivateOnMouseHover->setChecked( m_cache.m_fActivateHoveredMachineWindow);100 m_pCheckBoxActivateOnMouseHover->setChecked(oldData.m_fActivateHoveredMachineWindow); 89 101 } 90 102 91 103 void UIGlobalSettingsDisplay::putToCache() 92 104 { 93 /* Upload to cache: */ 105 /* Prepare new data: */ 106 UIDataSettingsGlobalDisplay newData = m_cache.base(); 107 108 /* Gather new data: */ 94 109 if (m_pMaxResolutionCombo->itemData(m_pMaxResolutionCombo->currentIndex()).toString() == "auto") 95 110 { 96 111 /* If resolution current combo item is "auto" => resolution set to "auto": */ 97 m_cache.m_strMaxGuestResolution = QString();112 newData.m_strMaxGuestResolution = QString(); 98 113 } 99 114 else if (m_pMaxResolutionCombo->itemData(m_pMaxResolutionCombo->currentIndex()).toString() == "any" || … … 102 117 /* Else if resolution current combo item is "any" 103 118 * or any of the resolution field attributes is zero => resolution set to "any": */ 104 m_cache.m_strMaxGuestResolution = "any";119 newData.m_strMaxGuestResolution = "any"; 105 120 } 106 121 else if (m_pResolutionWidthSpin->value() != 0 && m_pResolutionHeightSpin->value() != 0) 107 122 { 108 123 /* Else if both field attributes are non-zeroes => resolution set to "fixed": */ 109 m_cache.m_strMaxGuestResolution = QString("%1,%2").arg(m_pResolutionWidthSpin->value()).arg(m_pResolutionHeightSpin->value()); 110 } 111 m_cache.m_fActivateHoveredMachineWindow = m_pCheckBoxActivateOnMouseHover->isChecked(); 124 newData.m_strMaxGuestResolution = QString("%1,%2").arg(m_pResolutionWidthSpin->value()).arg(m_pResolutionHeightSpin->value()); 125 } 126 newData.m_fActivateHoveredMachineWindow = m_pCheckBoxActivateOnMouseHover->isChecked(); 127 128 /* Cache new data: */ 129 m_cache.cacheCurrentData(newData); 112 130 } 113 131 … … 117 135 UISettingsPageGlobal::fetchData(data); 118 136 119 /* Save from cache: */ 120 m_settings.setMaxGuestRes(m_cache.m_strMaxGuestResolution); 121 gEDataManager->setActivateHoveredMachineWindow(m_cache.m_fActivateHoveredMachineWindow); 137 /* Save new data from cache: */ 138 if (m_cache.wasChanged()) 139 { 140 if (m_cache.data().m_strMaxGuestResolution != m_cache.base().m_strMaxGuestResolution) 141 m_settings.setMaxGuestRes(m_cache.data().m_strMaxGuestResolution); 142 if (m_cache.data().m_fActivateHoveredMachineWindow != m_cache.base().m_fActivateHoveredMachineWindow) 143 gEDataManager->setActivateHoveredMachineWindow(m_cache.data().m_fActivateHoveredMachineWindow); 144 } 122 145 123 146 /* Upload properties & settings to data: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h
r65678 r65681 24 24 25 25 26 /** Global settings: Display page cachestructure. */27 struct UI SettingsCacheGlobalDisplay26 /** Global settings: Display page data structure. */ 27 struct UIDataSettingsGlobalDisplay 28 28 { 29 /** Constructs data. */ 30 UIDataSettingsGlobalDisplay() 31 : m_strMaxGuestResolution(QString()) 32 , m_fActivateHoveredMachineWindow(false) 33 {} 34 35 /** Returns whether the @a other passed data is equal to this one. */ 36 bool equal(const UIDataSettingsGlobalDisplay &other) const 37 { 38 return true 39 && (m_strMaxGuestResolution == other.m_strMaxGuestResolution) 40 && (m_fActivateHoveredMachineWindow == other.m_fActivateHoveredMachineWindow) 41 ; 42 } 43 44 /** Returns whether the @a other passed data is equal to this one. */ 45 bool operator==(const UIDataSettingsGlobalDisplay &other) const { return equal(other); } 46 /** Returns whether the @a other passed data is different from this one. */ 47 bool operator!=(const UIDataSettingsGlobalDisplay &other) const { return !equal(other); } 48 29 49 /** Holds the maximum guest resolution or preset name. */ 30 50 QString m_strMaxGuestResolution; … … 32 52 bool m_fActivateHoveredMachineWindow; 33 53 }; 54 typedef UISettingsCache<UIDataSettingsGlobalDisplay> UISettingsCacheGlobalDisplay; 34 55 35 56
Note:
See TracChangeset
for help on using the changeset viewer.