VirtualBox

Ignore:
Timestamp:
Jun 10, 2013 4:48:17 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86322
Message:

FE/Qt: VM settings: Display page: Video tab: Overall cleanup (part 8): Reworking tab to use QSpinBoxes instead of QLineEditors; Allow the user to pick no more than 8 monitors using slider, and up to *actual border* using spin-box; Make sure maximum video memory size taken into account.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
3 edited

Legend:

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

    r46477 r46479  
    140140
    141141    /* Load Video data to page: */
    142     m_pSliderVideoScreenCount->setValue(displayData.m_cGuestScreenCount);
     142    m_pEditorVideoScreenCount->setValue(displayData.m_cGuestScreenCount);
    143143    m_pCheckbox3D->setChecked(displayData.m_f3dAccelerationEnabled);
    144144#ifdef VBOX_WITH_VIDEOHWACCEL
    145145    m_pCheckbox2DVideo->setChecked(displayData.m_f2dAccelerationEnabled);
    146146#endif /* VBOX_WITH_VIDEOHWACCEL */
    147     checkVRAMRequirements();
    148     m_pSliderVideoMemorySize->setValue(displayData.m_iCurrentVRAM);
     147    /* Should be the last one from this tab: */
     148    m_pEditorVideoMemorySize->setValue(displayData.m_iCurrentVRAM);
    149149
    150150    /* If Remote Display server is supported: */
     
    184184
    185185    /* Gather Video data from page: */
    186     displayData.m_iCurrentVRAM = m_pSliderVideoMemorySize->value();
    187     displayData.m_cGuestScreenCount = m_pSliderVideoScreenCount->value();
     186    displayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value();
     187    displayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value();
    188188    displayData.m_f3dAccelerationEnabled = m_pCheckbox3D->isChecked();
    189189#ifdef VBOX_WITH_VIDEOHWACCEL
     
    300300    if (shouldWeWarnAboutLowVideoMemory() && !m_guestOSType.isNull())
    301301    {
    302         quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), m_pSliderVideoScreenCount->value());
     302        quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), m_pEditorVideoScreenCount->value());
    303303
    304304        /* Basic video RAM amount test: */
    305         if ((quint64)m_pSliderVideoMemorySize->value() * _1M < uNeedBytes)
     305        if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
    306306        {
    307307            strWarning = tr("you have assigned less than <b>%1</b> of video memory which is "
     
    316316        {
    317317            uNeedBytes += VBoxGlobal::required2DOffscreenVideoMemory();
    318             if ((quint64)m_pSliderVideoMemorySize->value() * _1M < uNeedBytes)
     318            if ((quint64)m_pEditorVideoMemorySize->value() * _1M < uNeedBytes)
    319319            {
    320320                strWarning = tr("you have assigned less than <b>%1</b> of video memory which is "
     
    329329        if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported)
    330330        {
    331             int cGuestScreenCount = m_pSliderVideoScreenCount->value();
     331            int cGuestScreenCount = m_pEditorVideoScreenCount->value();
    332332            uNeedBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount);
    333333            uNeedBytes = qMax(uNeedBytes, 128 * _1M);
     
    403403    m_pLabelVideoMemorySizeMax->setText(tr("<qt>%1&nbsp;MB</qt>").arg(m_iMaxVRAMVisible));
    404404    m_pLabelVideoScreenCountMin->setText(tr("<qt>%1</qt>").arg(1));
    405     m_pLabelVideoScreenCountMax->setText(tr("<qt>%1</qt>").arg(sys.GetMaxGuestMonitors()));
     405    m_pLabelVideoScreenCountMax->setText(tr("<qt>%1</qt>").arg(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));
    406406
    407407    /* Remote Display stuff: */
     
    444444}
    445445
    446 void UIMachineSettingsDisplay::sltValueChangedVRAM(int iValue)
    447 {
    448     m_pEditorVideoMemorySize->setText(QString::number(iValue));
    449 }
    450 
    451 void UIMachineSettingsDisplay::sltTextChangedVRAM(const QString &strText)
    452 {
    453     m_pSliderVideoMemorySize->setValue(strText.toInt());
    454 }
    455 
    456 void UIMachineSettingsDisplay::sltValueChangedScreens(int iValue)
    457 {
    458     m_pEditorVideoScreenCount->setText(QString::number(iValue));
     446void UIMachineSettingsDisplay::sltHandleVideoMemorySizeSliderChange()
     447{
     448    /* Apply proposed memory-size: */
     449    m_pEditorVideoMemorySize->blockSignals(true);
     450    m_pEditorVideoMemorySize->setValue(m_pSliderVideoMemorySize->value());
     451    m_pEditorVideoMemorySize->blockSignals(false);
     452
     453    /* Revalidate if possible: */
     454    if (m_pValidator)
     455        m_pValidator->revalidate();
     456}
     457
     458void UIMachineSettingsDisplay::sltHandleVideoMemorySizeEditorChange()
     459{
     460    /* Apply proposed memory-size: */
     461    m_pSliderVideoMemorySize->blockSignals(true);
     462    m_pSliderVideoMemorySize->setValue(m_pEditorVideoMemorySize->value());
     463    m_pSliderVideoMemorySize->blockSignals(false);
     464
     465    /* Revalidate if possible: */
     466    if (m_pValidator)
     467        m_pValidator->revalidate();
     468}
     469
     470void UIMachineSettingsDisplay::sltHandleVideoScreenCountSliderChange()
     471{
     472    /* Apply proposed screen-count: */
     473    m_pEditorVideoScreenCount->blockSignals(true);
     474    m_pEditorVideoScreenCount->setValue(m_pSliderVideoScreenCount->value());
     475    m_pEditorVideoScreenCount->blockSignals(false);
     476
     477    /* Update Video RAM requirements: */
    459478    checkVRAMRequirements();
    460 }
    461 
    462 void UIMachineSettingsDisplay::sltTextChangedScreens(const QString &strText)
    463 {
    464     m_pSliderVideoScreenCount->setValue(strText.toInt());
     479
     480    /* Revalidate if possible: */
     481    if (m_pValidator)
     482        m_pValidator->revalidate();
     483}
     484
     485void UIMachineSettingsDisplay::sltHandleVideoScreenCountEditorChange()
     486{
     487    /* Apply proposed screen-count: */
     488    m_pSliderVideoScreenCount->blockSignals(true);
     489    m_pSliderVideoScreenCount->setValue(m_pEditorVideoScreenCount->value());
     490    m_pSliderVideoScreenCount->blockSignals(false);
     491
     492    /* Update Video RAM requirements: */
     493    checkVRAMRequirements();
     494
     495    /* Revalidate if possible: */
     496    if (m_pValidator)
     497        m_pValidator->revalidate();
    465498}
    466499
     
    564597    const uint cHostScreens = QApplication::desktop()->numScreens();
    565598#endif /* !(QT_VERSION >= 0x040600) */
    566     const uint cMinGuestScreens = 1;
    567     const uint cMaxGuestScreens = sys.GetMaxGuestMonitors();
    568 
    569     /* Setup validators: */
    570     m_pEditorVideoMemorySize->setValidator(new QIntValidator(m_iMinVRAM, m_iMaxVRAMVisible, this));
    571     m_pEditorVideoScreenCount->setValidator(new QIntValidator(cMinGuestScreens, cMaxGuestScreens, this));
    572 
    573     /* Setup connections: */
    574     connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedVRAM(int)));
    575     connect(m_pEditorVideoMemorySize, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedVRAM(const QString&)));
    576     connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedScreens(int)));
    577     connect(m_pEditorVideoScreenCount, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedScreens(const QString&)));
    578 
    579     /* Setup widgets: */
     599    m_pSliderVideoMemorySize->setMinimum(m_iMinVRAM);
     600    m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
    580601    m_pSliderVideoMemorySize->setPageStep(calcPageStep(m_iMaxVRAMVisible));
    581602    m_pSliderVideoMemorySize->setSingleStep(m_pSliderVideoMemorySize->pageStep() / 4);
    582603    m_pSliderVideoMemorySize->setTickInterval(m_pSliderVideoMemorySize->pageStep());
     604    m_pSliderVideoMemorySize->setSnappingEnabled(true);
     605    m_pSliderVideoMemorySize->setErrorHint(0, 1);
     606    connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeSliderChange()));
     607
     608    /* Prepare memory-size editor: */
     609    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoMemorySize, 4);
     610    m_pEditorVideoMemorySize->setMinimum(m_iMinVRAM);
     611    m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
     612    connect(m_pEditorVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeEditorChange()));
     613
     614    /* Prepare screen-count slider: */
     615    const uint cMinGuestScreens = 1;
     616    const uint cMaxGuestScreens = sys.GetMaxGuestMonitors();
     617    const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8);
     618    m_pSliderVideoScreenCount->setMinimum(cMinGuestScreens);
     619    m_pSliderVideoScreenCount->setMaximum(cMaxGuestScreensForSlider);
    583620    m_pSliderVideoScreenCount->setPageStep(1);
    584621    m_pSliderVideoScreenCount->setSingleStep(1);
    585622    m_pSliderVideoScreenCount->setTickInterval(1);
    586 
    587     /* Setup the scale so that ticks are at page step boundaries: */
    588     m_pSliderVideoMemorySize->setMinimum((m_iMinVRAM / m_pSliderVideoMemorySize->pageStep()) * m_pSliderVideoMemorySize->pageStep());
    589     m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
    590     m_pSliderVideoMemorySize->setSnappingEnabled(true);
    591     m_pSliderVideoMemorySize->setErrorHint(0, 1);
    592     m_pSliderVideoScreenCount->setMinimum(cMinGuestScreens);
    593     m_pSliderVideoScreenCount->setMaximum(cMaxGuestScreens);
    594     m_pSliderVideoScreenCount->setErrorHint(0, cMinGuestScreens);
    595623    m_pSliderVideoScreenCount->setOptimalHint(cMinGuestScreens, cHostScreens);
    596     m_pSliderVideoScreenCount->setWarningHint(cHostScreens, cMaxGuestScreens);
    597 
    598     /* Limit min/max. size of QLineEdit: */
    599     m_pEditorVideoMemorySize->setFixedWidthByText(QString().fill('8', 4));
    600     m_pEditorVideoScreenCount->setFixedWidthByText(QString().fill('8', 4));
    601 
    602     /* Ensure value and validation is updated: */
    603     sltValueChangedVRAM(m_pSliderVideoMemorySize->value());
    604     sltValueChangedScreens(m_pSliderVideoScreenCount->value());
     624    m_pSliderVideoScreenCount->setWarningHint(cHostScreens, cMaxGuestScreensForSlider);
     625    connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountSliderChange()));
     626
     627    /* Prepare screen-count editor: */
     628    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoScreenCount, 3);
     629    m_pEditorVideoScreenCount->setMinimum(1);
     630    m_pEditorVideoScreenCount->setMaximum(cMaxGuestScreens);
     631    connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountEditorChange()));
    605632
    606633#ifndef VBOX_WITH_VIDEOHWACCEL
     
    699726
    700727    /* Get monitors count and base video memory requirements: */
    701     int cGuestScreenCount = m_pSliderVideoScreenCount->value();
     728    int cGuestScreenCount = m_pEditorVideoScreenCount->value();
    702729    quint64 uNeedMBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), cGuestScreenCount) / _1M;
    703730
    704     /* Initial values: */
     731    /* Initial value: */
    705732    m_iMaxVRAMVisible = cGuestScreenCount * 32;
    706     if (m_iMaxVRAMVisible < 128)
     733
     734    /* No more than m_iMaxVRAM: */
     735    if (m_iMaxVRAMVisible > m_iMaxVRAM)
     736        m_iMaxVRAMVisible = m_iMaxVRAM;
     737
     738    /* No less than 128MB (if possible): */
     739    if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128)
    707740        m_iMaxVRAMVisible = 128;
     741
     742    /* No less than initial VRAM size (wtf?): */
    708743    if (m_iMaxVRAMVisible < m_iInitialVRAM)
    709744        m_iMaxVRAMVisible = m_iInitialVRAM;
     
    715750    }
    716751#endif /* VBOX_WITH_VIDEOHWACCEL */
     752
    717753#ifdef VBOX_WITH_CRHGSMI
    718754    if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported)
     
    723759        uNeedMBytes = qMin(uNeedMBytes, 256);
    724760# endif
    725         m_iMaxVRAMVisible = 256;
     761        /* No less than 256MB (if possible): */
     762        if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256)
     763            m_iMaxVRAMVisible = 256;
    726764    }
    727765#endif /* VBOX_WITH_CRHGSMI */
    728766
    729     m_pSliderVideoMemorySize->setWarningHint(1, uNeedMBytes);
     767    m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
     768    m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
    730769    m_pSliderVideoMemorySize->setPageStep(calcPageStep(m_iMaxVRAMVisible));
    731     m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible);
    732     m_pSliderVideoMemorySize->setOptimalHint(uNeedMBytes, m_iMaxVRAMVisible);
    733     m_pEditorVideoMemorySize->setValidator(new QIntValidator(m_iMinVRAM, m_iMaxVRAMVisible, this));
     770    m_pSliderVideoMemorySize->setWarningHint(1, qMin((int)uNeedMBytes, m_iMaxVRAMVisible));
     771    m_pSliderVideoMemorySize->setOptimalHint(qMin((int)uNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible);
    734772    m_pLabelVideoMemorySizeMax->setText(tr("<qt>%1&nbsp;MB</qt>").arg(m_iMaxVRAMVisible));
    735773}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r46477 r46479  
    161161
    162162    /* Handlers: Video stuff: */
    163     void sltValueChangedVRAM(int iValue);
    164     void sltTextChangedVRAM(const QString &strText);
    165     void sltValueChangedScreens(int iValue);
    166     void sltTextChangedScreens(const QString &strText);
     163    void sltHandleVideoMemorySizeSliderChange();
     164    void sltHandleVideoMemorySizeEditorChange();
     165    void sltHandleVideoScreenCountSliderChange();
     166    void sltHandleVideoScreenCountEditorChange();
    167167
    168168    /* Handlers: Video Capture stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui

    r46476 r46479  
    8787          </item>
    8888          <item row="0" column="2">
    89            <widget class="QILineEdit" name="m_pEditorVideoMemorySize">
    90             <property name="sizePolicy">
    91              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
    92               <horstretch>0</horstretch>
    93               <verstretch>0</verstretch>
    94              </sizepolicy>
    95             </property>
     89           <widget class="QSpinBox" name="m_pEditorVideoMemorySize">
    9690            <property name="whatsThis">
    9791             <string>Controls the amount of video memory provided to the virtual machine.</string>
     
    159153          </item>
    160154          <item row="2" column="2">
    161            <widget class="QILineEdit" name="m_pEditorVideoScreenCount">
    162             <property name="sizePolicy">
    163              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
    164               <horstretch>0</horstretch>
    165               <verstretch>0</verstretch>
    166              </sizepolicy>
    167             </property>
     155           <widget class="QSpinBox" name="m_pEditorVideoScreenCount">
    168156            <property name="whatsThis">
    169157             <string>Controls the amount of virtual monitors provided to the virtual machine.</string>
     
    647635 </widget>
    648636 <customwidgets>
    649   <customwidget>
    650    <class>QILineEdit</class>
    651    <extends>QLineEdit</extends>
    652    <header>QILineEdit.h</header>
    653   </customwidget>
    654637  <customwidget>
    655638   <class>QIAdvancedSlider</class>
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