Changeset 73118 in vbox
- Timestamp:
- Jul 13, 2018 12:07:42 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 moved
-
Makefile.kmk (modified) (2 diffs)
-
src/precomp.h (modified) (1 diff)
-
src/widgets/UIApplianceEditorWidget.cpp (modified) (5 diffs)
-
src/widgets/UIGuestOSTypeSelectionButton.cpp (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxOSTypeSelectorButton.cpp ) (2 diffs)
-
src/widgets/UIGuestOSTypeSelectionButton.h (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxOSTypeSelectorButton.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72815 r73118 700 700 src/widgets/UIApplianceImportEditorWidget.h \ 701 701 src/widgets/UIEmptyFilePathSelector.h \ 702 src/widgets/UIGuestOSTypeSelectionButton.h \ 702 703 src/widgets/UILineTextEdit.h \ 703 704 src/widgets/UISlidingWidget.h \ 704 705 src/widgets/UITabBar.h \ 705 706 src/widgets/UIMenuToolBar.h \ 706 src/widgets/VBoxOSTypeSelectorButton.h \707 707 src/widgets/graphics/UIGraphicsButton.h \ 708 708 src/widgets/graphics/UIGraphicsRotatorButton.h \ … … 1345 1345 src/widgets/UIApplianceImportEditorWidget.cpp \ 1346 1346 src/widgets/UIEmptyFilePathSelector.cpp \ 1347 src/widgets/UIGuestOSTypeSelectionButton.cpp \ 1347 1348 src/widgets/UILineTextEdit.cpp \ 1348 1349 src/widgets/UISlidingWidget.cpp \ 1349 1350 src/widgets/UITabBar.cpp \ 1350 1351 src/widgets/UIMenuToolBar.cpp \ 1351 src/widgets/VBoxOSTypeSelectorButton.cpp \1352 1352 src/widgets/graphics/UIGraphicsButton.cpp \ 1353 1353 src/widgets/graphics/UIGraphicsRotatorButton.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/precomp.h
r71948 r73118 643 643 #include "VBoxLicenseViewer.h" 644 644 #include "UIMediaComboBox.h" 645 #include " VBoxOSTypeSelectorButton.h"645 #include "UIGuestOSTypeSelectionButton.h" 646 646 #include "UISettingsSelector.h" 647 647 #include "UISnapshotDetailsWidget.h" -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp
r73062 r73118 34 34 # include "QITreeView.h" 35 35 # include "VBoxGlobal.h" 36 # include " VBoxOSTypeSelectorButton.h"36 # include "UIGuestOSTypeSelectionButton.h" 37 37 # include "UIApplianceEditorWidget.h" 38 38 # include "UIConverter.h" … … 591 591 case KVirtualSystemDescriptionType_OS: 592 592 { 593 VBoxOSTypeSelectorButton *pButton = new VBoxOSTypeSelectorButton(pParent);593 UIGuestOSTypeSelectionButton *pButton = new UIGuestOSTypeSelectionButton(pParent); 594 594 /* Fill the background with the highlight color in the case 595 595 * the button hasn't a rectangle shape. This prevents the … … 722 722 case KVirtualSystemDescriptionType_OS: 723 723 { 724 if ( VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pEditor))724 if (UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pEditor)) 725 725 { 726 726 pButton->setOSTypeId(m_strConfigValue); … … 818 818 case KVirtualSystemDescriptionType_OS: 819 819 { 820 if ( VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pEditor))820 if (UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pEditor)) 821 821 { 822 822 m_strConfigValue = pButton->osTypeId(); … … 1284 1284 * the popup menu is shown. Prevent this here, cause otherwise the new 1285 1285 * selected OS will not be updated. */ 1286 VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pObject);1286 UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pObject); 1287 1287 if (pButton && pButton->isMenuShown()) 1288 1288 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.cpp
r73117 r73118 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBoxOSTypeSelectorButton class implementation.3 * VBox Qt GUI - UIGuestOSTypeSelectionButton class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 27 27 /* GUI includes */ 28 # include "VBoxOSTypeSelectorButton.h"29 28 # include "VBoxGlobal.h" 29 # include "UIGuestOSTypeSelectionButton.h" 30 30 31 31 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 32 32 33 33 34 VBoxOSTypeSelectorButton::VBoxOSTypeSelectorButton (QWidget *aParent)35 : QIWithRetranslateUI <QPushButton> (aParent)34 UIGuestOSTypeSelectionButton::UIGuestOSTypeSelectionButton(QWidget *pParent) 35 : QIWithRetranslateUI<QPushButton>(pParent) 36 36 { 37 37 /* Determine icon metric: */ 38 const QStyle *pStyle = QApplication::style(); 39 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 40 /* We have to make sure that the button has strong focus, otherwise the 41 * editing is ended when the menu is shown */ 42 setFocusPolicy (Qt::StrongFocus); 43 setIconSize (QSize (iIconMetric, iIconMetric)); 44 /* Create a signal mapper so that we not have to react to every single 45 * menu activation ourself. */ 46 mSignalMapper = new QSignalMapper (this); 47 connect (mSignalMapper, SIGNAL (mapped (const QString &)), 48 this, SLOT (setOSTypeId (const QString &))); 49 mMainMenu = new QMenu (aParent); 50 setMenu (mMainMenu); 38 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 39 setIconSize(QSize(iIconMetric, iIconMetric)); 51 40 41 /* We have to make sure that the button has strong focus, otherwise 42 * the editing is ended when the menu is shown: */ 43 setFocusPolicy(Qt::StrongFocus); 44 45 /* Create a signal mapper so that we not have to react to 46 * every single menu activation ourself: */ 47 m_pSignalMapper = new QSignalMapper(this); 48 if (m_pSignalMapper) 49 connect(m_pSignalMapper, static_cast<void(QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), 50 this, &UIGuestOSTypeSelectionButton::setOSTypeId); 51 52 /* Create main menu: */ 53 m_pMainMenu = new QMenu(pParent); 54 if (m_pMainMenu) 55 setMenu(m_pMainMenu); 56 57 /* Apply language settings: */ 52 58 retranslateUi(); 53 59 } 54 60 55 void VBoxOSTypeSelectorButton::setOSTypeId (const QString& aOSTypeId) 61 bool UIGuestOSTypeSelectionButton::isMenuShown() const 56 62 { 57 mOSTypeId = aOSTypeId; 58 CGuestOSType type = vboxGlobal().vmGuestOSType (aOSTypeId); 59 /* Looks ugly on the Mac */ 60 #ifndef VBOX_WS_MAC 61 setIcon (vboxGlobal().vmGuestOSTypePixmapDefault (type.GetId())); 62 #endif /* VBOX_WS_MAC */ 63 setText (type.GetDescription()); 63 return m_pMainMenu->isVisible(); 64 64 } 65 65 66 bool VBoxOSTypeSelectorButton::isMenuShown() const 66 void UIGuestOSTypeSelectionButton::setOSTypeId(const QString &strOSTypeId) 67 67 { 68 return mMainMenu->isVisible(); 68 m_strOSTypeId = strOSTypeId; 69 CGuestOSType enmType = vboxGlobal().vmGuestOSType(strOSTypeId); 70 71 #ifndef VBOX_WS_MAC 72 /* Looks ugly on the Mac: */ 73 setIcon(vboxGlobal().vmGuestOSTypePixmapDefault(enmType.GetId())); 74 #endif 75 76 setText(enmType.GetDescription()); 69 77 } 70 78 71 void VBoxOSTypeSelectorButton::retranslateUi()79 void UIGuestOSTypeSelectionButton::retranslateUi() 72 80 { 73 81 populateMenu(); 74 82 } 75 83 76 void VBoxOSTypeSelectorButton::populateMenu()84 void UIGuestOSTypeSelectionButton::populateMenu() 77 85 { 78 mMainMenu->clear(); 86 m_pMainMenu->clear(); 87 79 88 /* Create a list of all possible OS types */ 80 QList <CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList();81 foreach (const CGuestOSType& family, families)89 QList<CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList(); 90 foreach(const CGuestOSType &comFamily, families) 82 91 { 83 QMenu * subMenu = mMainMenu->addMenu (family.GetFamilyDescription());84 QList <CGuestOSType> types = vboxGlobal().vmGuestOSTypeList (family.GetFamilyId());85 foreach (const CGuestOSType & type, types)92 QMenu *pSubMenu = m_pMainMenu->addMenu(comFamily.GetFamilyDescription()); 93 QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(comFamily.GetFamilyId()); 94 foreach (const CGuestOSType &comType, types) 86 95 { 87 QAction *a = subMenu->addAction (vboxGlobal().vmGuestOSTypePixmapDefault (type.GetId()), type.GetDescription()); 88 connect(a, SIGNAL (triggered()), 89 mSignalMapper, SLOT(map())); 90 mSignalMapper->setMapping (a, type.GetId()); 96 QAction *pAction = pSubMenu->addAction(vboxGlobal().vmGuestOSTypePixmapDefault(comType.GetId()), 97 comType.GetDescription()); 98 connect(pAction, &QAction::triggered, 99 m_pSignalMapper, static_cast<void(QSignalMapper::*)(void)>(&QSignalMapper::map)); 100 m_pSignalMapper->setMapping(pAction, comType.GetId()); 91 101 } 92 102 } 93 103 } 94 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.h
r73117 r73118 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBoxOSTypeSelectorButton class declaration.3 * VBox Qt GUI - UIGuestOSTypeSelectionButton class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ VBoxOSTypeSelectorButton_h__19 #define __ VBoxOSTypeSelectorButton_h__18 #ifndef ___UIGuestOSTypeSelectionButton_h___ 19 #define ___UIGuestOSTypeSelectionButton_h___ 20 20 21 /* VBox includes */ 21 /* Qt includes: */ 22 #include <QPushButton> 23 24 /* GUI includes: */ 22 25 #include "QIWithRetranslateUI.h" 23 26 24 /* Qt includes */ 25 #include <QPushButton> 26 27 /* Forward declarations: */ 28 class QMenu; 27 29 class QSignalMapper; 28 30 29 class VBoxOSTypeSelectorButton: public QIWithRetranslateUI<QPushButton> 31 /** QPushButton sub-class for choosing guest OS family/type inside appliance editor widget. */ 32 class UIGuestOSTypeSelectionButton : public QIWithRetranslateUI<QPushButton> 30 33 { 31 34 Q_OBJECT; 32 35 33 36 public: 34 VBoxOSTypeSelectorButton (QWidget *aParent);35 QString osTypeId() const { return mOSTypeId; }36 37 38 /** Constructs a button passing @a pParent to the base-class. */ 39 UIGuestOSTypeSelectionButton(QWidget *pParent); 40 41 /** Returns whether the menu is shown. */ 37 42 bool isMenuShown() const; 38 43 39 void retranslateUi(); 44 /** Returns current guest OS type ID. */ 45 QString osTypeId() const { return m_strOSTypeId; } 40 46 41 47 public slots: 42 void setOSTypeId (const QString& aOSTypeId); 48 49 /** Defines current guest @a strOSTypeId. */ 50 void setOSTypeId(const QString &strOSTypeId); 51 52 protected: 53 54 /** Handles translation event. */ 55 virtual void retranslateUi() /* override */; 43 56 44 57 private: 58 59 /** Populates menu. */ 45 60 void populateMenu(); 46 61 47 /* Private member vars */ 48 QString mOSTypeId; 49 QMenu *mMainMenu; 50 QSignalMapper *mSignalMapper; 62 /** Holds the current guest OS type ID. */ 63 QString m_strOSTypeId; 64 65 /** Holds the menu instance. */ 66 QMenu *m_pMainMenu; 67 /** Holds the signal mapper instance. */ 68 QSignalMapper *m_pSignalMapper; 51 69 }; 52 70 53 #endif /* __VBoxOSTypeSelectorButton_h__ */ 54 71 #endif /* !___UIGuestOSTypeSelectionButton_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.

