VirtualBox

Changeset 101226 in vbox for trunk


Ignore:
Timestamp:
Sep 21, 2023 4:10:07 PM (17 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10523. Fixing 'guest os type detection from vm name' functionality.

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

Legend:

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

    r101209 r101226  
    109109}
    110110
     111UIGuestOSTypeII UIGuestOSTypeManager::findGuestTypeById(const QString &strTypeId) const
     112{
     113    if (strTypeId.isEmpty())
     114        return UIGuestOSTypeII();
     115    foreach (const UIGuestOSTypeII &type, m_guestOSTypes)
     116    {
     117        if (type.getId() == strTypeId)
     118            return type;
     119    }
     120    return UIGuestOSTypeII();
     121}
     122
     123UIGuestOSTypeII::UIGuestOSTypeII()
     124{
     125}
    111126
    112127UIGuestOSTypeII::UIGuestOSTypeII(const CGuestOSType &comGuestOSType)
    113128    : m_comGuestOSType(comGuestOSType)
    114129{
     130}
     131
     132bool UIGuestOSTypeII::isOk() const
     133{
     134    return (!m_comGuestOSType.isNull() && m_comGuestOSType.isOk());
    115135}
    116136
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSTypeII.h

    r101209 r101226  
    6161    UIGuestOSTypeInfo getTypeListForVariant(const QString &strVariant) const;
    6262
     63    UIGuestOSTypeII findGuestTypeById(const QString &strTypeId) const;
     64
    6365private:
    6466
     
    7476class SHARED_LIBRARY_STUFF UIGuestOSTypeII
    7577{
     78
    7679public:
    7780
    7881
    7982    UIGuestOSTypeII(const CGuestOSType &comGuestOSType);
     83    UIGuestOSTypeII();
    8084
    8185    const QString &getFamilyId() const;
     
    8589    const QString &getDescription() const;
    8690
     91    bool isOk() const;
    8792
    8893private:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r101209 r101226  
    4747enum
    4848{
    49     TypeID = Qt::UserRole + 1
     49    TypeID = Qt::UserRole + 1,
     50    FamilyID = Qt::UserRole + 2
    5051};
    5152
     
    250251}
    251252
     253void UINameAndSystemEditor::setGuestOSTypeByTypeId(const QString &strTypeId)
     254{
     255    AssertReturnVoid(m_pComboFamily);
     256
     257    const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager();
     258    AssertReturnVoid(pGuestOSTypeManager);
     259    const UIGuestOSTypeII &type = pGuestOSTypeManager->findGuestTypeById(strTypeId);
     260    if (!type.isOk())
     261        return;
     262
     263    int iFamilyComboIndex = -1;
     264    /* We already have to have an item in the family combo box for this family id: */
     265    for (int i = 0; i < m_pComboFamily->count() && iFamilyComboIndex == -1; ++i)
     266    {
     267        QString strComboFamilyId = m_pComboFamily->itemData(i, FamilyID).toString();
     268        if (!strComboFamilyId.isEmpty() && strComboFamilyId == type.getFamilyId())
     269            iFamilyComboIndex = i;
     270    }
     271    /* Bail out if family combo has no such item: */
     272    if (iFamilyComboIndex == -1)
     273        return;
     274    /* Set the family combo's index. This will cause variant combo to be populated accordingly: */
     275    m_pComboFamily->setCurrentIndex(iFamilyComboIndex);
     276
     277    /* If variant is not empty then try to select correct index. This will populate type combo: */
     278    if (!type.getVariant().isEmpty())
     279    {
     280        int index = -1;
     281        for (int i = 0; i < m_pComboVariant->count() && index == -1; ++i)
     282        {
     283            if (type.getVariant() == m_pComboVariant->itemText(i))
     284                index = i;
     285        }
     286        if (index != -1)
     287            m_pComboVariant->setCurrentIndex(index);
     288        else
     289            return;
     290    }
     291
     292    /* At this point type combo should include the type we want to select: */
     293    int iTypeIndex = -1;
     294    for (int i = 0; i < m_pComboType->count() && iTypeIndex == -1; ++i)
     295    {
     296        if (strTypeId == m_pComboType->itemData(i, TypeID))
     297            iTypeIndex = i;
     298    }
     299    if (iTypeIndex != -1)
     300        m_pComboType->setCurrentIndex(iTypeIndex);
     301}
     302
    252303QString UINameAndSystemEditor::typeId() const
    253304{
     
    375426    AssertReturnVoid(pGuestOSTypeManager);
    376427
    377     QString strFamilyId = m_pComboFamily->itemData(index).toString();
     428    QString strFamilyId = m_pComboFamily->itemData(index, FamilyID).toString();
    378429
    379430    AssertReturnVoid(!strFamilyId.isEmpty());
     
    742793
    743794        m_pComboFamily->addItem(families[i].second);
    744         m_pComboFamily->setItemData(i, families[i].first);
     795        m_pComboFamily->setItemData(i, families[i].first, FamilyID);
    745796
    746797        /* Fill in the type cache: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r101209 r101226  
    121121    void setISOImagePath(const QString &strPath);
    122122
     123    /* strTypeId should be one of the type ids defined in Global.cpp and returned by IGuestOSType::getId(). */
     124    void setGuestOSTypeByTypeId(const QString &strTypeId);
    123125    /** Defines the VM OS @a strTypeId and @a strFamilyId if passed. */
    124126    void setTypeId(QString strTypeId, QString strFamilyId = QString());
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r101217 r101226  
    189189    { QRegularExpression("jessie.*32",                        QRegularExpression::CaseInsensitiveOption), "Debian8" },
    190190    { QRegularExpression("stretch.*64",                       QRegularExpression::CaseInsensitiveOption), "Debian9_x64" },
     191    { QRegularExpression("debian.*9.*64",                     QRegularExpression::CaseInsensitiveOption), "Debian9_x64" },
     192    { QRegularExpression("debian.*9.*32",                     QRegularExpression::CaseInsensitiveOption), "Debian9" },
    191193    { QRegularExpression("stretch.*32",                       QRegularExpression::CaseInsensitiveOption), "Debian9" },
    192194    { QRegularExpression("buster.*64",                        QRegularExpression::CaseInsensitiveOption), "Debian10_x64" },
     195    { QRegularExpression("debian.*10.*64",                    QRegularExpression::CaseInsensitiveOption), "Debian10_x64" },
    193196    { QRegularExpression("buster.*32",                        QRegularExpression::CaseInsensitiveOption), "Debian10" },
     197    { QRegularExpression("debian.*10.*32",                    QRegularExpression::CaseInsensitiveOption), "Debian10" },
    194198    { QRegularExpression("bullseye.*64",                      QRegularExpression::CaseInsensitiveOption), "Debian11_x64" },
     199    { QRegularExpression("debian.*11.*64",                    QRegularExpression::CaseInsensitiveOption), "Debian11_x64" },
    195200    { QRegularExpression("bullseye.*32",                      QRegularExpression::CaseInsensitiveOption), "Debian11" },
     201    { QRegularExpression("debian.*11.*32",                    QRegularExpression::CaseInsensitiveOption), "Debian11" },
    196202    { QRegularExpression("bookworm.*64",                      QRegularExpression::CaseInsensitiveOption), "Debian12_x64" },
     203    { QRegularExpression("debian.*12.*64",                    QRegularExpression::CaseInsensitiveOption), "Debian12_x64" },
     204    { QRegularExpression("debian.*12",                        QRegularExpression::CaseInsensitiveOption), "Debian12" },
    197205    { QRegularExpression("bookworm.*32",                      QRegularExpression::CaseInsensitiveOption), "Debian12" },
    198206    { QRegularExpression("((trixie)|(sid)).*64",              QRegularExpression::CaseInsensitiveOption), "Debian_x64" },
     
    280288        if (strNewName.contains(gs_OSTypePattern[i].pattern))
    281289        {
    282             pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
     290            pNameAndSystemEditor->setGuestOSTypeByTypeId(gs_OSTypePattern[i].pcstId);
    283291            return true;
    284292        }
     
    290298{
    291299    AssertReturn(pNameAndSystemEditor, false);
     300
    292301    if (!strDetectedOSType.isEmpty())
    293302    {
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