Changeset 41387 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 22, 2012 10:42:51 AM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r41373 r41387 356 356 src/widgets/VBoxMiniToolBar.h \ 357 357 src/widgets/VBoxOSTypeSelectorButton.h \ 358 src/widgets/ VBoxOSTypeSelectorWidget.h \358 src/widgets/UINameAndSystemEditor.h \ 359 359 src/widgets/VBoxWarningPane.h \ 360 360 src/wizards/UIWizard.h \ … … 565 565 src/widgets/VBoxMiniToolBar.cpp \ 566 566 src/widgets/VBoxOSTypeSelectorButton.cpp \ 567 src/widgets/ VBoxOSTypeSelectorWidget.cpp \567 src/widgets/UINameAndSystemEditor.cpp \ 568 568 src/widgets/VBoxWarningPane.cpp \ 569 569 src/wizards/UIWizard.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/precomp.h
r38977 r41387 229 229 #include "VBoxNewVMWzd.h" 230 230 #include "VBoxOSTypeSelectorButton.h" 231 #include " VBoxOSTypeSelectorWidget.h"231 #include "UINameAndSystemEditor.h" 232 232 #include "UIMessageCenter.h" 233 233 #include "VBoxProgressDialog.h" -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r38311 r41387 24 24 25 25 #include <QDir> 26 #include <QLineEdit> 26 27 27 28 UIMachineSettingsGeneral::UIMachineSettingsGeneral() … … 33 34 34 35 /* Setup validators */ 35 m LeName->setValidator (new QRegExpValidator (QRegExp(".+"), this));36 m_pNameAndSystemEditor->nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this)); 36 37 37 38 /* Shared Clipboard mode */ … … 51 52 CGuestOSType UIMachineSettingsGeneral::guestOSType() const 52 53 { 53 return m OSTypeSelector->type();54 return m_pNameAndSystemEditor->type(); 54 55 } 55 56 … … 61 62 bool UIMachineSettingsGeneral::is64BitOSTypeSelected() const 62 63 { 63 return m OSTypeSelector->type().GetIs64Bit();64 return m_pNameAndSystemEditor->type().GetIs64Bit(); 64 65 } 65 66 … … 67 68 bool UIMachineSettingsGeneral::isWindowsOSTypeSelected() const 68 69 { 69 return m OSTypeSelector->type().GetFamilyId() == "Windows";70 return m_pNameAndSystemEditor->type().GetFamilyId() == "Windows"; 70 71 } 71 72 #endif /* VBOX_WITH_VIDEOHWACCEL */ … … 113 114 114 115 /* Load general data to page: */ 115 m LeName->setText(generalData.m_strName);116 m OSTypeSelector->setType(vboxGlobal().vmGuestOSType(generalData.m_strGuestOsTypeId));116 m_pNameAndSystemEditor->setName(generalData.m_strName); 117 m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(generalData.m_strGuestOsTypeId)); 117 118 mCbSaveMounted->setChecked(generalData.m_fSaveMountedAtRuntime); 118 119 mCbShowToolBar->setChecked(generalData.m_fShowMiniToolBar); … … 139 140 140 141 /* Gather general data: */ 141 generalData.m_strName = m LeName->text();142 generalData.m_strGuestOsTypeId = m OSTypeSelector->type().GetId();142 generalData.m_strName = m_pNameAndSystemEditor->name(); 143 generalData.m_strGuestOsTypeId = m_pNameAndSystemEditor->type().GetId(); 143 144 generalData.m_fSaveMountedAtRuntime = mCbSaveMounted->isChecked(); 144 145 generalData.m_fShowMiniToolBar = mCbShowToolBar->isChecked(); … … 197 198 { 198 199 mValidator = aVal; 199 connect (m OSTypeSelector, SIGNAL (osTypeChanged()), mValidator, SLOT (revalidate()));200 connect (m_pNameAndSystemEditor, SIGNAL (sigOsTypeChanged()), mValidator, SLOT (revalidate())); 200 201 } 201 202 … … 213 214 /* Basic tab-order */ 214 215 setTabOrder (aWidget, mTwGeneral->focusProxy()); 215 setTabOrder (mTwGeneral->focusProxy(), mLeName); 216 setTabOrder (mLeName, mOSTypeSelector); 216 setTabOrder (mTwGeneral->focusProxy(), m_pNameAndSystemEditor); 217 217 218 218 /* Advanced tab-order */ 219 setTabOrder (m OSTypeSelector, mPsSnapshot);219 setTabOrder (m_pNameAndSystemEditor, mPsSnapshot); 220 220 setTabOrder (mPsSnapshot, mCbClipboard); 221 221 setTabOrder (mCbClipboard, mCbSaveMounted); … … 248 248 { 249 249 /* Basic tab: */ 250 mLbName->setEnabled(isMachineOffline()); 251 mLeName->setEnabled(isMachineOffline()); 252 mOSTypeSelector->setEnabled(isMachineOffline()); 250 m_pNameAndSystemEditor->setEnabled(isMachineOffline()); 253 251 /* Advanced tab: */ 254 252 mLbSnapshot->setEnabled(isMachineOffline()); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.ui
r37616 r41387 38 38 </property> 39 39 <item> 40 <widget class="VBoxOSTypeSelectorWidget" native="1" name="mOSTypeSelector" > 41 <layout class="QGridLayout" name="mLtOSTypeSelector" > 42 <property name="margin" > 43 <number>0</number> 44 </property> 45 <item row="0" column="0" > 46 <widget class="QLabel" name="mLbName" > 47 <property name="text" > 48 <string>&Name:</string> 49 </property> 50 <property name="alignment" > 51 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 52 </property> 53 <property name="buddy" > 54 <cstring>mLeName</cstring> 55 </property> 56 </widget> 57 </item> 58 <item row="0" column="1" colspan="2" > 59 <widget class="QLineEdit" name="mLeName" > 60 <property name="whatsThis" > 61 <string>Displays the name of the virtual machine.</string> 62 </property> 63 </widget> 64 </item> 65 </layout> 66 </widget> 40 <widget class="UINameAndSystemEditor" native="1" name="m_pNameAndSystemEditor" /> 67 41 </item> 68 42 <item> … … 278 252 <customwidgets> 279 253 <customwidget> 280 <class> VBoxOSTypeSelectorWidget</class>254 <class>UINameAndSystemEditor</class> 281 255 <extends>QWidget</extends> 282 <header> VBoxOSTypeSelectorWidget.h</header>256 <header>UINameAndSystemEditor.h</header> 283 257 </customwidget> 284 258 <customwidget> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp
r41372 r41387 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VBoxOSTypeSelectorWidgetclass implementation5 * UINameAndSystemEditor class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 2008-201 0Oracle Corporation9 * Copyright (C) 2008-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 #include "VBoxOSTypeSelectorWidget.h" 21 20 /* Global includes: */ 21 #include <QGridLayout> 22 #include <QVBoxLayout> 23 #include <QLabel> 24 #include <QLineEdit> 22 25 #include <QComboBox> 23 #include <QLabel> 24 #include <QVBoxLayout> 26 27 /* Local includes: */ 28 #include "UINameAndSystemEditor.h" 25 29 26 30 enum 27 31 { 28 RoleTypeID = Qt::UserRole + 132 TypeID = Qt::UserRole + 1 29 33 }; 30 34 31 VBoxOSTypeSelectorWidget::VBoxOSTypeSelectorWidget (QWidget *aParent) 32 : QIWithRetranslateUI <QWidget> (aParent) 33 , mTxFamilyName (new QLabel (this)) 34 , mTxTypeName (new QLabel (this)) 35 , mPxTypeIcon (new QLabel (this)) 36 , mCbFamily (new QComboBox (this)) 37 , mCbType (new QComboBox (this)) 38 , mLayoutPosition (-1) 39 , mLayoutActivated (false) 40 { 41 /* Register CGuestOSType type */ 35 UINameAndSystemEditor::UINameAndSystemEditor(QWidget *pParent) 36 : QIWithRetranslateUI<QWidget>(pParent) 37 { 38 /* Register CGuestOSType type: */ 42 39 qRegisterMetaType<CGuestOSType>(); 43 40 44 /* Setup widgets */ 45 mTxFamilyName->setAlignment (Qt::AlignRight); 46 mTxTypeName->setAlignment (Qt::AlignRight); 47 mTxFamilyName->setBuddy (mCbFamily); 48 mTxTypeName->setBuddy (mCbType); 49 mTxFamilyName->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed); 50 mTxTypeName->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed); 51 mCbFamily->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed); 52 mCbType->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed); 53 mPxTypeIcon->setFixedSize (32, 32); 54 55 /* Check if host supports (AMD-V or VT-x) and long mode */ 41 /* Create widgets: */ 42 QGridLayout *pMainLayout = new QGridLayout(this); 43 { 44 m_pNameLabel = new QLabel(this); 45 { 46 m_pNameLabel->setAlignment(Qt::AlignRight); 47 m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 48 } 49 m_pNameEditor = new QLineEdit(this); 50 { 51 m_pNameEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 52 m_pNameLabel->setBuddy(m_pNameEditor); 53 } 54 m_pFamilyLabel = new QLabel(this); 55 { 56 m_pFamilyLabel->setAlignment(Qt::AlignRight); 57 m_pFamilyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 58 } 59 m_pFamilyCombo = new QComboBox(this); 60 { 61 m_pFamilyCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 62 m_pFamilyLabel->setBuddy(m_pFamilyCombo); 63 } 64 m_pTypeLabel = new QLabel(this); 65 { 66 m_pTypeLabel->setAlignment(Qt::AlignRight); 67 m_pTypeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 68 } 69 m_pTypeCombo = new QComboBox(this); 70 { 71 m_pTypeCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 72 m_pTypeLabel->setBuddy(m_pTypeCombo); 73 } 74 QVBoxLayout *pIconLayout = new QVBoxLayout; 75 { 76 m_pTypeIcon = new QLabel(this); 77 { 78 m_pTypeIcon->setFixedSize(32, 32); 79 } 80 pIconLayout->addWidget(m_pTypeIcon); 81 pIconLayout->addStretch(); 82 } 83 pMainLayout->addWidget(m_pNameLabel, 0, 0); 84 pMainLayout->addWidget(m_pNameEditor, 0, 1, 1, 2); 85 pMainLayout->addWidget(m_pFamilyLabel, 1, 0); 86 pMainLayout->addWidget(m_pFamilyCombo, 1, 1); 87 pMainLayout->addWidget(m_pTypeLabel, 2, 0); 88 pMainLayout->addWidget(m_pTypeCombo, 2, 1); 89 pMainLayout->addItem(pIconLayout, 1, 2, 2, 1); 90 } 91 92 /* Check if host supports (AMD-V or VT-x) and long mode: */ 56 93 CHost host = vboxGlobal().host(); 57 94 m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx); 58 95 m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode); 59 96 60 /* Fill OS family selector */ 61 int maximumSize = 0; 62 QFontMetrics fm (mCbFamily->font()); 63 QList <CGuestOSType> families (vboxGlobal().vmGuestOSFamilyList()); 64 for (int i = 0; i < families.size(); ++ i) 65 { 66 /* Search for maximum length among family names */ 67 QString familyName (families [i].GetFamilyDescription()); 68 maximumSize = maximumSize < fm.width (familyName) ? 69 fm.width (familyName) : maximumSize; 70 mCbFamily->insertItem (i, familyName); 71 mCbFamily->setItemData (i, families [i].GetFamilyId(), RoleTypeID); 72 /* Search for maximum length among type names */ 73 QList <CGuestOSType> types (vboxGlobal().vmGuestOSTypeList (families [i].GetFamilyId())); 74 for (int j = 0; j < types.size(); ++ j) 75 { 76 QString typeName (types [j].GetDescription()); 77 maximumSize = maximumSize < fm.width (typeName) ? 78 fm.width (typeName) : maximumSize; 79 } 80 } 81 mCbFamily->setCurrentIndex (0); 82 onFamilyChanged (mCbFamily->currentIndex()); 83 84 /* Set the minimum size for OS Type & Family selectors. */ 85 QStyleOptionComboBox options; 86 options.initFrom (mCbFamily); 87 QSize size (style()->sizeFromContents (QStyle::CT_ComboBox, &options, 88 QSize (maximumSize, fm.height()), mCbFamily)); 89 mCbFamily->setMinimumWidth (size.width()); 90 mCbType->setMinimumWidth (size.width()); 91 92 /* Slots connections */ 93 connect (mCbFamily, SIGNAL (currentIndexChanged (int)), 94 this, SLOT (onFamilyChanged (int))); 95 connect (mCbType, SIGNAL (currentIndexChanged (int)), 96 this, SLOT (onTypeChanged (int))); 97 98 /* Retranslate */ 97 /* Fill OS family selector: */ 98 QList<CGuestOSType> families(vboxGlobal().vmGuestOSFamilyList()); 99 for (int i = 0; i < families.size(); ++i) 100 { 101 QString familyName(families[i].GetFamilyDescription()); 102 m_pFamilyCombo->insertItem(i, familyName); 103 m_pFamilyCombo->setItemData(i, families[i].GetFamilyId(), TypeID); 104 } 105 m_pFamilyCombo->setCurrentIndex(0); 106 sltFamilyChanged(m_pFamilyCombo->currentIndex()); 107 108 /* Setup connections: */ 109 connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &))); 110 connect(m_pFamilyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int))); 111 connect(m_pTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltTypeChanged(int))); 112 113 /* Retranslate: */ 99 114 retranslateUi(); 100 115 } 101 116 102 void VBoxOSTypeSelectorWidget::setType (const CGuestOSType &aType) 103 { 104 QString familyId (aType.GetFamilyId()); 105 QString typeId (aType.GetId()); 106 107 int familyIndex = mCbFamily->findData (familyId, RoleTypeID); 108 AssertMsg (familyIndex != -1, ("Family ID should be valid: '%s'", familyId.toLatin1().constData())); 109 if (familyIndex != -1) 110 mCbFamily->setCurrentIndex (familyIndex); 111 112 int typeIndex = mCbType->findData (typeId, RoleTypeID); 113 AssertMsg (typeIndex != -1, ("Type ID should be valid: '%s'", typeId.toLatin1().constData())); 114 if (typeIndex != -1) 115 mCbType->setCurrentIndex (typeIndex); 116 } 117 118 CGuestOSType VBoxOSTypeSelectorWidget::type() const 119 { 120 return mType; 121 } 122 123 void VBoxOSTypeSelectorWidget::setLayoutPosition (int aPos) 124 { 125 mLayoutPosition = aPos; 126 } 127 128 void VBoxOSTypeSelectorWidget::activateLayout() 129 { 130 if (mLayoutActivated) 131 return; 132 133 mLayoutActivated = true; 134 135 /* Layouting widgets */ 136 QVBoxLayout *layout1 = new QVBoxLayout(); 137 layout1->setSpacing (0); 138 layout1->addWidget (mPxTypeIcon); 139 layout1->addStretch(); 140 141 QGridLayout *layout2 = layout() ? static_cast <QGridLayout*> (layout()) : 142 new QGridLayout (this); 143 layout2->setMargin (0); 144 int row = mLayoutPosition == -1 ? layout2->rowCount() : mLayoutPosition; 145 layout2->addWidget (mTxFamilyName, row, 0); 146 layout2->addWidget (mCbFamily, row, 1); 147 layout2->addWidget (mTxTypeName, row + 1, 0); 148 layout2->addWidget (mCbType, row + 1, 1); 149 layout2->addLayout (layout1, row, 2, 2, 1); 150 } 151 152 void VBoxOSTypeSelectorWidget::retranslateUi() 153 { 154 mTxFamilyName->setText (tr ("&Type:")); 155 mCbFamily->setWhatsThis (tr ("Displays the operating system family that " 156 "you plan to install into this virtual machine.")); 157 mTxTypeName->setText (tr ("&Version:")); 158 mCbType->setWhatsThis (tr ("Displays the operating system type that " 159 "you plan to install into this virtual " 160 "machine (called a guest operating system).")); 161 } 162 163 void VBoxOSTypeSelectorWidget::showEvent (QShowEvent *aEvent) 164 { 165 activateLayout(); /* if not yet */ 166 QIWithRetranslateUI <QWidget>::showEvent (aEvent); 167 } 168 169 void VBoxOSTypeSelectorWidget::onFamilyChanged (int aIndex) 170 { 171 /* Lock the signals of mCbType to prevent it's reaction on clearing */ 172 mCbType->blockSignals (true); 173 mCbType->clear(); 174 175 /* Populate combo-box with OS Types related to currently selected Family ID */ 176 QString familyId (mCbFamily->itemData (aIndex, RoleTypeID).toString()); 177 QList <CGuestOSType> types (vboxGlobal().vmGuestOSTypeList (familyId)); 178 for (int i = 0; i < types.size(); ++ i) 179 { 180 if (types [i].GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode)) 117 QLineEdit* UINameAndSystemEditor::nameEditor() const 118 { 119 return m_pNameEditor; 120 } 121 122 void UINameAndSystemEditor::setName(const QString &strName) 123 { 124 m_pNameEditor->setText(strName); 125 } 126 127 QString UINameAndSystemEditor::name() const 128 { 129 return m_pNameEditor->text(); 130 } 131 132 void UINameAndSystemEditor::setType(const CGuestOSType &type) 133 { 134 /* Initialize variables: */ 135 QString strFamilyId(type.GetFamilyId()); 136 QString strTypeId(type.GetId()); 137 138 /* Get/check family index: */ 139 int iFamilyIndex = m_pFamilyCombo->findData(strFamilyId, TypeID); 140 AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData())); 141 if (iFamilyIndex != -1) 142 m_pFamilyCombo->setCurrentIndex(iFamilyIndex); 143 144 /* Get/check type index: */ 145 int iTypeIndex = m_pTypeCombo->findData(strTypeId, TypeID); 146 AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData())); 147 if (iTypeIndex != -1) 148 m_pTypeCombo->setCurrentIndex(iTypeIndex); 149 } 150 151 CGuestOSType UINameAndSystemEditor::type() const 152 { 153 return m_type; 154 } 155 156 void UINameAndSystemEditor::retranslateUi() 157 { 158 m_pNameLabel->setText(tr("&Name:")); 159 m_pNameEditor->setWhatsThis(tr("Displays the name of the virtual machine.")); 160 m_pFamilyLabel->setText(tr("&Type:")); 161 m_pFamilyCombo->setWhatsThis(tr("Displays the operating system family that " 162 "you plan to install into this virtual machine.")); 163 m_pTypeLabel->setText(tr("&Version:")); 164 m_pTypeCombo->setWhatsThis(tr("Displays the operating system type that " 165 "you plan to install into this virtual machine " 166 "(called a guest operating system).")); 167 } 168 169 void UINameAndSystemEditor::sltFamilyChanged(int iIndex) 170 { 171 /* Lock the signals of m_pTypeCombo to prevent it's reaction on clearing: */ 172 m_pTypeCombo->blockSignals(true); 173 m_pTypeCombo->clear(); 174 175 /* Populate combo-box with OS types related to currently selected family id: */ 176 QString strFamilyId(m_pFamilyCombo->itemData(iIndex, TypeID).toString()); 177 QList<CGuestOSType> types(vboxGlobal().vmGuestOSTypeList(strFamilyId)); 178 for (int i = 0; i < types.size(); ++i) 179 { 180 if (types[i].GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode)) 181 181 continue; 182 int index = mCbType->count(); 183 mCbType->insertItem (index, types [i].GetDescription()); 184 mCbType->setItemData (index, types [i].GetId(), RoleTypeID); 185 } 186 187 /* Select the most recently chosen item */ 188 if (mCurrentIds.contains (familyId)) 189 { 190 QString typeId (mCurrentIds [familyId]); 191 int typeIndex = mCbType->findData (typeId, RoleTypeID); 192 if (typeIndex != -1) 193 mCbType->setCurrentIndex (typeIndex); 194 } 195 /* Or select WinXP item for Windows family as default */ 196 else if (familyId == "Windows") 197 { 198 int xpIndex = mCbType->findData ("WindowsXP", RoleTypeID); 199 if (xpIndex != -1) 200 mCbType->setCurrentIndex (xpIndex); 201 } 202 /* Or select Ubuntu item for Linux family as default */ 203 else if (familyId == "Linux") 204 { 205 int ubIndex = mCbType->findData ("Ubuntu", RoleTypeID); 206 if (ubIndex != -1) 207 mCbType->setCurrentIndex (ubIndex); 208 } 209 /* Else simply select the first one present */ 210 else mCbType->setCurrentIndex (0); 211 212 /* Update all the stuff with new type */ 213 onTypeChanged (mCbType->currentIndex()); 214 215 /* Unlock the signals of mCbType */ 216 mCbType->blockSignals (false); 217 } 218 219 void VBoxOSTypeSelectorWidget::onTypeChanged (int aIndex) 220 { 221 /* Save the new selected OS Type */ 222 mType = vboxGlobal().vmGuestOSType ( 223 mCbType->itemData (aIndex, RoleTypeID).toString(), 224 mCbFamily->itemData (mCbFamily->currentIndex(), RoleTypeID).toString()); 225 mPxTypeIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (mType.GetId())); 226 227 /* Save the most recently used item */ 228 mCurrentIds [mType.GetFamilyId()] = mType.GetId(); 229 230 /* Notify connected objects about type was changed */ 231 emit osTypeChanged(); 232 } 233 182 int iIndex = m_pTypeCombo->count(); 183 m_pTypeCombo->insertItem(iIndex, types[i].GetDescription()); 184 m_pTypeCombo->setItemData(iIndex, types[i].GetId(), TypeID); 185 } 186 187 /* Select the most recently chosen item: */ 188 if (m_currentIds.contains(strFamilyId)) 189 { 190 QString strTypeId(m_currentIds[strFamilyId]); 191 int iTypeIndex = m_pTypeCombo->findData(strTypeId, TypeID); 192 if (iTypeIndex != -1) 193 m_pTypeCombo->setCurrentIndex(iTypeIndex); 194 } 195 /* Or select WinXP item for Windows family as default: */ 196 else if (strFamilyId == "Windows") 197 { 198 int iIndexWinXP = m_pTypeCombo->findData("WindowsXP", TypeID); 199 if (iIndexWinXP != -1) 200 m_pTypeCombo->setCurrentIndex(iIndexWinXP); 201 } 202 /* Or select Ubuntu item for Linux family as default: */ 203 else if (strFamilyId == "Linux") 204 { 205 int iIndexUbuntu = m_pTypeCombo->findData("Ubuntu", TypeID); 206 if (iIndexUbuntu != -1) 207 m_pTypeCombo->setCurrentIndex(iIndexUbuntu); 208 } 209 /* Else simply select the first one present: */ 210 else m_pTypeCombo->setCurrentIndex(0); 211 212 /* Update all the stuff: */ 213 sltTypeChanged(m_pTypeCombo->currentIndex()); 214 215 /* Unlock the signals of m_pTypeCombo: */ 216 m_pTypeCombo->blockSignals (false); 217 } 218 219 void UINameAndSystemEditor::sltTypeChanged(int iIndex) 220 { 221 /* Save the new selected OS Type: */ 222 m_type = vboxGlobal().vmGuestOSType(m_pTypeCombo->itemData(iIndex, TypeID).toString(), 223 m_pFamilyCombo->itemData(m_pFamilyCombo->currentIndex(), TypeID).toString()); 224 m_pTypeIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m_type.GetId())); 225 226 /* Save the most recently used item: */ 227 m_currentIds[m_type.GetFamilyId()] = m_type.GetId(); 228 229 /* Notifies listeners about OS type change: */ 230 emit sigOsTypeChanged(); 231 } 232 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h
r41361 r41387 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VBoxOSTypeSelectorWidgetclass declaration4 * UINameAndSystemEditor class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2008-201 0Oracle Corporation8 * Copyright (C) 2008-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __ VBoxOSTypeSelectorWidget_h__20 #define __ VBoxOSTypeSelectorWidget_h__19 #ifndef __UINameAndSystemEditor_h__ 20 #define __UINameAndSystemEditor_h__ 21 21 22 /* Global includes: */ 23 #include <QWidget> 24 25 /* Local includes: */ 22 26 #include "QIWithRetranslateUI.h" 23 27 #include "VBoxGlobal.h" 24 28 25 #include <QWidget> 29 /* Forward declarations: */ 30 class QLabel; 31 class QLineEdit; 32 class QComboBox; 26 33 27 class QComboBox; 28 class QLabel; 29 30 class VBoxOSTypeSelectorWidget : public QIWithRetranslateUI <QWidget> 34 /* QWidget reimplementation providing editor for basic VM parameters: */ 35 class UINameAndSystemEditor : public QIWithRetranslateUI<QWidget> 31 36 { 32 37 Q_OBJECT; 38 Q_PROPERTY(QString name READ name WRITE setName); 33 39 Q_PROPERTY(CGuestOSType type READ type WRITE setType); 40 41 signals: 42 43 /* Notifies listeners about VM name change: */ 44 void sigNameChanged(const QString &strNewName); 45 46 /* Notifies listeners about VM operating system type change: */ 47 void sigOsTypeChanged(); 34 48 35 49 public: 36 50 37 VBoxOSTypeSelectorWidget (QWidget *aParent); 51 /* Constructor: */ 52 UINameAndSystemEditor(QWidget *pParent); 38 53 39 void setType (const CGuestOSType &aType); 54 /* Name stuff: */ 55 QLineEdit* nameEditor() const; 56 void setName(const QString &strName); 57 QString name() const; 58 59 /* Operating system type stuff: */ 60 void setType(const CGuestOSType &type); 40 61 CGuestOSType type() const; 41 42 void setLayoutPosition (int aPos);43 void activateLayout();44 45 signals:46 47 void osTypeChanged();48 62 49 63 protected: 50 64 65 /* Translation stuff: */ 51 66 void retranslateUi(); 52 void showEvent (QShowEvent *aEvent);53 67 54 68 private slots: 55 69 56 void onFamilyChanged (int aIndex); 57 void onTypeChanged (int aIndex); 70 /* Handles OS family change: */ 71 void sltFamilyChanged(int iIndex); 72 73 /* Handles OS type change: */ 74 void sltTypeChanged(int iIndex); 58 75 59 76 private: 60 77 61 QLabel *mTxFamilyName; 62 QLabel *mTxTypeName; 63 QLabel *mPxTypeIcon; 64 QComboBox *mCbFamily; 65 QComboBox *mCbType; 78 /* Widgets: */ 79 QLabel *m_pNameLabel; 80 QLabel *m_pFamilyLabel; 81 QLabel *m_pTypeLabel; 82 QLabel *m_pTypeIcon; 83 QLineEdit *m_pNameEditor; 84 QComboBox *m_pFamilyCombo; 85 QComboBox *m_pTypeCombo; 66 86 67 CGuestOSType mType; 68 QMap <QString, QString> mCurrentIds; 69 70 int mLayoutPosition; 71 bool mLayoutActivated; 72 87 /* Variables: */ 88 CGuestOSType m_type; 89 QMap<QString, QString> m_currentIds; 73 90 bool m_fSupportsHWVirtEx; 74 91 bool m_fSupportsLongMode; 75 92 }; 76 93 77 #endif /* __ VBoxOSTypeSelectorWidget_h__ */94 #endif /* __UINameAndSystemEditor_h__ */ 78 95 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp
r41372 r41387 402 402 switch (m_type) 403 403 { 404 /* New VM wizard much wider than others, fixing: */405 case UIWizardType_NewVM:406 dRatio -= 0.5;407 break;408 /* New VD wizard much taller than others, fixing: */409 404 case UIWizardType_NewVD: 410 405 case UIWizardType_CloneVD: -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r41373 r41387 29 29 #include "UIWizardNewVM.h" 30 30 #include "UIMessageCenter.h" 31 #include " VBoxOSTypeSelectorWidget.h"31 #include "UINameAndSystemEditor.h" 32 32 #include "QIRichTextLabel.h" 33 33 … … 148 148 if (strNewName.contains(gs_OSTypePattern[i].pattern)) 149 149 { 150 m_p TypeSelector->blockSignals(true);151 m_p TypeSelector->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId));152 m_p TypeSelector->blockSignals(false);150 m_pNameAndSystemEditor->blockSignals(true); 151 m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId)); 152 m_pNameAndSystemEditor->blockSignals(false); 153 153 break; 154 154 } … … 159 159 /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore. 160 160 * So simply disconnect the text-edit signal. */ 161 m_pName Editor->disconnect(thisImp());161 m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &))); 162 162 } 163 163 … … 181 181 QString strDefaultMachinesFolder = vbox.GetSystemProperties().GetDefaultMachineFolder(); 182 182 /* Compose machine filename: */ 183 QString strMachineFilename = vbox.ComposeMachineFilename(m_pName Editor->text(), strDefaultMachinesFolder);183 QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), strDefaultMachinesFolder); 184 184 /* Compose machine folder/basename: */ 185 185 QFileInfo fileInfo(strMachineFilename); … … 228 228 { 229 229 m_pLabel = new QIRichTextLabel(this); 230 m_pName Cnt = new QGroupBox(this);230 m_pNameAndSystemCnt = new QGroupBox(this); 231 231 { 232 m_pName Cnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);233 QHBoxLayout *pName CntLayout = new QHBoxLayout(m_pNameCnt);232 m_pNameAndSystemCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 233 QHBoxLayout *pNameAndSystemLayout = new QHBoxLayout(m_pNameAndSystemCnt); 234 234 { 235 m_pNameEditor = new QLineEdit(m_pNameCnt); 236 pNameCntLayout->addWidget(m_pNameEditor); 237 } 238 } 239 m_pTypeCnt = new QGroupBox(this); 240 { 241 m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 242 QHBoxLayout *pTypeSelectorLayout = new QHBoxLayout(m_pTypeCnt); 243 { 244 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt); 245 { 246 m_pTypeSelector->activateLayout(); 247 } 248 pTypeSelectorLayout->addWidget(m_pTypeSelector); 235 m_pNameAndSystemEditor = new UINameAndSystemEditor(m_pNameAndSystemCnt); 236 pNameAndSystemLayout->addWidget(m_pNameAndSystemEditor); 249 237 } 250 238 } 251 239 pMainLayout->addWidget(m_pLabel); 252 pMainLayout->addWidget(m_pNameCnt); 253 pMainLayout->addWidget(m_pTypeCnt); 240 pMainLayout->addWidget(m_pNameAndSystemCnt); 254 241 pMainLayout->addStretch(); 255 242 } 256 243 257 244 /* Setup connections: */ 258 connect(m_pName Editor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&)));259 connect(m_p TypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged()));245 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &))); 246 connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged())); 260 247 261 248 /* Register fields: */ 262 registerField("name*", m_pName Editor);263 registerField("type", m_p TypeSelector, "type", SIGNAL(osTypeChanged()));249 registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &))); 250 registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged())); 264 251 registerField("machineFolder", this, "machineFolder"); 265 252 registerField("machineBaseName", this, "machineBaseName"); … … 288 275 "The name you choose will be used throughout VirtualBox " 289 276 "to identify this machine.")); 290 m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name")); 291 m_pTypeCnt->setTitle(UIWizardNewVM::tr("Operating system")); 277 m_pNameAndSystemCnt->setTitle(UIWizardNewVM::tr("Name and operating system")); 292 278 } 293 279 … … 296 282 /* Translate page: */ 297 283 retranslateUi(); 298 299 /* 'Name' field should have focus initially: */300 m_pNameEditor->setFocus();301 284 } 302 285 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h
r41373 r41387 25 25 /* Forward declarations: */ 26 26 class QGroupBox; 27 class QLineEdit; 28 class VBoxOSTypeSelectorWidget; 27 class UINameAndSystemEditor; 29 28 class QIRichTextLabel; 30 29 … … 59 58 60 59 /* Widgets: */ 61 QGroupBox *m_pNameCnt; 62 QLineEdit *m_pNameEditor; 63 QGroupBox *m_pTypeCnt; 64 VBoxOSTypeSelectorWidget *m_pTypeSelector; 60 QGroupBox *m_pNameAndSystemCnt; 61 UINameAndSystemEditor *m_pNameAndSystemEditor; 65 62 }; 66 63 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r41372 r41387 32 32 #include "UIWizardNewVM.h" 33 33 #include "UIIconPool.h" 34 #include " VBoxOSTypeSelectorWidget.h"34 #include "UINameAndSystemEditor.h" 35 35 #include "VBoxGuestRAMSlider.h" 36 36 #include "VBoxMediaComboBox.h" … … 44 44 { 45 45 pMainLayout->setContentsMargins(8, 6, 8, 6); 46 m_pNameCnt = new QGroupBox(this); 47 { 48 m_pNameCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 49 QHBoxLayout *pNameCntLayout = new QHBoxLayout(m_pNameCnt); 50 { 51 m_pNameEditor = new QLineEdit(m_pNameCnt); 52 pNameCntLayout->addWidget(m_pNameEditor); 53 } 54 } 55 m_pTypeCnt = new QGroupBox(this); 56 { 57 m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 58 QHBoxLayout *pTypeCntLayout = new QHBoxLayout(m_pTypeCnt); 59 { 60 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt); 61 { 62 m_pTypeSelector->activateLayout(); 63 } 64 pTypeCntLayout->addWidget(m_pTypeSelector); 46 m_pNameAndSystemCnt = new QGroupBox(this); 47 { 48 m_pNameAndSystemCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 49 QHBoxLayout *pNameAndSystemLayout = new QHBoxLayout(m_pNameAndSystemCnt); 50 { 51 m_pNameAndSystemEditor = new UINameAndSystemEditor(m_pNameAndSystemCnt); 52 pNameAndSystemLayout->addWidget(m_pNameAndSystemEditor); 65 53 } 66 54 } … … 75 63 m_pRamSlider->setOrientation(Qt::Horizontal); 76 64 m_pRamSlider->setTickPosition(QSlider::TicksBelow); 77 m_pRamSlider->setValue(m_p TypeSelector->type().GetRecommendedRAM());65 m_pRamSlider->setValue(m_pNameAndSystemEditor->type().GetRecommendedRAM()); 78 66 } 79 67 m_pRamEditor = new QILineEdit(m_pMemoryCnt); … … 83 71 m_pRamEditor->setAlignment(Qt::AlignRight); 84 72 m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this)); 85 m_pRamEditor->setText(QString::number(m_p TypeSelector->type().GetRecommendedRAM()));73 m_pRamEditor->setText(QString::number(m_pNameAndSystemEditor->type().GetRecommendedRAM())); 86 74 } 87 75 m_pRamUnits = new QLabel(m_pMemoryCnt); … … 141 129 } 142 130 } 143 pMainLayout->addWidget(m_pNameCnt); 144 pMainLayout->addWidget(m_pTypeCnt); 131 pMainLayout->addWidget(m_pNameAndSystemCnt); 145 132 pMainLayout->addWidget(m_pMemoryCnt); 146 133 pMainLayout->addWidget(m_pDiskCnt); … … 150 137 151 138 /* Setup connections: */ 152 connect(m_pName Editor, SIGNAL(textChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));153 connect(m_p TypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged()));139 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &))); 140 connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged())); 154 141 connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int))); 155 142 connect(m_pRamEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltRamEditorTextChanged(const QString &))); … … 163 150 qRegisterMetaType<CMedium>(); 164 151 /* Register fields: */ 165 registerField("name*", m_pName Editor);166 registerField("type", m_p TypeSelector, "type", SIGNAL(osTypeChanged()));152 registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &))); 153 registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged())); 167 154 registerField("machineFolder", this, "machineFolder"); 168 155 registerField("machineBaseName", this, "machineBaseName"); … … 179 166 180 167 /* Fetch recommended RAM value: */ 181 CGuestOSType type = m_p TypeSelector->type();168 CGuestOSType type = m_pNameAndSystemEditor->type(); 182 169 m_pRamSlider->setValue(type.GetRecommendedRAM()); 183 170 m_pRamEditor->setText(QString::number(type.GetRecommendedRAM())); … … 193 180 194 181 /* Fetch recommended RAM value: */ 195 CGuestOSType type = m_p TypeSelector->type();182 CGuestOSType type = m_pNameAndSystemEditor->type(); 196 183 m_pRamSlider->setValue(type.GetRecommendedRAM()); 197 184 m_pRamEditor->setText(QString::number(type.GetRecommendedRAM())); … … 237 224 { 238 225 /* Translate widgets: */ 239 m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name")); 240 m_pTypeCnt->setTitle(UIWizardNewVM::tr("Operating system")); 226 m_pNameAndSystemCnt->setTitle(UIWizardNewVM::tr("Name and operating system")); 241 227 m_pMemoryCnt->setTitle(UIWizardNewVM::tr("&Memory size")); 242 228 m_pRamUnits->setText(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")); … … 253 239 /* Translate page: */ 254 240 retranslateUi(); 255 256 /* 'Name' field should have focus initially: */257 m_pNameEditor->setFocus();258 241 } 259 242
Note:
See TracChangeset
for help on using the changeset viewer.