VirtualBox

Changeset 73129 in vbox


Ignore:
Timestamp:
Jul 13, 2018 4:12:14 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123717
Message:

FE/Qt: bugref:9206: A bit of cleanup for UINameAndSystemEditor.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

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

    r73119 r73129  
    137137    m_pComboType->clear();
    138138
     139    /* Acquire family ID: */
     140    const QString strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString();
     141
    139142    /* Populate combo-box with OS types related to currently selected family id: */
    140     const QString strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString();
    141     const QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(strFamilyId);
    142     for (int i = 0; i < types.size(); ++i)
    143     {
    144         /* Skip 64bit OS types is hardware virtualization or long mode is not supported: */
    145         if (types.at(i).GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
     143    foreach (const CGuestOSType &comType, vboxGlobal().vmGuestOSTypeList(strFamilyId))
     144    {
     145        /* Skip 64bit OS types if hardware virtualization or long mode is not supported: */
     146        if (comType.GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
    146147            continue;
    147148        const int iIndex = m_pComboType->count();
    148         m_pComboType->insertItem(iIndex, types[i].GetDescription());
    149         m_pComboType->setItemData(iIndex, types[i].GetId(), TypeID);
     149        m_pComboType->insertItem(iIndex, comType.GetDescription());
     150        m_pComboType->setItemData(iIndex, comType.GetId(), TypeID);
    150151    }
    151152
     
    191192void UINameAndSystemEditor::sltTypeChanged(int iIndex)
    192193{
     194    /* Acquire type/family IDs: */
     195    const QString strTypeId = m_pComboType->itemData(iIndex, TypeID).toString();
     196    const QString strFamilyId = m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString();
     197
    193198    /* Save the new selected OS type: */
    194     m_enmType = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(),
    195                                         m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString());
    196     m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_enmType.GetId()));
     199    m_enmType = vboxGlobal().vmGuestOSType(strTypeId, strFamilyId);
     200
     201    /* Update selected type pixmap: */
     202    m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(strTypeId));
    197203
    198204    /* Save the most recently used item: */
    199     m_currentIds[m_enmType.GetFamilyId()] = m_enmType.GetId();
     205    m_currentIds[strFamilyId] = strTypeId;
    200206
    201207    /* Notifies listeners about OS type change: */
     
    211217    /* Prepare connections: */
    212218    prepareConnections();
    213     /* Retranslate: */
     219    /* Apply language settings: */
    214220    retranslateUi();
    215221}
     
    229235    if (pMainLayout)
    230236    {
    231         /* Configure main-layout: */
    232237        pMainLayout->setContentsMargins(0, 0, 0, 0);
    233238
     239        int iRow = 0;
     240
     241        /* Create name label: */
    234242        m_pNameLabel = new QLabel;
    235         int iRow = 0;
    236243        if (m_pNameLabel)
    237244        {
    238245            m_pNameLabel->setAlignment(Qt::AlignRight);
    239246            m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     247
     248            /* Add into layout: */
    240249            pMainLayout->addWidget(m_pNameLabel, iRow, 0, 1, 1);
    241250        }
     251        /* Create name editor: */
    242252        m_pNameLineEdit = new QILineEdit;
    243253        if (m_pNameLineEdit)
    244254        {
    245             pMainLayout->addWidget(m_pNameLineEdit, iRow++, 1, 1, 2);
    246         }
     255            /* Add into layout: */
     256            pMainLayout->addWidget(m_pNameLineEdit, iRow, 1, 1, 2);
     257        }
     258
     259        ++iRow;
    247260
    248261        if (m_fChooseLocation)
    249262        {
     263            /* Create path label: */
    250264            m_pPathLabel = new QLabel;
    251265            if (m_pPathLabel)
     
    253267                m_pPathLabel->setAlignment(Qt::AlignRight);
    254268                m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     269
     270                /* Add into layout: */
    255271                pMainLayout->addWidget(m_pPathLabel, iRow, 0, 1, 1);
    256272            }
    257 
     273            /* Create path selector: */
    258274            m_pPathSelector = new UIFilePathSelector;
    259275            if (m_pPathSelector)
    260276            {
    261                 pMainLayout->addWidget(m_pPathSelector, iRow++, 1, 1, 2);
    262277                QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    263278                m_pPathSelector->setPath(strDefaultMachineFolder);
    264279                m_pPathSelector->setDefaultPath(strDefaultMachineFolder);
     280
     281                /* Add into layout: */
     282                pMainLayout->addWidget(m_pPathSelector, iRow, 1, 1, 2);
    265283            }
     284
     285            ++iRow;
    266286        }
    267287
     
    270290        if (m_pLabelFamily)
    271291        {
    272             /* Configure VM OS family label: */
    273292            m_pLabelFamily->setAlignment(Qt::AlignRight);
    274293            m_pLabelFamily->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    275             /* Add VM OS family label into main-layout: */
     294
     295            /* Add into layout: */
    276296            pMainLayout->addWidget(m_pLabelFamily, iRow, 0);
    277297        }
     298
    278299        int iIconRow = iRow;
     300
    279301        /* Create VM OS family combo: */
    280302        m_pComboFamily = new QComboBox;
    281303        if (m_pComboFamily)
    282304        {
    283             /* Configure VM OS family combo: */
    284305            m_pComboFamily->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    285306            m_pLabelFamily->setBuddy(m_pComboFamily);
    286             /* Add VM OS family combo into main-layout: */
    287             pMainLayout->addWidget(m_pComboFamily, iRow++, 1);
    288         }
     307
     308            /* Add into layout: */
     309            pMainLayout->addWidget(m_pComboFamily, iRow, 1);
     310        }
     311
     312        ++iRow;
    289313
    290314        /* Create VM OS type label: */
     
    292316        if (m_pLabelType)
    293317        {
    294             /* Configure VM OS type label: */
    295318            m_pLabelType->setAlignment(Qt::AlignRight);
    296319            m_pLabelType->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    297             /* Add VM OS type label into main-layout: */
     320
     321            /* Add into layout: */
    298322            pMainLayout->addWidget(m_pLabelType, iRow, 0);
    299323        }
    300 
    301324        /* Create VM OS type combo: */
    302325        m_pComboType = new QComboBox;
    303326        if (m_pComboType)
    304327        {
    305             /* Configure VM OS type combo: */
    306328            m_pComboType->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    307329            m_pLabelType->setBuddy(m_pComboType);
    308             /* Add VM OS type combo into main-layout: */
    309             pMainLayout->addWidget(m_pComboType, iRow++, 1);
    310         }
     330
     331            /* Add into layout: */
     332            pMainLayout->addWidget(m_pComboType, iRow, 1);
     333        }
     334
     335        ++iRow;
    311336
    312337        /* Create sub-layout: */
     
    318343            if (m_pIconType)
    319344            {
    320                 /* Configure VM OS type icon: */
    321345                m_pIconType->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    322                 /* Add VM OS type icon into sub-layout: */
     346
     347                /* Add into layout: */
    323348                pLayoutIcon->addWidget(m_pIconType);
    324349            }
     350
    325351            /* Add stretch to sub-layout: */
    326352            pLayoutIcon->addStretch();
    327             /* Add sub-layout into main-layout: */
     353
     354            /* Add into layout: */
    328355            pMainLayout->addLayout(pLayoutIcon, iIconRow, 2, 2, 1);
    329356        }
     
    366393}
    367394
    368 void UINameAndSystemEditor::setNameFieldValidator(const QString &strValidatorString)
     395void UINameAndSystemEditor::setNameFieldValidator(const QString &strValidator)
    369396{
    370397    if (!m_pNameLineEdit)
    371398        return;
    372     m_pNameLineEdit->setValidator(new QRegExpValidator(QRegExp(strValidatorString), this));
    373 }
     399    m_pNameLineEdit->setValidator(new QRegExpValidator(QRegExp(strValidator), this));
     400}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r72603 r73129  
    7272    void setType(const CGuestOSType &enmType);
    7373
    74     void setNameFieldValidator(const QString &strValidatorString);
     74    /** Defines the name-field @a strValidator. */
     75    void setNameFieldValidator(const QString &strValidator);
    7576
    7677protected:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette