VirtualBox

Changeset 74722 in vbox


Ignore:
Timestamp:
Oct 9, 2018 5:08:55 PM (6 years ago)
Author:
vboxsync
Message:

bugref:9255. Switch to the new scale factor widget in vm settings dialog

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

Legend:

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

    r74701 r74722  
    39703970}
    39713971
    3972 double UIExtraDataManager::scaleFactor(const QString &strID, const int uScreenIndex /* = 0 */)
     3972double UIExtraDataManager::scaleFactor(const QString &strID, const int uScreenIndex)
    39733973{
    39743974    /* Get corresponding extra-data value: */
     
    39873987}
    39883988
    3989 void UIExtraDataManager::setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex /* = 0 */)
     3989void UIExtraDataManager::setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex)
    39903990{
    39913991    /* Set corresponding extra-data value: */
     
    45274527            emit sigStatusBarConfigurationChange(strMachineID);
    45284528        /* Scale-factor change: */
    4529         else if (strKey == GUI_ScaleFactor)
     4529        else if (strKey.contains(GUI_ScaleFactor))
    45304530            emit sigScaleFactorChange(strMachineID);
    45314531        /* Scaling optimization type change: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r74701 r74722  
    597597
    598598        /** Returns the scale-factor. */
    599         double scaleFactor(const QString &strID, const int uScreenIndex = 0);
     599        double scaleFactor(const QString &strID, const int uScreenIndex);
    600600        /** Defines the @a dScaleFactor. */
    601         void setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex = 0);
     601        void setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex);
    602602
    603603        /** Returns the scaling optimization type. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp

    r73847 r74722  
    31573157    /* Change scale-factor directly: */
    31583158    const double dScaleFactor = pAction->property("Requested Scale Factor").toDouble();
    3159     gEDataManager->setScaleFactor(dScaleFactor, vboxGlobal().managedVMUuid());
     3159    gEDataManager->setScaleFactor(dScaleFactor, vboxGlobal().managedVMUuid(), 0);
    31603160}
    31613161
     
    37833783
    37843784        /* Get current scale-factor: */
    3785         const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     3785        const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), 0);
    37863786
    37873787        /* Get device-pixel-ratio: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r71106 r74722  
    248248{
    249249    /* Acquire selected scale-factor: */
    250     double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     250    double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), m_uScreenId);
    251251
    252252    /* Take the device-pixel-ratio into account: */
     
    508508
    509509    /* Acquire selected scale-factor: */
    510     double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     510    double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), m_uScreenId);
    511511
    512512    /* Take the device-pixel-ratio into account: */
     
    702702
    703703        /* Acquire selected scale-factor: */
    704         double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     704        double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), m_uScreenId);
    705705
    706706        /* Take the device-pixel-ratio into account: */
     
    19041904    return size;
    19051905}
    1906 
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r74701 r74722  
    7575               && (m_cGuestScreenCount == other.m_cGuestScreenCount)
    7676               && (m_dScaleFactor == other.m_dScaleFactor)
     77               && (m_scaleFactors == other.m_scaleFactors)
    7778               && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled)
    7879#ifdef VBOX_WITH_VIDEOHWACCEL
     
    245246    /** Holds the guest screen scale-factor. */
    246247    double  m_dScaleFactor;
     248    QList<double> m_scaleFactors;
    247249    /** Holds whether the 3D acceleration is enabled. */
    248250    bool    m_f3dAccelerationEnabled;
     
    362364    oldDisplayData.m_iCurrentVRAM = m_machine.GetVRAMSize();
    363365    oldDisplayData.m_cGuestScreenCount = m_machine.GetMonitorCount();
    364     oldDisplayData.m_dScaleFactor = gEDataManager->scaleFactor(m_machine.GetId());
     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
    365371    oldDisplayData.m_f3dAccelerationEnabled = m_machine.GetAccelerate3DEnabled();
    366372#ifdef VBOX_WITH_VIDEOHWACCEL
     
    410416    m_pEditorVideoScreenCount->setValue(oldDisplayData.m_cGuestScreenCount);
    411417    m_pScaleFactorEditor->setMonitorCount(oldDisplayData.m_cGuestScreenCount);
    412     m_pScaleFactorEditor->hide();
    413     m_pLabelGuestScreenScaleFactorEditor->hide();
    414     m_pEditorGuestScreenScale->setValue((int)(oldDisplayData.m_dScaleFactor * 100));
     418    m_pScaleFactorEditor->setScaleFactors(oldDisplayData.m_scaleFactors);
    415419    m_pCheckbox3D->setChecked(oldDisplayData.m_f3dAccelerationEnabled);
    416420#ifdef VBOX_WITH_VIDEOHWACCEL
     
    469473    newDisplayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value();
    470474    newDisplayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value();
    471     newDisplayData.m_dScaleFactor = (double)m_pEditorGuestScreenScale->value() / 100;
     475    newDisplayData.m_scaleFactors = m_pScaleFactorEditor->scaleFactors();
    472476    newDisplayData.m_f3dAccelerationEnabled = m_pCheckbox3D->isChecked();
    473477#ifdef VBOX_WITH_VIDEOHWACCEL
     
    662666    setTabOrder(m_pEditorVideoMemorySize, m_pSliderVideoScreenCount);
    663667    setTabOrder(m_pSliderVideoScreenCount, m_pEditorVideoScreenCount);
    664     setTabOrder(m_pEditorVideoScreenCount, m_pSliderGuestScreenScale);
    665     setTabOrder(m_pSliderGuestScreenScale, m_pEditorGuestScreenScale);
    666     setTabOrder(m_pEditorGuestScreenScale, m_pCheckbox3D);
    667668#ifdef VBOX_WITH_VIDEOHWACCEL
    668669    setTabOrder(m_pCheckbox3D, m_pCheckbox2DVideo);
     
    702703    m_pLabelVideoScreenCountMin->setText(QString::number(1));
    703704    m_pLabelVideoScreenCountMax->setText(QString::number(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));
    704     m_pLabelGuestScreenScaleMin->setText(tr("%1%").arg(100));
    705     m_pLabelGuestScreenScaleMax->setText(tr("%1%").arg(200));
    706705
    707706    /* Remote Display stuff: */
     
    741740    m_pLabelVideoScreenCountMax->setEnabled(isMachineOffline());
    742741    m_pEditorVideoScreenCount->setEnabled(isMachineOffline());
    743     m_pLabelGuestScreenScale->setEnabled(isMachineInValidMode());
    744     m_pSliderGuestScreenScale->setEnabled(isMachineInValidMode());
    745     m_pLabelGuestScreenScaleMin->setEnabled(isMachineInValidMode());
    746     m_pLabelGuestScreenScaleMax->setEnabled(isMachineInValidMode());
    747     m_pEditorGuestScreenScale->setEnabled(isMachineInValidMode());
     742    m_pScaleFactorEditor->setEnabled(isMachineInValidMode());
    748743    m_pLabelVideoOptions->setEnabled(isMachineOffline());
    749744    m_pCheckbox3D->setEnabled(isMachineOffline());
     
    820815    /* Revalidate: */
    821816    revalidate();
    822 }
    823 
    824 void UIMachineSettingsDisplay::sltHandleGuestScreenScaleSliderChange()
    825 {
    826     /* Apply proposed scale-factor: */
    827     m_pEditorGuestScreenScale->blockSignals(true);
    828     m_pEditorGuestScreenScale->setValue(m_pSliderGuestScreenScale->value());
    829     m_pEditorGuestScreenScale->blockSignals(false);
    830 }
    831 
    832 void UIMachineSettingsDisplay::sltHandleGuestScreenScaleEditorChange()
    833 {
    834     /* Apply proposed scale-factor: */
    835     m_pSliderGuestScreenScale->blockSignals(true);
    836     m_pSliderGuestScreenScale->setValue(m_pEditorGuestScreenScale->value());
    837     m_pSliderGuestScreenScale->blockSignals(false);
    838817}
    839818
     
    1017996            m_pEditorVideoScreenCount->setMinimum(1);
    1018997            m_pEditorVideoScreenCount->setMaximum(cMaxGuestScreens);
    1019         }
    1020 
    1021         /* Scale-factor slider created in the .ui file. */
    1022         AssertPtrReturnVoid(m_pSliderGuestScreenScale);
    1023         {
    1024             /* Configure slider: */
    1025             m_pSliderGuestScreenScale->setMinimum(100);
    1026             m_pSliderGuestScreenScale->setMaximum(200);
    1027             m_pSliderGuestScreenScale->setPageStep(10);
    1028             m_pSliderGuestScreenScale->setSingleStep(1);
    1029             m_pSliderGuestScreenScale->setTickInterval(10);
    1030             m_pSliderGuestScreenScale->setSnappingEnabled(true);
    1031         }
    1032 
    1033         /* Scale-factor editor created in the .ui file. */
    1034         AssertPtrReturnVoid(m_pEditorGuestScreenScale);
    1035         {
    1036             /* Configure editor: */
    1037             m_pEditorGuestScreenScale->setMinimum(100);
    1038             m_pEditorGuestScreenScale->setMaximum(200);
    1039             vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorGuestScreenScale, 5);
    1040998        }
    1041999    }
     
    12111169    connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountSliderChange()));
    12121170    connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountEditorChange()));
    1213     connect(m_pSliderGuestScreenScale, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenScaleSliderChange()));
    1214     connect(m_pEditorGuestScreenScale, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenScaleEditorChange()));
     1171
    12151172    connect(m_pCheckbox3D, SIGNAL(stateChanged(int)), this, SLOT(revalidate()));
    12161173#ifdef VBOX_WITH_VIDEOHWACCEL
     
    14521409        /* Save guest-screen scale-factor: */
    14531410        if (fSuccess && newDisplayData.m_dScaleFactor != oldDisplayData.m_dScaleFactor)
    1454             /* fSuccess = */ gEDataManager->setScaleFactor(newDisplayData.m_dScaleFactor, strMachineId);
     1411            /* fSuccess = */ gEDataManager->setScaleFactor(newDisplayData.m_dScaleFactor, strMachineId, 0);
     1412        if (fSuccess && newDisplayData.m_scaleFactors != oldDisplayData.m_scaleFactors)
     1413        {
     1414            int listSize = newDisplayData.m_scaleFactors.size();
     1415            for (int i = 0; i < listSize; ++i)
     1416                gEDataManager->setScaleFactor(newDisplayData.m_scaleFactors[i], strMachineId, i);
     1417        }
    14551418    }
    14561419    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r73134 r74722  
    9393    /** Handles Guest Screen count editor change. */
    9494    void sltHandleGuestScreenCountEditorChange();
    95     /** Handles Guest Screen scale-factor slider change. */
    96     void sltHandleGuestScreenScaleSliderChange();
    97     /** Handles Guest Screen scale-factor editor change. */
    98     void sltHandleGuestScreenScaleEditorChange();
    9995
    10096    /** Handles Video Capture toggle. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui

    r74701 r74722  
    147147          </item>
    148148          <item row="4" column="0">
    149            <widget class="QLabel" name="m_pLabelGuestScreenScale">
    150             <property name="text">
    151              <string>Scale Factor:</string>
    152             </property>
    153             <property name="alignment">
    154              <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    155             </property>
    156            </widget>
    157           </item>
    158           <item row="4" column="1" rowspan="2">
    159            <layout class="QGridLayout" name="m_pLayoutGuestScreenScaleSlider">
    160             <property name="spacing">
    161              <number>0</number>
    162             </property>
    163             <item row="0" column="0" colspan="3">
    164              <widget class="QIAdvancedSlider" name="m_pSliderGuestScreenScale">
    165               <property name="whatsThis">
    166                <string>Controls the guest screen scale factor.</string>
    167               </property>
    168               <property name="orientation">
    169                <enum>Qt::Horizontal</enum>
    170               </property>
    171              </widget>
    172             </item>
    173             <item row="1" column="0">
    174              <widget class="QLabel" name="m_pLabelGuestScreenScaleMin"/>
    175             </item>
    176             <item row="1" column="1">
    177              <spacer name="m_pSpacerGuestScreenScale">
    178               <property name="orientation">
    179                <enum>Qt::Horizontal</enum>
    180               </property>
    181               <property name="sizeHint" stdset="0">
    182                <size>
    183                 <width>0</width>
    184                 <height>0</height>
    185                </size>
    186               </property>
    187              </spacer>
    188             </item>
    189             <item row="1" column="2">
    190              <widget class="QLabel" name="m_pLabelGuestScreenScaleMax"/>
    191             </item>
    192            </layout>
    193           </item>
    194           <item row="4" column="2">
    195            <widget class="QSpinBox" name="m_pEditorGuestScreenScale">
    196             <property name="whatsThis">
    197              <string>Controls the guest screen scale factor.</string>
    198             </property>
    199             <property name="suffix">
    200              <string>%</string>
    201             </property>
    202            </widget>
    203           </item>
    204           <item row="6" column="0">
    205149           <widget class="QLabel" name="m_pLabelGuestScreenScaleFactorEditor">
    206150            <property name="text">
     
    212156           </widget>
    213157          </item>
    214           <item row="6" column="1" rowspan="2" colspan="2">
     158          <item row="4" column="1" rowspan="1" colspan="2">
    215159           <layout class="QGridLayout" name="m_pLayoutGuestScreenScaleFactorEditor">
    216160            <property name="spacing">
     
    226170           </layout>
    227171          </item>
    228           <item row="8" column="0">
     172          <item row="6" column="0">
    229173           <widget class="QLabel" name="m_pLabelVideoOptions">
    230174            <property name="text">
     
    236180           </widget>
    237181          </item>
    238           <item row="8" column="1">
     182          <item row="6" column="1">
    239183           <widget class="QCheckBox" name="m_pCheckbox3D">
    240184            <property name="sizePolicy">
     
    252196           </widget>
    253197          </item>
    254           <item row="9" column="1">
     198          <item row="7" column="1">
    255199           <widget class="QCheckBox" name="m_pCheckbox2DVideo">
    256200            <property name="sizePolicy">
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp

    r74701 r74722  
    4343}
    4444
     45void UIScaleFactorEditor::setMonitorCount(int iMonitorCount)
     46{
     47    if (!m_pMonitorComboBox)
     48        return;
     49    if (iMonitorCount == m_pMonitorComboBox->count())
     50        return;
     51
     52    m_pMonitorComboBox->blockSignals(true);
     53    m_pMonitorComboBox->clear();
     54    for (int i = 0; i < iMonitorCount; ++i)
     55    {
     56        m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i));
     57
     58    }
     59    m_pMonitorComboBox->blockSignals(false);
     60}
     61
     62void UIScaleFactorEditor::setScaleFactors(const QList<double> &scaleFactors)
     63{
     64    if (m_scaleFactors == scaleFactors)
     65        return;
     66    m_scaleFactors = scaleFactors;
     67
     68    /* Set the spinbox value for the currently selected monitor: */
     69    if (m_pMonitorComboBox)
     70    {
     71        int currentMonitorIndex = m_pMonitorComboBox->currentIndex();
     72        if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox)
     73            m_pScaleSpinBox->setValue(100 * m_scaleFactors.at(currentMonitorIndex));
     74    }
     75}
     76
     77const QList<double>& UIScaleFactorEditor::scaleFactors() const
     78{
     79    return m_scaleFactors;
     80}
     81
     82void UIScaleFactorEditor::retranslateUi()
     83{
     84}
     85
     86void UIScaleFactorEditor::sltScaleSpinBoxValueChanged(int value)
     87{
     88    setSliderValue(value);
     89    if (m_pMonitorComboBox)
     90        setScaleFactor(m_pMonitorComboBox->currentIndex(), value);
     91}
     92
     93void UIScaleFactorEditor::sltScaleSliderValueChanged(int value)
     94{
     95    setSpinBoxValue(value);
     96    if (m_pMonitorComboBox)
     97        setScaleFactor(m_pMonitorComboBox->currentIndex(), value);
     98}
     99
     100void UIScaleFactorEditor::sltMonitorComboIndexChanged(int index)
     101{
     102    if (index >= m_scaleFactors.size())
     103        return;
     104
     105    /* Update the slider and spinbox values without emitting signals: */
     106    int scaleFactor = 100 *m_scaleFactors[index];
     107    setSliderValue(scaleFactor);
     108    setSpinBoxValue(scaleFactor);
     109}
     110
    45111void UIScaleFactorEditor::prepare()
    46112{
    47     setStyleSheet("background-color:yellow;");
    48 
    49113    m_pMainLayout = new QGridLayout;
    50114    if (!m_pMainLayout)
     
    54118    {
    55119        m_pMainLayout->addWidget(m_pMonitorComboBox, 0, 0);
     120        connect(m_pMonitorComboBox ,static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     121                this, &UIScaleFactorEditor::sltMonitorComboIndexChanged);
    56122    }
    57123    m_pScaleSpinBox = new QSpinBox;
     
    80146}
    81147
    82 void UIScaleFactorEditor::setMonitorCount(int iMonitorCount)
     148void UIScaleFactorEditor::setScaleFactor(int iMonitorIndex, int iScaleFactor)
    83149{
    84     if (!m_pMonitorComboBox)
    85         return;
    86     if (iMonitorCount == m_pMonitorComboBox->count())
    87         return;
    88 
    89     m_pMonitorComboBox->blockSignals(true);
    90     m_pMonitorComboBox->clear();
    91     for (int i = 0; i < iMonitorCount; ++i)
     150    /* Make sure we have the corresponding scale value for the @p iMonitorIndex: */
     151    if (iMonitorIndex >= m_scaleFactors.size())
    92152    {
    93         m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i));
    94 
     153        for (int i = m_scaleFactors.size(); i <= iMonitorIndex; ++i)
     154            m_scaleFactors.append(1.0);
    95155    }
    96     m_pMonitorComboBox->blockSignals(false);
     156    m_scaleFactors[iMonitorIndex] = iScaleFactor / 100.0;
    97157}
    98158
    99 void UIScaleFactorEditor::sltScaleSpinBoxValueChanged(int value)
     159void UIScaleFactorEditor::setSliderValue(int iValue)
    100160{
    101     if (m_pScaleSlider && value != m_pScaleSlider->value())
     161    if (m_pScaleSlider && iValue != m_pScaleSlider->value())
    102162    {
    103163        m_pScaleSlider->blockSignals(true);
    104         m_pScaleSlider->setValue(value);
     164        m_pScaleSlider->setValue(iValue);
    105165        m_pScaleSlider->blockSignals(false);
    106166    }
    107167}
    108168
    109 void UIScaleFactorEditor::sltScaleSliderValueChanged(int value)
     169void UIScaleFactorEditor::setSpinBoxValue(int iValue)
    110170{
    111     if (m_pScaleSpinBox && value != m_pScaleSpinBox->value())
     171    if (m_pScaleSpinBox && iValue != m_pScaleSpinBox->value())
    112172    {
    113173        m_pScaleSpinBox->blockSignals(true);
    114         m_pScaleSpinBox->setValue(value);
     174        m_pScaleSpinBox->setValue(iValue);
    115175        m_pScaleSpinBox->blockSignals(false);
    116176    }
    117177}
    118 
    119 void UIScaleFactorEditor::retranslateUi()
    120 {
    121 }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h

    r74701 r74722  
    4141
    4242signals:
    43     void sigScaleFactorChanged(int iMonitorID, double scaleFactor);
    4443
    4544public:
     
    4847    UIScaleFactorEditor(QWidget *pParent);
    4948    void setMonitorCount(int iMonitorCount);
     49    void setScaleFactors(const QList<double> &scaleFactors);
     50    const QList<double>& scaleFactors() const;
    5051
    5152protected:
     
    5556    void sltScaleSpinBoxValueChanged(int value);
    5657    void sltScaleSliderValueChanged(int value);
     58    void sltMonitorComboIndexChanged(int index);
    5759
    5860private:
    5961    void prepare();
     62    void setScaleFactor(int iMonitorIndex, int iScaleFactor);
     63    void setSliderValue(int iValue);
     64    void setSpinBoxValue(int iValue);
    6065    QSpinBox          *m_pScaleSpinBox;
    6166    QGridLayout       *m_pMainLayout;
    6267    QComboBox         *m_pMonitorComboBox;
    6368    QIAdvancedSlider  *m_pScaleSlider;
     69    /* Stores the per-monitor scale factors in range [.., 1, ..] */
     70    QList<double>      m_scaleFactors;
    6471};
    6572
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