- Timestamp:
- Sep 26, 2017 1:20:35 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 118138
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r68435 r68877 65 65 , m_iVideoCaptureFrameRate(0) 66 66 , m_iVideoCaptureBitRate(0) 67 , m_strVideoCaptureOptions(QString()) 67 68 {} 68 69 … … 94 95 && (m_iVideoCaptureBitRate == other.m_iVideoCaptureBitRate) 95 96 && (m_screens == other.m_screens) 97 && (m_strVideoCaptureOptions == other.m_strVideoCaptureOptions) 96 98 ; 97 99 } … … 101 103 /** Returns whether the @a other passed data is different from this one. */ 102 104 bool operator!=(const UIDataSettingsMachineDisplay &other) const { return !equal(other); } 105 106 /** Video Capture Options. */ 107 enum VideoCaptureOption 108 { 109 VideoCaptureOption_Unknown, 110 VideoCaptureOption_AC, 111 }; 112 113 /** Returns enum value corresponding to passed @a strKey. */ 114 static VideoCaptureOption toVideoCaptureOptionKey(const QString &strKey) 115 { 116 /* Compare case-sensitive: */ 117 QMap<QString, VideoCaptureOption> keys; 118 keys["ac_enabled"] = VideoCaptureOption_AC; 119 /* Return known value or VideoCaptureOption_Unknown otherwise: */ 120 return keys.value(strKey, VideoCaptureOption_Unknown); 121 } 122 123 /** Returns bool value corresponding to passed @a strValue. */ 124 static bool toVideoCaptureOptionValue(const QString &strValue) 125 { 126 /* Compare case-sensitive: */ 127 QMap<QString, bool> values; 128 values["true"] = true; 129 values["false"] = false; 130 /* Return known value or true otherwise: */ 131 return values.value(strValue, true); 132 } 133 134 /** Returns string representation for passed enum @a enmKey. */ 135 static QString fromVideoCaptureOptionKey(VideoCaptureOption enmKey) 136 { 137 /* Compare case-sensitive: */ 138 QMap<VideoCaptureOption, QString> values; 139 values[VideoCaptureOption_AC] = "ac_enabled"; 140 /* Return known value or QString() otherwise: */ 141 return values.value(enmKey); 142 } 143 144 /** Returns string representation for passed bool @a fValue. */ 145 static QString fromVideoCaptureOptionValue(bool fValue) 146 { 147 /* Compare case-sensitive: */ 148 QMap<bool, QString> values; 149 values[true] = "true"; 150 values[false] = "false"; 151 /* Return known value or "true" otherwise: */ 152 return values.value(fValue, "true"); 153 } 154 155 /** Parses Video Capture Options. */ 156 static void parseVideoCaptureOptions(const QString &strOptions, 157 QList<VideoCaptureOption> &outKeys, 158 QList<bool> &outValues) 159 { 160 outKeys.clear(); 161 outValues.clear(); 162 const QStringList aPairs = strOptions.split(','); 163 foreach (const QString &strPair, aPairs) 164 { 165 const QStringList aPair = strPair.split('='); 166 const VideoCaptureOption enmKey = toVideoCaptureOptionKey(aPair.value(0)); 167 const bool fValue = toVideoCaptureOptionValue(aPair.value(1)); 168 if (enmKey == VideoCaptureOption_Unknown) 169 continue; 170 outKeys << enmKey; 171 outValues << fValue; 172 } 173 } 174 175 /** Serializes Video Capture Options. */ 176 static void serializeVideoCaptureOptions(const QList<VideoCaptureOption> &inKeys, 177 const QList<bool> &inValues, 178 QString &strOptions) 179 { 180 QStringList aPairs; 181 for (int i = 0; i < inKeys.size(); ++i) 182 { 183 QStringList aPair; 184 aPair << fromVideoCaptureOptionKey(inKeys.value(i)); 185 aPair << fromVideoCaptureOptionValue(inValues.value(i)); 186 aPairs << aPair.join('='); 187 } 188 strOptions = aPairs.join(','); 189 } 190 191 /** Returns whether passed Video Capture @a enmOption is enabled. */ 192 static bool isVideoCaptureOptionEnabled(const QString &strOptions, 193 VideoCaptureOption enmOption) 194 { 195 QList<VideoCaptureOption> aKeys; 196 QList<bool> aValues; 197 parseVideoCaptureOptions(strOptions, aKeys, aValues); 198 int iIndex = aKeys.indexOf(enmOption); 199 if (iIndex == -1) 200 return true; 201 return aValues.value(iIndex); 202 } 203 204 /** Defines whether passed Video Capture @a enmOption is @a fEnabled. */ 205 static QString setVideoCaptureOptionEnabled(const QString &strOptions, 206 VideoCaptureOption enmOption, 207 bool fEnabled) 208 { 209 QList<VideoCaptureOption> aKeys; 210 QList<bool> aValues; 211 parseVideoCaptureOptions(strOptions, aKeys, aValues); 212 int iIndex = aKeys.indexOf(enmOption); 213 if (iIndex == -1) 214 { 215 aKeys << enmOption; 216 aValues << fEnabled; 217 } 218 else 219 { 220 aValues[iIndex] = fEnabled; 221 } 222 QString strResult; 223 serializeVideoCaptureOptions(aKeys, aValues, strResult); 224 return strResult; 225 } 103 226 104 227 /** Holds the video RAM amount. */ … … 148 271 /** Holds which of the guest screens should be captured. */ 149 272 QVector<BOOL> m_screens; 273 /** Holds the video capture options. */ 274 QString m_strVideoCaptureOptions; 150 275 }; 151 276 … … 258 383 oldDisplayData.m_iVideoCaptureBitRate = m_machine.GetVideoCaptureRate(); 259 384 oldDisplayData.m_screens = m_machine.GetVideoCaptureScreens(); 385 oldDisplayData.m_strVideoCaptureOptions = m_machine.GetVideoCaptureOptions(); 260 386 261 387 /* Gather other old display data: */ … … 307 433 m_pEditorVideoCaptureBitRate->setValue(oldDisplayData.m_iVideoCaptureBitRate); 308 434 m_pScrollerVideoCaptureScreens->setValue(oldDisplayData.m_screens); 435 m_pCheckBoxVideoCaptureWithAudio->setChecked(UIDataSettingsMachineDisplay::isVideoCaptureOptionEnabled(oldDisplayData.m_strVideoCaptureOptions, 436 UIDataSettingsMachineDisplay::VideoCaptureOption_AC)); 309 437 310 438 /* Polish page finally: */ … … 353 481 newDisplayData.m_iVideoCaptureBitRate = m_pEditorVideoCaptureBitRate->value(); 354 482 newDisplayData.m_screens = m_pScrollerVideoCaptureScreens->value(); 483 newDisplayData.m_strVideoCaptureOptions = UIDataSettingsMachineDisplay::setVideoCaptureOptionEnabled(m_pCache->base().m_strVideoCaptureOptions, 484 UIDataSettingsMachineDisplay::VideoCaptureOption_AC, 485 m_pCheckBoxVideoCaptureWithAudio->isChecked()); 355 486 356 487 /* Cache new display data: */ … … 706 837 m_pContainerSliderVideoCaptureQuality->setEnabled(fIsVideoCaptureOptionsEnabled); 707 838 m_pEditorVideoCaptureBitRate->setEnabled(fIsVideoCaptureOptionsEnabled); 839 840 m_pLabelVideoCaptureExtended->setEnabled(fIsVideoCaptureOptionsEnabled); 841 m_pCheckBoxVideoCaptureWithAudio->setEnabled(fIsVideoCaptureOptionsEnabled); 708 842 709 843 m_pLabelVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled); … … 1481 1615 fSuccess = m_machine.isOk(); 1482 1616 } 1617 /* Save video capture options: */ 1618 if (fSuccess && newDisplayData.m_strVideoCaptureOptions != oldDisplayData.m_strVideoCaptureOptions) 1619 { 1620 m_machine.SetVideoCaptureOptions(newDisplayData.m_strVideoCaptureOptions); 1621 fSuccess = m_machine.isOk(); 1622 } 1483 1623 } 1484 1624 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui
r67067 r68877 674 674 </item> 675 675 <item row="7" column="0"> 676 <widget class="QLabel" name="m_pLabelVideoCaptureExtended"> 677 <property name="text"> 678 <string>Extended Features:</string> 679 </property> 680 <property name="alignment"> 681 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 682 </property> 683 </widget> 684 </item> 685 <item row="7" column="1" colspan="3"> 686 <widget class="QCheckBox" name="m_pCheckBoxVideoCaptureWithAudio"> 687 <property name="whatsThis"> 688 <string>When checked, VirtualBox will record the audio stream to video file as well.</string> 689 </property> 690 <property name="text"> 691 <string>&Record Audio</string> 692 </property> 693 </widget> 694 </item> 695 <item row="8" column="0"> 676 696 <widget class="QLabel" name="m_pLabelVideoCaptureScreens"> 677 697 <property name="text"> … … 686 706 </widget> 687 707 </item> 688 <item row=" 7" column="1" colspan="3">708 <item row="8" column="1" colspan="3"> 689 709 <widget class="UIFilmContainer" name="m_pScrollerVideoCaptureScreens"> 690 710 <property name="whatsThis">
Note:
See TracChangeset
for help on using the changeset viewer.