VirtualBox

Changeset 28178 in vbox


Ignore:
Timestamp:
Apr 12, 2010 8:20:25 AM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: Introduce a soft limit to save careless users from assigning the maximum value for VRAM to a VM. That value depends on the number of virtual monitors.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsDisplay.cpp

    r27957 r28178  
    5656    m_minVRAM = sys.GetMinGuestVRAM();
    5757    m_maxVRAM = sys.GetMaxGuestVRAM();
     58    m_maxVRAMVisible = m_maxVRAM;
    5859    const uint MinMonitors = 1;
    5960    const uint MaxMonitors = sys.GetMaxGuestMonitors();
    6061
    6162    /* Setup validators */
    62     mLeMemory->setValidator (new QIntValidator (m_minVRAM, m_maxVRAM, this));
     63    mLeMemory->setValidator (new QIntValidator (m_minVRAM, m_maxVRAMVisible, this));
    6364    mLeMonitors->setValidator (new QIntValidator (MinMonitors, MaxMonitors, this));
    6465    mLeVRDPPort->setValidator (new QRegExpValidator (QRegExp ("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
     
    7273
    7374    /* Setup initial values */
    74     mSlMemory->setPageStep (calcPageStep (m_maxVRAM));
     75    mSlMemory->setPageStep (calcPageStep (m_maxVRAMVisible));
    7576    mSlMemory->setSingleStep (mSlMemory->pageStep() / 4);
    7677    mSlMemory->setTickInterval (mSlMemory->pageStep());
     
    8081    /* Setup the scale so that ticks are at page step boundaries */
    8182    mSlMemory->setMinimum ((m_minVRAM / mSlMemory->pageStep()) * mSlMemory->pageStep());
    82     mSlMemory->setMaximum (m_maxVRAM);
     83    mSlMemory->setMaximum (m_maxVRAMVisible);
    8384    mSlMemory->setSnappingEnabled (true);
    8485    quint64 needMBytes = VBoxGlobal::requiredVideoMemory (&mMachine) / _1M;
    8586    mSlMemory->setErrorHint (0, 1);
    8687    mSlMemory->setWarningHint (1, needMBytes);
    87     mSlMemory->setOptimalHint (needMBytes, m_maxVRAM);
     88    mSlMemory->setOptimalHint (needMBytes, m_maxVRAMVisible);
    8889    mSlMonitors->setMinimum (MinMonitors);
    8990    mSlMonitors->setMaximum (MaxMonitors);
     
    123124    mMachine = aMachine;
    124125
     126    int currentSize = mMachine.GetVRAMSize();
     127    m_initialVRAM = RT_MIN(currentSize, m_maxVRAM);
     128
     129    /* must come _before_ setting the initial memory value */
     130    checkMultiMonitorReqs();
     131
    125132    /* Memory Size */
    126     mSlMemory->setValue (mMachine.GetVRAMSize());
     133    mSlMemory->setValue (currentSize);
    127134
    128135    /* Monitors Count */
     
    155162        mTwDisplay->setTabEnabled (1, false);
    156163    }
    157 
    158     checkMultiMonitorReqs();
    159164}
    160165
     
    262267
    263268    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
    264     mLbMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (sys.GetMinGuestVRAM()));
    265     mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (sys.GetMaxGuestVRAM()));
     269    mLbMemoryMin->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_minVRAM));
     270    mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_maxVRAMVisible));
    266271    mLbMonitorsMin->setText (tr ("<qt>%1</qt>").arg (1));
    267272    mLbMonitorsMax->setText (tr ("<qt>%1</qt>").arg (sys.GetMaxGuestMonitors()));
     
    316321    /* The memory requirements have changed too. */
    317322    quint64 needMBytes = VBoxGlobal::requiredVideoMemory (&mMachine, cVal) / _1M;
     323    /* Limit the maximum memory to save careless users from setting useless big values */
     324    m_maxVRAMVisible = 128 + (cVal - 1) * 32;
     325    if (m_maxVRAMVisible < m_initialVRAM)
     326        m_maxVRAMVisible = m_initialVRAM;
    318327    mSlMemory->setWarningHint (1, needMBytes);
    319     mSlMemory->setOptimalHint (needMBytes, m_maxVRAM);
    320 }
    321 
     328    mSlMemory->setPageStep (calcPageStep (m_maxVRAMVisible));
     329    mSlMemory->setMaximum (m_maxVRAMVisible);
     330    mSlMemory->setOptimalHint (needMBytes, m_maxVRAMVisible);
     331    mLeMemory->setValidator (new QIntValidator (m_minVRAM, m_maxVRAMVisible, this));
     332    mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_maxVRAMVisible));
     333    /* ... or just call retranslateUi()? */
     334}
     335
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsDisplay.h

    r27413 r28178  
    6767    QIWidgetValidator *mValidator;
    6868
     69    /* System minimum lower limit of VRAM (MB). */
    6970    int m_minVRAM;
     71    /* System maximum limit of VRAM (MB). */
    7072    int m_maxVRAM;
     73    /* Upper limit of VRAM in MB for this dialog. This value is lower than
     74     * m_maxVRAM to save careless users from setting useless big values. */
     75    int m_maxVRAMVisible;
     76    /* Initial VRAM value when the dialog is opened. */
     77    int m_initialVRAM;
    7178};
    7279
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