VirtualBox

Changeset 68877 in vbox for trunk/src


Ignore:
Timestamp:
Sep 26, 2017 1:20:35 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118138
Message:

FE/Qt: bugref:8720: VM settings: Display page: Video Capture tab: Record Audio check-box.

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  
    6565        , m_iVideoCaptureFrameRate(0)
    6666        , m_iVideoCaptureBitRate(0)
     67        , m_strVideoCaptureOptions(QString())
    6768    {}
    6869
     
    9495               && (m_iVideoCaptureBitRate == other.m_iVideoCaptureBitRate)
    9596               && (m_screens == other.m_screens)
     97               && (m_strVideoCaptureOptions == other.m_strVideoCaptureOptions)
    9698               ;
    9799    }
     
    101103    /** Returns whether the @a other passed data is different from this one. */
    102104    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    }
    103226
    104227    /** Holds the video RAM amount. */
     
    148271    /** Holds which of the guest screens should be captured. */
    149272    QVector<BOOL> m_screens;
     273    /** Holds the video capture options. */
     274    QString m_strVideoCaptureOptions;
    150275};
    151276
     
    258383    oldDisplayData.m_iVideoCaptureBitRate = m_machine.GetVideoCaptureRate();
    259384    oldDisplayData.m_screens = m_machine.GetVideoCaptureScreens();
     385    oldDisplayData.m_strVideoCaptureOptions = m_machine.GetVideoCaptureOptions();
    260386
    261387    /* Gather other old display data: */
     
    307433    m_pEditorVideoCaptureBitRate->setValue(oldDisplayData.m_iVideoCaptureBitRate);
    308434    m_pScrollerVideoCaptureScreens->setValue(oldDisplayData.m_screens);
     435    m_pCheckBoxVideoCaptureWithAudio->setChecked(UIDataSettingsMachineDisplay::isVideoCaptureOptionEnabled(oldDisplayData.m_strVideoCaptureOptions,
     436                                                                                                           UIDataSettingsMachineDisplay::VideoCaptureOption_AC));
    309437
    310438    /* Polish page finally: */
     
    353481    newDisplayData.m_iVideoCaptureBitRate = m_pEditorVideoCaptureBitRate->value();
    354482    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());
    355486
    356487    /* Cache new display data: */
     
    706837    m_pContainerSliderVideoCaptureQuality->setEnabled(fIsVideoCaptureOptionsEnabled);
    707838    m_pEditorVideoCaptureBitRate->setEnabled(fIsVideoCaptureOptionsEnabled);
     839
     840    m_pLabelVideoCaptureExtended->setEnabled(fIsVideoCaptureOptionsEnabled);
     841    m_pCheckBoxVideoCaptureWithAudio->setEnabled(fIsVideoCaptureOptionsEnabled);
    708842
    709843    m_pLabelVideoCaptureScreens->setEnabled(fIsVideoCaptureScreenOptionEnabled);
     
    14811615                fSuccess = m_machine.isOk();
    14821616            }
     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            }
    14831623        }
    14841624
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui

    r67067 r68877  
    674674             </item>
    675675             <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>&amp;Record Audio</string>
     692               </property>
     693              </widget>
     694             </item>
     695             <item row="8" column="0">
    676696              <widget class="QLabel" name="m_pLabelVideoCaptureScreens">
    677697               <property name="text">
     
    686706              </widget>
    687707             </item>
    688              <item row="7" column="1" colspan="3">
     708             <item row="8" column="1" colspan="3">
    689709              <widget class="UIFilmContainer" name="m_pScrollerVideoCaptureScreens">
    690710               <property name="whatsThis">
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