VirtualBox

Changeset 101242 in vbox


Ignore:
Timestamp:
Sep 22, 2023 3:41:24 PM (17 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10523. Mics. fixes in name and type selection widget.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r101232 r101242  
    316316}
    317317
    318 void UINameAndSystemEditor::setType(const CGuestOSType &enmType)
    319 {
    320     // WORKAROUND:
    321     // We're getting here with a NULL enmType when creating new VMs.
    322     // Very annoying, so just workarounded for now.
    323     /** @todo find out the reason and way to fix that.. */
    324     if (enmType.isNull())
    325         return;
    326 
    327     /* Pass to function above: */
    328     setTypeId(enmType.GetId(), enmType.GetFamilyId());
    329 }
     318// void UINameAndSystemEditor::setType(const CGuestOSType &enmType)
     319// {
     320//     // WORKAROUND:
     321//     // We're getting here with a NULL enmType when creating new VMs.
     322//     // Very annoying, so just workarounded for now.
     323//     /** @todo find out the reason and way to fix that.. */
     324//     if (enmType.isNull())
     325//         return;
     326
     327//     /* Pass to function above: */
     328//     setTypeId(enmType.GetId(), enmType.GetFamilyId());
     329// }
    330330
    331331CGuestOSType UINameAndSystemEditor::type() const
     
    402402        m_pLabelType->setText(tr("&Version:"));
    403403    if (m_pLabelVariant)
    404         m_pLabelVariant->setText(tr("Variant:"));
     404        m_pLabelVariant->setText(tr("Kind:"));
    405405
    406406    if (m_pEditorName)
     
    427427    AssertReturnVoid(pGuestOSTypeManager);
    428428
    429     QString strFamilyId = m_pComboFamily->itemData(index, FamilyID).toString();
    430 
    431     AssertReturnVoid(!strFamilyId.isEmpty());
     429    m_strFamilyId = m_pComboFamily->itemData(index, FamilyID).toString();
     430
     431    AssertReturnVoid(!m_strFamilyId.isEmpty());
    432432
    433433    m_pComboVariant->blockSignals(true);
     
    437437    m_pComboVariant->clear();
    438438
    439     const QStringList variantList = pGuestOSTypeManager->getVariantListForFamilyId(strFamilyId);
     439    const QStringList variantList = pGuestOSTypeManager->getVariantListForFamilyId(m_strFamilyId);
    440440
    441441    if (variantList.isEmpty())
     
    444444        m_pLabelVariant->setEnabled(false);
    445445        /* If variant list is empty the all the types of the family are added to typ selection combo: */
    446         populateTypeCombo(pGuestOSTypeManager->getTypeListForFamilyId(strFamilyId));
     446        populateTypeCombo(pGuestOSTypeManager->getTypeListForFamilyId(m_strFamilyId));
    447447    }
    448448    else
     
    461461    // m_pComboType->clear();
    462462
    463     // /* Acquire family ID: */
    464     // m_strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString();
    465463
    466464    // /* Populate combo-box with OS types related to currently selected family id: */
     
    472470    // }
    473471
     472
     473    // /* Update all the stuff: */
     474    // sltTypeChanged(m_pComboType->currentIndex());
     475
     476    // /* Unlock the signals of m_pComboType: */
     477    // m_pComboType->blockSignals(false);
     478
     479    /* Notify listeners about this change: */
     480    emit sigOSFamilyChanged(m_strFamilyId);
     481}
     482
     483void UINameAndSystemEditor::sltVariantChanged(const QString &strVariant)
     484{
     485    const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager();
     486    AssertReturnVoid(pGuestOSTypeManager);
     487    m_strVariant = strVariant;
     488    populateTypeCombo(pGuestOSTypeManager->getTypeListForVariant(strVariant));
     489}
     490
     491void UINameAndSystemEditor::populateTypeCombo(const UIGuestOSTypeManager::UIGuestOSTypeInfo &typeList)
     492{
     493    AssertReturnVoid(m_pComboType);
     494    AssertReturnVoid(!typeList.isEmpty());
     495
     496    m_pComboType->blockSignals(true);
     497    m_pComboType->clear();
     498    for (int i = 0; i < typeList.size(); ++i)
     499    {
     500        m_pComboType->addItem(typeList[i].second);
     501        m_pComboType->setItemData(i, typeList[i].first, TypeID);
     502    }
     503    m_pComboType->blockSignals(false);
     504    selectPreferredType();
     505    sltTypeChanged(m_pComboType->currentIndex());
     506}
     507
     508void UINameAndSystemEditor::selectPreferredType()
     509{
    474510    // /* Select the most recently chosen item: */
    475511    // if (m_currentIds.contains(m_strFamilyId))
     
    481517    // }
    482518    // /* Or select Windows 10 item for Windows family as default: */
    483     // else if (m_strFamilyId == "Windows")
    484     // {
    485     //     QString strDefaultID = "Windows11_64";
    486     //     const int iIndexWin = m_pComboType->findData(strDefaultID, TypeID);
    487     //     if (iIndexWin != -1)
    488     //         m_pComboType->setCurrentIndex(iIndexWin);
    489     // }
    490     // /* Or select Oracle Linux item for Linux family as default: */
    491     // else if (m_strFamilyId == "Linux")
    492     // {
    493     //     QString strDefaultID = "Oracle_64";
    494     //     const int iIndexOracle = m_pComboType->findData(strDefaultID, TypeID);
    495     //     if (iIndexOracle != -1)
    496     //         m_pComboType->setCurrentIndex(iIndexOracle);
    497     // }
    498     // else if (m_strFamilyId == "Other")
    499     // {
    500     //     QString strDefaultID = "Other_64";
    501     //     const int iIndexOther = m_pComboType->findData(strDefaultID, TypeID);
    502     //     if (iIndexOther != -1)
    503     //         m_pComboType->setCurrentIndex(iIndexOther);
    504     // }
    505     // /* Else try to pick the first 64-bit one if it exists.: */
    506519    // else
    507     // {
    508     //    QString strDefaultID = "_64";
    509     //    const int iIndexAll = m_pComboType->findData(strDefaultID, TypeID, Qt::MatchContains);
    510     //    if (iIndexAll != -1)
    511     //        m_pComboType->setCurrentIndex(iIndexAll);
    512     //    else
    513     //        m_pComboType->setCurrentIndex(0);
    514     // }
    515 
    516     // /* Update all the stuff: */
    517     // sltTypeChanged(m_pComboType->currentIndex());
    518 
    519     // /* Unlock the signals of m_pComboType: */
    520     // m_pComboType->blockSignals(false);
    521 
    522     // /* Notify listeners about this change: */
    523     // emit sigOSFamilyChanged(m_strFamilyId);
    524 }
    525 
    526 void UINameAndSystemEditor::sltVariantChanged(const QString &strVariant)
    527 {
    528     const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager();
    529     AssertReturnVoid(pGuestOSTypeManager);
    530 
    531     populateTypeCombo(pGuestOSTypeManager->getTypeListForVariant(strVariant));
    532 }
    533 
    534 void UINameAndSystemEditor::populateTypeCombo(const UIGuestOSTypeManager::UIGuestOSTypeInfo &typeList)
    535 {
    536     AssertReturnVoid(m_pComboType);
    537     AssertReturnVoid(!typeList.isEmpty());
    538 
    539     m_pComboType->blockSignals(true);
    540     m_pComboType->clear();
    541     for (int i = 0; i < typeList.size(); ++i)
    542     {
    543         m_pComboType->addItem(typeList[i].second);
    544         m_pComboType->setItemData(i, typeList[i].first, TypeID);
    545     }
    546     m_pComboType->blockSignals(false);
    547     sltTypeChanged(m_pComboType->currentIndex());
     520    if (m_strFamilyId == "Windows")
     521    {
     522        QString strDefaultID = "Windows11_x64";
     523        const int iIndexWin = m_pComboType->findData(strDefaultID, TypeID);
     524        if (iIndexWin != -1)
     525        {
     526            m_pComboType->setCurrentIndex(iIndexWin);
     527            return;
     528        }
     529    }
     530    /* Or select Oracle Linux item for Linux family as default: */
     531    if (m_strVariant == "Oracle")
     532    {
     533        QString strDefaultID = "Oracle_x64";
     534        const int iIndexOracle = m_pComboType->findData(strDefaultID, TypeID);
     535        if (iIndexOracle != -1)
     536        {
     537            m_pComboType->setCurrentIndex(iIndexOracle);
     538            return;
     539        }
     540    }
     541
     542    /* Else try to pick the first 64-bit one if it exists.: */
     543    QString strDefaultID = "_x64";
     544    const int iIndexAll = m_pComboType->findData(strDefaultID, TypeID, Qt::MatchContains);
     545    if (iIndexAll != -1)
     546        m_pComboType->setCurrentIndex(iIndexAll);
     547    else
     548        m_pComboType->setCurrentIndex(0);
    548549}
    549550
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r101232 r101242  
    5353    Q_OBJECT;
    5454    Q_PROPERTY(QString name READ name WRITE setName);
    55     Q_PROPERTY(CGuestOSType type READ type WRITE setType);
    5655
    5756    /** Simple struct representing CGuestOSType cache. */
     
    130129    QString familyId() const;
    131130
    132     /** Defines the VM OS @a enmType. */
    133     void setType(const CGuestOSType &enmType);
    134131    /** Returns the VM OS type. */
    135132    CGuestOSType type() const;
     
    182179    ulong selectedEditionIndex() const;
    183180    void populateTypeCombo(const QList<QPair<QString, QString> > &typeList);
     181    void selectPreferredType();
    184182
    185183    /** @name Arguments
     
    206204        /** Holds the VM OS family ID. */
    207205        QString  m_strFamilyId;
     206        QString  m_strVariant;
    208207
    209208        /** Holds the currently chosen OS type IDs on per-family basis. */
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