VirtualBox

Ignore:
Timestamp:
Apr 26, 2016 4:00:22 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​​​​​​​bugref:6769: Rework/cleanup for VM properties editor (part 05): Prepare cascade.

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

Legend:

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

    r60697 r60708  
    4242    : QIWithRetranslateUI<QWidget>(pParent)
    4343{
    44     /* Register CGuestOSType type: */
    45     qRegisterMetaType<CGuestOSType>();
    46 
     44    /* Prepare: */
     45    prepare();
     46}
     47
     48void UINameAndSystemEditor::prepare()
     49{
     50    /* Prepare this: */
     51    prepareThis();
     52    /* Prepare widgets: */
     53    prepareWidgets();
     54    /* Prepare connections: */
     55    prepareConnections();
     56    /* Retranslate: */
     57    retranslateUi();
     58}
     59
     60void UINameAndSystemEditor::prepareThis()
     61{
     62    /* Check if host supports (AMD-V or VT-x) and long mode: */
     63    CHost host = vboxGlobal().host();
     64    m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
     65    m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
     66}
     67
     68void UINameAndSystemEditor::prepareWidgets()
     69{
    4770    /* Create main-layout: */
    4871    QGridLayout *pMainLayout = new QGridLayout(this);
     72    AssertPtrReturnVoid(pMainLayout);
    4973    {
    5074        /* Configure main-layout: */
     
    5377        /* Create VM name label: */
    5478        m_pLabelName = new QLabel;
     79        AssertPtrReturnVoid(m_pLabelName);
    5580        {
    5681            /* Configure VM name label: */
     
    6388        /* Create VM name editor: */
    6489        m_pEditorName = new QLineEdit;
     90        AssertPtrReturnVoid(m_pEditorName);
    6591        {
    6692            /* Configure VM name editor: */
     
    7399        /* Create VM OS family label: */
    74100        m_pLabelFamily = new QLabel;
     101        AssertPtrReturnVoid(m_pLabelFamily);
    75102        {
    76103            /* Configure VM OS family label: */
     
    83110        /* Create VM OS family combo: */
    84111        m_pComboFamily = new QComboBox;
     112        AssertPtrReturnVoid(m_pComboFamily);
    85113        {
    86114            /* Configure VM OS family combo: */
     
    93121        /* Create VM OS type label: */
    94122        m_pLabelType = new QLabel;
     123        AssertPtrReturnVoid(m_pLabelType);
    95124        {
    96125            /* Configure VM OS type label: */
     
    103132        /* Create VM OS type combo: */
    104133        m_pComboType = new QComboBox;
     134        AssertPtrReturnVoid(m_pComboType);
    105135        {
    106136            /* Configure VM OS type combo: */
     
    113143        /* Create sub-layout: */
    114144        QVBoxLayout *pLayoutIcon = new QVBoxLayout;
     145        AssertPtrReturnVoid(pLayoutIcon);
    115146        {
    116147            /* Create VM OS type icon: */
    117148            m_pIconType = new QLabel;
     149            AssertPtrReturnVoid(m_pIconType);
    118150            {
    119151                /* Configure VM OS type icon: */
     
    122154                pLayoutIcon->addWidget(m_pIconType);
    123155            }
     156
    124157            /* Add stretch to sub-layout: */
    125158            pLayoutIcon->addStretch();
     
    129162    }
    130163
    131     /* Check if host supports (AMD-V or VT-x) and long mode: */
    132     CHost host = vboxGlobal().host();
    133     m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
    134     m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
    135 
    136     /* Fill OS family selector: */
     164    /* Initialize VM OS family combo
     165     * after all widgets were created: */
     166    prepareFamilyCombo();
     167}
     168
     169void UINameAndSystemEditor::prepareFamilyCombo()
     170{
     171    /* Populate VM OS family combo: */
    137172    const QList<CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList();
    138173    for (int i = 0; i < families.size(); ++i)
     
    142177        m_pComboFamily->setItemData(i, families.at(i).GetFamilyId(), TypeID);
    143178    }
     179
     180    /* Choose the 1st item to be the current: */
    144181    m_pComboFamily->setCurrentIndex(0);
     182    /* And update the linked widgets accordingly: */
    145183    sltFamilyChanged(m_pComboFamily->currentIndex());
    146 
    147     /* Setup connections: */
     184}
     185
     186void UINameAndSystemEditor::prepareConnections()
     187{
     188    /* Prepare connections: */
    148189    connect(m_pEditorName, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &)));
    149190    connect(m_pComboFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int)));
    150191    connect(m_pComboType, SIGNAL(currentIndexChanged(int)), this, SLOT(sltTypeChanged(int)));
    151 
    152     /* Retranslate: */
    153     retranslateUi();
    154192}
    155193
     
    261299void UINameAndSystemEditor::sltTypeChanged(int iIndex)
    262300{
    263     /* Save the new selected OS Type: */
     301    /* Save the new selected OS type: */
    264302    m_type = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(),
    265303                                        m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString());
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r60696 r60708  
    6666protected:
    6767
     68    /** @name Prepare cascade.
     69      * @{ */
     70        /** Prepares all. */
     71        void prepare();
     72        /** Prepares this. */
     73        void prepareThis();
     74        /** Prepares widgets. */
     75        void prepareWidgets();
     76        /** Prepares VM OS family combo. */
     77        void prepareFamilyCombo();
     78        /** Prepares connections. */
     79        void prepareConnections();
     80    /** @} */
     81
    6882    /** Handles translation event. */
    6983    virtual void retranslateUi() /* override */;
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