VirtualBox

Ignore:
Timestamp:
Jul 12, 2018 6:50:54 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123663
Message:

FE/Qt: bugref:9012 Adding audio/video only choices for recording

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r72057 r73092  
    104104        VideoCaptureOption_Unknown,
    105105        VideoCaptureOption_AC,
     106        VideoCaptureOption_VC
     107    };
     108
     109    enum CaptureMode
     110    {
     111        CaptureMode_VideoAudio,
     112        CaptureMode_VideoOnly,
     113        CaptureMode_AudioOnly
    106114    };
    107115
     
    112120        QMap<QString, VideoCaptureOption> keys;
    113121        keys["ac_enabled"] = VideoCaptureOption_AC;
     122        keys["vc_enabled"] = VideoCaptureOption_VC;
    114123        /* Return known value or VideoCaptureOption_Unknown otherwise: */
    115124        return keys.value(strKey, VideoCaptureOption_Unknown);
     
    133142        QMap<VideoCaptureOption, QString> values;
    134143        values[VideoCaptureOption_AC] = "ac_enabled";
     144        values[VideoCaptureOption_VC] = "vc_enabled";
    135145        /* Return known value or QString() otherwise: */
    136146        return values.value(enmKey);
     
    214224        {
    215225            aValues[iIndex] = fEnabled;
     226        }
     227        QString strResult;
     228        serializeVideoCaptureOptions(aKeys, aValues, strResult);
     229        return strResult;
     230    }
     231
     232    /** Defines whether passed Video Capture Options @a enmOptions is @a flags (enabled). */
     233    static QString setVideoCaptureOptionEnabled(const QString &strOptions,
     234                                                const QVector<VideoCaptureOption> &enmOptions,
     235                                                const QVector<bool> &flags)
     236    {
     237        if (enmOptions.size() != flags.size())
     238            return QString();
     239        QList<VideoCaptureOption> aKeys;
     240        QList<bool> aValues;
     241        parseVideoCaptureOptions(strOptions, aKeys, aValues);
     242        for(int i = 0; i < flags.size(); ++i)
     243        {
     244            int iIndex = aKeys.indexOf(enmOptions[i]);
     245            if (iIndex == -1)
     246            {
     247                aKeys << enmOptions[i];
     248                aValues << flags[i];
     249            }
     250            else
     251            {
     252                aValues[iIndex] = flags[i];
     253            }
    216254        }
    217255        QString strResult;
     
    418456    m_pEditorVideoCaptureBitRate->setValue(oldDisplayData.m_iVideoCaptureBitRate);
    419457    m_pScrollerVideoCaptureScreens->setValue(oldDisplayData.m_screens);
    420     m_pCheckBoxVideoCaptureWithAudio->setChecked(UIDataSettingsMachineDisplay::isVideoCaptureOptionEnabled(oldDisplayData.m_strVideoCaptureOptions,
    421                                                                                                            UIDataSettingsMachineDisplay::VideoCaptureOption_AC));
     458
     459    bool fAudioCapture = UIDataSettingsMachineDisplay::isVideoCaptureOptionEnabled(oldDisplayData.m_strVideoCaptureOptions,
     460                                                                                   UIDataSettingsMachineDisplay::VideoCaptureOption_AC);
     461    bool fVideoCapture = UIDataSettingsMachineDisplay::isVideoCaptureOptionEnabled(oldDisplayData.m_strVideoCaptureOptions,
     462                                                                                   UIDataSettingsMachineDisplay::VideoCaptureOption_VC);
     463    if (fAudioCapture && fVideoCapture)
     464        m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_VideoAudio));
     465    else if (!fAudioCapture && fVideoCapture)
     466        m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_VideoOnly));
     467    else if (fAudioCapture && !fVideoCapture)
     468        m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_AudioOnly));
    422469
    423470    /* Polish page finally: */
     
    463510    newDisplayData.m_iVideoCaptureBitRate = m_pEditorVideoCaptureBitRate->value();
    464511    newDisplayData.m_screens = m_pScrollerVideoCaptureScreens->value();
     512
     513    QVector<bool> flagsVector;
     514    flagsVector.push_back(
     515                          m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_VideoAudio) ||
     516                          m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_VideoOnly));
     517
     518    flagsVector.push_back(
     519                          m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_VideoAudio) ||
     520                          m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::CaptureMode_AudioOnly));
     521
     522    QVector<UIDataSettingsMachineDisplay::VideoCaptureOption> videoCaptureOptionVector;
     523    videoCaptureOptionVector.push_back(UIDataSettingsMachineDisplay::VideoCaptureOption_VC);
     524    videoCaptureOptionVector.push_back(UIDataSettingsMachineDisplay::VideoCaptureOption_AC);
     525
    465526    newDisplayData.m_strVideoCaptureOptions = UIDataSettingsMachineDisplay::setVideoCaptureOptionEnabled(m_pCache->base().m_strVideoCaptureOptions,
    466                                                                                                          UIDataSettingsMachineDisplay::VideoCaptureOption_AC,
    467                                                                                                          m_pCheckBoxVideoCaptureWithAudio->isChecked());
     527                                                                                                         videoCaptureOptionVector,
     528                                                                                                         flagsVector);
    468529
    469530    /* Cache new display data: */
     
    792853                                               (isMachineOnline() && !m_pCache->base().m_fVideoCaptureEnabled && m_pCheckboxVideoCapture->isChecked());
    793854
    794     /* Video Capture Screens option should be enabled only if:
    795      * Machine is in *any* valid state and check-box is checked. */
    796     const bool fIsVideoCaptureScreenOptionEnabled = isMachineInValidMode() && m_pCheckboxVideoCapture->isChecked();
     855    m_pLabelCaptureMode->setEnabled(fIsVideoCaptureOptionsEnabled);
     856    m_pComboBoxCaptureMode->setEnabled(fIsVideoCaptureOptionsEnabled);
    797857
    798858    m_pLabelVideoCapturePath->setEnabled(fIsVideoCaptureOptionsEnabled);
    799859    m_pEditorVideoCapturePath->setEnabled(fIsVideoCaptureOptionsEnabled);
    800860
    801     m_pLabelVideoCaptureSize->setEnabled(fIsVideoCaptureOptionsEnabled);
    802     m_pComboVideoCaptureSize->setEnabled(fIsVideoCaptureOptionsEnabled);
    803     m_pEditorVideoCaptureWidth->setEnabled(fIsVideoCaptureOptionsEnabled);
    804     m_pEditorVideoCaptureHeight->setEnabled(fIsVideoCaptureOptionsEnabled);
    805 
    806     m_pLabelVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled);
    807     m_pContainerSliderVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled);
    808     m_pEditorVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled);
    809 
    810     m_pLabelVideoCaptureRate->setEnabled(fIsVideoCaptureOptionsEnabled);
    811     m_pContainerSliderVideoCaptureQuality->setEnabled(fIsVideoCaptureOptionsEnabled);
    812     m_pEditorVideoCaptureBitRate->setEnabled(fIsVideoCaptureOptionsEnabled);
    813 
    814     m_pLabelVideoCaptureExtended->setEnabled(fIsVideoCaptureOptionsEnabled);
    815     m_pCheckBoxVideoCaptureWithAudio->setEnabled(fIsVideoCaptureOptionsEnabled);
    816 
    817     m_pLabelVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled);
    818     m_pLabelVideoCaptureSizeHint->setEnabled(fIsVideoCaptureScreenOptionEnabled);
    819     m_pScrollerVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled);
     861    enableDisableCaptureWidgets();
    820862}
    821863
     
    895937}
    896938
     939void UIMachineSettingsDisplay::sltHandleCaptureComboBoxChange()
     940{
     941    enableDisableCaptureWidgets();
     942}
     943
    897944void UIMachineSettingsDisplay::prepare()
    898945{
     
    912959        /* Prepare 'Video Capture' tab: */
    913960        prepareTabVideoCapture();
     961        prepareModeCombo();
    914962        /* Prepare connections: */
    915963        prepareConnections();
     
    11421190}
    11431191
     1192void UIMachineSettingsDisplay::prepareModeCombo()
     1193{
     1194    if (!m_pComboBoxCaptureMode)
     1195        return;
     1196    m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::CaptureMode_VideoAudio, "Video/Audio");
     1197    m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::CaptureMode_VideoOnly, "Video Only");
     1198    m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::CaptureMode_AudioOnly, "Audio Only");
     1199}
     1200
    11441201void UIMachineSettingsDisplay::prepareConnections()
    11451202{
     
    11701227    connect(m_pSliderVideoCaptureQuality, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureQualitySliderChange()));
    11711228    connect(m_pEditorVideoCaptureBitRate, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureBitRateEditorChange()));
     1229
     1230    connect(m_pComboBoxCaptureMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     1231                this, &UIMachineSettingsDisplay::sltHandleCaptureComboBoxChange);
    11721232}
    11731233
     
    16001660}
    16011661
     1662void UIMachineSettingsDisplay::enableDisableCaptureWidgets()
     1663{
     1664    /* Video Capture options should be enabled only if:
     1665     * 1. Machine is in 'offline' or 'saved' state and check-box is checked,
     1666     * 2. Machine is in 'online' state, check-box is checked, and video recording is *disabled* currently. */
     1667    const bool fIsVideoCaptureOptionsEnabled = ((isMachineOffline() || isMachineSaved()) && m_pCheckboxVideoCapture->isChecked()) ||
     1668                                               (isMachineOnline() && !m_pCache->base().m_fVideoCaptureEnabled && m_pCheckboxVideoCapture->isChecked());
     1669
     1670    const UIDataSettingsMachineDisplay::CaptureMode enmCaptureMode =
     1671        static_cast<UIDataSettingsMachineDisplay::CaptureMode>(m_pComboBoxCaptureMode->currentIndex());
     1672
     1673    /* Video Capture Screens option should be enabled only if:
     1674     * Machine is in *any* valid state and check-box is checked. */
     1675    const bool fIsVideoCaptureScreenOptionEnabled = isMachineInValidMode() && m_pCheckboxVideoCapture->isChecked();
     1676
     1677    bool fVideoCapture = enmCaptureMode == UIDataSettingsMachineDisplay::CaptureMode_VideoOnly ||
     1678        enmCaptureMode == UIDataSettingsMachineDisplay::CaptureMode_VideoAudio;
     1679
     1680    m_pLabelVideoCaptureSize->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1681    m_pComboVideoCaptureSize->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1682    m_pEditorVideoCaptureWidth->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1683    m_pEditorVideoCaptureHeight->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1684
     1685    m_pLabelVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1686    m_pContainerSliderVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1687    m_pEditorVideoCaptureFrameRate->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1688
     1689    m_pLabelVideoCaptureRate->setEnabled(fIsVideoCaptureOptionsEnabled);
     1690    m_pContainerSliderVideoCaptureQuality->setEnabled(fIsVideoCaptureOptionsEnabled);
     1691    m_pEditorVideoCaptureBitRate->setEnabled(fIsVideoCaptureOptionsEnabled && fVideoCapture);
     1692    m_pScrollerVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled && fVideoCapture);
     1693
     1694    m_pLabelVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled && fVideoCapture);
     1695    m_pLabelVideoCaptureSizeHint->setEnabled(fIsVideoCaptureScreenOptionEnabled && fVideoCapture);
     1696}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r72109 r73092  
    114114    /** Handles Video Capture bit-rate editor change. */
    115115    void sltHandleVideoCaptureBitRateEditorChange();
     116    void sltHandleCaptureComboBoxChange();
    116117
    117118private:
     
    125126    /** Prepares 'Video Capture' tab. */
    126127    void prepareTabVideoCapture();
     128    /** Populates Capture Mode combobox with related items. */
     129    void prepareModeCombo();
    127130    /** Prepares connections. */
    128131    void prepareConnections();
     
    158161    /** Saves existing 'Video Capture' data from the cache. */
    159162    bool saveVideoCaptureData();
     163    /** Decide which of the capture related widgets are to be disabled/enabled. */
     164    void enableDisableCaptureWidgets();
    160165
    161166    /** Holds the guest OS type ID. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui

    r71104 r73092  
    411411     <widget class="QWidget" name="m_pTabVideoCapture">
    412412      <attribute name="title">
    413        <string>Video &amp;Capture</string>
     413       <string>&amp;Capture</string>
    414414      </attribute>
    415415      <layout class="QVBoxLayout" name="m_pLayoutTabVideoCapture">
     
    426426            </property>
    427427            <property name="text">
    428              <string>&amp;Enable Video Capture</string>
     428             <string>&amp;Enable Capture</string>
    429429            </property>
    430430           </widget>
     
    453453            <layout class="QGridLayout" name="m_pContainerLayoutVideoCapture">
    454454             <item row="0" column="0">
     455              <widget class="QLabel" name="m_pLabelCaptureMode">
     456               <property name="text">
     457                <string>Capture &amp;Mode:</string>
     458               </property>
     459               <property name="alignment">
     460                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
     461               </property>
     462               <property name="buddy">
     463                <cstring>m_pEditorVideoCapturePath</cstring>
     464               </property>
     465              </widget>
     466             </item>
     467             <item row="0" column="1" colspan="1">
     468              <widget class="QComboBox" name="m_pComboBoxCaptureMode">
     469               <property name="whatsThis">
     470                <string>Stores the capture mode.</string>
     471               </property>
     472              </widget>
     473             </item>
     474             <item row="1" column="0">
    455475              <widget class="QLabel" name="m_pLabelVideoCapturePath">
    456476               <property name="text">
     
    465485              </widget>
    466486             </item>
    467              <item row="0" column="1" colspan="3">
     487             <item row="1" column="1" colspan="3">
    468488              <widget class="UIFilePathSelector" name="m_pEditorVideoCapturePath">
    469489               <property name="whatsThis">
     
    472492              </widget>
    473493             </item>
    474              <item row="1" column="0">
     494             <item row="2" column="0">
    475495              <widget class="QLabel" name="m_pLabelVideoCaptureSize">
    476496               <property name="text">
     
    485505              </widget>
    486506             </item>
    487              <item row="1" column="1">
     507             <item row="2" column="1">
    488508              <widget class="QComboBox" name="m_pComboVideoCaptureSize">
    489509               <property name="sizePolicy">
     
    498518              </widget>
    499519             </item>
    500              <item row="1" column="2">
     520             <item row="2" column="2">
    501521              <widget class="QSpinBox" name="m_pEditorVideoCaptureWidth">
    502522               <property name="whatsThis">
     
    505525              </widget>
    506526             </item>
    507              <item row="1" column="3">
     527             <item row="2" column="3">
    508528              <widget class="QSpinBox" name="m_pEditorVideoCaptureHeight">
    509529               <property name="whatsThis">
     
    512532              </widget>
    513533             </item>
    514              <item row="2" column="0">
     534             <item row="3" column="0">
    515535              <widget class="QLabel" name="m_pLabelVideoCaptureFrameRate">
    516536               <property name="text">
     
    525545              </widget>
    526546             </item>
    527              <item row="2" column="1" rowspan="2">
     547             <item row="3" column="1" rowspan="2">
    528548              <widget class="QWidget" name="m_pContainerSliderVideoCaptureFrameRate">
    529549               <layout class="QGridLayout" name="m_pContainerLayoutSliderVideoCaptureFrameRate">
     
    563583              </widget>
    564584             </item>
    565              <item row="2" column="2" colspan="2">
     585             <item row="3" column="2" colspan="2">
    566586              <widget class="QSpinBox" name="m_pEditorVideoCaptureFrameRate">
    567587               <property name="whatsThis">
     
    570590              </widget>
    571591             </item>
    572              <item row="4" column="0">
     592             <item row="5" column="0">
    573593              <widget class="QLabel" name="m_pLabelVideoCaptureRate">
    574594               <property name="text">
     
    583603              </widget>
    584604             </item>
    585              <item row="4" column="1" rowspan="2">
     605             <item row="5" column="1" rowspan="2">
    586606              <widget class="QWidget" name="m_pContainerSliderVideoCaptureQuality">
    587607               <layout class="QGridLayout" name="m_pContainerLayoutSliderVideoCaptureQuality">
     
    637657              </widget>
    638658             </item>
    639              <item row="4" column="2" colspan="2">
     659             <item row="5" column="2" colspan="2">
    640660              <widget class="QSpinBox" name="m_pEditorVideoCaptureBitRate">
    641661               <property name="whatsThis">
     
    644664              </widget>
    645665             </item>
    646              <item row="6" column="1">
     666             <item row="7" column="1">
    647667              <widget class="QLabel" name="m_pLabelVideoCaptureSizeHint"/>
    648              </item>
    649              <item row="7" column="0">
    650               <widget class="QLabel" name="m_pLabelVideoCaptureExtended">
    651                <property name="text">
    652                 <string>Extended Features:</string>
    653                </property>
    654                <property name="alignment">
    655                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    656                </property>
    657               </widget>
    658              </item>
    659              <item row="7" column="1" colspan="3">
    660               <widget class="QCheckBox" name="m_pCheckBoxVideoCaptureWithAudio">
    661                <property name="whatsThis">
    662                 <string>When checked, VirtualBox will record the audio stream to video file as well.</string>
    663                </property>
    664                <property name="text">
    665                 <string>&amp;Record Audio</string>
    666                </property>
    667               </widget>
    668668             </item>
    669669             <item row="8" column="0">
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette