- Timestamp:
- Apr 19, 2018 1:56:18 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71923 r71924 565 565 src/widgets/UIMiniToolBar.h \ 566 566 src/widgets/VBoxOSTypeSelectorButton.h \ 567 src/widgets/UINameAndSystemEditor.h \568 567 src/widgets/UIWarningPane.h \ 569 568 src/widgets/graphics/UIGraphicsButton.h \ … … 686 685 src/widgets/UIMediumSizeEditor.h \ 687 686 src/widgets/UIMenuBar.h \ 687 src/widgets/UINameAndSystemEditor.h \ 688 688 src/widgets/UIPopupBox.h \ 689 689 src/widgets/UIPopupPane.h \ … … 780 780 src/widgets/UIMediumSizeEditor.h \ 781 781 src/widgets/UIMenuBar.h \ 782 src/widgets/UINameAndSystemEditor.h \ 782 783 src/widgets/UIPopupBox.h \ 783 784 src/widgets/UIPopupPane.h \ … … 1058 1059 src/widgets/UIMiniToolBar.cpp \ 1059 1060 src/widgets/VBoxOSTypeSelectorButton.cpp \ 1060 src/widgets/UINameAndSystemEditor.cpp \1061 1061 src/widgets/UIWarningPane.cpp \ 1062 1062 src/widgets/graphics/UIGraphicsButton.cpp \ … … 1218 1218 src/widgets/UIMediumSizeEditor.cpp \ 1219 1219 src/widgets/UIMenuBar.cpp \ 1220 src/widgets/UINameAndSystemEditor.cpp \ 1220 1221 src/widgets/UIPopupBox.cpp \ 1221 1222 src/widgets/UIPopupPane.cpp \ … … 1338 1339 src/widgets/UIMediumSizeEditor.cpp \ 1339 1340 src/widgets/UIMenuBar.cpp \ 1341 src/widgets/UINameAndSystemEditor.cpp \ 1340 1342 src/widgets/UIPopupBox.cpp \ 1341 1343 src/widgets/UIPopupPane.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r71845 r71924 26 26 /* GUI includes: */ 27 27 # include "QIWidgetValidator.h" 28 # include "VBoxGlobal.h" 28 29 # include "UIConverter.h" 30 # include "UIErrorString.h" 29 31 # include "UIMachineSettingsGeneral.h" 30 # include "UIErrorString.h"31 32 # include "UIModalWindowManager.h" 32 33 # include "UIProgressDialog.h" -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp
r71026 r71924 5 5 6 6 /* 7 * Copyright (C) 2008-201 7Oracle Corporation7 * Copyright (C) 2008-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QComboBox> 23 24 # include <QGridLayout> 24 # include <QVBoxLayout>25 25 # include <QLabel> 26 26 # include <QLineEdit> 27 # include <Q ComboBox>27 # include <QVBoxLayout> 28 28 29 29 /* GUI includes: */ 30 # include "VBoxGlobal.h" 31 # include "UIFilePathSelector.h" 30 32 # include "UINameAndSystemEditor.h" 31 # include "UIFilePathSelector.h"32 33 33 34 /* COM includes: */ … … 35 36 36 37 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 38 37 39 38 40 /** Defines the VM OS type ID. */ … … 61 63 } 62 64 65 QString UINameAndSystemEditor::name() const 66 { 67 if (!m_fChooseLocation) 68 return m_pEditorName->text(); 69 else 70 return m_pEditorLocation->path(); 71 } 72 73 void UINameAndSystemEditor::setName(const QString &strName) 74 { 75 if (!m_fChooseLocation) 76 m_pEditorName->setText(strName); 77 else 78 m_pEditorLocation->setPath(strName); 79 } 80 81 CGuestOSType UINameAndSystemEditor::type() const 82 { 83 return m_enmType; 84 } 85 86 void UINameAndSystemEditor::setType(const CGuestOSType &enmType) 87 { 88 // WORKAROUND: 89 // We're getting here with a NULL enmType when creating new VMs. 90 // Very annoying, so just workarounded for now. 91 /** @todo find out the reason and way to fix that.. */ 92 if (enmType.isNull()) 93 return; 94 95 /* Initialize variables: */ 96 const QString strFamilyId = enmType.GetFamilyId(); 97 const QString strTypeId = enmType.GetId(); 98 99 /* Get/check family index: */ 100 const int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID); 101 AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData())); 102 if (iFamilyIndex != -1) 103 m_pComboFamily->setCurrentIndex(iFamilyIndex); 104 105 /* Get/check type index: */ 106 const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 107 AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData())); 108 if (iTypeIndex != -1) 109 m_pComboType->setCurrentIndex(iTypeIndex); 110 } 111 112 void UINameAndSystemEditor::retranslateUi() 113 { 114 m_pLabelName->setText(tr("N&ame:")); 115 m_pLabelFamily->setText(tr("&Type:")); 116 m_pLabelType->setText(tr("&Version:")); 117 if (!m_fChooseLocation) 118 m_pEditorName->setWhatsThis(tr("Holds the name of the virtual machine.")); 119 else 120 m_pEditorLocation->setWhatsThis(tr("Holds the location of the virtual machine.")); 121 m_pComboFamily->setWhatsThis(tr("Selects the operating system family that " 122 "you plan to install into this virtual machine.")); 123 m_pComboType->setWhatsThis(tr("Selects the operating system type that " 124 "you plan to install into this virtual machine " 125 "(called a guest operating system).")); 126 } 127 128 void UINameAndSystemEditor::sltFamilyChanged(int iIndex) 129 { 130 /* Lock the signals of m_pComboType to prevent it's reaction on clearing: */ 131 m_pComboType->blockSignals(true); 132 m_pComboType->clear(); 133 134 /* Populate combo-box with OS types related to currently selected family id: */ 135 const QString strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString(); 136 const QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(strFamilyId); 137 for (int i = 0; i < types.size(); ++i) 138 { 139 /* Skip 64bit OS types is hardware virtualization or long mode is not supported: */ 140 if (types.at(i).GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode)) 141 continue; 142 const int iIndex = m_pComboType->count(); 143 m_pComboType->insertItem(iIndex, types[i].GetDescription()); 144 m_pComboType->setItemData(iIndex, types[i].GetId(), TypeID); 145 } 146 147 /* Select the most recently chosen item: */ 148 if (m_currentIds.contains(strFamilyId)) 149 { 150 const QString strTypeId = m_currentIds.value(strFamilyId); 151 const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 152 if (iTypeIndex != -1) 153 m_pComboType->setCurrentIndex(iTypeIndex); 154 } 155 /* Or select Windows 7 item for Windows family as default: */ 156 else if (strFamilyId == "Windows") 157 { 158 QString strDefaultID = "Windows7"; 159 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 160 strDefaultID += "_64"; 161 const int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID); 162 if (iIndexWin7 != -1) 163 m_pComboType->setCurrentIndex(iIndexWin7); 164 } 165 /* Or select Oracle Linux item for Linux family as default: */ 166 else if (strFamilyId == "Linux") 167 { 168 QString strDefaultID = "Oracle"; 169 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 170 strDefaultID += "_64"; 171 const int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID); 172 if (iIndexUbuntu != -1) 173 m_pComboType->setCurrentIndex(iIndexUbuntu); 174 } 175 /* Else simply select the first one present: */ 176 else 177 m_pComboType->setCurrentIndex(0); 178 179 /* Update all the stuff: */ 180 sltTypeChanged(m_pComboType->currentIndex()); 181 182 /* Unlock the signals of m_pComboType: */ 183 m_pComboType->blockSignals(false); 184 } 185 186 void UINameAndSystemEditor::sltTypeChanged(int iIndex) 187 { 188 /* Save the new selected OS type: */ 189 m_enmType = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(), 190 m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString()); 191 m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_enmType.GetId())); 192 193 /* Save the most recently used item: */ 194 m_currentIds[m_enmType.GetFamilyId()] = m_enmType.GetId(); 195 196 /* Notifies listeners about OS type change: */ 197 emit sigOsTypeChanged(); 198 } 199 63 200 void UINameAndSystemEditor::prepare() 64 201 { … … 85 222 /* Create main-layout: */ 86 223 QGridLayout *pMainLayout = new QGridLayout(this); 87 AssertPtrReturnVoid(pMainLayout);224 if (pMainLayout) 88 225 { 89 226 /* Configure main-layout: */ … … 92 229 /* Create VM name label: */ 93 230 m_pLabelName = new QLabel; 94 AssertPtrReturnVoid(m_pLabelName);231 if (m_pLabelName) 95 232 { 96 233 /* Configure VM name label: */ … … 105 242 /* Create VM name editor: */ 106 243 m_pEditorName = new QLineEdit; 107 AssertPtrReturnVoid(m_pEditorName);244 if (m_pEditorName) 108 245 { 109 246 /* Configure VM name editor: */ … … 118 255 /* Create VM location editor: */ 119 256 m_pEditorLocation = new UIFilePathSelector; 120 AssertPtrReturnVoid(m_pEditorLocation);257 if (m_pEditorLocation) 121 258 { 122 259 /* Configure advanced VM name editor: */ … … 133 270 /* Create VM OS family label: */ 134 271 m_pLabelFamily = new QLabel; 135 AssertPtrReturnVoid(m_pLabelFamily);272 if (m_pLabelFamily) 136 273 { 137 274 /* Configure VM OS family label: */ … … 144 281 /* Create VM OS family combo: */ 145 282 m_pComboFamily = new QComboBox; 146 AssertPtrReturnVoid(m_pComboFamily);283 if (m_pComboFamily) 147 284 { 148 285 /* Configure VM OS family combo: */ … … 155 292 /* Create VM OS type label: */ 156 293 m_pLabelType = new QLabel; 157 AssertPtrReturnVoid(m_pLabelType);294 if (m_pLabelType) 158 295 { 159 296 /* Configure VM OS type label: */ … … 166 303 /* Create VM OS type combo: */ 167 304 m_pComboType = new QComboBox; 168 AssertPtrReturnVoid(m_pComboType);305 if (m_pComboType) 169 306 { 170 307 /* Configure VM OS type combo: */ … … 177 314 /* Create sub-layout: */ 178 315 QVBoxLayout *pLayoutIcon = new QVBoxLayout; 179 AssertPtrReturnVoid(pLayoutIcon);316 if (pLayoutIcon) 180 317 { 181 318 /* Create VM OS type icon: */ 182 319 m_pIconType = new QLabel; 183 AssertPtrReturnVoid(m_pIconType);320 if (m_pIconType) 184 321 { 185 322 /* Configure VM OS type icon: */ … … 222 359 /* Prepare connections: */ 223 360 if (!m_fChooseLocation) 224 connect(m_pEditorName, SIGNAL(textChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &))); 225 else 226 connect(m_pEditorLocation, SIGNAL(pathChanged(const QString &)), this, SIGNAL(sigNameChanged(const QString &))); 227 connect(m_pComboFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(sltFamilyChanged(int))); 228 connect(m_pComboType, SIGNAL(currentIndexChanged(int)), this, SLOT(sltTypeChanged(int))); 229 } 230 231 QString UINameAndSystemEditor::name() const 232 { 233 if (!m_fChooseLocation) 234 return m_pEditorName->text(); 235 else 236 return m_pEditorLocation->path(); 237 } 238 239 void UINameAndSystemEditor::setName(const QString &strName) 240 { 241 if (!m_fChooseLocation) 242 m_pEditorName->setText(strName); 243 else 244 m_pEditorLocation->setPath(strName); 245 } 246 247 CGuestOSType UINameAndSystemEditor::type() const 248 { 249 return m_type; 250 } 251 252 void UINameAndSystemEditor::setType(const CGuestOSType &type) 253 { 254 /** @todo We're getting here with a NULL type when creating new VMs. Very 255 * annoying, so I've just shut it up for now. Sergey and Santosh can try 256 * figure out why this happens now with Qt5. */ 257 if (type.isNotNull()) 258 { 259 /* Initialize variables: */ 260 const QString strFamilyId = type.GetFamilyId(); 261 const QString strTypeId = type.GetId(); 262 263 /* Get/check family index: */ 264 const int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID); 265 AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData())); 266 if (iFamilyIndex != -1) 267 m_pComboFamily->setCurrentIndex(iFamilyIndex); 268 269 /* Get/check type index: */ 270 const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 271 AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData())); 272 if (iTypeIndex != -1) 273 m_pComboType->setCurrentIndex(iTypeIndex); 274 } 275 } 276 277 void UINameAndSystemEditor::retranslateUi() 278 { 279 m_pLabelName->setText(tr("N&ame:")); 280 m_pLabelFamily->setText(tr("&Type:")); 281 m_pLabelType->setText(tr("&Version:")); 282 if (!m_fChooseLocation) 283 m_pEditorName->setWhatsThis(tr("Holds the name of the virtual machine.")); 284 else 285 m_pEditorLocation->setWhatsThis(tr("Holds the location of the virtual machine.")); 286 m_pComboFamily->setWhatsThis(tr("Selects the operating system family that " 287 "you plan to install into this virtual machine.")); 288 m_pComboType->setWhatsThis(tr("Selects the operating system type that " 289 "you plan to install into this virtual machine " 290 "(called a guest operating system).")); 291 } 292 293 void UINameAndSystemEditor::sltFamilyChanged(int iIndex) 294 { 295 /* Lock the signals of m_pComboType to prevent it's reaction on clearing: */ 296 m_pComboType->blockSignals(true); 297 m_pComboType->clear(); 298 299 /* Populate combo-box with OS types related to currently selected family id: */ 300 const QString strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString(); 301 const QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(strFamilyId); 302 for (int i = 0; i < types.size(); ++i) 303 { 304 /* Skip 64bit OS types is hardware virtualization or long mode is not supported: */ 305 if (types.at(i).GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode)) 306 continue; 307 const int iIndex = m_pComboType->count(); 308 m_pComboType->insertItem(iIndex, types[i].GetDescription()); 309 m_pComboType->setItemData(iIndex, types[i].GetId(), TypeID); 310 } 311 312 /* Select the most recently chosen item: */ 313 if (m_currentIds.contains(strFamilyId)) 314 { 315 const QString strTypeId = m_currentIds.value(strFamilyId); 316 const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID); 317 if (iTypeIndex != -1) 318 m_pComboType->setCurrentIndex(iTypeIndex); 319 } 320 /* Or select Windows 7 item for Windows family as default: */ 321 else if (strFamilyId == "Windows") 322 { 323 QString strDefaultID = "Windows7"; 324 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 325 strDefaultID += "_64"; 326 const int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID); 327 if (iIndexWin7 != -1) 328 m_pComboType->setCurrentIndex(iIndexWin7); 329 } 330 /* Or select Oracle Linux item for Linux family as default: */ 331 else if (strFamilyId == "Linux") 332 { 333 QString strDefaultID = "Oracle"; 334 if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode) 335 strDefaultID += "_64"; 336 const int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID); 337 if (iIndexUbuntu != -1) 338 m_pComboType->setCurrentIndex(iIndexUbuntu); 339 } 340 /* Else simply select the first one present: */ 341 else 342 m_pComboType->setCurrentIndex(0); 343 344 /* Update all the stuff: */ 345 sltTypeChanged(m_pComboType->currentIndex()); 346 347 /* Unlock the signals of m_pComboType: */ 348 m_pComboType->blockSignals(false); 349 } 350 351 void UINameAndSystemEditor::sltTypeChanged(int iIndex) 352 { 353 /* Save the new selected OS type: */ 354 m_type = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(), 355 m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString()); 356 m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_type.GetId())); 357 358 /* Save the most recently used item: */ 359 m_currentIds[m_type.GetFamilyId()] = m_type.GetId(); 360 361 /* Notifies listeners about OS type change: */ 362 emit sigOsTypeChanged(); 363 } 364 361 connect(m_pEditorName, &QLineEdit::textChanged, 362 this, &UINameAndSystemEditor::sigNameChanged); 363 else 364 connect(m_pEditorLocation, &UIFilePathSelector::pathChanged, 365 this, &UINameAndSystemEditor::sigNameChanged); 366 connect(m_pComboFamily, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 367 this, &UINameAndSystemEditor::sltFamilyChanged); 368 connect(m_pComboType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 369 this, &UINameAndSystemEditor::sltTypeChanged); 370 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h
r69500 r71924 5 5 6 6 /* 7 * Copyright (C) 2008-201 7Oracle Corporation7 * Copyright (C) 2008-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 /* GUI includes: */ 25 25 #include "QIWithRetranslateUI.h" 26 #include "VBoxGlobal.h" 26 #include "UILibraryDefs.h" 27 28 /* COM includes: */ 29 #include "COMEnums.h" 30 #include "CGuestOSType.h" 27 31 28 32 /* Forward declarations: */ 33 class QComboBox; 29 34 class QLabel; 30 35 class QLineEdit; 31 class Q ComboBox;36 class QString; 32 37 class UIFilePathSelector; 33 38 34 /** QWidget extensionproviding complex editor for basic VM parameters. */35 class UINameAndSystemEditor : public QIWithRetranslateUI<QWidget>39 /** QWidget subclass providing complex editor for basic VM parameters. */ 40 class SHARED_LIBRARY_STUFF UINameAndSystemEditor : public QIWithRetranslateUI<QWidget> 36 41 { 37 42 Q_OBJECT; … … 49 54 public: 50 55 51 /** Constructs VM parameters editor on the basis of passed @a pParent.52 * @param fChooseFullPath determinewhether we should propose to choose location. */56 /** Constructs VM parameters editor passing @a pParent to the base-class. 57 * @param fChooseFullPath Brings whether we should propose to choose location. */ 53 58 UINameAndSystemEditor(QWidget *pParent, bool fChooseLocation = false); 54 59 55 60 /** Returns the VM name editor. */ 56 QLineEdit *nameEditor() const { return m_pEditorName; }61 QLineEdit *nameEditor() const { return m_pEditorName; } 57 62 /** Returns the VM location editor. */ 58 UIFilePathSelector *locationEditor() const { return m_pEditorLocation; }63 UIFilePathSelector *locationEditor() const { return m_pEditorLocation; } 59 64 60 65 /** Returns the VM name. */ … … 65 70 /** Returns the VM OS type. */ 66 71 CGuestOSType type() const; 67 /** Defines the VM OS @a type. */68 void setType(const CGuestOSType & type);72 /** Defines the VM OS @a enmType. */ 73 void setType(const CGuestOSType &enmType); 69 74 70 75 protected: 76 77 /** Handles translation event. */ 78 virtual void retranslateUi() /* override */; 79 80 private slots: 81 82 /** Handles VM OS family @a iIndex change. */ 83 void sltFamilyChanged(int iIndex); 84 85 /** Handles VM OS type @a iIndex change. */ 86 void sltTypeChanged(int iIndex); 87 88 private: 71 89 72 90 /** @name Prepare cascade. … … 84 102 /** @} */ 85 103 86 /** Handles translation event. */87 virtual void retranslateUi() /* override */;88 89 private slots:90 91 /** Handles VM OS family @a iIndex change. */92 void sltFamilyChanged(int iIndex);93 94 /** Handles VM OS type @a iIndex change. */95 void sltTypeChanged(int iIndex);96 97 private:98 99 104 /** Holds the VM OS type. */ 100 CGuestOSType m_ type;105 CGuestOSType m_enmType; 101 106 /** Holds the currently chosen OS type IDs on per-family basis. */ 102 107 QMap<QString, QString> m_currentIds; … … 127 132 128 133 #endif /* !___UINameAndSystemEditor_h___ */ 129 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r71027 r71924 22 22 /* Qt includes: */ 23 23 # include <QDir> 24 # include <QLineEdit> 25 # include <QHBoxLayout> 24 26 # include <QVBoxLayout> 25 # include <QHBoxLayout>26 # include <QLineEdit>27 27 28 28 /* GUI includes: */ 29 # include "QIRichTextLabel.h" 30 # include "VBoxGlobal.h" 31 # include "UIMessageCenter.h" 32 # include "UINameAndSystemEditor.h" 29 33 # include "UIWizardNewVMPageBasic1.h" 30 34 # include "UIWizardNewVM.h" 31 # include "UIMessageCenter.h"32 # include "UINameAndSystemEditor.h"33 # include "QIRichTextLabel.h"34 35 35 36 /* COM includes: */ 37 # include "CHost.h" 36 38 # include "CSystemProperties.h" 37 39
Note:
See TracChangeset
for help on using the changeset viewer.