VirtualBox

Changeset 73106 in vbox


Ignore:
Timestamp:
Jul 13, 2018 5:39:36 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123685
Message:

FE/Qt: bugref:9012 Internally use string-string pairs in video capture settings rather than string-bool pairs

File:
1 edited

Legend:

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

    r73092 r73106  
    125125    }
    126126
    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 
    138127    /** Returns string representation for passed enum @a enmKey. */
    139128    static QString fromVideoCaptureOptionKey(VideoCaptureOption enmKey)
     
    147136    }
    148137
    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 
    160138    /** Parses Video Capture Options. */
    161139    static void parseVideoCaptureOptions(const QString &strOptions,
    162140                                         QList<VideoCaptureOption> &outKeys,
    163                                          QList<bool> &outValues)
     141                                         QStringList &outValues)
    164142    {
    165143        outKeys.clear();
     
    169147        {
    170148            const QStringList aPair = strPair.split('=');
     149            if (aPair.size() != 2)
     150                continue;
    171151            const VideoCaptureOption enmKey = toVideoCaptureOptionKey(aPair.value(0));
    172             const bool fValue = toVideoCaptureOptionValue(aPair.value(1));
    173152            if (enmKey == VideoCaptureOption_Unknown)
    174153                continue;
    175154            outKeys << enmKey;
    176             outValues << fValue;
     155            outValues << aPair.value(1);
    177156        }
    178157    }
     
    180159    /** Serializes Video Capture Options. */
    181160    static void serializeVideoCaptureOptions(const QList<VideoCaptureOption> &inKeys,
    182                                              const QList<bool> &inValues,
     161                                             const QStringList &inValues,
    183162                                             QString &strOptions)
    184163    {
     
    188167            QStringList aPair;
    189168            aPair << fromVideoCaptureOptionKey(inKeys.value(i));
    190             aPair << fromVideoCaptureOptionValue(inValues.value(i));
     169            aPair << inValues.value(i);
    191170            aPairs << aPair.join('=');
    192171        }
     
    199178    {
    200179        QList<VideoCaptureOption> aKeys;
    201         QList<bool> aValues;
     180        QStringList aValues;
    202181        parseVideoCaptureOptions(strOptions, aKeys, aValues);
    203182        int iIndex = aKeys.indexOf(enmOption);
    204183        if (iIndex == -1)
    205184            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;
    207188    }
    208189
     
    213194    {
    214195        QList<VideoCaptureOption> aKeys;
    215         QList<bool> aValues;
     196        QStringList aValues;
    216197        parseVideoCaptureOptions(strOptions, aKeys, aValues);
    217198        int iIndex = aKeys.indexOf(enmOption);
     199        QString strValue = fEnabled ? "true" : "false";
    218200        if (iIndex == -1)
    219201        {
    220202            aKeys << enmOption;
    221             aValues << fEnabled;
     203            aValues << strValue;
    222204        }
    223205        else
    224206        {
    225             aValues[iIndex] = fEnabled;
     207            aValues[iIndex] = strValue;
    226208        }
    227209        QString strResult;
     
    238220            return QString();
    239221        QList<VideoCaptureOption> aKeys;
    240         QList<bool> aValues;
     222        QStringList aValues;
    241223        parseVideoCaptureOptions(strOptions, aKeys, aValues);
    242224        for(int i = 0; i < flags.size(); ++i)
    243225        {
     226            QString strValue = flags[i] ? "true" : "false";
    244227            int iIndex = aKeys.indexOf(enmOptions[i]);
    245228            if (iIndex == -1)
    246229            {
    247230                aKeys << enmOptions[i];
    248                 aValues << flags[i];
     231                aValues << strValue;
    249232            }
    250233            else
    251234            {
    252                 aValues[iIndex] = flags[i];
     235                aValues[iIndex] = strValue;
    253236            }
    254237        }
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