Changeset 73106 in vbox
- Timestamp:
- Jul 13, 2018 5:39:36 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123685
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r73092 r73106 125 125 } 126 126 127 /** Returns bool value corresponding to passed @a strValue. */128 static bool toVideoCaptureOptionValue(const QString &strValue)129 {130 /* Compare case-sensitive: */131 QMap<QString, bool> values;132 values["true"] = true;133 values["false"] = false;134 /* Return known value or true otherwise: */135 return values.value(strValue, false);136 }137 138 127 /** Returns string representation for passed enum @a enmKey. */ 139 128 static QString fromVideoCaptureOptionKey(VideoCaptureOption enmKey) … … 147 136 } 148 137 149 /** Returns string representation for passed bool @a fValue. */150 static QString fromVideoCaptureOptionValue(bool fValue)151 {152 /* Compare case-sensitive: */153 QMap<bool, QString> values;154 values[true] = "true";155 values[false] = "false";156 /* Return known value or "false" otherwise: */157 return values.value(fValue, "false");158 }159 160 138 /** Parses Video Capture Options. */ 161 139 static void parseVideoCaptureOptions(const QString &strOptions, 162 140 QList<VideoCaptureOption> &outKeys, 163 Q List<bool>&outValues)141 QStringList &outValues) 164 142 { 165 143 outKeys.clear(); … … 169 147 { 170 148 const QStringList aPair = strPair.split('='); 149 if (aPair.size() != 2) 150 continue; 171 151 const VideoCaptureOption enmKey = toVideoCaptureOptionKey(aPair.value(0)); 172 const bool fValue = toVideoCaptureOptionValue(aPair.value(1));173 152 if (enmKey == VideoCaptureOption_Unknown) 174 153 continue; 175 154 outKeys << enmKey; 176 outValues << fValue;155 outValues << aPair.value(1); 177 156 } 178 157 } … … 180 159 /** Serializes Video Capture Options. */ 181 160 static void serializeVideoCaptureOptions(const QList<VideoCaptureOption> &inKeys, 182 const Q List<bool>&inValues,161 const QStringList &inValues, 183 162 QString &strOptions) 184 163 { … … 188 167 QStringList aPair; 189 168 aPair << fromVideoCaptureOptionKey(inKeys.value(i)); 190 aPair << fromVideoCaptureOptionValue(inValues.value(i));169 aPair << inValues.value(i); 191 170 aPairs << aPair.join('='); 192 171 } … … 199 178 { 200 179 QList<VideoCaptureOption> aKeys; 201 Q List<bool>aValues;180 QStringList aValues; 202 181 parseVideoCaptureOptions(strOptions, aKeys, aValues); 203 182 int iIndex = aKeys.indexOf(enmOption); 204 183 if (iIndex == -1) 205 184 return false; /* If option is missing, assume disabled (false). */ 206 return aValues.value(iIndex); 185 if (aValues.value(iIndex).compare("true", Qt::CaseInsensitive) == 0) 186 return true; 187 return false; 207 188 } 208 189 … … 213 194 { 214 195 QList<VideoCaptureOption> aKeys; 215 Q List<bool>aValues;196 QStringList aValues; 216 197 parseVideoCaptureOptions(strOptions, aKeys, aValues); 217 198 int iIndex = aKeys.indexOf(enmOption); 199 QString strValue = fEnabled ? "true" : "false"; 218 200 if (iIndex == -1) 219 201 { 220 202 aKeys << enmOption; 221 aValues << fEnabled;203 aValues << strValue; 222 204 } 223 205 else 224 206 { 225 aValues[iIndex] = fEnabled;207 aValues[iIndex] = strValue; 226 208 } 227 209 QString strResult; … … 238 220 return QString(); 239 221 QList<VideoCaptureOption> aKeys; 240 Q List<bool>aValues;222 QStringList aValues; 241 223 parseVideoCaptureOptions(strOptions, aKeys, aValues); 242 224 for(int i = 0; i < flags.size(); ++i) 243 225 { 226 QString strValue = flags[i] ? "true" : "false"; 244 227 int iIndex = aKeys.indexOf(enmOptions[i]); 245 228 if (iIndex == -1) 246 229 { 247 230 aKeys << enmOptions[i]; 248 aValues << flags[i];231 aValues << strValue; 249 232 } 250 233 else 251 234 { 252 aValues[iIndex] = flags[i];235 aValues[iIndex] = strValue; 253 236 } 254 237 }
Note:
See TracChangeset
for help on using the changeset viewer.