Changeset 101242 in vbox
- Timestamp:
- Sep 22, 2023 3:41:24 PM (17 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r101232 r101242 316 316 } 317 317 318 void UINameAndSystemEditor::setType(const CGuestOSType &enmType)319 {320 // WORKAROUND:321 // We're getting here with a NULL enmType when creating new VMs.322 // Very annoying, so just workarounded for now.323 /** @todo find out the reason and way to fix that.. */324 if (enmType.isNull())325 return;326 327 /* Pass to function above: */328 setTypeId(enmType.GetId(), enmType.GetFamilyId());329 }318 // void UINameAndSystemEditor::setType(const CGuestOSType &enmType) 319 // { 320 // // WORKAROUND: 321 // // We're getting here with a NULL enmType when creating new VMs. 322 // // Very annoying, so just workarounded for now. 323 // /** @todo find out the reason and way to fix that.. */ 324 // if (enmType.isNull()) 325 // return; 326 327 // /* Pass to function above: */ 328 // setTypeId(enmType.GetId(), enmType.GetFamilyId()); 329 // } 330 330 331 331 CGuestOSType UINameAndSystemEditor::type() const … … 402 402 m_pLabelType->setText(tr("&Version:")); 403 403 if (m_pLabelVariant) 404 m_pLabelVariant->setText(tr(" Variant:"));404 m_pLabelVariant->setText(tr("Kind:")); 405 405 406 406 if (m_pEditorName) … … 427 427 AssertReturnVoid(pGuestOSTypeManager); 428 428 429 QStringstrFamilyId = m_pComboFamily->itemData(index, FamilyID).toString();430 431 AssertReturnVoid(! strFamilyId.isEmpty());429 m_strFamilyId = m_pComboFamily->itemData(index, FamilyID).toString(); 430 431 AssertReturnVoid(!m_strFamilyId.isEmpty()); 432 432 433 433 m_pComboVariant->blockSignals(true); … … 437 437 m_pComboVariant->clear(); 438 438 439 const QStringList variantList = pGuestOSTypeManager->getVariantListForFamilyId( strFamilyId);439 const QStringList variantList = pGuestOSTypeManager->getVariantListForFamilyId(m_strFamilyId); 440 440 441 441 if (variantList.isEmpty()) … … 444 444 m_pLabelVariant->setEnabled(false); 445 445 /* If variant list is empty the all the types of the family are added to typ selection combo: */ 446 populateTypeCombo(pGuestOSTypeManager->getTypeListForFamilyId( strFamilyId));446 populateTypeCombo(pGuestOSTypeManager->getTypeListForFamilyId(m_strFamilyId)); 447 447 } 448 448 else … … 461 461 // m_pComboType->clear(); 462 462 463 // /* Acquire family ID: */464 // m_strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString();465 463 466 464 // /* Populate combo-box with OS types related to currently selected family id: */ … … 472 470 // } 473 471 472 473 // /* Update all the stuff: */ 474 // sltTypeChanged(m_pComboType->currentIndex()); 475 476 // /* Unlock the signals of m_pComboType: */ 477 // m_pComboType->blockSignals(false); 478 479 /* Notify listeners about this change: */ 480 emit sigOSFamilyChanged(m_strFamilyId); 481 } 482 483 void UINameAndSystemEditor::sltVariantChanged(const QString &strVariant) 484 { 485 const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager(); 486 AssertReturnVoid(pGuestOSTypeManager); 487 m_strVariant = strVariant; 488 populateTypeCombo(pGuestOSTypeManager->getTypeListForVariant(strVariant)); 489 } 490 491 void UINameAndSystemEditor::populateTypeCombo(const UIGuestOSTypeManager::UIGuestOSTypeInfo &typeList) 492 { 493 AssertReturnVoid(m_pComboType); 494 AssertReturnVoid(!typeList.isEmpty()); 495 496 m_pComboType->blockSignals(true); 497 m_pComboType->clear(); 498 for (int i = 0; i < typeList.size(); ++i) 499 { 500 m_pComboType->addItem(typeList[i].second); 501 m_pComboType->setItemData(i, typeList[i].first, TypeID); 502 } 503 m_pComboType->blockSignals(false); 504 selectPreferredType(); 505 sltTypeChanged(m_pComboType->currentIndex()); 506 } 507 508 void UINameAndSystemEditor::selectPreferredType() 509 { 474 510 // /* Select the most recently chosen item: */ 475 511 // if (m_currentIds.contains(m_strFamilyId)) … … 481 517 // } 482 518 // /* Or select Windows 10 item for Windows family as default: */ 483 // else if (m_strFamilyId == "Windows")484 // {485 // QString strDefaultID = "Windows11_64";486 // const int iIndexWin = m_pComboType->findData(strDefaultID, TypeID);487 // if (iIndexWin != -1)488 // m_pComboType->setCurrentIndex(iIndexWin);489 // }490 // /* Or select Oracle Linux item for Linux family as default: */491 // else if (m_strFamilyId == "Linux")492 // {493 // QString strDefaultID = "Oracle_64";494 // const int iIndexOracle = m_pComboType->findData(strDefaultID, TypeID);495 // if (iIndexOracle != -1)496 // m_pComboType->setCurrentIndex(iIndexOracle);497 // }498 // else if (m_strFamilyId == "Other")499 // {500 // QString strDefaultID = "Other_64";501 // const int iIndexOther = m_pComboType->findData(strDefaultID, TypeID);502 // if (iIndexOther != -1)503 // m_pComboType->setCurrentIndex(iIndexOther);504 // }505 // /* Else try to pick the first 64-bit one if it exists.: */506 519 // else 507 // { 508 // QString strDefaultID = "_64"; 509 // const int iIndexAll = m_pComboType->findData(strDefaultID, TypeID, Qt::MatchContains); 510 // if (iIndexAll != -1) 511 // m_pComboType->setCurrentIndex(iIndexAll); 512 // else 513 // m_pComboType->setCurrentIndex(0); 514 // } 515 516 // /* Update all the stuff: */ 517 // sltTypeChanged(m_pComboType->currentIndex()); 518 519 // /* Unlock the signals of m_pComboType: */ 520 // m_pComboType->blockSignals(false); 521 522 // /* Notify listeners about this change: */ 523 // emit sigOSFamilyChanged(m_strFamilyId); 524 } 525 526 void UINameAndSystemEditor::sltVariantChanged(const QString &strVariant) 527 { 528 const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager(); 529 AssertReturnVoid(pGuestOSTypeManager); 530 531 populateTypeCombo(pGuestOSTypeManager->getTypeListForVariant(strVariant)); 532 } 533 534 void UINameAndSystemEditor::populateTypeCombo(const UIGuestOSTypeManager::UIGuestOSTypeInfo &typeList) 535 { 536 AssertReturnVoid(m_pComboType); 537 AssertReturnVoid(!typeList.isEmpty()); 538 539 m_pComboType->blockSignals(true); 540 m_pComboType->clear(); 541 for (int i = 0; i < typeList.size(); ++i) 542 { 543 m_pComboType->addItem(typeList[i].second); 544 m_pComboType->setItemData(i, typeList[i].first, TypeID); 545 } 546 m_pComboType->blockSignals(false); 547 sltTypeChanged(m_pComboType->currentIndex()); 520 if (m_strFamilyId == "Windows") 521 { 522 QString strDefaultID = "Windows11_x64"; 523 const int iIndexWin = m_pComboType->findData(strDefaultID, TypeID); 524 if (iIndexWin != -1) 525 { 526 m_pComboType->setCurrentIndex(iIndexWin); 527 return; 528 } 529 } 530 /* Or select Oracle Linux item for Linux family as default: */ 531 if (m_strVariant == "Oracle") 532 { 533 QString strDefaultID = "Oracle_x64"; 534 const int iIndexOracle = m_pComboType->findData(strDefaultID, TypeID); 535 if (iIndexOracle != -1) 536 { 537 m_pComboType->setCurrentIndex(iIndexOracle); 538 return; 539 } 540 } 541 542 /* Else try to pick the first 64-bit one if it exists.: */ 543 QString strDefaultID = "_x64"; 544 const int iIndexAll = m_pComboType->findData(strDefaultID, TypeID, Qt::MatchContains); 545 if (iIndexAll != -1) 546 m_pComboType->setCurrentIndex(iIndexAll); 547 else 548 m_pComboType->setCurrentIndex(0); 548 549 } 549 550 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r101232 r101242 53 53 Q_OBJECT; 54 54 Q_PROPERTY(QString name READ name WRITE setName); 55 Q_PROPERTY(CGuestOSType type READ type WRITE setType);56 55 57 56 /** Simple struct representing CGuestOSType cache. */ … … 130 129 QString familyId() const; 131 130 132 /** Defines the VM OS @a enmType. */133 void setType(const CGuestOSType &enmType);134 131 /** Returns the VM OS type. */ 135 132 CGuestOSType type() const; … … 182 179 ulong selectedEditionIndex() const; 183 180 void populateTypeCombo(const QList<QPair<QString, QString> > &typeList); 181 void selectPreferredType(); 184 182 185 183 /** @name Arguments … … 206 204 /** Holds the VM OS family ID. */ 207 205 QString m_strFamilyId; 206 QString m_strVariant; 208 207 209 208 /** Holds the currently chosen OS type IDs on per-family basis. */
Note:
See TracChangeset
for help on using the changeset viewer.