VirtualBox

Ignore:
Timestamp:
Apr 25, 2016 5:44:39 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​​​​​​​bugref:6769: Rework/cleanup for VM properties editor (part 02): Renaming.

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

Legend:

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

    r60692 r60694  
    4949    {
    5050        pMainLayout->setContentsMargins(0, 0, 0, 0);
    51         m_pNameLabel = new QLabel(this);
    52         {
    53             m_pNameLabel->setAlignment(Qt::AlignRight);
    54             m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    55         }
    56         m_pNameEditor = new QLineEdit(this);
    57         {
    58             m_pNameEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    59             m_pNameLabel->setBuddy(m_pNameEditor);
    60         }
    61         m_pFamilyLabel = new QLabel(this);
    62         {
    63             m_pFamilyLabel->setAlignment(Qt::AlignRight);
    64             m_pFamilyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    65         }
    66         m_pFamilyCombo = new QComboBox(this);
    67         {
    68             m_pFamilyCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    69             m_pFamilyLabel->setBuddy(m_pFamilyCombo);
    70         }
    71         m_pTypeLabel = new QLabel(this);
    72         {
    73             m_pTypeLabel->setAlignment(Qt::AlignRight);
    74             m_pTypeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    75         }
    76         m_pTypeCombo = new QComboBox(this);
    77         {
    78             m_pTypeCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    79             m_pTypeLabel->setBuddy(m_pTypeCombo);
    80         }
    81         QVBoxLayout *pIconLayout = new QVBoxLayout;
    82         {
    83             m_pTypeIcon = new QLabel(this);
     51        m_pLabelName = new QLabel(this);
     52        {
     53            m_pLabelName->setAlignment(Qt::AlignRight);
     54            m_pLabelName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     55        }
     56        m_pEditorName = new QLineEdit(this);
     57        {
     58            m_pEditorName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     59            m_pLabelName->setBuddy(m_pEditorName);
     60        }
     61        m_pLabelFamily = new QLabel(this);
     62        {
     63            m_pLabelFamily->setAlignment(Qt::AlignRight);
     64            m_pLabelFamily->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     65        }
     66        m_pComboFamily = new QComboBox(this);
     67        {
     68            m_pComboFamily->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     69            m_pLabelFamily->setBuddy(m_pComboFamily);
     70        }
     71        m_pLabelType = new QLabel(this);
     72        {
     73            m_pLabelType->setAlignment(Qt::AlignRight);
     74            m_pLabelType->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     75        }
     76        m_pComboType = new QComboBox(this);
     77        {
     78            m_pComboType->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     79            m_pLabelType->setBuddy(m_pComboType);
     80        }
     81        QVBoxLayout *pLayoutIcon = new QVBoxLayout;
     82        {
     83            m_pIconType = new QLabel(this);
    8484            {
    85                 m_pTypeIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     85                m_pIconType->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    8686            }
    87             pIconLayout->addWidget(m_pTypeIcon);
    88             pIconLayout->addStretch();
    89         }
    90         pMainLayout->addWidget(m_pNameLabel, 0, 0);
    91         pMainLayout->addWidget(m_pNameEditor, 0, 1, 1, 2);
    92         pMainLayout->addWidget(m_pFamilyLabel, 1, 0);
    93         pMainLayout->addWidget(m_pFamilyCombo, 1, 1);
    94         pMainLayout->addWidget(m_pTypeLabel, 2, 0);
    95         pMainLayout->addWidget(m_pTypeCombo, 2, 1);
    96         pMainLayout->addLayout(pIconLayout, 1, 2, 2, 1);
     87            pLayoutIcon->addWidget(m_pIconType);
     88            pLayoutIcon->addStretch();
     89        }
     90        pMainLayout->addWidget(m_pLabelName, 0, 0);
     91        pMainLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
     92        pMainLayout->addWidget(m_pLabelFamily, 1, 0);
     93        pMainLayout->addWidget(m_pComboFamily, 1, 1);
     94        pMainLayout->addWidget(m_pLabelType, 2, 0);
     95        pMainLayout->addWidget(m_pComboType, 2, 1);
     96        pMainLayout->addLayout(pLayoutIcon, 1, 2, 2, 1);
    9797    }
    9898
     
    106106    for (int i = 0; i < families.size(); ++i)
    107107    {
    108         QString familyName(families[i].GetFamilyDescription());
    109         m_pFamilyCombo->insertItem(i, familyName);
    110         m_pFamilyCombo->setItemData(i, families[i].GetFamilyId(), TypeID);
    111     }
    112     m_pFamilyCombo->setCurrentIndex(0);
    113     sltFamilyChanged(m_pFamilyCombo->currentIndex());
     108        QString strFamilyName(families[i].GetFamilyDescription());
     109        m_pComboFamily->insertItem(i, strFamilyName);
     110        m_pComboFamily->setItemData(i, families[i].GetFamilyId(), TypeID);
     111    }
     112    m_pComboFamily->setCurrentIndex(0);
     113    sltFamilyChanged(m_pComboFamily->currentIndex());
    114114
    115115    /* Setup connections: */
    116     connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &)));
    117     connect(m_pFamilyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int)));
    118     connect(m_pTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltTypeChanged(int)));
     116    connect(m_pEditorName, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &)));
     117    connect(m_pComboFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int)));
     118    connect(m_pComboType, SIGNAL(currentIndexChanged(int)), this, SLOT(sltTypeChanged(int)));
    119119
    120120    /* Retranslate: */
     
    124124QLineEdit* UINameAndSystemEditor::nameEditor() const
    125125{
    126     return m_pNameEditor;
     126    return m_pEditorName;
    127127}
    128128
    129129void UINameAndSystemEditor::setName(const QString &strName)
    130130{
    131     m_pNameEditor->setText(strName);
     131    m_pEditorName->setText(strName);
    132132}
    133133
    134134QString UINameAndSystemEditor::name() const
    135135{
    136     return m_pNameEditor->text();
     136    return m_pEditorName->text();
    137137}
    138138
     
    144144
    145145    /* Get/check family index: */
    146     int iFamilyIndex = m_pFamilyCombo->findData(strFamilyId, TypeID);
     146    int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
    147147    AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData()));
    148148    if (iFamilyIndex != -1)
    149         m_pFamilyCombo->setCurrentIndex(iFamilyIndex);
     149        m_pComboFamily->setCurrentIndex(iFamilyIndex);
    150150
    151151    /* Get/check type index: */
    152     int iTypeIndex = m_pTypeCombo->findData(strTypeId, TypeID);
     152    int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    153153    AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData()));
    154154    if (iTypeIndex != -1)
    155         m_pTypeCombo->setCurrentIndex(iTypeIndex);
     155        m_pComboType->setCurrentIndex(iTypeIndex);
    156156}
    157157
     
    163163void UINameAndSystemEditor::retranslateUi()
    164164{
    165     m_pNameLabel->setText(tr("N&ame:"));
    166     m_pNameEditor->setWhatsThis(tr("Holds the name of the virtual machine."));
    167     m_pFamilyLabel->setText(tr("&Type:"));
    168     m_pFamilyCombo->setWhatsThis(tr("Selects the operating system family that "
     165    m_pLabelName->setText(tr("N&ame:"));
     166    m_pEditorName->setWhatsThis(tr("Holds the name of the virtual machine."));
     167    m_pLabelFamily->setText(tr("&Type:"));
     168    m_pComboFamily->setWhatsThis(tr("Selects the operating system family that "
    169169                                    "you plan to install into this virtual machine."));
    170     m_pTypeLabel->setText(tr("&Version:"));
    171     m_pTypeCombo->setWhatsThis(tr("Selects the operating system type that "
     170    m_pLabelType->setText(tr("&Version:"));
     171    m_pComboType->setWhatsThis(tr("Selects the operating system type that "
    172172                                  "you plan to install into this virtual machine "
    173173                                  "(called a guest operating system)."));
     
    176176void UINameAndSystemEditor::sltFamilyChanged(int iIndex)
    177177{
    178     /* Lock the signals of m_pTypeCombo to prevent it's reaction on clearing: */
    179     m_pTypeCombo->blockSignals(true);
    180     m_pTypeCombo->clear();
     178    /* Lock the signals of m_pComboType to prevent it's reaction on clearing: */
     179    m_pComboType->blockSignals(true);
     180    m_pComboType->clear();
    181181
    182182    /* Populate combo-box with OS types related to currently selected family id: */
    183     QString strFamilyId(m_pFamilyCombo->itemData(iIndex, TypeID).toString());
     183    QString strFamilyId(m_pComboFamily->itemData(iIndex, TypeID).toString());
    184184    QList<CGuestOSType> types(vboxGlobal().vmGuestOSTypeList(strFamilyId));
    185185    for (int i = 0; i < types.size(); ++i)
     
    187187        if (types[i].GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
    188188            continue;
    189         int iIndex = m_pTypeCombo->count();
    190         m_pTypeCombo->insertItem(iIndex, types[i].GetDescription());
    191         m_pTypeCombo->setItemData(iIndex, types[i].GetId(), TypeID);
     189        int iIndex = m_pComboType->count();
     190        m_pComboType->insertItem(iIndex, types[i].GetDescription());
     191        m_pComboType->setItemData(iIndex, types[i].GetId(), TypeID);
    192192    }
    193193
     
    196196    {
    197197        QString strTypeId(m_currentIds[strFamilyId]);
    198         int iTypeIndex = m_pTypeCombo->findData(strTypeId, TypeID);
     198        int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    199199        if (iTypeIndex != -1)
    200             m_pTypeCombo->setCurrentIndex(iTypeIndex);
     200            m_pComboType->setCurrentIndex(iTypeIndex);
    201201    }
    202202    /* Or select Windows 7 item for Windows family as default: */
     
    206206        if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode)
    207207            strDefaultID += "_64";
    208         int iIndexWin7 = m_pTypeCombo->findData(strDefaultID, TypeID);
     208        int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID);
    209209        if (iIndexWin7 != -1)
    210             m_pTypeCombo->setCurrentIndex(iIndexWin7);
     210            m_pComboType->setCurrentIndex(iIndexWin7);
    211211    }
    212212    /* Or select Ubuntu item for Linux family as default: */
     
    216216        if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode)
    217217            strDefaultID += "_64";
    218         int iIndexUbuntu = m_pTypeCombo->findData(strDefaultID, TypeID);
     218        int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID);
    219219        if (iIndexUbuntu != -1)
    220             m_pTypeCombo->setCurrentIndex(iIndexUbuntu);
     220            m_pComboType->setCurrentIndex(iIndexUbuntu);
    221221    }
    222222    /* Else simply select the first one present: */
    223     else m_pTypeCombo->setCurrentIndex(0);
     223    else m_pComboType->setCurrentIndex(0);
    224224
    225225    /* Update all the stuff: */
    226     sltTypeChanged(m_pTypeCombo->currentIndex());
    227 
    228     /* Unlock the signals of m_pTypeCombo: */
    229     m_pTypeCombo->blockSignals(false);
     226    sltTypeChanged(m_pComboType->currentIndex());
     227
     228    /* Unlock the signals of m_pComboType: */
     229    m_pComboType->blockSignals(false);
    230230}
    231231
     
    233233{
    234234    /* Save the new selected OS Type: */
    235     m_type = vboxGlobal().vmGuestOSType(m_pTypeCombo->itemData(iIndex, TypeID).toString(),
    236                                         m_pFamilyCombo->itemData(m_pFamilyCombo->currentIndex(), TypeID).toString());
    237     m_pTypeIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m_type.GetId()));
     235    m_type = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(),
     236                                        m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString());
     237    m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m_type.GetId()));
    238238
    239239    /* Save the most recently used item: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r60692 r60694  
    8080
    8181    /** Holds the VM name label instance. */
    82     QLabel *m_pNameLabel;
     82    QLabel *m_pLabelName;
    8383    /** Holds the VM OS family label instance. */
    84     QLabel *m_pFamilyLabel;
     84    QLabel *m_pLabelFamily;
    8585    /** Holds the VM OS type label instance. */
    86     QLabel *m_pTypeLabel;
     86    QLabel *m_pLabelType;
    8787    /** Holds the VM OS type icon instance. */
    88     QLabel *m_pTypeIcon;
     88    QLabel *m_pIconType;
    8989    /** Holds the VM name editor instance. */
    90     QLineEdit *m_pNameEditor;
     90    QLineEdit *m_pEditorName;
    9191    /** Holds the VM OS family combo instance. */
    92     QComboBox *m_pFamilyCombo;
     92    QComboBox *m_pComboFamily;
    9393    /** Holds the VM OS type combo instance. */
    94     QComboBox *m_pTypeCombo;
     94    QComboBox *m_pComboType;
    9595
    9696    /** Holds the VM OS type. */
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