VirtualBox

Ignore:
Timestamp:
Mar 24, 2022 7:03:55 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Machine settings: Display page accessibility improvements for Screen tab, part 5; Moving monitor count stuff to separate editor.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r94361 r94362  
    909909        src/settings/editors/UIMachineDisplayScreenFeaturesEditor.h \
    910910        src/settings/editors/UIMaximumGuestScreenSizeEditor.h \
     911        src/settings/editors/UIMonitorCountEditor.h \
    911912        src/settings/editors/UINameAndSystemEditor.h \
    912913        src/settings/editors/UINetworkAttachmentEditor.h \
     
    14661467        src/settings/editors/UIMachineDisplayScreenFeaturesEditor.cpp \
    14671468        src/settings/editors/UIMaximumGuestScreenSizeEditor.cpp \
     1469        src/settings/editors/UIMonitorCountEditor.cpp \
    14681470        src/settings/editors/UINameAndSystemEditor.cpp \
    14691471        src/settings/editors/UINetworkAttachmentEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMonitorCountEditor.cpp

    r94361 r94362  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVideoMemoryEditor class implementation.
     3 * VBox Qt GUI - UIMonitorCountEditor class implementation.
    44 */
    55
     
    1818/* Qt includes: */
    1919#include <QGridLayout>
    20 #include <QHBoxLayout>
    2120#include <QLabel>
    2221#include <QSpinBox>
    23 #include <QVBoxLayout>
    2422
    2523/* GUI includes: */
    2624#include "QIAdvancedSlider.h"
    2725#include "UICommon.h"
    28 #include "UIVideoMemoryEditor.h"
     26#include "UIDesktopWidgetWatchdog.h"
     27#include "UIMonitorCountEditor.h"
    2928
    3029/* COM includes: */
     30#include "COMEnums.h"
    3131#include "CSystemProperties.h"
    3232
    3333
    34 UIVideoMemoryEditor::UIVideoMemoryEditor(QWidget *pParent /* = 0 */)
     34UIMonitorCountEditor::UIMonitorCountEditor(QWidget *pParent /* = 0 */)
    3535    : QIWithRetranslateUI<QWidget>(pParent)
    36     , m_comGuestOSType(CGuestOSType())
    37     , m_cGuestScreenCount(1)
    38     , m_enmGraphicsControllerType(KGraphicsControllerType_Null)
    39 #ifdef VBOX_WITH_3D_ACCELERATION
    40     , m_f3DAccelerationSupported(false)
    41     , m_f3DAccelerationEnabled(false)
    42 #endif
    43     , m_iMinVRAM(0)
    44     , m_iMaxVRAM(0)
    45     , m_iMaxVRAMVisible(0)
    46     , m_iInitialVRAM(0)
     36    , m_iValue(1)
    4737    , m_pLayout(0)
    48     , m_pLabelMemory(0)
     38    , m_pLabel(0)
    4939    , m_pSlider(0)
    50     , m_pLabelMemoryMin(0)
    51     , m_pLabelMemoryMax(0)
    5240    , m_pSpinBox(0)
     41    , m_pLabelMin(0)
     42    , m_pLabelMax(0)
    5343{
    5444    prepare();
    5545}
    5646
    57 void UIVideoMemoryEditor::setValue(int iValue)
     47void UIMonitorCountEditor::setValue(int iValue)
    5848{
    59     if (m_pSlider)
     49    if (m_iValue != iValue)
    6050    {
    61         m_iInitialVRAM = RT_MIN(iValue, m_iMaxVRAM);
    62         m_pSlider->setValue(m_iInitialVRAM);
     51        m_iValue = iValue;
     52        if (m_pSlider)
     53            m_pSlider->setValue(m_iValue);
     54        if (m_pSpinBox)
     55            m_pSpinBox->setValue(m_iValue);
    6356    }
    6457}
    6558
    66 int UIVideoMemoryEditor::value() const
     59int UIMonitorCountEditor::value() const
    6760{
    68     return m_pSlider ? m_pSlider->value() : 0;
     61    return m_pSpinBox ? m_pSpinBox->value() : m_iValue;
    6962}
    7063
    71 void UIVideoMemoryEditor::setGuestOSType(const CGuestOSType &comGuestOSType)
     64int UIMonitorCountEditor::minimumLabelHorizontalHint() const
    7265{
    73     /* Check if guest OS type really changed: */
    74     if (m_comGuestOSType == comGuestOSType)
    75         return;
    76 
    77     /* Remember new guest OS type: */
    78     m_comGuestOSType = comGuestOSType;
    79 
    80     /* Update requirements: */
    81     updateRequirements();
     66    return m_pLabel->minimumSizeHint().width();
    8267}
    8368
    84 void UIVideoMemoryEditor::setGuestScreenCount(int cGuestScreenCount)
    85 {
    86     /* Check if guest screen count really changed: */
    87     if (m_cGuestScreenCount == cGuestScreenCount)
    88         return;
    89 
    90     /* Remember new guest screen count: */
    91     m_cGuestScreenCount = cGuestScreenCount;
    92 
    93     /* Update requirements: */
    94     updateRequirements();
    95 }
    96 
    97 void UIVideoMemoryEditor::setGraphicsControllerType(const KGraphicsControllerType &enmGraphicsControllerType)
    98 {
    99     /* Check if graphics controller type really changed: */
    100     if (m_enmGraphicsControllerType == enmGraphicsControllerType)
    101         return;
    102 
    103     /* Remember new graphics controller type: */
    104     m_enmGraphicsControllerType = enmGraphicsControllerType;
    105 
    106     /* Update requirements: */
    107     updateRequirements();
    108 }
    109 
    110 #ifdef VBOX_WITH_3D_ACCELERATION
    111 void UIVideoMemoryEditor::set3DAccelerationSupported(bool fSupported)
    112 {
    113     /* Check if 3D acceleration really changed: */
    114     if (m_f3DAccelerationSupported == fSupported)
    115         return;
    116 
    117     /* Remember new 3D acceleration: */
    118     m_f3DAccelerationSupported = fSupported;
    119 
    120     /* Update requirements: */
    121     updateRequirements();
    122 }
    123 
    124 void UIVideoMemoryEditor::set3DAccelerationEnabled(bool fEnabled)
    125 {
    126     /* Check if 3D acceleration really changed: */
    127     if (m_f3DAccelerationEnabled == fEnabled)
    128         return;
    129 
    130     /* Remember new 3D acceleration: */
    131     m_f3DAccelerationEnabled = fEnabled;
    132 
    133     /* Update requirements: */
    134     updateRequirements();
    135 }
    136 #endif /* VBOX_WITH_3D_ACCELERATION */
    137 
    138 int UIVideoMemoryEditor::minimumLabelHorizontalHint() const
    139 {
    140     return m_pLabelMemory->minimumSizeHint().width();
    141 }
    142 
    143 void UIVideoMemoryEditor::setMinimumLayoutIndent(int iIndent)
     69void UIMonitorCountEditor::setMinimumLayoutIndent(int iIndent)
    14470{
    14571    if (m_pLayout)
     
    14773}
    14874
    149 void UIVideoMemoryEditor::retranslateUi()
     75void UIMonitorCountEditor::retranslateUi()
    15076{
    151     if (m_pLabelMemory)
    152         m_pLabelMemory->setText(tr("Video &Memory:"));
     77    if (m_pLabel)
     78        m_pLabel->setText(tr("Mo&nitor Count:"));
    15379
    15480    if (m_pSlider)
    155         m_pSlider->setToolTip(tr("Holds the amount of video memory provided to the virtual machine."));
     81        m_pSlider->setToolTip(tr("Holds the amount of virtual monitors provided to the virtual machine."));
    15682    if (m_pSpinBox)
    157         m_pSpinBox->setToolTip(tr("Holds the amount of video memory provided to the virtual machine."));
     83        m_pSpinBox->setToolTip(tr("Holds the amount of virtual monitors provided to the virtual machine."));
    15884
    159     if (m_pLabelMemoryMin)
    160     {
    161         m_pLabelMemoryMin->setText(tr("%1 MB").arg(m_iMinVRAM));
    162         m_pLabelMemoryMin->setToolTip(tr("Minimum possible video memory size."));
    163     }
    164     if (m_pLabelMemoryMax)
    165     {
    166         m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible));
    167         m_pLabelMemoryMax->setToolTip(tr("Maximum possible video memory size."));
    168     }
    169 
    170     if (m_pSpinBox)
    171         m_pSpinBox->setSuffix(QString(" %1").arg(tr("MB")));
     85    if (m_pLabelMin)
     86        m_pLabelMin->setToolTip(tr("Minimum possible monitor count."));
     87    if (m_pLabelMax)
     88        m_pLabelMax->setToolTip(tr("Maximum possible monitor count."));
    17289}
    17390
    174 void UIVideoMemoryEditor::sltHandleSliderChange()
     91void UIMonitorCountEditor::sltHandleSliderChange()
    17592{
    176     /* Apply spin-box value keeping it's signals disabled: */
     93    /* Apply spin-box value keeping signals disabled: */
    17794    if (m_pSpinBox && m_pSlider)
    17895    {
     
    18299    }
    183100
    184     /* Revalidate to send signal to listener: */
    185     revalidate();
     101    /* Notify listeners about value changed: */
     102    emit sigValidChanged();
    186103}
    187104
    188 void UIVideoMemoryEditor::sltHandleSpinBoxChange()
     105void UIMonitorCountEditor::sltHandleSpinBoxChange()
    189106{
    190     /* Apply slider value keeping it's signals disabled: */
    191     if (m_pSpinBox && m_pSlider)
     107    /* Apply slider value keeping signals disabled: */
     108    if (m_pSlider && m_pSpinBox)
    192109    {
    193110        m_pSlider->blockSignals(true);
     
    196113    }
    197114
    198     /* Revalidate to send signal to listener: */
    199     revalidate();
     115    /* Notify listeners about value changed: */
     116    emit sigValidChanged();
    200117}
    201118
    202 void UIVideoMemoryEditor::prepare()
     119void UIMonitorCountEditor::prepare()
    203120{
    204121    /* Prepare common variables: */
    205122    const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    206     m_iMinVRAM = comProperties.GetMinGuestVRAM();
    207     m_iMaxVRAM = comProperties.GetMaxGuestVRAM();
    208     m_iMaxVRAMVisible = m_iMaxVRAM;
    209123
    210     /* Create main layout: */
     124    /* Prepare main layout: */
    211125    m_pLayout = new QGridLayout(this);
    212126    if (m_pLayout)
    213127    {
    214128        m_pLayout->setContentsMargins(0, 0, 0, 0);
     129        m_pLayout->setColumnStretch(2, 1); // spacer between min&max labels
    215130
    216         /* Create memory label: */
    217         m_pLabelMemory = new QLabel(this);
    218         if (m_pLabelMemory)
     131        /* Prepare main label: */
     132        m_pLabel = new QLabel(this);
     133        if (m_pLabel)
    219134        {
    220             m_pLabelMemory->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    221             m_pLayout->addWidget(m_pLabelMemory, 0, 0);
     135            m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     136            m_pLayout->addWidget(m_pLabel, 0, 0);
    222137        }
    223138
    224         /* Create slider layout: */
    225         QVBoxLayout *pSliderLayout = new QVBoxLayout;
    226         if (pSliderLayout)
     139        /* Prepare slider: */
     140        m_pSlider = new QIAdvancedSlider(this);
     141        if (m_pSlider)
    227142        {
    228             pSliderLayout->setContentsMargins(0, 0, 0, 0);
     143            const uint cHostScreens = gpDesktop->screenCount();
     144            const uint cMinGuestScreens = 1;
     145            const uint cMaxGuestScreens = comProperties.GetMaxGuestMonitors();
     146            const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8);
     147            m_pSlider->setOrientation(Qt::Horizontal);
     148            m_pSlider->setMinimum(cMinGuestScreens);
     149            m_pSlider->setMaximum(cMaxGuestScreensForSlider);
     150            m_pSlider->setPageStep(1);
     151            m_pSlider->setSingleStep(1);
     152            m_pSlider->setTickInterval(1);
     153            m_pSlider->setOptimalHint(cMinGuestScreens, cHostScreens);
     154            m_pSlider->setWarningHint(cHostScreens, cMaxGuestScreensForSlider);
    229155
    230             /* Create memory slider: */
    231             m_pSlider = new QIAdvancedSlider(this);
    232             if (m_pSlider)
    233             {
    234                 m_pSlider->setMinimum(m_iMinVRAM);
    235                 m_pSlider->setMaximum(m_iMaxVRAMVisible);
    236                 m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible));
    237                 m_pSlider->setSingleStep(m_pSlider->pageStep() / 4);
    238                 m_pSlider->setTickInterval(m_pSlider->pageStep());
    239                 m_pSlider->setSnappingEnabled(true);
    240                 m_pSlider->setErrorHint(0, 1);
    241                 m_pSlider->setMinimumWidth(150);
    242                 connect(m_pSlider, &QIAdvancedSlider::valueChanged,
    243                         this, &UIVideoMemoryEditor::sltHandleSliderChange);
    244                 pSliderLayout->addWidget(m_pSlider);
    245             }
    246 
    247             /* Create legend layout: */
    248             QHBoxLayout *pLegendLayout = new QHBoxLayout;
    249             if (pLegendLayout)
    250             {
    251                 pLegendLayout->setContentsMargins(0, 0, 0, 0);
    252 
    253                 /* Create min label: */
    254                 m_pLabelMemoryMin = new QLabel(this);
    255                 if (m_pLabelMemoryMin)
    256                     pLegendLayout->addWidget(m_pLabelMemoryMin);
    257 
    258                 /* Push labels from each other: */
    259                 pLegendLayout->addStretch();
    260 
    261                 /* Create max label: */
    262                 m_pLabelMemoryMax = new QLabel(this);
    263                 if (m_pLabelMemoryMax)
    264                     pLegendLayout->addWidget(m_pLabelMemoryMax);
    265 
    266                 /* Add legend layout to slider layout: */
    267                 pSliderLayout->addLayout(pLegendLayout);
    268             }
    269 
    270             /* Add slider layout to main layout: */
    271             m_pLayout->addLayout(pSliderLayout, 0, 1, 2, 1);
     156            m_pLayout->addWidget(m_pSlider, 0, 1, 1, 3);
    272157        }
    273158
    274         /* Create memory spin-box: */
     159        /* Prepare spin-box: */
    275160        m_pSpinBox = new QSpinBox(this);
    276161        if (m_pSpinBox)
    277162        {
    278             setFocusProxy(m_pSpinBox);
    279             if (m_pLabelMemory)
    280                 m_pLabelMemory->setBuddy(m_pSpinBox);
    281             m_pSpinBox->setMinimum(m_iMinVRAM);
    282             m_pSpinBox->setMaximum(m_iMaxVRAMVisible);
    283             connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
    284                     this, &UIVideoMemoryEditor::sltHandleSpinBoxChange);
    285             m_pLayout->addWidget(m_pSpinBox, 0, 2);
     163            if (m_pLabel)
     164                m_pLabel->setBuddy(m_pSpinBox);
     165            m_pSpinBox->setMinimum(1);
     166            m_pSpinBox->setMaximum(comProperties.GetMaxGuestMonitors());
     167
     168            m_pLayout->addWidget(m_pSpinBox, 0, 4);
     169        }
     170
     171        /* Prepare min label: */
     172        m_pLabelMin = new QLabel(this);
     173        if (m_pLabelMin)
     174        {
     175            m_pLabelMin->setText(QString::number(1));
     176            m_pLayout->addWidget(m_pLabelMin, 1, 1);
     177        }
     178
     179        /* Prepare max label: */
     180        m_pLabelMax = new QLabel(this);
     181        if (m_pLabelMax)
     182        {
     183            m_pLabelMax->setText(QString::number(qMin(comProperties.GetMaxGuestMonitors(), (ULONG)8)));
     184            m_pLayout->addWidget(m_pLabelMax, 1, 3);
    286185        }
    287186    }
     187
     188    /* Prepare connections: */
     189    if (m_pSlider)
     190        connect(m_pSlider, &QIAdvancedSlider::valueChanged,
     191                this, &UIMonitorCountEditor::sltHandleSliderChange);
     192    if (m_pSpinBox)
     193        connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
     194                this, &UIMonitorCountEditor::sltHandleSpinBoxChange);
    288195
    289196    /* Apply language settings: */
    290197    retranslateUi();
    291198}
    292 
    293 void UIVideoMemoryEditor::updateRequirements()
    294 {
    295     /* Make sure guest OS type is set: */
    296     if (m_comGuestOSType.isNull())
    297         return;
    298 
    299     /* Init visible maximum VRAM: */
    300     m_iMaxVRAMVisible = m_cGuestScreenCount * 32;
    301 
    302     /* Get monitors count and recommended VRAM: */
    303     int iNeedMBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_cGuestScreenCount) / _1M;
    304     /* Adjust visible maximum VRAM to be no less than 128MB (if possible): */
    305     if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128)
    306         m_iMaxVRAMVisible = 128;
    307 
    308 #ifdef VBOX_WITH_3D_ACCELERATION
    309     if (m_f3DAccelerationEnabled && m_f3DAccelerationSupported)
    310     {
    311         /* Adjust recommended VRAM to be no less than 128MB: */
    312         iNeedMBytes = qMax(iNeedMBytes, 128);
    313         /* Adjust visible maximum VRAM to be no less than 256MB (if possible): */
    314         if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256)
    315             m_iMaxVRAMVisible = 256;
    316     }
    317 #endif
    318 
    319     /* Adjust visible maximum VRAM to be no less than initial VRAM: */
    320     m_iMaxVRAMVisible = qMax(m_iMaxVRAMVisible, m_iInitialVRAM);
    321     /* Adjust visible maximum VRAM to be no less than recommended VRAM: */
    322     m_iMaxVRAMVisible = qMax(m_iMaxVRAMVisible, iNeedMBytes);
    323 
    324     /* Adjust recommended VRAM to be no more than actual maximum VRAM: */
    325     iNeedMBytes = qMin(iNeedMBytes, m_iMaxVRAM);
    326     /* Adjust visible maximum VRAM to be no more than actual maximum VRAM: */
    327     m_iMaxVRAMVisible = qMin(m_iMaxVRAMVisible, m_iMaxVRAM);
    328 
    329     if (m_pSpinBox)
    330         m_pSpinBox->setMaximum(m_iMaxVRAMVisible);
    331     if (m_pSlider)
    332     {
    333         m_pSlider->setMaximum(m_iMaxVRAMVisible);
    334         m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible));
    335         m_pSlider->setWarningHint(1, qMin(iNeedMBytes, m_iMaxVRAMVisible));
    336         m_pSlider->setOptimalHint(qMin(iNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible);
    337     }
    338     if (m_pLabelMemoryMax)
    339         m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible));
    340 }
    341 
    342 void UIVideoMemoryEditor::revalidate()
    343 {
    344     if (m_pSlider)
    345         emit sigValidChanged(   m_enmGraphicsControllerType == KGraphicsControllerType_Null
    346                              || m_pSlider->value() > 0);
    347 }
    348 
    349 /* static */
    350 int UIVideoMemoryEditor::calculatePageStep(int iMax)
    351 {
    352     /* Reasonable max. number of page steps is 32. */
    353     const uint uPage = ((uint)iMax + 31) / 32;
    354     /* Make it a power of 2: */
    355     uint uP = uPage, p2 = 0x1;
    356     while ((uP >>= 1))
    357         p2 <<= 1;
    358     if (uPage != p2)
    359         p2 <<= 1;
    360     if (p2 < 4)
    361         p2 = 4;
    362     return (int)p2;
    363 }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMonitorCountEditor.h

    r94361 r94362  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVideoMemoryEditor class declaration.
     3 * VBox Qt GUI - UIMonitorCountEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIVideoMemoryEditor_h
    19 #define FEQT_INCLUDED_SRC_settings_editors_UIVideoMemoryEditor_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2929#include "UILibraryDefs.h"
    3030
    31 /* COM includes: */
    32 #include "COMEnums.h"
    33 #include "CGuestOSType.h"
    34 
    3531/* Forward declarations: */
    3632class QGridLayout;
     
    3935class QIAdvancedSlider;
    4036
    41 /** QWidget subclass used as a video memory editor. */
    42 class SHARED_LIBRARY_STUFF UIVideoMemoryEditor : public QIWithRetranslateUI<QWidget>
     37/** QWidget subclass used as a monitor count editor. */
     38class SHARED_LIBRARY_STUFF UIMonitorCountEditor : public QIWithRetranslateUI<QWidget>
    4339{
    4440    Q_OBJECT;
     
    4642signals:
    4743
    48     /** Notifies listeners about value has became @a fValid. */
    49     void sigValidChanged(bool fValid);
     44    /** Notifies listeners about value changed. */
     45    void sigValidChanged();
    5046
    5147public:
    5248
    53     /** Constructs video-memory editor passing @a pParent to the base-class. */
    54     UIVideoMemoryEditor(QWidget *pParent = 0);
     49    /** Constructs monitor count editor passing @a pParent to the base-class. */
     50    UIMonitorCountEditor(QWidget *pParent = 0);
    5551
    5652    /** Defines editor @a iValue. */
     
    5854    /** Returns editor value. */
    5955    int value() const;
    60 
    61     /** Defines @a comGuestOSType. */
    62     void setGuestOSType(const CGuestOSType &comGuestOSType);
    63 
    64     /** Defines @a cGuestScreenCount. */
    65     void setGuestScreenCount(int cGuestScreenCount);
    66 
    67     /** Defines @a enmGraphicsControllerType. */
    68     void setGraphicsControllerType(const KGraphicsControllerType &enmGraphicsControllerType);
    69 
    70 #ifdef VBOX_WITH_3D_ACCELERATION
    71     /** Defines whether 3D acceleration is @a fSupported. */
    72     void set3DAccelerationSupported(bool fSupported);
    73     /** Defines whether 3D acceleration is @a fEnabled. */
    74     void set3DAccelerationEnabled(bool fEnabled);
    75 #endif
    7656
    7757    /** Returns minimum layout hint. */
     
    9777    void prepare();
    9878
    99     /** Update requirements. */
    100     void updateRequirements();
    101 
    10279    /** Revalidates and emits validity change signal. */
    10380    void revalidate();
    10481
    105     /** Calculates the reasonably sane slider page step. */
    106     static int calculatePageStep(int iMax);
    107 
    108     /** Holds the guest OS type ID. */
    109     CGuestOSType             m_comGuestOSType;
    110     /** Holds the guest screen count. */
    111     int                      m_cGuestScreenCount;
    112     /** Holds the graphics controller type. */
    113     KGraphicsControllerType  m_enmGraphicsControllerType;
    114 #ifdef VBOX_WITH_3D_ACCELERATION
    115     /** Holds whether 3D acceleration is supported. */
    116     bool                     m_f3DAccelerationSupported;
    117     /** Holds whether 3D acceleration is enabled. */
    118     bool                     m_f3DAccelerationEnabled;
    119 #endif
    120 
    121     /** Holds the minimum lower limit of VRAM (MiB). */
    122     int  m_iMinVRAM;
    123     /** Holds the maximum upper limit of VRAM (MiB). */
    124     int  m_iMaxVRAM;
    125     /** Holds the upper limit of VRAM (MiB) for this dialog.
    126       * @note This value is lower than m_iMaxVRAM to save
    127       *       careless users from setting useless big values. */
    128     int  m_iMaxVRAMVisible;
    129     /** Holds the initial VRAM value when the dialog is opened. */
    130     int  m_iInitialVRAM;
     82    /** Holds the value to be selected. */
     83    int  m_iValue;
    13184
    13285    /** Holds the main layout instance. */
    13386    QGridLayout      *m_pLayout;
    134     /** Holds the memory label instance. */
    135     QLabel           *m_pLabelMemory;
    136     /** Holds the memory slider instance. */
     87    /** Holds the main label instance. */
     88    QLabel           *m_pLabel;
     89    /** Holds the slider instance. */
    13790    QIAdvancedSlider *m_pSlider;
    138     /** Holds minimum memory label instance. */
    139     QLabel           *m_pLabelMemoryMin;
    140     /** Holds maximum memory label instance. */
    141     QLabel           *m_pLabelMemoryMax;
    142     /** Holds the memory spin-box instance. */
     91    /** Holds the spin-box instance. */
    14392    QSpinBox         *m_pSpinBox;
     93    /** Holds minimum label instance. */
     94    QLabel           *m_pLabelMin;
     95    /** Holds maximum label instance. */
     96    QLabel           *m_pLabelMax;
    14497};
    14598
    146 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIVideoMemoryEditor_h */
     99#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r94361 r94362  
    3333#include "UICommon.h"
    3434#include "UIConverter.h"
    35 #include "UIDesktopWidgetWatchdog.h"
    3635#include "UIErrorString.h"
    3736#include "UIExtraDataManager.h"
     
    4342#endif
    4443#include "UIMachineSettingsDisplay.h"
     44#include "UIMonitorCountEditor.h"
    4545#include "UIScaleFactorEditor.h"
    4646#include "UITranslator.h"
     
    306306    , m_pTabWidget(0)
    307307    , m_pTabScreen(0)
    308     , m_pLayoutScreen(0)
    309308    , m_pEditorVideoMemorySize(0)
    310     , m_pLabelMonitorCount(0)
    311     , m_pSliderMonitorCount(0)
    312     , m_pSpinboxMonitorCount(0)
    313     , m_pLabelMonitorCountMin(0)
    314     , m_pLabelMonitorCountMax(0)
     309    , m_pEditorMonitorCount(0)
    315310    , m_pEditorScaleFactor(0)
    316311    , m_pEditorGraphicsController(0)
     
    500495
    501496    /* Load old 'Screen' data from cache: */
    502     m_pSpinboxMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount);
     497    m_pEditorMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount);
    503498    m_pEditorScaleFactor->setScaleFactors(oldDisplayData.m_scaleFactors);
    504499    m_pEditorScaleFactor->setMonitorCount(oldDisplayData.m_cGuestScreenCount);
     
    508503#endif
    509504    /* Push required value to m_pEditorVideoMemorySize: */
    510     sltHandleGuestScreenCountEditorChange();
     505    sltHandleMonitorCountChange();
    511506    sltHandleGraphicsControllerComboChange();
    512507#ifdef VBOX_WITH_3D_ACCELERATION
     
    566561    /* Gather new 'Screen' data: */
    567562    newDisplayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value();
    568     newDisplayData.m_cGuestScreenCount = m_pSpinboxMonitorCount->value();
     563    newDisplayData.m_cGuestScreenCount = m_pEditorMonitorCount->value();
    569564    newDisplayData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
    570565    newDisplayData.m_graphicsControllerType = m_pEditorGraphicsController->value();
     
    653648        if (shouldWeWarnAboutLowVRAM() && !m_comGuestOSType.isNull())
    654649        {
    655             quint64 uNeedBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_pSpinboxMonitorCount->value());
     650            quint64 uNeedBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_pEditorMonitorCount->value());
    656651
    657652            /* Basic video RAM amount test: */
     
    752747    setTabOrder(pWidget, m_pTabWidget->focusProxy());
    753748    setTabOrder(m_pTabWidget->focusProxy(), m_pEditorVideoMemorySize);
    754     setTabOrder(m_pEditorVideoMemorySize, m_pSliderMonitorCount);
    755     setTabOrder(m_pSliderMonitorCount, m_pSpinboxMonitorCount);
    756     setTabOrder(m_pSpinboxMonitorCount, m_pEditorScaleFactor);
     749    setTabOrder(m_pEditorVideoMemorySize, m_pEditorMonitorCount);
     750    setTabOrder(m_pEditorMonitorCount, m_pEditorScaleFactor);
    757751    setTabOrder(m_pEditorScaleFactor, m_pEditorGraphicsController);
    758752
     
    777771void UIMachineSettingsDisplay::retranslateUi()
    778772{
    779     m_pLabelMonitorCount->setText(tr("Mo&nitor Count:"));
    780     m_pSliderMonitorCount->setToolTip(tr("Controls the amount of virtual monitors provided to the virtual machine."));
    781     m_pSpinboxMonitorCount->setToolTip(tr("Controls the amount of virtual monitors provided to the virtual machine."));
    782     m_pEditorScaleFactor->setToolTip(tr("Controls the guest screen scale factor."));
    783773    m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabScreen), tr("&Screen"));
    784774    m_pCheckboxRemoteDisplay->setToolTip(tr("When checked, the VM will act as a Remote Desktop Protocol (RDP) server, allowing "
     
    826816    m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabRecording), tr("Re&cording"));
    827817
    828     /* Screen stuff: */
    829     CSystemProperties sys = uiCommon().virtualBox().GetSystemProperties();
    830     m_pLabelMonitorCountMin->setText(QString::number(1));
    831     m_pLabelMonitorCountMax->setText(QString::number(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));
    832 
    833818    /* Translate Remote Display auth method combo: */
    834819    AssertPtrReturnVoid(m_pComboRemoteDisplayAuthMethod);
     
    859844    int iMinimumLayoutHint = 0;
    860845    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorVideoMemorySize->minimumLabelHorizontalHint());
    861     iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pLabelMonitorCount->minimumSizeHint().width());
     846    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorMonitorCount->minimumLabelHorizontalHint());
    862847    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorScaleFactor->minimumLabelHorizontalHint());
    863848    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorGraphicsController->minimumLabelHorizontalHint());
     
    866851#endif
    867852    m_pEditorVideoMemorySize->setMinimumLayoutIndent(iMinimumLayoutHint);
     853    m_pEditorMonitorCount->setMinimumLayoutIndent(iMinimumLayoutHint);
    868854    m_pEditorScaleFactor->setMinimumLayoutIndent(iMinimumLayoutHint);
    869855    m_pEditorGraphicsController->setMinimumLayoutIndent(iMinimumLayoutHint);
     
    871857    m_pEditorDisplayScreenFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
    872858#endif
    873     m_pLayoutScreen->setColumnMinimumWidth(0, iMinimumLayoutHint);
    874859
    875860    updateRecordingFileSizeHint();
     
    883868    /* Polish 'Screen' availability: */
    884869    m_pEditorVideoMemorySize->setEnabled(isMachineOffline());
    885     m_pLabelMonitorCount->setEnabled(isMachineOffline());
    886     m_pSliderMonitorCount->setEnabled(isMachineOffline());
    887     m_pLabelMonitorCountMin->setEnabled(isMachineOffline());
    888     m_pLabelMonitorCountMax->setEnabled(isMachineOffline());
    889     m_pSpinboxMonitorCount->setEnabled(isMachineOffline());
     870    m_pEditorMonitorCount->setEnabled(isMachineOffline());
    890871    m_pEditorScaleFactor->setEnabled(isMachineInValidMode());
    891872    m_pEditorGraphicsController->setEnabled(isMachineOffline());
     
    906887}
    907888
    908 void UIMachineSettingsDisplay::sltHandleGuestScreenCountSliderChange()
    909 {
    910     /* Apply proposed screen-count: */
    911     m_pSpinboxMonitorCount->blockSignals(true);
    912     m_pSpinboxMonitorCount->setValue(m_pSliderMonitorCount->value());
    913     m_pSpinboxMonitorCount->blockSignals(false);
    914 
    915     /* Update Video RAM requirements: */
    916     m_pEditorVideoMemorySize->setGuestScreenCount(m_pSliderMonitorCount->value());
    917 
    918     /* Update recording tab screen count: */
    919     updateGuestScreenCount();
    920 
    921     /* Revalidate: */
    922     revalidate();
    923 }
    924 
    925 void UIMachineSettingsDisplay::sltHandleGuestScreenCountEditorChange()
    926 {
    927     /* Apply proposed screen-count: */
    928     m_pSliderMonitorCount->blockSignals(true);
    929     m_pSliderMonitorCount->setValue(m_pSpinboxMonitorCount->value());
    930     m_pSliderMonitorCount->blockSignals(false);
    931 
    932     /* Update Video RAM requirements: */
    933     m_pEditorVideoMemorySize->setGuestScreenCount(m_pSpinboxMonitorCount->value());
    934 
     889void UIMachineSettingsDisplay::sltHandleMonitorCountChange()
     890{
    935891    /* Update recording tab screen count: */
    936892    updateGuestScreenCount();
     
    10931049void UIMachineSettingsDisplay::prepareTabScreen()
    10941050{
    1095     /* Prepare common variables: */
    1096     const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    1097 
    10981051    /* Prepare 'Screen' tab: */
    10991052    m_pTabScreen = new QWidget;
     
    11011054    {
    11021055        /* Prepare 'Screen' tab layout: */
    1103         m_pLayoutScreen = new QGridLayout(m_pTabScreen);
    1104         if (m_pLayoutScreen)
     1056        QVBoxLayout *pLayoutScreen = new QVBoxLayout(m_pTabScreen);
     1057        if (pLayoutScreen)
    11051058        {
    1106             m_pLayoutScreen->setRowStretch(8, 1);
    1107 
    11081059            /* Prepare video memory editor: */
    11091060            m_pEditorVideoMemorySize = new UIVideoMemoryEditor(m_pTabScreen);
    11101061            if (m_pEditorVideoMemorySize)
    1111                 m_pLayoutScreen->addWidget(m_pEditorVideoMemorySize, 0, 0, 1, 3);
    1112 
    1113             /* Prepare monitor count label: */
    1114             m_pLabelMonitorCount = new QLabel(m_pTabScreen);
    1115             if (m_pLabelMonitorCount)
    1116             {
    1117                 m_pLabelMonitorCount->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    1118                 m_pLayoutScreen->addWidget(m_pLabelMonitorCount, 1, 0);
    1119             }
    1120             /* Prepare monitor count layout: */
    1121             QVBoxLayout *pLayoutMonitorCount = new QVBoxLayout;
    1122             if (pLayoutMonitorCount)
    1123             {
    1124                 pLayoutMonitorCount->setContentsMargins(0, 0, 0, 0);
    1125 
    1126                 /* Prepare monitor count slider: */
    1127                 m_pSliderMonitorCount = new QIAdvancedSlider(m_pTabScreen);
    1128                 if (m_pSliderMonitorCount)
    1129                 {
    1130                     const uint cHostScreens = gpDesktop->screenCount();
    1131                     const uint cMinGuestScreens = 1;
    1132                     const uint cMaxGuestScreens = comProperties.GetMaxGuestMonitors();
    1133                     const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8);
    1134                     m_pSliderMonitorCount->setOrientation(Qt::Horizontal);
    1135                     m_pSliderMonitorCount->setMinimum(cMinGuestScreens);
    1136                     m_pSliderMonitorCount->setMaximum(cMaxGuestScreensForSlider);
    1137                     m_pSliderMonitorCount->setPageStep(1);
    1138                     m_pSliderMonitorCount->setSingleStep(1);
    1139                     m_pSliderMonitorCount->setTickInterval(1);
    1140                     m_pSliderMonitorCount->setOptimalHint(cMinGuestScreens, cHostScreens);
    1141                     m_pSliderMonitorCount->setWarningHint(cHostScreens, cMaxGuestScreensForSlider);
    1142 
    1143                     pLayoutMonitorCount->addWidget(m_pSliderMonitorCount);
    1144                 }
    1145                 /* Prepare monitor count scale layout: */
    1146                 QHBoxLayout *pLayoutMonitorCountScale = new QHBoxLayout;
    1147                 if (pLayoutMonitorCountScale)
    1148                 {
    1149                     pLayoutMonitorCountScale->setContentsMargins(0, 0, 0, 0);
    1150 
    1151                     /* Prepare monitor count min label: */
    1152                     m_pLabelMonitorCountMin = new QLabel(m_pTabScreen);
    1153                     if (m_pLabelMonitorCountMin)
    1154                         pLayoutMonitorCountScale->addWidget(m_pLabelMonitorCountMin);
    1155                     pLayoutMonitorCountScale->addStretch();
    1156                     /* Prepare monitor count max label: */
    1157                     m_pLabelMonitorCountMax = new QLabel(m_pTabScreen);
    1158                     if (m_pLabelMonitorCountMax)
    1159                         pLayoutMonitorCountScale->addWidget(m_pLabelMonitorCountMax);
    1160 
    1161                     pLayoutMonitorCount->addLayout(pLayoutMonitorCountScale);
    1162                 }
    1163 
    1164                 m_pLayoutScreen->addLayout(pLayoutMonitorCount, 1, 1, 2, 1);
    1165             }
    1166             /* Prepare monitor count spinbox: */
    1167             m_pSpinboxMonitorCount = new QSpinBox(m_pTabScreen);
    1168             if (m_pSpinboxMonitorCount)
    1169             {
    1170                 if (m_pLabelMonitorCount)
    1171                     m_pLabelMonitorCount->setBuddy(m_pSpinboxMonitorCount);
    1172                 m_pSpinboxMonitorCount->setMinimum(1);
    1173                 m_pSpinboxMonitorCount->setMaximum(comProperties.GetMaxGuestMonitors());
    1174 
    1175                 m_pLayoutScreen->addWidget(m_pSpinboxMonitorCount, 1, 2);
    1176             }
     1062                pLayoutScreen->addWidget(m_pEditorVideoMemorySize);
     1063
     1064            /* Prepare monitor count editor: */
     1065            m_pEditorMonitorCount = new UIMonitorCountEditor(m_pTabScreen);
     1066            if (m_pEditorMonitorCount)
     1067                pLayoutScreen->addWidget(m_pEditorMonitorCount);
    11771068
    11781069            /* Prepare scale factor editor: */
    11791070            m_pEditorScaleFactor = new UIScaleFactorEditor(m_pTabScreen);
    11801071            if (m_pEditorScaleFactor)
    1181                 m_pLayoutScreen->addWidget(m_pEditorScaleFactor, 3, 0, 1, 3);
     1072                pLayoutScreen->addWidget(m_pEditorScaleFactor);
    11821073
    11831074            /* Prepare graphics controller editor: */
    11841075            m_pEditorGraphicsController = new UIGraphicsControllerEditor(m_pTabScreen);
    11851076            if (m_pEditorGraphicsController)
    1186                 m_pLayoutScreen->addWidget(m_pEditorGraphicsController, 4, 0, 1, 3);
     1077                pLayoutScreen->addWidget(m_pEditorGraphicsController);
    11871078
    11881079#ifdef VBOX_WITH_3D_ACCELERATION
     
    11901081            m_pEditorDisplayScreenFeatures = new UIMachineDisplayScreenFeaturesEditor(m_pTabScreen);
    11911082            if (m_pEditorDisplayScreenFeatures)
    1192                 m_pLayoutScreen->addWidget(m_pEditorDisplayScreenFeatures, 5, 0, 1, 2);
     1083                pLayoutScreen->addWidget(m_pEditorDisplayScreenFeatures);
    11931084#endif /* VBOX_WITH_3D_ACCELERATION */
     1085
     1086            pLayoutScreen->addStretch();
    11941087        }
    11951088
     
    16771570    connect(m_pEditorVideoMemorySize, &UIVideoMemoryEditor::sigValidChanged,
    16781571            this, &UIMachineSettingsDisplay::revalidate);
    1679     connect(m_pSliderMonitorCount, &QIAdvancedSlider::valueChanged,
    1680             this, &UIMachineSettingsDisplay::sltHandleGuestScreenCountSliderChange);
    1681     connect(m_pSpinboxMonitorCount, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
    1682             this, &UIMachineSettingsDisplay::sltHandleGuestScreenCountEditorChange);
     1572    connect(m_pEditorMonitorCount, &UIMonitorCountEditor::sigValidChanged,
     1573            this, &UIMachineSettingsDisplay::sltHandleMonitorCountChange);
    16831574    connect(m_pEditorGraphicsController, &UIGraphicsControllerEditor::sigValueChanged,
    16841575            this, &UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange);
     
    17691660    /* Update copy of the cached item to get the desired result: */
    17701661    QVector<BOOL> screens = m_pCache->base().m_vecRecordingScreens;
    1771     screens.resize(m_pSpinboxMonitorCount->value());
     1662    screens.resize(m_pEditorMonitorCount->value());
    17721663    m_pScrollerRecordingScreens->setValue(screens);
    1773     m_pEditorScaleFactor->setMonitorCount(m_pSpinboxMonitorCount->value());
     1664    m_pEditorScaleFactor->setMonitorCount(m_pEditorMonitorCount->value());
    17741665}
    17751666
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r94361 r94362  
    3333class QLabel;
    3434class QLineEdit;
    35 class QGridLayout;
    3635class QSpinBox;
    3736class QStackedLayout;
     
    4645class UIMachineDisplayScreenFeaturesEditor;
    4746#endif
     47class UIMonitorCountEditor;
    4848class UIScaleFactorEditor;
    4949class UIVideoMemoryEditor;
     
    108108private slots:
    109109
    110     /** Handles Guest Screen count slider change. */
    111     void sltHandleGuestScreenCountSliderChange();
    112     /** Handles Guest Screen count editor change. */
    113     void sltHandleGuestScreenCountEditorChange();
     110    /** Handles monitor count change. */
     111    void sltHandleMonitorCountChange();
    114112    /** Handles Graphics Controller combo change. */
    115113    void sltHandleGraphicsControllerComboChange();
     
    202200        /** Holds the 'Screen' tab instance. */
    203201        QWidget                              *m_pTabScreen;
    204         /** Holds the 'Screen' layout instance. */
    205         QGridLayout                          *m_pLayoutScreen;
    206202        /** Holds the video memory size editor instance. */
    207203        UIVideoMemoryEditor                  *m_pEditorVideoMemorySize;
    208         /** Holds the monitor count label instance. */
    209         QLabel                               *m_pLabelMonitorCount;
    210         /** Holds the monitor count slider instance. */
    211         QIAdvancedSlider                     *m_pSliderMonitorCount;
    212204        /** Holds the monitor count spinbox instance. */
    213         QSpinBox                             *m_pSpinboxMonitorCount;
    214         /** Holds the monitor count min label instance. */
    215         QLabel                               *m_pLabelMonitorCountMin;
    216         /** Holds the monitor count max label instance. */
    217         QLabel                               *m_pLabelMonitorCountMax;
     205        UIMonitorCountEditor                 *m_pEditorMonitorCount;
    218206        /** Holds the scale factor editor instance. */
    219207        UIScaleFactorEditor                  *m_pEditorScaleFactor;
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