Changeset 60694 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 25, 2016 5:44:39 PM (9 years ago)
- 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 49 49 { 50 50 pMainLayout->setContentsMargins(0, 0, 0, 0); 51 m_p NameLabel= new QLabel(this);52 { 53 m_p NameLabel->setAlignment(Qt::AlignRight);54 m_p NameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);55 } 56 m_p NameEditor= new QLineEdit(this);57 { 58 m_p NameEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);59 m_p NameLabel->setBuddy(m_pNameEditor);60 } 61 m_p FamilyLabel= new QLabel(this);62 { 63 m_p FamilyLabel->setAlignment(Qt::AlignRight);64 m_p FamilyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);65 } 66 m_p FamilyCombo= new QComboBox(this);67 { 68 m_p FamilyCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);69 m_p FamilyLabel->setBuddy(m_pFamilyCombo);70 } 71 m_p TypeLabel= new QLabel(this);72 { 73 m_p TypeLabel->setAlignment(Qt::AlignRight);74 m_p TypeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);75 } 76 m_p TypeCombo= new QComboBox(this);77 { 78 m_p TypeCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);79 m_p TypeLabel->setBuddy(m_pTypeCombo);80 } 81 QVBoxLayout *p IconLayout= new QVBoxLayout;82 { 83 m_p TypeIcon= 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); 84 84 { 85 m_p TypeIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);85 m_pIconType->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 86 86 } 87 p IconLayout->addWidget(m_pTypeIcon);88 p IconLayout->addStretch();89 } 90 pMainLayout->addWidget(m_p NameLabel, 0, 0);91 pMainLayout->addWidget(m_p NameEditor, 0, 1, 1, 2);92 pMainLayout->addWidget(m_p FamilyLabel, 1, 0);93 pMainLayout->addWidget(m_p FamilyCombo, 1, 1);94 pMainLayout->addWidget(m_p TypeLabel, 2, 0);95 pMainLayout->addWidget(m_p TypeCombo, 2, 1);96 pMainLayout->addLayout(p IconLayout, 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); 97 97 } 98 98 … … 106 106 for (int i = 0; i < families.size(); ++i) 107 107 { 108 QString familyName(families[i].GetFamilyDescription());109 m_p FamilyCombo->insertItem(i, familyName);110 m_p FamilyCombo->setItemData(i, families[i].GetFamilyId(), TypeID);111 } 112 m_p FamilyCombo->setCurrentIndex(0);113 sltFamilyChanged(m_p FamilyCombo->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()); 114 114 115 115 /* Setup connections: */ 116 connect(m_p NameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &)));117 connect(m_p FamilyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int)));118 connect(m_p TypeCombo, 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))); 119 119 120 120 /* Retranslate: */ … … 124 124 QLineEdit* UINameAndSystemEditor::nameEditor() const 125 125 { 126 return m_p NameEditor;126 return m_pEditorName; 127 127 } 128 128 129 129 void UINameAndSystemEditor::setName(const QString &strName) 130 130 { 131 m_p NameEditor->setText(strName);131 m_pEditorName->setText(strName); 132 132 } 133 133 134 134 QString UINameAndSystemEditor::name() const 135 135 { 136 return m_p NameEditor->text();136 return m_pEditorName->text(); 137 137 } 138 138 … … 144 144 145 145 /* Get/check family index: */ 146 int iFamilyIndex = m_p FamilyCombo->findData(strFamilyId, TypeID);146 int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID); 147 147 AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData())); 148 148 if (iFamilyIndex != -1) 149 m_p FamilyCombo->setCurrentIndex(iFamilyIndex);149 m_pComboFamily->setCurrentIndex(iFamilyIndex); 150 150 151 151 /* Get/check type index: */ 152 int iTypeIndex = m_p TypeCombo->findData(strTypeId, TypeID);152 int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 153 153 AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData())); 154 154 if (iTypeIndex != -1) 155 m_p TypeCombo->setCurrentIndex(iTypeIndex);155 m_pComboType->setCurrentIndex(iTypeIndex); 156 156 } 157 157 … … 163 163 void UINameAndSystemEditor::retranslateUi() 164 164 { 165 m_p NameLabel->setText(tr("N&ame:"));166 m_p NameEditor->setWhatsThis(tr("Holds the name of the virtual machine."));167 m_p FamilyLabel->setText(tr("&Type:"));168 m_p FamilyCombo->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 " 169 169 "you plan to install into this virtual machine.")); 170 m_p TypeLabel->setText(tr("&Version:"));171 m_p TypeCombo->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 " 172 172 "you plan to install into this virtual machine " 173 173 "(called a guest operating system).")); … … 176 176 void UINameAndSystemEditor::sltFamilyChanged(int iIndex) 177 177 { 178 /* Lock the signals of m_p TypeComboto prevent it's reaction on clearing: */179 m_p TypeCombo->blockSignals(true);180 m_p TypeCombo->clear();178 /* Lock the signals of m_pComboType to prevent it's reaction on clearing: */ 179 m_pComboType->blockSignals(true); 180 m_pComboType->clear(); 181 181 182 182 /* Populate combo-box with OS types related to currently selected family id: */ 183 QString strFamilyId(m_p FamilyCombo->itemData(iIndex, TypeID).toString());183 QString strFamilyId(m_pComboFamily->itemData(iIndex, TypeID).toString()); 184 184 QList<CGuestOSType> types(vboxGlobal().vmGuestOSTypeList(strFamilyId)); 185 185 for (int i = 0; i < types.size(); ++i) … … 187 187 if (types[i].GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode)) 188 188 continue; 189 int iIndex = m_p TypeCombo->count();190 m_p TypeCombo->insertItem(iIndex, types[i].GetDescription());191 m_p TypeCombo->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); 192 192 } 193 193 … … 196 196 { 197 197 QString strTypeId(m_currentIds[strFamilyId]); 198 int iTypeIndex = m_p TypeCombo->findData(strTypeId, TypeID);198 int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 199 199 if (iTypeIndex != -1) 200 m_p TypeCombo->setCurrentIndex(iTypeIndex);200 m_pComboType->setCurrentIndex(iTypeIndex); 201 201 } 202 202 /* Or select Windows 7 item for Windows family as default: */ … … 206 206 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 207 207 strDefaultID += "_64"; 208 int iIndexWin7 = m_p TypeCombo->findData(strDefaultID, TypeID);208 int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID); 209 209 if (iIndexWin7 != -1) 210 m_p TypeCombo->setCurrentIndex(iIndexWin7);210 m_pComboType->setCurrentIndex(iIndexWin7); 211 211 } 212 212 /* Or select Ubuntu item for Linux family as default: */ … … 216 216 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 217 217 strDefaultID += "_64"; 218 int iIndexUbuntu = m_p TypeCombo->findData(strDefaultID, TypeID);218 int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID); 219 219 if (iIndexUbuntu != -1) 220 m_p TypeCombo->setCurrentIndex(iIndexUbuntu);220 m_pComboType->setCurrentIndex(iIndexUbuntu); 221 221 } 222 222 /* Else simply select the first one present: */ 223 else m_p TypeCombo->setCurrentIndex(0);223 else m_pComboType->setCurrentIndex(0); 224 224 225 225 /* Update all the stuff: */ 226 sltTypeChanged(m_p TypeCombo->currentIndex());227 228 /* Unlock the signals of m_p TypeCombo: */229 m_p TypeCombo->blockSignals(false);226 sltTypeChanged(m_pComboType->currentIndex()); 227 228 /* Unlock the signals of m_pComboType: */ 229 m_pComboType->blockSignals(false); 230 230 } 231 231 … … 233 233 { 234 234 /* Save the new selected OS Type: */ 235 m_type = vboxGlobal().vmGuestOSType(m_p TypeCombo->itemData(iIndex, TypeID).toString(),236 m_p FamilyCombo->itemData(m_pFamilyCombo->currentIndex(), TypeID).toString());237 m_p TypeIcon->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())); 238 238 239 239 /* Save the most recently used item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h
r60692 r60694 80 80 81 81 /** Holds the VM name label instance. */ 82 QLabel *m_p NameLabel;82 QLabel *m_pLabelName; 83 83 /** Holds the VM OS family label instance. */ 84 QLabel *m_p FamilyLabel;84 QLabel *m_pLabelFamily; 85 85 /** Holds the VM OS type label instance. */ 86 QLabel *m_p TypeLabel;86 QLabel *m_pLabelType; 87 87 /** Holds the VM OS type icon instance. */ 88 QLabel *m_p TypeIcon;88 QLabel *m_pIconType; 89 89 /** Holds the VM name editor instance. */ 90 QLineEdit *m_p NameEditor;90 QLineEdit *m_pEditorName; 91 91 /** Holds the VM OS family combo instance. */ 92 QComboBox *m_p FamilyCombo;92 QComboBox *m_pComboFamily; 93 93 /** Holds the VM OS type combo instance. */ 94 QComboBox *m_p TypeCombo;94 QComboBox *m_pComboType; 95 95 96 96 /** Holds the VM OS type. */
Note:
See TracChangeset
for help on using the changeset viewer.