VirtualBox

Changeset 37168 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 20, 2011 4:56:46 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: VM Settings Dialog: Page correlation moved into corresponding page files.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r36396 r37168  
    38053805}
    38063806
    3807 /* static */
    3808 bool VBoxGlobal::shouldWarnAboutToLowVRAM(const CMachine *pMachine /* = 0 */)
    3809 {
    3810     static QStringList osList = QStringList()
    3811         << "Other" << "DOS" << "Netware" << "L4" << "QNX" << "JRockitVE";
    3812 
    3813     bool fResult = true;
    3814     if (   pMachine
    3815         && !pMachine->isNull()
    3816         && osList.contains(pMachine->GetOSTypeId()))
    3817         fResult = false;
    3818 
    3819     return fResult;
    3820 }
    3821 
    38223807/**
    38233808 *  Returns the required video memory in bytes for the current desktop
     
    38253810 */
    38263811/* static */
    3827 quint64 VBoxGlobal::requiredVideoMemory (CMachine *aMachine /* = 0 */, int cMonitors /* = 1 */)
     3812quint64 VBoxGlobal::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
    38283813{
    38293814    QSize desktopRes = QApplication::desktop()->screenGeometry().size();
     
    38633848                         needBits / (8 * _1M) /* convert to megabytes */;
    38643849
    3865     if (aMachine && !aMachine->isNull())
    3866     {
    3867        QString typeId = aMachine->GetOSTypeId();
    3868        if (typeId.startsWith("Windows"))
     3850    if (strGuestOSTypeId.startsWith("Windows"))
     3851    {
     3852       /* Windows guests need offscreen VRAM too for graphics acceleration features: */
     3853#ifdef VBOX_WITH_CRHGSMI
     3854       if (strGuestOSTypeId == "WindowsVista" || strGuestOSTypeId == "Windows7")
    38693855       {
    3870            /* Windows guests need offscreen VRAM too for graphics acceleration features. */
    3871 #ifdef VBOX_WITH_CRHGSMI
    3872            if (typeId == "WindowsVista" || typeId == "Windows7")
    3873            {
    3874                /* wddm mode, there are two surfaces for each screen: shadow & primary */
    3875                needMBytes *= 3;
    3876            }
    3877            else
    3878 #endif
    3879            {
    3880                needMBytes *= 2;
    3881            }
     3856           /* wddm mode, there are two surfaces for each screen: shadow & primary */
     3857           needMBytes *= 3;
     3858       }
     3859       else
     3860#endif /* VBOX_WITH_CRHGSMI */
     3861       {
     3862           needMBytes *= 2;
    38823863       }
    38833864    }
     
    44344415#ifdef VBOX_WITH_CRHGSMI
    44354416/* static */
    4436 quint64 VBoxGlobal::required3DWddmOffscreenVideoMemory(CMachine *aMachine /* = 0 */, int cMonitors /* = 1 */)
     4417quint64 VBoxGlobal::required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
    44374418{
    44384419    cMonitors = RT_MAX(cMonitors, 1);
    4439     quint64 cbSize = VBoxGlobal::requiredVideoMemory(aMachine, 1); /* why not cMonitors? */
     4420    quint64 cbSize = VBoxGlobal::requiredVideoMemory(strGuestOSTypeId, 1); /* why not cMonitors? */
    44404421    cbSize += 64 * _1M;
    44414422    return cbSize;
    44424423}
    4443 #endif
     4424#endif /* VBOX_WITH_CRHGSMI */
    44444425
    44454426#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r36104 r37168  
    636636    /* public static stuff */
    637637
    638     static bool shouldWarnAboutToLowVRAM(const CMachine *pMachine = 0);
    639638    static bool isDOSType (const QString &aOSTypeId);
    640639
     
    663662                               VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);
    664663
    665     static quint64 requiredVideoMemory (CMachine *aMachine = 0, int cMonitors = 1);
     664    static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
    666665
    667666    static QString locationForHTML (const QString &aFileName);
     
    715714
    716715#ifdef VBOX_WITH_CRHGSMI
    717     static quint64 required3DWddmOffscreenVideoMemory(CMachine *aMachine = 0, int cMonitors = 1);
    718 #endif
     716    static quint64 required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
     717#endif /* VBOX_WITH_CRHGSMI */
    719718
    720719#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r37138 r37168  
    174174    QString strTitle = m_pSelector->itemTextByPage(pSettingsPage);
    175175
     176    /* Recorrelate page with others before revalidation: */
     177    recorrelate(pSettingsPage);
     178
    176179    /* Revalidate the page: */
    177180    bool fValid = pSettingsPage->revalidate(strWarning, strTitle);
    178 
    179     /* If revalidation is fully passed - recorrelate the pages: */
    180     if (fValid && strWarning.isEmpty())
    181         fValid = recorrelate(pSettingsPage, strWarning);
    182181
    183182    /* Compose a message: */
     
    370369    if (pSettingsPage)
    371370        assignValidator(pSettingsPage);
    372 }
    373 
    374 bool UISettingsDialog::recorrelate(QWidget * /* pPage */, QString & /* strWarning */)
    375 {
    376     return true;
    377371}
    378372
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r37138 r37168  
    9696                 UISettingsPage* pSettingsPage = 0, int iParentId = -1);
    9797
    98     /* Correlation handler: */
    99     virtual bool recorrelate(QWidget *pPage, QString &strWarning);
     98    /* Settings page correlator: */
     99    virtual void recorrelate(UISettingsPage *pSettingsPage) { Q_UNUSED(pSettingsPage); }
    100100
    101101    /* Protected variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r37143 r37168  
    909909}
    910910
    911 bool UISettingsDialogMachine::recorrelate(QWidget *pPage, QString &strWarning)
    912 {
    913     /* This method performs correlation option check
    914      * between different pages of VM Settings dialog: */
    915 
    916     if (pPage == m_pSelector->idToPage(VMSettingsPage_General))
    917     {
    918         /* Get General & System pages: */
    919         UIMachineSettingsGeneral *pGeneralPage =
    920             qobject_cast<UIMachineSettingsGeneral*>(m_pSelector->idToPage(VMSettingsPage_General));
    921         UIMachineSettingsSystem *pSystemPage =
    922             qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(VMSettingsPage_System));
    923 
    924         /* Guest OS type & VT-x/AMD-V option correlation test: */
    925         if (pGeneralPage && pSystemPage &&
    926             pGeneralPage->is64BitOSTypeSelected() && !pSystemPage->isHWVirtExEnabled())
    927         {
    928             strWarning = tr(
    929                 "you have selected a 64-bit guest OS type for this VM. As such guests "
    930                 "require hardware virtualization (VT-x/AMD-V), this feature will be enabled "
    931                 "automatically.");
    932             return true;
    933         }
    934     }
    935 
    936 #if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI)
    937     /* 2D Video Acceleration is available for Windows guests only: */
    938     if (pPage == m_pSelector->idToPage(VMSettingsPage_Display))
    939     {
    940         /* Get General & Display pages: */
    941         UIMachineSettingsGeneral *pGeneralPage =
    942             qobject_cast<UIMachineSettingsGeneral*>(m_pSelector->idToPage(VMSettingsPage_General));
    943         UIMachineSettingsDisplay *pDisplayPage =
    944             qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(VMSettingsPage_Display));
    945 #ifdef VBOX_WITH_CRHGSMI
    946         if (pGeneralPage && pDisplayPage)
    947         {
    948             bool bWddmSupported = pGeneralPage->isWddmSupportedForOSType();
    949             pDisplayPage->setWddmMode(bWddmSupported);
    950         }
    951 #endif
    952 #ifdef VBOX_WITH_VIDEOHWACCEL
    953         if (pGeneralPage && pDisplayPage &&
    954             pDisplayPage->isAcceleration2DVideoSelected() && !pGeneralPage->isWindowsOSTypeSelected())
    955         {
    956             strWarning = tr(
    957                 "you have 2D Video Acceleration enabled. As 2D Video Acceleration "
    958                 "is supported for Windows guests only, this feature will be disabled.");
    959             return true;
    960         }
    961 #endif
    962     }
    963 #endif /* VBOX_WITH_VIDEOHWACCEL */
    964 
    965     if (pPage == m_pSelector->idToPage(VMSettingsPage_System))
    966     {
    967         /* Get System & USB pages: */
    968         UIMachineSettingsSystem *pSystemPage =
    969             qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(VMSettingsPage_System));
    970         UIMachineSettingsUSB *pUsbPage =
    971             qobject_cast<UIMachineSettingsUSB*>(m_pSelector->idToPage(VMSettingsPage_USB));
    972         if (pSystemPage && pUsbPage &&
    973             pSystemPage->isHIDEnabled() && !pUsbPage->isOHCIEnabled())
    974         {
    975             strWarning = tr(
    976                 "you have enabled a USB HID (Human Interface Device). "
    977                 "This will not work unless USB emulation is also enabled. "
    978                 "This will be done automatically when you accept the VM Settings "
    979                 "by pressing the OK button.");
    980             return true;
    981         }
    982     }
    983 
    984     if (pPage == m_pSelector->idToPage(VMSettingsPage_Storage))
    985     {
    986         /* Get System & Storage pages: */
    987         UIMachineSettingsSystem *pSystemPage =
    988             qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(VMSettingsPage_System));
    989         UIMachineSettingsStorage *pStoragePage =
    990             qobject_cast<UIMachineSettingsStorage*>(m_pSelector->idToPage(VMSettingsPage_Storage));
    991         if (pSystemPage && pStoragePage)
    992         {
    993             /* Update chiset type for the Storage settings page: */
    994             if (pStoragePage->chipsetType() != pSystemPage->chipsetType())
     911void UISettingsDialogMachine::recorrelate(UISettingsPage *pSettingsPage)
     912{
     913    switch (pSettingsPage->id())
     914    {
     915        case VMSettingsPage_General:
     916        {
     917            UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(pSettingsPage);
     918            UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(VMSettingsPage_System));
     919            if (pGeneralPage && pSystemPage)
     920                pGeneralPage->setHWVirtExEnabled(pSystemPage->isHWVirtExEnabled());
     921            break;
     922        }
     923        case VMSettingsPage_Display:
     924        {
     925            UIMachineSettingsDisplay *pDisplayPage = qobject_cast<UIMachineSettingsDisplay*>(pSettingsPage);
     926            UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(m_pSelector->idToPage(VMSettingsPage_General));
     927            if (pDisplayPage && pGeneralPage)
     928                pDisplayPage->setGuestOSType(pGeneralPage->guestOSType());
     929            break;
     930        }
     931        case VMSettingsPage_System:
     932        {
     933            UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(pSettingsPage);
     934            UIMachineSettingsUSB *pUsbPage = qobject_cast<UIMachineSettingsUSB*>(m_pSelector->idToPage(VMSettingsPage_USB));
     935            if (pSystemPage && pUsbPage)
     936                pSystemPage->setOHCIEnabled(pUsbPage->isOHCIEnabled());
     937            break;
     938        }
     939        case VMSettingsPage_Storage:
     940        {
     941            UIMachineSettingsStorage *pStoragePage = qobject_cast<UIMachineSettingsStorage*>(pSettingsPage);
     942            UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(VMSettingsPage_System));
     943            if (pStoragePage && pSystemPage)
    995944                pStoragePage->setChipsetType(pSystemPage->chipsetType());
    996             /* Check for excessive controllers on Storage page controllers list: */
    997             QStringList excessiveList;
    998             QMap<KStorageBus, int> currentType = pStoragePage->currentControllerTypes();
    999             QMap<KStorageBus, int> maximumType = pStoragePage->maximumControllerTypes();
    1000             for (int iStorageBusType = KStorageBus_IDE; iStorageBusType <= KStorageBus_SAS; ++iStorageBusType)
    1001             {
    1002                 if (currentType[(KStorageBus)iStorageBusType] > maximumType[(KStorageBus)iStorageBusType])
    1003                 {
    1004                     QString strExcessiveRecord = QString("%1 (%2)");
    1005                     strExcessiveRecord = strExcessiveRecord.arg(QString("<b>%1</b>").arg(vboxGlobal().toString((KStorageBus)iStorageBusType)));
    1006                     strExcessiveRecord = strExcessiveRecord.arg(maximumType[(KStorageBus)iStorageBusType] == 1 ?
    1007                                                                 tr("at most one supported") :
    1008                                                                 tr("up to %1 supported").arg(maximumType[(KStorageBus)iStorageBusType]));
    1009                     excessiveList << strExcessiveRecord;
    1010                 }
    1011             }
    1012             if (!excessiveList.isEmpty())
    1013             {
    1014                 strWarning = tr(
    1015                     "you are currently using more storage controllers than a %1 chipset supports. "
    1016                     "Please change the chipset type on the System settings page or reduce the number "
    1017                     "of the following storage controllers on the Storage settings page: %2.")
    1018                     .arg(vboxGlobal().toString(pStoragePage->chipsetType()))
    1019                     .arg(excessiveList.join(", "));
    1020                 return false;
    1021             }
    1022         }
    1023     }
    1024 
    1025     return true;
     945            break;
     946        }
     947        default:
     948            break;
     949    }
    1026950}
    1027951
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h

    r37143 r37168  
    9494    QString title() const;
    9595
    96     bool recorrelate(QWidget *pPage, QString &strWarning);
     96    void recorrelate(UISettingsPage *pSettingsPage);
    9797
    9898private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r37126 r37168  
    5151    , m_maxVRAMVisible(0)
    5252    , m_initialVRAM(0)
     53#ifdef VBOX_WITH_VIDEOHWACCEL
     54    , m_f2DVideoAccelerationSupported(false)
     55#endif /* VBOX_WITH_VIDEOHWACCEL */
    5356#ifdef VBOX_WITH_CRHGSMI
    54     , m_bWddmMode(false)
    55 #endif
     57    , m_fWddmModeSupported(false)
     58#endif /* VBOX_WITH_CRHGSMI */
    5659{
    5760    /* Apply UI decorations */
     
    9497    mSlMemory->setMaximum (m_maxVRAMVisible);
    9598    mSlMemory->setSnappingEnabled (true);
    96     quint64 needMBytes = VBoxGlobal::requiredVideoMemory (&m_machine) / _1M;
    9799    mSlMemory->setErrorHint (0, 1);
    98     mSlMemory->setWarningHint (1, needMBytes);
    99     mSlMemory->setOptimalHint (needMBytes, m_maxVRAMVisible);
    100100    mSlMonitors->setMinimum (MinMonitors);
    101101    mSlMonitors->setMaximum (MaxMonitors);
     
    120120#endif
    121121
    122 #ifdef VBOX_WITH_CRHGSMI
    123     m_bWddmMode = false;
    124 #endif
    125 
    126122    /* Applying language settings */
    127123    retranslateUi();
    128124}
    129125
     126void UIMachineSettingsDisplay::setGuestOSType(CGuestOSType guestOSType)
     127{
     128    /* Check if guest os type changed: */
     129    if (m_guestOSType == guestOSType)
     130        return;
     131
     132    /* Remember new guest os type: */
     133    m_guestOSType = guestOSType;
     134
     135#ifdef VBOX_WITH_VIDEOHWACCEL
     136    /* Check if 2D video acceleration supported by the guest OS type: */
     137    QString strguestOSTypeFamily = m_guestOSType.GetFamilyId();
     138    m_f2DVideoAccelerationSupported = strguestOSTypeFamily == "Windows";
     139#endif /* VBOX_WITH_VIDEOHWACCEL */
     140#ifdef VBOX_WITH_CRHGSMI
     141    /* Check if WDDM mode supported by the guest OS type: */
     142    QString strguestOSTypeId = m_guestOSType.GetId();
     143    m_fWddmModeSupported = strguestOSTypeId == "WindowsVista" || strguestOSTypeId == "Windows7";
     144#endif /* VBOX_WITH_CRHGSMI */
     145
     146    /* Recheck video RAM requirement: */
     147    checkVRAMRequirements();
     148}
     149
    130150#ifdef VBOX_WITH_VIDEOHWACCEL
    131151bool UIMachineSettingsDisplay::isAcceleration2DVideoSelected() const
     
    133153    return mCb2DVideo->isChecked();
    134154}
    135 #endif
    136 
    137 #ifdef VBOX_WITH_CRHGSMI
    138 void UIMachineSettingsDisplay::setWddmMode(bool bWddm)
    139 {
    140     if (bWddm == m_bWddmMode)
    141         return;
    142 
    143     m_bWddmMode = bWddm;
    144     checkVRAMRequirements();
    145 }
    146 #endif
     155#endif /* VBOX_WITH_VIDEOHWACCEL */
    147156
    148157/* Load data to cashe from corresponding external object(s),
     
    313322}
    314323
    315 bool UIMachineSettingsDisplay::revalidate (QString &aWarning, QString & /* aTitle */)
    316 {
    317     /* Video RAM amount test */
    318     quint64 needBytes = VBoxGlobal::requiredVideoMemory (&m_machine, mSlMonitors->value());
    319     if (   vboxGlobal().shouldWarnAboutToLowVRAM(&m_machine)
    320         && (quint64)mSlMemory->value() * _1M < needBytes)
    321     {
    322         aWarning = tr (
    323                        "you have assigned less than <b>%1</b> of video memory which is "
    324                        "the minimum amount required to switch the virtual machine to "
    325                        "fullscreen or seamless mode.")
    326             .arg (vboxGlobal().formatSize (needBytes, 0, VBoxDefs::FormatSize_RoundUp));
    327     }
    328 #ifdef VBOX_WITH_VIDEOHWACCEL
    329     else if (mCb2DVideo->isChecked())
    330     {
    331         needBytes += VBoxGlobal::required2DOffscreenVideoMemory();
    332         if ((quint64) mSlMemory->value() * _1M < needBytes)
     324bool UIMachineSettingsDisplay::revalidate(QString &strWarning, QString & /* strTitle */)
     325{
     326    /* Check if video RAM requirement changed first: */
     327    checkVRAMRequirements();
     328
     329    /* Video RAM amount test: */
     330    if (shouldWeWarnAboutLowVideoMemory() && !m_guestOSType.isNull())
     331    {
     332        quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), mSlMonitors->value());
     333
     334        /* Basic video RAM amount test: */
     335        if ((quint64)mSlMemory->value() * _1M < uNeedBytes)
    333336        {
    334             aWarning = tr (
    335                 "you have assigned less than <b>%1</b> of video memory which is "
    336                 "the minimum amount required for HD Video to be played efficiently.")
    337                 .arg (vboxGlobal().formatSize (needBytes, 0, VBoxDefs::FormatSize_RoundUp));
     337            strWarning = tr("you have assigned less than <b>%1</b> of video memory which is "
     338                            "the minimum amount required to switch the virtual machine to "
     339                            "fullscreen or seamless mode.")
     340                            .arg(vboxGlobal().formatSize(uNeedBytes, 0, VBoxDefs::FormatSize_RoundUp));
     341            return true;
    338342        }
    339     }
    340 #endif
    341 #ifdef VBOX_WITH_CRHGSMI
    342     else if (false) // m_bWddmMode && mCb3D->isChecked())
    343     {
    344         int cVal = mSlMonitors->value();
    345         needBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(&m_machine, cVal);
    346         needBytes = RT_MAX(needBytes, 128 * _1M);
    347         needBytes = RT_MIN(needBytes, 256 * _1M);
    348         if ((quint64) mSlMemory->value() * _1M < needBytes)
     343#ifdef VBOX_WITH_VIDEOHWACCEL
     344        /* 2D acceleration video RAM amount test: */
     345        if (mCb2DVideo->isChecked() && m_f2DVideoAccelerationSupported)
    349346        {
    350             aWarning = tr(
    351                 "You have 3D Acceleration enabled for a operation system which uses the WDDM video driver. "
    352                 "For maximal performance set the guest VRAM to at least <b>%1</b>."
    353                 ).arg (vboxGlobal().formatSize (needBytes, 0, VBoxDefs::FormatSize_RoundUp));
     347            uNeedBytes += VBoxGlobal::required2DOffscreenVideoMemory();
     348            if ((quint64)mSlMemory->value() * _1M < uNeedBytes)
     349            {
     350                strWarning = tr("you have assigned less than <b>%1</b> of video memory which is "
     351                                "the minimum amount required for HD Video to be played efficiently.")
     352                                .arg(vboxGlobal().formatSize(uNeedBytes, 0, VBoxDefs::FormatSize_RoundUp));
     353                return true;
     354            }
    354355        }
    355     }
    356 #endif
    357     checkVRAMRequirements();
     356#endif /* VBOX_WITH_VIDEOHWACCEL */
     357#if 0
     358# ifdef VBOX_WITH_CRHGSMI
     359        if (mCb3D->isChecked() && m_fWddmModeSupported)
     360        {
     361            int cMonitorsCount = mSlMonitors->value();
     362            uNeedBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cMonitorsCount);
     363            uNeedBytes = RT_MAX(uNeedBytes, 128 * _1M);
     364            uNeedBytes = RT_MIN(uNeedBytes, 256 * _1M);
     365            if ((quint64)mSlMemory->value() * _1M < uNeedBytes)
     366            {
     367                strWarning = tr("you have 3D Acceleration enabled for a operation system which uses the WDDM video driver. "
     368                                "For maximal performance set the guest VRAM to at least <b>%1</b>.")
     369                                .arg(vboxGlobal().formatSize(uNeedBytes, 0, VBoxDefs::FormatSize_RoundUp));
     370                return true;
     371            }
     372        }
     373# endif /* VBOX_WITH_CRHGSMI */
     374#endif /* 0 */
     375    }
     376
     377    /* Check mode availability: */
     378#ifdef VBOX_WITH_VIDEOHWACCEL
     379    /* 2D video acceleration is available for Windows guests only: */
     380    if (mCb2DVideo->isChecked() && !m_f2DVideoAccelerationSupported)
     381    {
     382        strWarning = tr("you have 2D Video Acceleration enabled. As 2D Video Acceleration "
     383                        "is supported for Windows guests only, this feature will be disabled.");
     384        return true;
     385    }
     386#endif /* VBOX_WITH_VIDEOHWACCEL */
     387
    358388    return true;
    359389}
     
    424454void UIMachineSettingsDisplay::checkVRAMRequirements()
    425455{
    426     int cVal = mSlMonitors->value();
    427     /* The memory requirements have changed too. */
    428     quint64 needMBytes = VBoxGlobal::requiredVideoMemory (&m_machine, cVal) / _1M;
    429     /* Limit the maximum memory to save careless users from setting useless big values */
    430 #ifdef VBOX_WITH_VIDEOHWACCEL
    431     if (mCb2DVideo->isChecked())
    432     {
    433         needMBytes += VBoxGlobal::required2DOffscreenVideoMemory() / _1M;
    434     }
    435 #endif
    436 #if 0 // def VBOX_WITH_CRHGSMI
    437     if (m_bWddmMode && mCb3D->isChecked())
    438     {
    439         needMBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(&m_machine, cVal) / _1M;
    440         needMBytes = RT_MAX(needMBytes, 128);
    441         needMBytes = RT_MIN(needMBytes, 256);
     456    if (m_guestOSType.isNull())
     457        return;
     458
     459    /* Get monitors count and base video memory requirements: */
     460    int cMonitorsCount = mSlMonitors->value();
     461    quint64 uNeedMBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), cMonitorsCount) / _1M;
     462
     463    /* Initial values: */
     464    m_maxVRAMVisible = cMonitorsCount * 32;
     465    if (m_maxVRAMVisible < 128)
     466        m_maxVRAMVisible = 128;
     467    if (m_maxVRAMVisible < m_initialVRAM)
     468        m_maxVRAMVisible = m_initialVRAM;
     469
     470#ifdef VBOX_WITH_VIDEOHWACCEL
     471    if (mCb2DVideo->isChecked() && m_f2DVideoAccelerationSupported)
     472    {
     473        uNeedMBytes += VBoxGlobal::required2DOffscreenVideoMemory() / _1M;
     474    }
     475#endif /* VBOX_WITH_VIDEOHWACCEL */
     476#if 0
     477# ifdef VBOX_WITH_CRHGSMI
     478    if (mCb3D->isChecked() && m_fWddmModeSupported)
     479    {
     480        uNeedMBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cMonitorsCount) / _1M;
     481        uNeedMBytes = RT_MAX(uNeedMBytes, 128);
     482        uNeedMBytes = RT_MIN(uNeedMBytes, 256);
    442483        m_maxVRAMVisible = 256;
    443484    }
    444     else
    445 #endif
    446     {
    447         m_maxVRAMVisible = cVal * 32;
    448         if (m_maxVRAMVisible < 128)
    449             m_maxVRAMVisible = 128;
    450         if (m_maxVRAMVisible < m_initialVRAM)
    451             m_maxVRAMVisible = m_initialVRAM;
    452     }
    453     mSlMemory->setWarningHint (1, needMBytes);
    454     mSlMemory->setPageStep (calcPageStep (m_maxVRAMVisible));
    455     mSlMemory->setMaximum (m_maxVRAMVisible);
    456     mSlMemory->setOptimalHint (needMBytes, m_maxVRAMVisible);
    457     mLeMemory->setValidator (new QIntValidator (m_minVRAM, m_maxVRAMVisible, this));
    458     mLbMemoryMax->setText (tr ("<qt>%1&nbsp;MB</qt>").arg (m_maxVRAMVisible));
    459     /* ... or just call retranslateUi()? */
     485# endif /* VBOX_WITH_CRHGSMI */
     486#endif /* 0 */
     487
     488    mSlMemory->setWarningHint(1, uNeedMBytes);
     489    mSlMemory->setPageStep(calcPageStep(m_maxVRAMVisible));
     490    mSlMemory->setMaximum(m_maxVRAMVisible);
     491    mSlMemory->setOptimalHint(uNeedMBytes, m_maxVRAMVisible);
     492    mLeMemory->setValidator(new QIntValidator(m_minVRAM, m_maxVRAMVisible, this));
     493    mLbMemoryMax->setText(tr("<qt>%1&nbsp;MB</qt>").arg(m_maxVRAMVisible));
     494}
     495
     496bool UIMachineSettingsDisplay::shouldWeWarnAboutLowVideoMemory()
     497{
     498    bool fResult = true;
     499
     500    QStringList excludingOSList = QStringList()
     501        << "Other" << "DOS" << "Netware" << "L4" << "QNX" << "JRockitVE";
     502    if (excludingOSList.contains(m_guestOSType.GetId()))
     503        fResult = false;
     504
     505    return fResult;
    460506}
    461507
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r37143 r37168  
    8686    UIMachineSettingsDisplay();
    8787
     88    void setGuestOSType(CGuestOSType guestOSType);
     89
    8890#ifdef VBOX_WITH_VIDEOHWACCEL
    8991    bool isAcceleration2DVideoSelected() const;
    90 #endif
    91 
    92 #ifdef VBOX_WITH_CRHGSMI
    93     void setWddmMode(bool bWddm);
    94 #endif
     92#endif /* VBOX_WITH_VIDEOHWACCEL */
    9593
    9694protected:
     
    130128
    131129    void checkVRAMRequirements();
     130    bool shouldWeWarnAboutLowVideoMemory();
    132131
    133132    void polishPage();
     
    135134    QIWidgetValidator *mValidator;
    136135
     136    /* Guest OS type id: */
     137    CGuestOSType m_guestOSType;
    137138    /* System minimum lower limit of VRAM (MiB). */
    138139    int m_minVRAM;
     
    144145    /* Initial VRAM value when the dialog is opened. */
    145146    int m_initialVRAM;
     147#ifdef VBOX_WITH_VIDEOHWACCEL
     148    /* Specifies whether the guest OS supports 2D video-acceleration: */
     149    bool m_f2DVideoAccelerationSupported;
     150#endif /* VBOX_WITH_VIDEOHWACCEL */
    146151#ifdef VBOX_WITH_CRHGSMI
    147     /* Specifies whether the guest os is wddm-capable: */
    148     bool m_bWddmMode;
    149 #endif
     152    /* Specifies whether the guest OS supports WDDM: */
     153    bool m_fWddmModeSupported;
     154#endif /* VBOX_WITH_CRHGSMI */
    150155
    151156    /* Cache: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r37126 r37168  
    2727UIMachineSettingsGeneral::UIMachineSettingsGeneral()
    2828    : mValidator(0)
     29    , m_fHWVirtExEnabled(false)
    2930{
    3031    /* Apply UI decorations */
     
    4849}
    4950
     51CGuestOSType UIMachineSettingsGeneral::guestOSType() const
     52{
     53    return mOSTypeSelector->type();
     54}
     55
     56void UIMachineSettingsGeneral::setHWVirtExEnabled(bool fEnabled)
     57{
     58    m_fHWVirtExEnabled = fEnabled;
     59}
     60
    5061bool UIMachineSettingsGeneral::is64BitOSTypeSelected() const
    5162{
     
    5869    return mOSTypeSelector->type().GetFamilyId() == "Windows";
    5970}
    60 #endif
    61 
    62 #ifdef VBOX_WITH_CRHGSMI
    63 bool UIMachineSettingsGeneral::isWddmSupportedForOSType() const
    64 {
    65     const QString &strOsId = mOSTypeSelector->type().GetId();
    66     return strOsId == "WindowsVista" || strOsId == "Windows7";
    67 }
    68 #endif
     71#endif /* VBOX_WITH_VIDEOHWACCEL */
    6972
    7073/* Load data to cashe from corresponding external object(s),
     
    197200}
    198201
     202bool UIMachineSettingsGeneral::revalidate(QString &strWarning, QString& /* strTitle */)
     203{
     204    if (is64BitOSTypeSelected() && !m_fHWVirtExEnabled)
     205        strWarning = tr("you have selected a 64-bit guest OS type for this VM. As such guests "
     206                        "require hardware virtualization (VT-x/AMD-V), this feature will be enabled "
     207                        "automatically.");
     208    return true;
     209}
     210
    199211void UIMachineSettingsGeneral::setOrderAfter (QWidget *aWidget)
    200212{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r37143 r37168  
    7777    UIMachineSettingsGeneral();
    7878
     79    CGuestOSType guestOSType() const;
     80    void setHWVirtExEnabled(bool fEnabled);
    7981    bool is64BitOSTypeSelected() const;
    80 
    8182#ifdef VBOX_WITH_VIDEOHWACCEL
    8283    bool isWindowsOSTypeSelected() const;
    83 #endif
    84 
    85 #ifdef VBOX_WITH_CRHGSMI
    86     bool isWddmSupportedForOSType() const;
    87 #endif
     84#endif /* VBOX_WITH_VIDEOHWACCEL */
    8885
    8986protected:
     
    107104
    108105    void setValidator (QIWidgetValidator *aVal);
     106    bool revalidate(QString &strWarning, QString &strTitle);
    109107
    110108    void setOrderAfter (QWidget *aWidget);
     
    117115
    118116    QIWidgetValidator *mValidator;
     117    bool m_fHWVirtExEnabled;
    119118
    120119    /* Cache: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r37140 r37168  
    17661766}
    17671767
    1768 KChipsetType UIMachineSettingsStorage::chipsetType() const
    1769 {
    1770     return mStorageModel->chipsetType();
    1771 }
    1772 
    17731768void UIMachineSettingsStorage::setChipsetType(KChipsetType type)
    17741769{
    17751770    mStorageModel->setChipsetType(type);
    17761771    updateActionsState();
    1777 }
    1778 
    1779 QMap<KStorageBus, int> UIMachineSettingsStorage::currentControllerTypes() const
    1780 {
    1781     return mStorageModel->currentControllerTypes();
    1782 }
    1783 
    1784 QMap<KStorageBus, int> UIMachineSettingsStorage::maximumControllerTypes() const
    1785 {
    1786     return mStorageModel->maximumControllerTypes();
    17871772}
    17881773
     
    17971782    m_cache.clear();
    17981783
    1799     /* Prepare storage data: */
    1800     UIDataSettingsMachineStorage storageData;
    1801 
    18021784    /* Gather storage data: */
    1803     storageData.m_strMachineId = m_machine.GetId();
     1785    m_strMachineId = m_machine.GetId();
     1786    m_strMachineSettingsFilePath = m_machine.GetSettingsFilePath();
     1787    m_strMachineGuestOSTypeId = m_machine.GetOSTypeId();
    18041788
    18051789    /* For each controller: */
     
    18511835    }
    18521836
    1853     /* Cache storage data: */
    1854     m_cache.cacheInitialData(storageData);
    1855 
    18561837    /* Upload machine to data: */
    18571838    UISettingsPageMachine::uploadData(data);
     
    18651846    mStorageModel->clear();
    18661847
    1867     /* Get storage data from cache: */
    1868     const UIDataSettingsMachineStorage &storageData = m_cache.base();
    1869 
    18701848    /* Load storage data to page: */
    1871     mStorageModel->setMachineId(storageData.m_strMachineId);
     1849    mStorageModel->setMachineId(m_strMachineId);
    18721850
    18731851    /* For each storage controller: */
     
    19851963}
    19861964
    1987 bool UIMachineSettingsStorage::revalidate (QString &aWarning, QString &)
    1988 {
     1965bool UIMachineSettingsStorage::revalidate (QString &strWarning, QString& /* strTitle */)
     1966{
     1967    /* Check controllers for name emptiness & coincidence.
     1968     * Check attachments for the hd presence / uniqueness. */
    19891969    QModelIndex rootIndex = mStorageModel->root();
    19901970    QMap <QString, QString> config;
     
    19981978        if (ctrName.isEmpty())
    19991979        {
    2000             aWarning = tr("no name specified for controller at position <b>%1</b>.").arg(i + 1);
    2001             return aWarning.isNull();
     1980            strWarning = tr("no name specified for controller at position <b>%1</b>.").arg(i + 1);
     1981            return false;
    20021982        }
    20031983        /* Check for name coincidence: */
    20041984        if (names.values().contains(ctrName))
    20051985        {
    2006             aWarning = tr("controller at position <b>%1</b> uses the name that is "
     1986            strWarning = tr("controller at position <b>%1</b> uses the name that is "
    20071987                          "already used by controller at position <b>%2</b>.")
    20081988                          .arg(i + 1).arg(names.key(ctrName) + 1);
    2009             return aWarning.isNull();
     1989            return false;
    20101990        }
    20111991        else names.insert(i, ctrName);
     
    20212001            if (vboxGlobal().findMedium (key).isNull() && attDevice == KDeviceType_HardDisk)
    20222002            {
    2023                 aWarning = tr ("no hard disk is selected for <i>%1</i>.").arg (value);
    2024                 return aWarning.isNull();
     2003                strWarning = tr ("no hard disk is selected for <i>%1</i>.").arg (value);
     2004                return false;
    20252005            }
    20262006            /* Check for coincidence */
    20272007            if (!vboxGlobal().findMedium (key).isNull() && config.contains (key))
    20282008            {
    2029                 aWarning = tr ("<i>%1</i> uses a medium that is already attached to <i>%2</i>.")
     2009                strWarning = tr ("<i>%1</i> uses a medium that is already attached to <i>%2</i>.")
    20302010                              .arg (value).arg (config [key]);
    2031                 return aWarning.isNull();
     2011                return false;
    20322012            }
    20332013            else config.insert (key, value);
    20342014        }
    20352015    }
    2036     return aWarning.isNull();
     2016
     2017    /* Check for excessive controllers on Storage page controllers list: */
     2018    QStringList excessiveList;
     2019    QMap<KStorageBus, int> currentType = mStorageModel->currentControllerTypes();
     2020    QMap<KStorageBus, int> maximumType = mStorageModel->maximumControllerTypes();
     2021    for (int iStorageBusType = KStorageBus_IDE; iStorageBusType <= KStorageBus_SAS; ++iStorageBusType)
     2022    {
     2023        if (currentType[(KStorageBus)iStorageBusType] > maximumType[(KStorageBus)iStorageBusType])
     2024        {
     2025            QString strExcessiveRecord = QString("%1 (%2)");
     2026            strExcessiveRecord = strExcessiveRecord.arg(QString("<b>%1</b>").arg(vboxGlobal().toString((KStorageBus)iStorageBusType)));
     2027            strExcessiveRecord = strExcessiveRecord.arg(maximumType[(KStorageBus)iStorageBusType] == 1 ?
     2028                                                        tr("at most one supported", "controller") :
     2029                                                        tr("up to %1 supported", "controllers").arg(maximumType[(KStorageBus)iStorageBusType]));
     2030            excessiveList << strExcessiveRecord;
     2031        }
     2032    }
     2033    if (!excessiveList.isEmpty())
     2034    {
     2035        strWarning = tr("you are currently using more storage controllers than a %1 chipset supports. "
     2036                        "Please change the chipset type on the System settings page or reduce the number "
     2037                        "of the following storage controllers on the Storage settings page: %2.")
     2038                        .arg(vboxGlobal().toString(mStorageModel->chipsetType()))
     2039                        .arg(excessiveList.join(", "));
     2040        return false;
     2041    }
     2042
     2043    return true;
    20372044}
    20382045
     
    25152522void UIMachineSettingsStorage::sltChooseExistingMedium()
    25162523{
    2517     QString strMachineFolder(QFileInfo(m_machine.GetSettingsFilePath()).absolutePath());
     2524    QString strMachineFolder(QFileInfo(m_strMachineSettingsFilePath).absolutePath());
    25182525    QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediumIdHolder->type(), this, strMachineFolder);
    25192526    if (!strMediumId.isNull())
     
    28652872    Assert(mStorageModel->data(index, StorageModel::R_IsMoreAttachmentsPossible).toBool());
    28662873    QString strControllerName(mStorageModel->data(index, StorageModel::R_CtrName).toString());
    2867     QString strMachineFolder(QFileInfo(m_machine.GetSettingsFilePath()).absolutePath());
     2874    QString strMachineFolder(QFileInfo(m_strMachineSettingsFilePath).absolutePath());
    28682875
    28692876    QString strMediumId;
     
    29142921    UINewHDWzd dlg(this);
    29152922    /* Initialize variables: */
    2916     CGuestOSType guestOSType = vboxGlobal().virtualBox().GetGuestOSType(m_machine.GetOSTypeId());
     2923    CGuestOSType guestOSType = vboxGlobal().virtualBox().GetGuestOSType(m_strMachineGuestOSTypeId);
    29172924    dlg.setRecommendedSize(guestOSType.GetRecommendedHDD());
    2918     QString strMachineSettingsFilepath = m_machine.GetSettingsFilePath();
    2919     QFileInfo fileInfo(strMachineSettingsFilepath);
     2925    QFileInfo fileInfo(m_strMachineSettingsFilePath);
    29202926    dlg.setDefaultPath(fileInfo.absolutePath());
    29212927
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r37143 r37168  
    608608{
    609609    /* Default constructor: */
    610     UIDataSettingsMachineStorage()
    611         : m_strMachineId(QString()) {}
     610    UIDataSettingsMachineStorage() {}
    612611    /* Operators: */
    613     bool operator==(const UIDataSettingsMachineStorage &other) const { return m_strMachineId == other.m_strMachineId; }
    614     bool operator!=(const UIDataSettingsMachineStorage &other) const { return m_strMachineId != other.m_strMachineId; }
    615     /* Variables: */
    616     QString m_strMachineId;
     612    bool operator==(const UIDataSettingsMachineStorage& /* other */) const { return true; }
     613    bool operator!=(const UIDataSettingsMachineStorage& /* other */) const { return false; }
    617614};
    618615typedef UISettingsCachePool<UIDataSettingsMachineStorage, UICacheSettingsMachineStorageController> UICacheSettingsMachineStorage;
     
    628625    UIMachineSettingsStorage();
    629626
    630     KChipsetType chipsetType() const;
    631627    void setChipsetType(KChipsetType type);
    632 
    633     QMap<KStorageBus, int> currentControllerTypes() const;
    634     QMap<KStorageBus, int> maximumControllerTypes() const;
    635628
    636629signals:
     
    742735    QIWidgetValidator *mValidator;
    743736
     737    QString m_strMachineId;
     738    QString m_strMachineSettingsFilePath;
     739    QString m_strMachineGuestOSTypeId;
     740
    744741    StorageModel *mStorageModel;
    745742
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r37126 r37168  
    3131    : mValidator(0)
    3232    , mMinGuestCPU(0), mMaxGuestCPU(0)
     33    , m_fOHCIEnabled(false)
    3334{
    3435    /* Apply UI decorations */
     
    148149}
    149150
    150 int UIMachineSettingsSystem::cpuCount() const
    151 {
    152     return mSlCPU->value();
    153 }
    154 
    155151bool UIMachineSettingsSystem::isHIDEnabled() const
    156152{
     
    161157{
    162158    return (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt();
     159}
     160
     161void UIMachineSettingsSystem::setOHCIEnabled(bool fEnabled)
     162{
     163    m_fOHCIEnabled = fEnabled;
    163164}
    164165
     
    427428            "you have assigned ICH9 chipset type to this VM. "
    428429            "It will not work properly unless the IO-APIC feature is also enabled. "
     430            "This will be done automatically when you accept the VM Settings "
     431            "by pressing the OK button.");
     432        return true;
     433    }
     434
     435    /* HID dependency from OHCI feature: */
     436    if (mCbUseAbsHID->isChecked() && !m_fOHCIEnabled)
     437    {
     438        aWarning = tr (
     439            "you have enabled a USB HID (Human Interface Device). "
     440            "This will not work unless USB emulation is also enabled. "
    429441            "This will be done automatically when you accept the VM Settings "
    430442            "by pressing the OK button.");
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r37143 r37168  
    106106
    107107    bool isHWVirtExEnabled() const;
    108     int cpuCount() const;
    109108    bool isHIDEnabled() const;
    110109    KChipsetType chipsetType() const;
     110    void setOHCIEnabled(bool fEnabled);
    111111
    112112signals:
     
    165165    QList<KDeviceType> m_possibleBootItems;
    166166
     167    bool m_fOHCIEnabled;
     168
    167169    /* Cache: */
    168170    UICacheSettingsMachineSystem m_cache;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp

    r36334 r37168  
    740740    /* VRAM size - select maximum between recommended and minimum for fullscreen */
    741741    m_Machine.SetVRAMSize (qMax (type.GetRecommendedVRAM(),
    742                                 (ULONG) (VBoxGlobal::requiredVideoMemory(&m_Machine) / _1M)));
     742                                (ULONG) (VBoxGlobal::requiredVideoMemory(typeId) / _1M)));
    743743
    744744    /* Selecting recommended chipset type */
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