VirtualBox

Changeset 101272 in vbox for trunk


Ignore:
Timestamp:
Sep 26, 2023 3:37:01 PM (16 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10523. New vm wizard does not cache guest OS type object anymore.

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

Legend:

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

    r101265 r101272  
    133133}
    134134
     135ULONG UIGuestOSTypeManager::getRecommendedRAM(const QString &strTypeId) const
     136{
     137    if (strTypeId.isEmpty())
     138        return 0;
     139    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     140    {
     141        if (type.getId() == strTypeId)
     142            return type.getRecommendedRAM();
     143    }
     144    return 0;
     145}
     146
     147ULONG UIGuestOSTypeManager::getRecommendedCPUCount(const QString &strTypeId) const
     148{
     149    if (strTypeId.isEmpty())
     150        return 0;
     151    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     152    {
     153        if (type.getId() == strTypeId)
     154            return type.getRecommendedCPUCount();
     155    }
     156    return 0;
     157}
     158
     159KFirmwareType UIGuestOSTypeManager::getRecommendedFirmware(const QString &strTypeId) const
     160{
     161    if (strTypeId.isEmpty())
     162        return KFirmwareType_Max;
     163    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     164    {
     165        if (type.getId() == strTypeId)
     166            return type.getRecommendedFirmware();
     167    }
     168    return KFirmwareType_Max;
     169}
     170
     171QString UIGuestOSTypeManager::getDescription(const QString &strTypeId) const
     172{
     173    if (strTypeId.isEmpty())
     174        return QString();
     175    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     176    {
     177        if (type.getId() == strTypeId)
     178            return type.getDescription();
     179    }
     180    return QString();
     181}
     182
     183LONG64 UIGuestOSTypeManager::getRecommendedHDD(const QString &strTypeId) const
     184{
     185    if (strTypeId.isEmpty())
     186        return 0;
     187    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     188    {
     189        if (type.getId() == strTypeId)
     190            return type.getRecommendedHDD();
     191    }
     192    return 0;
     193}
     194
     195KStorageBus UIGuestOSTypeManager::getRecommendedHDStorageBus(const QString &strTypeId) const
     196{
     197    if (strTypeId.isEmpty())
     198        return KStorageBus_Null;
     199    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     200    {
     201        if (type.getId() == strTypeId)
     202            return type.getRecommendedHDStorageBus();
     203    }
     204    return KStorageBus_Null;
     205}
     206
     207KStorageBus UIGuestOSTypeManager::getRecommendedDVDStorageBus(const QString &strTypeId) const
     208{
     209    if (strTypeId.isEmpty())
     210        return KStorageBus_Null;
     211    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     212    {
     213        if (type.getId() == strTypeId)
     214            return type.getRecommendedDVDStorageBus();
     215    }
     216    return KStorageBus_Null;
     217}
     218
     219
     220bool UIGuestOSTypeManager::getRecommendedFloppy(const QString &strTypeId) const
     221{
     222    if (strTypeId.isEmpty())
     223        return false;
     224    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     225    {
     226        if (type.getId() == strTypeId)
     227            return type.getRecommendedFloppy();
     228    }
     229    return false;
     230}
     231
    135232UIGuestOSTypeII::UIGuestOSTypeII()
    136233{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSTypeII.h

    r101265 r101272  
    4545
    4646
    47 class UIGuestOSTypeManager
     47class SHARED_LIBRARY_STUFF UIGuestOSTypeManager
    4848{
    4949
     
    6464
    6565    KGraphicsControllerType getRecommendedGraphicsController(const QString &strTypeId) const;
     66    ULONG getRecommendedRAM(const QString &strTypeId) const;
     67    ULONG getRecommendedCPUCount(const QString &strTypeId) const;
     68    KFirmwareType getRecommendedFirmware(const QString &strTypeId) const;
     69    QString getDescription(const QString &strTypeId) const;
     70    LONG64 getRecommendedHDD(const QString &strTypeId) const;
     71    KStorageBus getRecommendedHDStorageBus(const QString &strTypeId) const;
     72    KStorageBus getRecommendedDVDStorageBus(const QString &strTypeId) const;
     73    bool getRecommendedFloppy(const QString &strTypeId) const;
    6674
    6775private:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r101263 r101272  
    326326// }
    327327
    328 UIGuestOSTypeII UINameAndSystemEditor::type() const
    329 {
    330     const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager();
    331     AssertReturn(pGuestOSTypeManager, UIGuestOSTypeII());
    332     return pGuestOSTypeManager->findGuestTypeById(m_strTypeId);
    333 }
     328// UIGuestOSTypeII UINameAndSystemEditor::type() const
     329// {
     330//     const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager();
     331//     AssertReturn(pGuestOSTypeManager, UIGuestOSTypeII());
     332//     return pGuestOSTypeManager->findGuestTypeById(m_strTypeId);
     333// }
    334334
    335335void UINameAndSystemEditor::markNameEditor(bool fError)
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r101263 r101272  
    131131
    132132    /** Returns the VM OS type. */
    133     UIGuestOSTypeII type() const;
     133    //UIGuestOSTypeII type() const;
    134134
    135135    /** Passes the @p fError to QILineEdit::mark(bool) effectively marking it for error. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r101253 r101272  
    3232/* GUI includes: */
    3333#include "UICommon.h"
     34#include "UIGuestOSTypeII.h"
    3435#include "UIMedium.h"
    3536#include "UINotificationCenter.h"
     
    149150{
    150151    CVirtualBox vbox = uiCommon().virtualBox();
    151     QString strTypeId = m_guestOSType.getId();
    152152
    153153    /* Create virtual machine: */
     
    160160                                       m_strMachineBaseName,
    161161                                       KPlatformArchitecture_x86,
    162                                        groups, strTypeId, QString(),
     162                                       groups, m_guestOSTypeId, QString(),
    163163                                       QString(), QString(), QString());
    164164        if (!vbox.isOk())
     
    180180    /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */
    181181    CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
    182     comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(strTypeId) / _1M)));
     182    comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(m_guestOSTypeId) / _1M)));
    183183    /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
    184184    if (iVPUCount > 1)
     
    279279    QUuid uMachineId = m_machine.GetId();
    280280    CSession session = uiCommon().openSession(uMachineId);
    281     if (!session.isNull())
     281    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     282    if (!session.isNull() && pManager)
    282283    {
    283284        CMachine machine = session.GetMachine();
    284285        if (!m_virtualDisk.isNull())
    285286        {
    286             KStorageBus enmHDDBus = m_guestOSType.getRecommendedHDStorageBus();
     287            KStorageBus enmHDDBus = pManager->getRecommendedHDStorageBus(m_guestOSTypeId);
    287288            CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);
    288289            if (!comHDDController.isNull())
     
    296297
    297298        /* Attach optical drive: */
    298         KStorageBus enmDVDBus = m_guestOSType.getRecommendedDVDStorageBus();
     299        KStorageBus enmDVDBus = pManager->getRecommendedDVDStorageBus(m_guestOSTypeId);
    299300        CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);
    300301        if (!comDVDController.isNull())
     
    317318
    318319        /* Attach an empty floppy drive if recommended */
    319         if (m_guestOSType.getRecommendedFloppy()) {
     320        if (pManager->getRecommendedFloppy(m_guestOSTypeId))
     321        {
    320322            CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);
    321323            if (!comFloppyController.isNull())
     
    523525}
    524526
    525 const UIGuestOSTypeII &UIWizardNewVM::guestOSType() const
    526 {
    527     return m_guestOSType;
    528 }
    529 
    530 void UIWizardNewVM::setGuestOSType(const UIGuestOSTypeII &guestOSType)
    531 {
    532     m_guestOSType = guestOSType;
     527const QString &UIWizardNewVM::guestOSTypeId() const
     528{
     529    return m_guestOSTypeId;
     530}
     531
     532void UIWizardNewVM::setGuestOSTypeId(const QString &guestOSTypeId)
     533{
     534    m_guestOSTypeId = guestOSTypeId;
    533535}
    534536
     
    789791    }
    790792    return variants;
     793}
     794
     795QString UIWizardNewVM::getGuestOSTypeDescription() const
     796{
     797    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     798    if (!pManager)
     799        return QString();
     800    return pManager->getDescription(m_guestOSTypeId);
    791801}
    792802
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r101253 r101272  
    3333
    3434/* GUI includes: */
    35 #include "UIGuestOSTypeII.h"
    3635#include "UINativeWizard.h"
    3736
     
    104103        void setGuestOSFamilyId(const QString &strGuestOSFamilyId);
    105104
    106         const UIGuestOSTypeII &guestOSType() const;
    107         void setGuestOSType(const UIGuestOSTypeII &guestOSType);
     105        const QString &guestOSTypeId() const;
     106        void setGuestOSTypeId(const QString &guestOSType);
    108107
    109108        bool installGuestAdditions() const;
     
    163162        void setDetectedWindowsImageNamesAndIndices(const QVector<QString> &names, const QVector<ulong> &ids);
    164163        const QVector<QString> &detectedWindowsImageNames() const;
    165     const QVector<ulong> &detectedWindowsImageIndices() const;
     164        const QVector<ulong> &detectedWindowsImageIndices() const;
    166165
    167166        void setSelectedWindowImageIndex(ulong uIndex);
     
    169168
    170169        QVector<KMediumVariant> mediumVariants() const;
     170
     171       QString getGuestOSTypeDescription() const;
    171172    /** @} */
    172173
     
    219220       QString  m_strGuestOSFamilyId;
    220221       /** Holds the VM OS type. */
    221        UIGuestOSTypeII m_guestOSType;
     222       QString m_guestOSTypeId;
    222223
    223224       /** True if guest additions are to be installed during unattended install. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPage.cpp

    r101253 r101272  
    3737#include "QIToolButton.h"
    3838#include "UIIconPool.h"
     39#include "UIGuestOSTypeII.h"
    3940#include "UIMediaComboBox.h"
    4041#include "UIMediumSelector.h"
     
    4748/* COM includes: */
    4849#include "COMEnums.h"
    49 #include "CGuestOSType.h"
    5050#include "CSystemProperties.h"
    5151
     
    206206    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
    207207    AssertReturnVoid(pWizard);
    208     const UIGuestOSTypeII &OSType = pWizard->guestOSType();
    209 
    210     QUuid uMediumId = UIWizardNewVMDiskCommon::getWithFileOpenDialog(OSType.getId(),
     208
     209    QUuid uMediumId = UIWizardNewVMDiskCommon::getWithFileOpenDialog(pWizard->guestOSTypeId(),
    211210                                                                     pWizard->machineFolder(),
    212211                                                                     this, m_pActionPool);
     
    266265
    267266    LONG64 iRecommendedSize = 0;
    268     const UIGuestOSTypeII &type = pWizard->guestOSType();
    269     if (!type.isOk() && !m_userModifiedParameters.contains("SelectedDiskSource"))
    270     {
    271         iRecommendedSize = type.getRecommendedHDD();
     267    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     268    if (pManager && !m_userModifiedParameters.contains("SelectedDiskSource"))
     269    {
     270        iRecommendedSize = pManager->getRecommendedHDD(pWizard->guestOSTypeId());
    272271        if (iRecommendedSize != 0)
    273272        {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp

    r101253 r101272  
    110110        if (UIWizardNewVMNameOSTypeCommon::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName))
    111111        {
    112             wizardWindow<UIWizardNewVM>()->setGuestOSType(m_pNameAndSystemEditor->type());
     112            wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    113113            /* Since the type `possibly` changed: */
    114114            setOSTypeDependedValues();
     
    140140    //m_userModifiedParameters << "GuestOSType";
    141141    if (m_pNameAndSystemEditor)
    142         wizardWindow<UIWizardNewVM>()->setGuestOSType(m_pNameAndSystemEditor->type());
     142        wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    143143    setOSTypeDependedValues();
    144144}
     
    148148    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
    149149    AssertReturnVoid(pWizard);
    150     const UIGuestOSTypeII &OSType = pWizard->guestOSType();
    151     AssertReturnVoid(!OSType.isOk());
    152     QUuid uMediumId = UIWizardNewVMDiskCommon::getWithFileOpenDialog(OSType.getId(),
     150    QUuid uMediumId = UIWizardNewVMDiskCommon::getWithFileOpenDialog(pWizard->guestOSTypeId(),
    153151                                                                     pWizard->machineFolder(),
    154152                                                                     this, m_pActionPool);
     
    345343{
    346344    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
     345    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
    347346    AssertReturnVoid(pWizard);
    348 
     347    AssertReturnVoid(pManager);
     348
     349    QString strTypeId = pWizard->guestOSTypeId();
    349350    /* Get recommended 'ram' field value: */
    350     const UIGuestOSTypeII &type = pWizard->guestOSType();
    351     ULONG recommendedRam = type.getRecommendedRAM();
     351    ULONG recommendedRam = pManager->getRecommendedRAM(strTypeId);
    352352
    353353    if (m_pHardwareWidgetContainer)
     
    363363
    364364        /* Set Firmware Type of the widget and the wizard: */
    365         KFirmwareType fwType = type.getRecommendedFirmware();
     365        KFirmwareType fwType = pManager->getRecommendedFirmware(strTypeId);
    366366        if (!m_userModifiedParameters.contains("EFIEnabled"))
    367367        {
     
    371371
    372372        /* Initialize CPU count:*/
    373         int iCPUCount = type.getRecommendedCPUCount();
     373        int iCPUCount = pManager->getRecommendedCPUCount(strTypeId);
    374374        if (!m_userModifiedParameters.contains("CPUCount"))
    375375        {
     
    380380    }
    381381
    382     LONG64 iRecommendedDiskSize = type.getRecommendedHDD();
     382    LONG64 iRecommendedDiskSize = pManager->getRecommendedHDD(strTypeId);
    383383    /* Prepare initial disk choice: */
    384384    if (!m_userModifiedParameters.contains("SelectedDiskSource"))
     
    425425            /* Guest OS type: */
    426426            pWizard->setGuestOSFamilyId(m_pNameAndSystemEditor->familyId());
    427             pWizard->setGuestOSType(m_pNameAndSystemEditor->type());
     427            pWizard->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    428428            /* Vm name, folder, file path etc. will be initilized by composeMachineFilePath: */
    429429        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePage.cpp

    r101253 r101272  
    3232#include "QIRichTextLabel.h"
    3333#include "UIBaseMemoryEditor.h"
     34#include "UIGuestOSTypeII.h"
    3435#include "UIVirtualCPUEditor.h"
    3536#include "UIWizardNewVM.h"
     
    3738#include "UIWizardNewVMHardwarePage.h"
    3839
    39 /* COM includes: */
    40 #include "CGuestOSType.h"
    4140
    4241UIWizardNewVMHardwarePage::UIWizardNewVMHardwarePage()
     
    8988
    9089    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
    91     if (pWizard && m_pHardwareWidgetContainer)
     90    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     91
     92    if (pManager && pWizard && m_pHardwareWidgetContainer)
    9293    {
    93         const UIGuestOSTypeII &type = pWizard->guestOSType();
     94        const QString &strTypeId = pWizard->guestOSTypeId();
    9495
    9596        m_pHardwareWidgetContainer->blockSignals(true);
    9697        if (!m_userModifiedParameters.contains("MemorySize"))
    9798        {
    98             ULONG recommendedRam = type.getRecommendedRAM();
     99            ULONG recommendedRam = pManager->getRecommendedRAM(strTypeId);
    99100            m_pHardwareWidgetContainer->setMemorySize(recommendedRam);
    100101            pWizard->setMemorySize(recommendedRam);
     
    102103        if (!m_userModifiedParameters.contains("CPUCount"))
    103104        {
    104             ULONG recommendedCPUs = type.getRecommendedCPUCount();
     105            ULONG recommendedCPUs = pManager->getRecommendedCPUCount(strTypeId);
    105106            m_pHardwareWidgetContainer->setCPUCount(recommendedCPUs);
    106107            pWizard->setCPUCount(recommendedCPUs);
     
    108109        if (!m_userModifiedParameters.contains("EFIEnabled"))
    109110        {
    110             KFirmwareType fwType = type.getRecommendedFirmware();
     111            KFirmwareType fwType = pManager->getRecommendedFirmware(strTypeId);
    111112            m_pHardwareWidgetContainer->setEFIEnabled(fwType != KFirmwareType_BIOS);
    112113            pWizard->setEFIEnabled(fwType != KFirmwareType_BIOS);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r101232 r101272  
    480480        if (UIWizardNewVMNameOSTypeCommon::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName))
    481481        {
    482             wizardWindow<UIWizardNewVM>()->setGuestOSType(m_pNameAndSystemEditor->type());
     482            wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    483483            m_userModifiedParameters << "GuestOSTypeFromName";
    484484        }
     
    500500    //m_userModifiedParameters << "GuestOSType";
    501501    if (m_pNameAndSystemEditor)
    502         wizardWindow<UIWizardNewVM>()->setGuestOSType(m_pNameAndSystemEditor->type());
     502        wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    503503}
    504504
     
    591591        {
    592592            pWizard->setGuestOSFamilyId(m_pNameAndSystemEditor->familyId());
    593             pWizard->setGuestOSType(m_pNameAndSystemEditor->type());
     593            pWizard->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
    594594            /* Vm name, folder, file path etc. will be initilized by composeMachineFilePath: */
    595595        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMSummaryPage.cpp

    r101253 r101272  
    3636#include "QITreeView.h"
    3737#include "UIIconPool.h"
     38#include "UIGuestOSTypeII.h"
    3839#include "UIMessageCenter.h"
    3940#include "UINotificationCenter.h"
     
    354355    pNameRoot->addChild(UIWizardNewVM::tr("Machine Folder"), pWizard->machineFolder());
    355356    pNameRoot->addChild(UIWizardNewVM::tr("ISO Image"), pWizard->ISOFilePath());
    356     pNameRoot->addChild(UIWizardNewVM::tr("Guest OS Type"), pWizard->guestOSType().getDescription());
     357    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     358    if (pManager)
     359        pNameRoot->addChild(UIWizardNewVM::tr("Guest OS Type"), pManager->getDescription(pWizard->guestOSTypeId()));
    357360
    358361    const QString &ISOPath = pWizard->ISOFilePath();
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