Changeset 101285 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 27, 2023 9:17:00 AM (16 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.h
r101278 r101285 44 44 45 45 46 46 /** A wrapper and manager class for Guest OS types (IGuestOSType). Logically we structure os types into families 47 * e.g. Window, Linux etc. Some families have so-called variants which for Linux corresponds to distros, while some 48 * families have no variant. Under variants (and when no variant exists direcly under family) we have guest os 49 * types, e.g. Debian12_x64 etc. */ 47 50 class SHARED_LIBRARY_STUFF UIGuestOSTypeManager 48 51 { … … 50 53 public: 51 54 55 /* A list of all OS families. 'first' of each pair is famil Id and 'second' is family description. */ 52 56 typedef QVector<QPair<QString, QString> > UIGuestOSTypeFamilyInfo; 53 57 typedef QVector<QPair<QString, QString> > UIGuestOSTypeInfo; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.cpp
r98103 r101285 33 33 /* GUI includes */ 34 34 #include "UICommon.h" 35 #include "UIGuestOSType.h" 35 36 #include "UIGuestOSTypeSelectionButton.h" 36 37 #include "UIIconPool.h" 37 38 39 /* Other VBox includes: */ 40 #include "iprt/assert.h" 38 41 39 42 UIGuestOSTypeSelectionButton::UIGuestOSTypeSelectionButton(QWidget *pParent) … … 76 79 void UIGuestOSTypeSelectionButton::setOSTypeId(const QString &strOSTypeId) 77 80 { 81 if (m_strOSTypeId == strOSTypeId) 82 return; 83 const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager(); 84 AssertReturnVoid(pManager); 85 78 86 m_strOSTypeId = strOSTypeId; 79 CGuestOSType enmType = uiCommon().vmGuestOSType(strOSTypeId);80 87 81 88 #ifndef VBOX_WS_MAC 82 89 /* Looks ugly on the Mac: */ 83 setIcon(generalIconPool().guestOSTypePixmapDefault( enmType.GetId()));90 setIcon(generalIconPool().guestOSTypePixmapDefault(m_strOSTypeId)); 84 91 #endif 85 92 86 setText( enmType.GetDescription());93 setText(pManager->getDescription(m_strOSTypeId)); 87 94 } 88 95 … … 92 99 } 93 100 101 void UIGuestOSTypeSelectionButton::createOSTypeMenu(const UIGuestOSTypeManager::UIGuestOSTypeInfo &typeList, QMenu *pMenu) 102 { 103 for (int j = 0; j < typeList.size(); ++j) 104 { 105 const QPair<QString, QString> &typeInfo = typeList[j]; 106 QAction *pAction = pMenu->addAction(generalIconPool().guestOSTypePixmapDefault(typeInfo.first), typeInfo.second); 107 connect(pAction, &QAction::triggered, 108 m_pSignalMapper, static_cast<void(QSignalMapper::*)(void)>(&QSignalMapper::map)); 109 m_pSignalMapper->setMapping(pAction, typeInfo.first); 110 } 111 } 112 94 113 void UIGuestOSTypeSelectionButton::populateMenu() 95 114 { 96 /* Clea initially: */115 /* Clear initially: */ 97 116 m_pMainMenu->clear(); 98 117 99 /* Create a list of all possible OS types: */ 100 foreach(const QString &strFamilyId, uiCommon().vmGuestOSFamilyIDs()) 118 const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager(); 119 AssertReturnVoid(pManager); 120 UIGuestOSTypeManager::UIGuestOSTypeFamilyInfo familyList = pManager->getFamilies(); 121 122 for (int i = 0; i < familyList.size(); ++i) 101 123 { 102 QMenu *pSubMenu = m_pMainMenu->addMenu(uiCommon().vmGuestOSFamilyDescription(strFamilyId)); 103 foreach (const CGuestOSType &comType, uiCommon().vmGuestOSTypeList(strFamilyId)) 124 const QPair<QString, QString> &familyInfo = familyList[i]; 125 QMenu *pSubMenu = m_pMainMenu->addMenu(familyInfo.second); 126 QStringList variantList = pManager->getVariantListForFamilyId(familyInfo.first); 127 128 if (variantList.isEmpty()) 129 createOSTypeMenu(pManager->getTypeListForFamilyId(familyInfo.first), pSubMenu); 130 else 104 131 { 105 QAction *pAction = pSubMenu->addAction(generalIconPool().guestOSTypePixmapDefault(comType.GetId()), 106 comType.GetDescription()); 107 connect(pAction, &QAction::triggered, 108 m_pSignalMapper, static_cast<void(QSignalMapper::*)(void)>(&QSignalMapper::map)); 109 m_pSignalMapper->setMapping(pAction, comType.GetId()); 132 foreach (const QString &strVariant, variantList) 133 createOSTypeMenu(pManager->getTypeListForVariant(strVariant), pSubMenu->addMenu(strVariant)); 110 134 } 111 135 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.h
r98103 r101285 72 72 /** Populates menu. */ 73 73 void populateMenu(); 74 74 /** A help fundtion for populateMenu(). @p is the list of os type and @p pMenu is the menu to populate. */ 75 void createOSTypeMenu(const QVector<QPair<QString, QString> > &typeList, QMenu *pMenu); 75 76 /** Holds the current guest OS type ID. */ 76 77 QString m_strOSTypeId;
Note:
See TracChangeset
for help on using the changeset viewer.