- Timestamp:
- Nov 2, 2023 9:51:36 AM (18 months ago)
- svn:sync-xref-src-repo-rev:
- 159807
- 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
r101712 r101713 109 109 if (m_pLabelFamily) 110 110 m_pLabelFamily->setEnabled(fEnabled); 111 if (m_pLabelDistribution) 112 m_pLabelDistribution->setEnabled(fEnabled); 111 113 if (m_pLabelType) 112 114 m_pLabelType->setEnabled(fEnabled); 113 115 if (m_pComboFamily) 114 116 m_pComboFamily->setEnabled(fEnabled); 117 if (m_pComboDistribution) 118 m_pComboDistribution->setEnabled(fEnabled); 115 119 if (m_pComboType) 116 120 m_pComboType->setEnabled(fEnabled); … … 256 260 if (m_pLabelFamily) 257 261 iWidth = qMax(iWidth, m_pLabelFamily->width()); 262 if (m_pLabelDistribution) 263 iWidth = qMax(iWidth, m_pLabelDistribution->width()); 258 264 if (m_pLabelType) 259 265 iWidth = qMax(iWidth, m_pLabelType->width()); … … 285 291 m_pComboFamily->setToolTip(tr("Selects the operating system type that " 286 292 "you plan to install into this virtual machine.")); 293 if (m_pComboDistribution) 294 m_pComboDistribution->setToolTip(tr("Selects the operating system subtype that " 295 "you plan to install into this virtual machine.")); 287 296 if (m_pComboType) 288 297 m_pComboType->setToolTip(tr("Selects the operating system version that " … … 303 312 /* Sanity check: */ 304 313 AssertPtrReturnVoid(m_pComboFamily); 305 AssertPtrReturnVoid(m_pComboDistribution);306 314 307 315 /* Acquire new family ID: */ … … 309 317 AssertReturnVoid(!m_strFamilyId.isEmpty()); 310 318 311 m_pComboDistribution->blockSignals(true);312 m_pLabelDistribution->setEnabled(true);313 314 m_pComboDistribution->setEnabled(true);315 m_pComboDistribution->clear();316 317 const QStringList distributionList = uiCommon().guestOSTypeManager().getSubtypeListForFamilyId(m_strFamilyId);318 319 if (distributionList.isEmpty())320 {321 m_pComboDistribution->setEnabled(false);322 m_pLabelDistribution->setEnabled(false);323 /* If subtype list is empty the all the types of the family are added to typ selection combo: */324 populateTypeCombo(uiCommon().guestOSTypeManager().getTypeListForFamilyId(m_strFamilyId));325 }326 else327 {328 /* Populate distribution combo: */329 /* If family is Linux then select Oracle Linux as subtype: */330 int iOracleIndex = -1;331 foreach (const QString &strDistribution, distributionList)332 {333 m_pComboDistribution->addItem(strDistribution);334 if (strDistribution.contains(QRegularExpression("Oracle.*Linux")))335 iOracleIndex = m_pComboDistribution->count() - 1;336 }337 if (iOracleIndex != -1)338 m_pComboDistribution->setCurrentIndex(iOracleIndex);339 340 populateTypeCombo(uiCommon().guestOSTypeManager().getTypeListForSubtype(m_pComboDistribution->currentText()));341 }342 m_pComboDistribution->blockSignals(false);343 344 319 /* Notify listeners about this change: */ 345 320 emit sigOSFamilyChanged(m_strFamilyId); 321 322 /* Pupulate distribution combo: */ 323 populateDistributionCombo(); 346 324 } 347 325 … … 351 329 m_strDistribution = strDistribution; 352 330 331 /* If distribution list is empty, all the types of the family are added to type combo: */ 332 const UIGuestOSTypeManager::UIGuestOSTypeInfo types 333 = m_strDistribution.isEmpty() 334 ? uiCommon().guestOSTypeManager().getTypeListForFamilyId(m_strFamilyId) 335 : uiCommon().guestOSTypeManager().getTypeListForSubtype(m_strDistribution); 336 337 /* Save the most recently used item: */ 338 m_familyToDistribution[m_strFamilyId] = m_strDistribution; 339 353 340 /* Populate type combo: */ 354 populateTypeCombo( uiCommon().guestOSTypeManager().getTypeListForSubtype(strDistribution));341 populateTypeCombo(types); 355 342 } 356 343 … … 368 355 369 356 /* Save the most recently used item: */ 370 m_currentIds[m_strFamilyId] = m_strTypeId; 371 372 /* Notifies listeners about OS type change: */ 357 if (m_strDistribution.isEmpty()) 358 m_familyToType[m_strFamilyId] = m_strTypeId; 359 else 360 m_distributionToType[m_strDistribution] = m_strTypeId; 361 362 /* Notifies listeners about this change: */ 373 363 emit sigOsTypeChanged(); 374 364 } … … 634 624 } 635 625 626 void UINameAndSystemEditor::populateDistributionCombo() 627 { 628 /* Sanity check: */ 629 AssertPtrReturnVoid(m_pComboDistribution); 630 631 /* Acquire a list of suitable sub-types: */ 632 const QStringList distributions = uiCommon().guestOSTypeManager().getSubtypeListForFamilyId(m_strFamilyId); 633 m_pLabelDistribution->setEnabled(!distributions.isEmpty()); 634 m_pComboDistribution->setEnabled(!distributions.isEmpty()); 635 636 /* Block signals initially and clear the combo: */ 637 m_pComboDistribution->blockSignals(true); 638 m_pComboDistribution->clear(); 639 640 /* Populate distribution combo: */ 641 m_pComboDistribution->addItems(distributions); 642 643 /* Unblock signals finally: */ 644 m_pComboDistribution->blockSignals(false); 645 646 /* Select preferred OS distribution: */ 647 selectPreferredDistribution(); 648 649 /* Trigger distribution change handler manually: */ 650 sltDistributionChanged(m_pComboDistribution->currentText()); 651 } 652 636 653 void UINameAndSystemEditor::populateTypeCombo(const UIGuestOSTypeManager::UIGuestOSTypeInfo &types) 637 654 { … … 661 678 } 662 679 680 void UINameAndSystemEditor::selectPreferredDistribution() 681 { 682 /* Try to restore current distribution if possible: */ 683 if (m_familyToDistribution.contains(m_strFamilyId)) 684 m_pComboDistribution->setCurrentText(m_familyToDistribution.value(m_strFamilyId)); 685 /* Oracle Linux for Linux family: */ 686 else if (m_strFamilyId == "Linux") 687 { 688 const int iOracleIndex = m_pComboDistribution->findText("Oracle", Qt::MatchContains); 689 if (iOracleIndex != -1) 690 m_pComboDistribution->setCurrentIndex(iOracleIndex); 691 } 692 } 693 663 694 void UINameAndSystemEditor::selectPreferredType() 664 695 { 696 /* Try to restore current type if possible: */ 697 if ( m_familyToType.contains(m_strFamilyId) 698 || m_distributionToType.contains(m_strDistribution)) 699 { 700 const QString strCurrentType = m_familyToType.contains(m_strFamilyId) 701 ? m_familyToType.value(m_strFamilyId) 702 : m_distributionToType.contains(m_strDistribution) 703 ? m_distributionToType.value(m_strDistribution) 704 : QString(); 705 const int iCurrentIndex = m_pComboType->findData(strCurrentType); 706 if (iCurrentIndex != -1) 707 m_pComboType->setCurrentIndex(iCurrentIndex); 708 } 665 709 /* Windows 11 for Windows family: */ 666 if (m_strFamilyId == "Windows")710 else if (m_strFamilyId == "Windows") 667 711 { 668 712 const QString strDefaultID = GUEST_OS_ID_STR_X64("Windows11"); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r101711 r101713 169 169 /** Pupulates VM OS family combo. */ 170 170 void populateFamilyCombo(); 171 /** Pupulates VM OS distribution combo. */ 172 void populateDistributionCombo(); 171 173 /** Pupulates VM OS type combo. 172 174 * @param types Brings the list of type pairs. */ 173 175 void populateTypeCombo(const QList<QPair<QString, QString> > &types); 174 176 177 /** Selects preferred distribution. */ 178 void selectPreferredDistribution(); 175 179 /** Selects preferred type. */ 176 180 void selectPreferredType(); … … 199 203 QString m_strTypeId; 200 204 205 /** Holds the currently chosen OS distributions on per-family basis. */ 206 QMap<QString, QString> m_familyToDistribution; 201 207 /** Holds the currently chosen OS type IDs on per-family basis. */ 202 QMap<QString, QString> m_currentIds; 208 QMap<QString, QString> m_familyToType; 209 /** Holds the currently chosen OS type IDs on per-distribution basis. */ 210 QMap<QString, QString> m_distributionToType; 203 211 /** @} */ 204 212
Note:
See TracChangeset
for help on using the changeset viewer.