VirtualBox

Changeset 74757 in vbox for trunk


Ignore:
Timestamp:
Oct 11, 2018 10:16:30 AM (6 years ago)
Author:
vboxsync
Message:

bugref:9255. Update the scale factor editor actively as the # of monitors change in the dialog

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r74722 r74757  
    39723972double UIExtraDataManager::scaleFactor(const QString &strID, const int uScreenIndex)
    39733973{
    3974     /* Get corresponding extra-data value: */
    3975     const QString strValue = extraDataString(extraDataKeyPerScreen(GUI_ScaleFactor, uScreenIndex), strID);
    3976 
    3977     /* Try to convert loaded data to double: */
     3974    /* Get corresponding extra-data: */
     3975    const QStringList data = extraDataStringList(GUI_ScaleFactor, strID);
     3976
     3977    /* 1.0 is default scale factor: */
     3978    if (data.size() == 0)
     3979        return 1.0;
     3980
     3981    int index = uScreenIndex;
     3982    /* use the 0th. scale factor in case we dont have a scale factor for @p uScreenIndex: */
     3983    if (data.size() <= uScreenIndex)
     3984        index = 0;
     3985
    39783986    bool fOk = false;
    3979     double dValue = strValue.toDouble(&fOk);
    3980 
    3981     /* Invent the default value: */
    3982     if (!fOk || !dValue)
    3983         dValue = 1;
    3984 
    3985     /* Return value: */
    3986     return dValue;
     3987    double scaleFactor = data[index].toDouble(&fOk);
     3988    if (!fOk)
     3989        return 1.0;
     3990    return scaleFactor;
     3991}
     3992
     3993QList<double> UIExtraDataManager::scaleFactors(const QString &strID)
     3994{
     3995    QList<double> scaleFactorList;
     3996    const QStringList data = extraDataStringList(GUI_ScaleFactor, strID);
     3997    bool fOk = false;
     3998    double scaleFactor;
     3999    for (int i = 0; i < data.size(); ++i)
     4000    {
     4001        scaleFactor = data[i].toDouble(&fOk);
     4002        if (!fOk)
     4003            scaleFactor = 1.0;
     4004        scaleFactorList.append(scaleFactor);
     4005    }
     4006    return scaleFactorList;
    39874007}
    39884008
    39894009void UIExtraDataManager::setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex)
    39904010{
    3991     /* Set corresponding extra-data value: */
    3992     setExtraDataString(extraDataKeyPerScreen(GUI_ScaleFactor, uScreenIndex), QString::number(dScaleFactor), strID);
     4011    QStringList data = extraDataStringList(GUI_ScaleFactor, strID);
     4012
     4013    /* Just make sure that we have corresponding data item: */
     4014    if (data.size() <= uScreenIndex)
     4015    {
     4016        int listSize = data.size();
     4017        for (int i = listSize; i <= uScreenIndex; ++i)
     4018            data.append(QString::number(1.0));
     4019    }
     4020
     4021    data[uScreenIndex] = QString::number(dScaleFactor);
     4022
     4023    setExtraDataStringList(GUI_ScaleFactor, data, strID);
     4024}
     4025
     4026void UIExtraDataManager::setScaleFactors(const QList<double> &scaleFactors, const QString &strID)
     4027{
     4028    QStringList data;
     4029    for (int i = 0; i < scaleFactors.size(); ++i)
     4030        data.append(QString::number(scaleFactors[i]));
     4031    setExtraDataStringList(GUI_ScaleFactor, data, strID);
    39934032}
    39944033
     
    45274566            emit sigStatusBarConfigurationChange(strMachineID);
    45284567        /* Scale-factor change: */
    4529         else if (strKey.contains(GUI_ScaleFactor))
     4568        else if (strKey ==GUI_ScaleFactor)
    45304569            emit sigScaleFactorChange(strMachineID);
    45314570        /* Scaling optimization type change: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r74722 r74757  
    598598        /** Returns the scale-factor. */
    599599        double scaleFactor(const QString &strID, const int uScreenIndex);
     600        QList<double> scaleFactors(const QString &strID);
    600601        /** Defines the @a dScaleFactor. */
    601602        void setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex);
     603        void setScaleFactors(const QList<double> &scaleFactors, const QString &strID);
    602604
    603605        /** Returns the scaling optimization type. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r74722 r74757  
    4747        : m_iCurrentVRAM(0)
    4848        , m_cGuestScreenCount(0)
    49         , m_dScaleFactor(1.0)
    5049        , m_f3dAccelerationEnabled(false)
    5150#ifdef VBOX_WITH_VIDEOHWACCEL
     
    7473               && (m_iCurrentVRAM == other.m_iCurrentVRAM)
    7574               && (m_cGuestScreenCount == other.m_cGuestScreenCount)
    76                && (m_dScaleFactor == other.m_dScaleFactor)
    7775               && (m_scaleFactors == other.m_scaleFactors)
    7876               && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled)
     
    245243    int     m_cGuestScreenCount;
    246244    /** Holds the guest screen scale-factor. */
    247     double  m_dScaleFactor;
    248245    QList<double> m_scaleFactors;
    249246    /** Holds whether the 3D acceleration is enabled. */
     
    364361    oldDisplayData.m_iCurrentVRAM = m_machine.GetVRAMSize();
    365362    oldDisplayData.m_cGuestScreenCount = m_machine.GetMonitorCount();
    366     oldDisplayData.m_dScaleFactor = gEDataManager->scaleFactor(m_machine.GetId(), 0);
    367     oldDisplayData.m_scaleFactors.clear();
    368     for (unsigned i = 0; i < m_machine.GetMonitorCount(); ++i)
    369         oldDisplayData.m_scaleFactors.append(gEDataManager->scaleFactor(m_machine.GetId(), (int)i));
    370 
     363    oldDisplayData.m_scaleFactors = gEDataManager->scaleFactors(m_machine.GetId());
    371364    oldDisplayData.m_f3dAccelerationEnabled = m_machine.GetAccelerate3DEnabled();
    372365#ifdef VBOX_WITH_VIDEOHWACCEL
     
    12931286    screens.resize(m_pEditorVideoScreenCount->value());
    12941287    m_pScrollerVideoCaptureScreens->setValue(screens);
     1288    m_pScaleFactorEditor->setMonitorCount(m_pEditorVideoScreenCount->value());
    12951289}
    12961290
     
    14081402
    14091403        /* Save guest-screen scale-factor: */
    1410         if (fSuccess && newDisplayData.m_dScaleFactor != oldDisplayData.m_dScaleFactor)
    1411             /* fSuccess = */ gEDataManager->setScaleFactor(newDisplayData.m_dScaleFactor, strMachineId, 0);
    14121404        if (fSuccess && newDisplayData.m_scaleFactors != oldDisplayData.m_scaleFactors)
    14131405        {
    1414             int listSize = newDisplayData.m_scaleFactors.size();
    1415             for (int i = 0; i < listSize; ++i)
    1416                 gEDataManager->setScaleFactor(newDisplayData.m_scaleFactors[i], strMachineId, i);
     1406            gEDataManager->setScaleFactors(newDisplayData.m_scaleFactors, strMachineId);
    14171407        }
    14181408    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp

    r74732 r74757  
    5656
    5757    m_pMonitorComboBox->blockSignals(true);
    58     m_pMonitorComboBox->clear();
    59     for (int i = 0; i < iMonitorCount; ++i)
    60     {
    61         m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i));
    62 
     58    int iCurrentMonitorCount = m_pMonitorComboBox->count();
     59    int iCurrentMonitorIndex = m_pMonitorComboBox->currentIndex();
     60    //m_pMonitorComboBox->clear();
     61    if (iCurrentMonitorCount < iMonitorCount)
     62    {
     63        for (int i = iCurrentMonitorCount; i < iMonitorCount; ++i)
     64        {
     65            m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i));
     66            /* In case that we have increased the # of monitors add new scale factors to the scale factor cache: */
     67            if (i >= m_scaleFactors.size())
     68                m_scaleFactors.append(1.0);
     69        }
     70    }
     71    else
     72    {
     73        for (int i = iCurrentMonitorCount - 1; i >= iMonitorCount; --i)
     74            m_pMonitorComboBox->removeItem(i);
    6375    }
    6476    m_pMonitorComboBox->blockSignals(false);
     77
     78    if (iCurrentMonitorIndex != m_pMonitorComboBox->currentIndex())
     79        showMonitorScaleFactor();
    6580}
    6681
     
    6984    if (m_scaleFactors == scaleFactors)
    7085        return;
    71     m_scaleFactors = scaleFactors;
    72 
    73     /* Set the spinbox value for the currently selected monitor: */
    74     if (m_pMonitorComboBox)
    75     {
    76         int currentMonitorIndex = m_pMonitorComboBox->currentIndex();
    77         if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox)
    78             setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex));
    79     }
    80 }
     86    /* if m_scaleFactors has more items than @p scaleFactors than we keep the additional items
     87       this can happen for example when extra data has 4 scale factor while machine has 5 monitors: */
     88    if (m_scaleFactors.size() > scaleFactors.size())
     89    {
     90        for (int i = 0; i < scaleFactors.size(); ++i)
     91            m_scaleFactors[i] = scaleFactors[i];
     92    }
     93    else
     94    {
     95        m_scaleFactors = scaleFactors;
     96    }
     97    showMonitorScaleFactor();
     98}
     99
    81100
    82101const QList<double>& UIScaleFactorEditor::scaleFactors() const
     
    212231    }
    213232}
     233
     234void UIScaleFactorEditor::showMonitorScaleFactor()
     235{
     236    /* Set the spinbox value for the currently selected monitor: */
     237    if (m_pMonitorComboBox)
     238    {
     239        int currentMonitorIndex = m_pMonitorComboBox->currentIndex();
     240        if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox)
     241        {
     242            setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex));
     243            setSliderValue(100 * m_scaleFactors.at(currentMonitorIndex));
     244        }
     245    }
     246}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h

    r74732 r74757  
    6161private:
    6262
    63     void prepare();
    64     void setScaleFactor(int iMonitorIndex, int iScaleFactor);
     63    void               prepare();
     64    void               setScaleFactor(int iMonitorIndex, int iScaleFactor);
    6565    /* Blocks slider's signals before settting the value. */
    66     void setSliderValue(int iValue);
     66    void               setSliderValue(int iValue);
    6767    /* Blocks slider's signals before settting the value. */
    68     void setSpinBoxValue(int iValue);
     68    void               setSpinBoxValue(int iValue);
     69    /* Set the spinbox and slider to scale factor of currently selected monitor */
     70    void               showMonitorScaleFactor();
    6971    QSpinBox          *m_pScaleSpinBox;
    7072    QGridLayout       *m_pMainLayout;
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