VirtualBox

Changeset 76044 in vbox for trunk/src


Ignore:
Timestamp:
Dec 7, 2018 9:50:51 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9012. Make the recording mode selection combo text translatable

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r75886 r76044  
    3030#include "UIMediumDefs.h"
    3131#include "UIExtraDataDefs.h"
     32#include "UISettingsDefs.h"
    3233
    3334/* Other VBox includes: */
     
    120121template<> SHARED_LIBRARY_STUFF bool canConvert<MaxGuestResolutionPolicy>();
    121122template<> SHARED_LIBRARY_STUFF bool canConvert<UIMediumFormat>();
    122 
     123template<> SHARED_LIBRARY_STUFF bool canConvert<UISettingsDefs::RecordingMode>();
    123124
    124125/* Declare COM canConvert specializations: */
     
    259260template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIMediumFormat &enmUIMediumFormat);
    260261template<> SHARED_LIBRARY_STUFF UIMediumFormat fromInternalString<UIMediumFormat>(const QString &strUIMediumFormat);
     262template<> SHARED_LIBRARY_STUFF QString toString(const UISettingsDefs::RecordingMode &enmRecordingMode);
     263template<> SHARED_LIBRARY_STUFF QString toInternalString(const UISettingsDefs::RecordingMode &enmRecordingMode);
     264template<> SHARED_LIBRARY_STUFF UISettingsDefs::RecordingMode fromInternalString<UISettingsDefs::RecordingMode>(const QString &enmRecordingMode);
    261265
    262266
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r75966 r76044  
    8484template<> bool canConvert<MaxGuestResolutionPolicy>() { return true; }
    8585template<> bool canConvert<UIMediumFormat>() { return true; }
     86template<> bool canConvert<UISettingsDefs::RecordingMode>() { return true; }
    8687
    8788
     
    25022503    return values.at(keys.indexOf(QRegExp(strUIMediumFormat, Qt::CaseInsensitive)));
    25032504}
     2505
     2506/* QString <= UISettingsDefs::RecordingMode: */
     2507template<> QString toString(const UISettingsDefs::RecordingMode &enmRecordingMode)
     2508{
     2509    QString strResult;
     2510    switch (enmRecordingMode)
     2511    {
     2512        case UISettingsDefs::RecordingMode_VideoAudio: strResult = QApplication::translate("VBoxGlobal", "Video/Audio", "UISettingsDefs::RecordingMode"); break;
     2513        case UISettingsDefs::RecordingMode_VideoOnly:  strResult = QApplication::translate("VBoxGlobal", "Video Only", "UISettingsDefs::RecordingMode"); break;
     2514        case UISettingsDefs::RecordingMode_AudioOnly:  strResult = QApplication::translate("VBoxGlobal", "Audio Only", "UISettingsDefs::RecordingMode"); break;
     2515        default:
     2516        {
     2517            AssertMsgFailed(("No text for recording mode format=%d", enmRecordingMode));
     2518            break;
     2519        }
     2520    }
     2521    return strResult;
     2522}
     2523
     2524/* QString <= UISettingsDefs::RecordingMode: */
     2525template<> QString toInternalString(const UISettingsDefs::RecordingMode &enmRecordingMode)
     2526{
     2527    QString strResult;
     2528    switch (enmRecordingMode)
     2529    {
     2530        case UISettingsDefs::RecordingMode_VideoAudio: strResult = "Video/Audio"; break;
     2531        case UISettingsDefs::RecordingMode_VideoOnly:  strResult = "VideoOnly";   break;
     2532        case UISettingsDefs::RecordingMode_AudioOnly:  strResult = "AudioOnly";   break;
     2533        default:
     2534        {
     2535            AssertMsgFailed(("No text for recording mode=%d", enmRecordingMode));
     2536            break;
     2537        }
     2538    }
     2539    return strResult;
     2540}
     2541
     2542/* UISettingsDefs::RecordingMode <= QString: */
     2543template<> UISettingsDefs::RecordingMode fromInternalString<UISettingsDefs::RecordingMode>(const QString &strRecordingMode)
     2544{
     2545    /* Here we have some fancy stuff allowing us
     2546     * to search through the keys using 'case-insensitive' rule: */
     2547    QStringList keys;       QList<UISettingsDefs::RecordingMode> values;
     2548    keys << "Video/Audio";  values << UISettingsDefs::RecordingMode_VideoAudio;
     2549    keys << "VideoOnly";    values << UISettingsDefs::RecordingMode_VideoOnly;
     2550    keys << "AudioOnly";    values << UISettingsDefs::RecordingMode_AudioOnly;
     2551    /* VDI format for unknown words: */
     2552    if (!keys.contains(strRecordingMode, Qt::CaseInsensitive))
     2553        return UISettingsDefs::RecordingMode_VideoAudio;
     2554    /* Corresponding format for known words: */
     2555    return values.at(keys.indexOf(QRegExp(strRecordingMode, Qt::CaseInsensitive)));
     2556}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDefs.h

    r71630 r76044  
    4949    };
    5050
     51    /** Recording mode enum is used in Display setting page to determine the recording mode. */
     52    enum RecordingMode
     53    {
     54        RecordingMode_VideoAudio = 0,
     55        RecordingMode_VideoOnly  = 1,
     56        RecordingMode_AudioOnly  = 2
     57    };
     58
    5159    /** Determines configuration access level for passed @a enmSessionState and @a enmMachineState. */
    5260    SHARED_LIBRARY_STUFF ConfigurationAccessLevel configurationAccessLevel(KSessionState enmSessionState,
     
    287295
    288296#endif /* !___UISettingsDefs_h___ */
    289 
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r75926 r76044  
    111111        RecordingOption_VC,
    112112        RecordingOption_AC_Profile
    113     };
    114 
    115     enum RecordingMode
    116     {
    117         RecordingMode_VideoAudio,
    118         RecordingMode_VideoOnly,
    119         RecordingMode_AudioOnly
    120113    };
    121114
     
    466459                                                                                UIDataSettingsMachineDisplay::RecordingOption_VC);
    467460    if (fRecordAudio && fRecordVideo)
    468         m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_VideoAudio));
     461        m_pComboBoxCaptureMode->setCurrentIndex(m_pComboBoxCaptureMode->findText(gpConverter->toString(UISettingsDefs::RecordingMode_VideoAudio)));
    469462    else if (fRecordAudio && !fRecordVideo)
    470         m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_AudioOnly));
     463        m_pComboBoxCaptureMode->setCurrentIndex(m_pComboBoxCaptureMode->findText(gpConverter->toString(UISettingsDefs::RecordingMode_AudioOnly)));
    471464    else
    472         m_pComboBoxCaptureMode->setCurrentIndex(static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_VideoOnly));
     465        m_pComboBoxCaptureMode->setCurrentIndex(m_pComboBoxCaptureMode->findText(gpConverter->toString(UISettingsDefs::RecordingMode_VideoOnly)));
    473466
    474467    m_pSliderAudioCaptureQuality->setValue(UIDataSettingsMachineDisplay::getAudioQualityFromOptions(oldDisplayData.m_strRecordingVideoOptions));
     
    519512    /* Update recording options */
    520513    QStringList optionValues;
    521     optionValues.push_back((m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_VideoAudio) ||
    522                             m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_VideoOnly)) ? "true" : "false");
    523     optionValues.push_back((m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_VideoAudio) ||
    524                             m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UIDataSettingsMachineDisplay::RecordingMode_AudioOnly)) ? "true" : "false");
     514    optionValues.push_back((m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UISettingsDefs::RecordingMode_VideoAudio) ||
     515                            m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UISettingsDefs::RecordingMode_VideoOnly)) ? "true" : "false");
     516    optionValues.push_back((m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UISettingsDefs::RecordingMode_VideoAudio) ||
     517                            m_pComboBoxCaptureMode->currentIndex() == static_cast<int>(UISettingsDefs::RecordingMode_AudioOnly)) ? "true" : "false");
    525518    if (m_pSliderAudioCaptureQuality->value() == 1)
    526519        optionValues.push_back("low");
     
    742735    m_pLabelAudioCaptureQualityMed->setText(tr("medium", "quality"));
    743736    m_pLabelAudioCaptureQualityMax->setText(tr("high", "quality"));
     737
     738    m_pComboBoxCaptureMode->setItemText(0, gpConverter->toString(UISettingsDefs::RecordingMode_VideoAudio));
     739    m_pComboBoxCaptureMode->setItemText(1, gpConverter->toString(UISettingsDefs::RecordingMode_VideoOnly));
     740    m_pComboBoxCaptureMode->setItemText(2, gpConverter->toString(UISettingsDefs::RecordingMode_AudioOnly));
     741
    744742    updateRecordingFileSizeHint();
    745743}
     
    10751073        AssertPtrReturnVoid(m_pComboBoxCaptureMode);
    10761074        {
    1077             m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::RecordingMode_VideoAudio, "Video/Audio");
    1078             m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::RecordingMode_VideoOnly, "Video Only");
    1079             m_pComboBoxCaptureMode->insertItem(UIDataSettingsMachineDisplay::RecordingMode_AudioOnly, "Audio Only");
     1075            m_pComboBoxCaptureMode->insertItem(0, ""); /* UISettingsDefs::RecordingMode_VideoAudio */
     1076            m_pComboBoxCaptureMode->insertItem(1, ""); /* UISettingsDefs::RecordingMode_VideoOnly */
     1077            m_pComboBoxCaptureMode->insertItem(2, ""); /* UISettingsDefs::RecordingMode_AudioOnly */
    10801078        }
    10811079
     
    17291727                                             (isMachineOnline() && !m_pCache->base().m_fRecordingEnabled && m_pCheckboxVideoCapture->isChecked());
    17301728
    1731     const UIDataSettingsMachineDisplay::RecordingMode enmRecordingMode =
    1732         static_cast<UIDataSettingsMachineDisplay::RecordingMode>(m_pComboBoxCaptureMode->currentIndex());
     1729    const UISettingsDefs::RecordingMode enmRecordingMode =
     1730        static_cast<UISettingsDefs::RecordingMode>(m_pComboBoxCaptureMode->currentIndex());
    17331731
    17341732    /* Video Capture Screens option should be enabled only if:
     
    17361734    const bool fIsVideoCaptureScreenOptionEnabled = isMachineInValidMode() && m_pCheckboxVideoCapture->isChecked();
    17371735
    1738     bool fRecordVideo = enmRecordingMode == UIDataSettingsMachineDisplay::RecordingMode_VideoOnly ||
    1739         enmRecordingMode == UIDataSettingsMachineDisplay::RecordingMode_VideoAudio;
    1740     bool fRecordAudio = enmRecordingMode == UIDataSettingsMachineDisplay::RecordingMode_AudioOnly ||
    1741         enmRecordingMode == UIDataSettingsMachineDisplay::RecordingMode_VideoAudio;
     1736    bool fRecordVideo = enmRecordingMode == UISettingsDefs::RecordingMode_VideoOnly ||
     1737        enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio;
     1738    bool fRecordAudio = enmRecordingMode == UISettingsDefs::RecordingMode_AudioOnly ||
     1739        enmRecordingMode == UISettingsDefs::RecordingMode_VideoAudio;
    17421740
    17431741    m_pLabelVideoCaptureSize->setEnabled(fIsRecordingOptionsEnabled && fRecordVideo);
Note: See TracChangeset for help on using the changeset viewer.

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