VirtualBox

Changeset 73118 in vbox


Ignore:
Timestamp:
Jul 13, 2018 12:07:42 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9206: Reworking VBoxOSTypeSelectorButton widget, renaming it to UIGuestOSTypeSelectionButton and doing proper makeup.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r72815 r73118  
    700700        src/widgets/UIApplianceImportEditorWidget.h \
    701701        src/widgets/UIEmptyFilePathSelector.h \
     702        src/widgets/UIGuestOSTypeSelectionButton.h \
    702703        src/widgets/UILineTextEdit.h \
    703704        src/widgets/UISlidingWidget.h \
    704705        src/widgets/UITabBar.h \
    705706        src/widgets/UIMenuToolBar.h \
    706         src/widgets/VBoxOSTypeSelectorButton.h \
    707707        src/widgets/graphics/UIGraphicsButton.h \
    708708        src/widgets/graphics/UIGraphicsRotatorButton.h \
     
    13451345        src/widgets/UIApplianceImportEditorWidget.cpp \
    13461346        src/widgets/UIEmptyFilePathSelector.cpp \
     1347        src/widgets/UIGuestOSTypeSelectionButton.cpp \
    13471348        src/widgets/UILineTextEdit.cpp \
    13481349        src/widgets/UISlidingWidget.cpp \
    13491350        src/widgets/UITabBar.cpp \
    13501351        src/widgets/UIMenuToolBar.cpp \
    1351         src/widgets/VBoxOSTypeSelectorButton.cpp \
    13521352        src/widgets/graphics/UIGraphicsButton.cpp \
    13531353        src/widgets/graphics/UIGraphicsRotatorButton.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/precomp.h

    r71948 r73118  
    643643#include "VBoxLicenseViewer.h"
    644644#include "UIMediaComboBox.h"
    645 #include "VBoxOSTypeSelectorButton.h"
     645#include "UIGuestOSTypeSelectionButton.h"
    646646#include "UISettingsSelector.h"
    647647#include "UISnapshotDetailsWidget.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r73062 r73118  
    3434# include "QITreeView.h"
    3535# include "VBoxGlobal.h"
    36 # include "VBoxOSTypeSelectorButton.h"
     36# include "UIGuestOSTypeSelectionButton.h"
    3737# include "UIApplianceEditorWidget.h"
    3838# include "UIConverter.h"
     
    591591            case KVirtualSystemDescriptionType_OS:
    592592            {
    593                 VBoxOSTypeSelectorButton *pButton = new VBoxOSTypeSelectorButton(pParent);
     593                UIGuestOSTypeSelectionButton *pButton = new UIGuestOSTypeSelectionButton(pParent);
    594594                /* Fill the background with the highlight color in the case
    595595                 * the button hasn't a rectangle shape. This prevents the
     
    722722        case KVirtualSystemDescriptionType_OS:
    723723        {
    724             if (VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pEditor))
     724            if (UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pEditor))
    725725            {
    726726                pButton->setOSTypeId(m_strConfigValue);
     
    818818        case KVirtualSystemDescriptionType_OS:
    819819        {
    820             if (VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pEditor))
     820            if (UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pEditor))
    821821            {
    822822                m_strConfigValue = pButton->osTypeId();
     
    12841284         * the popup menu is shown. Prevent this here, cause otherwise the new
    12851285         * selected OS will not be updated. */
    1286         VBoxOSTypeSelectorButton *pButton = qobject_cast<VBoxOSTypeSelectorButton*>(pObject);
     1286        UIGuestOSTypeSelectionButton *pButton = qobject_cast<UIGuestOSTypeSelectionButton*>(pObject);
    12871287        if (pButton && pButton->isMenuShown())
    12881288            return false;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.cpp

    r73117 r73118  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - VBoxOSTypeSelectorButton class implementation.
     3 * VBox Qt GUI - UIGuestOSTypeSelectionButton class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626
    2727/* GUI includes */
    28 # include "VBoxOSTypeSelectorButton.h"
    2928# include "VBoxGlobal.h"
     29# include "UIGuestOSTypeSelectionButton.h"
    3030
    3131#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3232
    3333
    34 VBoxOSTypeSelectorButton::VBoxOSTypeSelectorButton (QWidget *aParent)
    35   : QIWithRetranslateUI <QPushButton> (aParent)
     34UIGuestOSTypeSelectionButton::UIGuestOSTypeSelectionButton(QWidget *pParent)
     35    : QIWithRetranslateUI<QPushButton>(pParent)
    3636{
    3737    /* 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));
    5140
     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: */
    5258    retranslateUi();
    5359}
    5460
    55 void VBoxOSTypeSelectorButton::setOSTypeId (const QString& aOSTypeId)
     61bool UIGuestOSTypeSelectionButton::isMenuShown() const
    5662{
    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();
    6464}
    6565
    66 bool VBoxOSTypeSelectorButton::isMenuShown() const
     66void UIGuestOSTypeSelectionButton::setOSTypeId(const QString &strOSTypeId)
    6767{
    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());
    6977}
    7078
    71 void VBoxOSTypeSelectorButton::retranslateUi()
     79void UIGuestOSTypeSelectionButton::retranslateUi()
    7280{
    7381    populateMenu();
    7482}
    7583
    76 void VBoxOSTypeSelectorButton::populateMenu()
     84void UIGuestOSTypeSelectionButton::populateMenu()
    7785{
    78     mMainMenu->clear();
     86    m_pMainMenu->clear();
     87
    7988    /* 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)
    8291    {
    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)
    8695        {
    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());
    91101        }
    92102    }
    93103}
    94 
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.h

    r73117 r73118  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - VBoxOSTypeSelectorButton class declaration.
     3 * VBox Qt GUI - UIGuestOSTypeSelectionButton class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __VBoxOSTypeSelectorButton_h__
    19 #define __VBoxOSTypeSelectorButton_h__
     18#ifndef ___UIGuestOSTypeSelectionButton_h___
     19#define ___UIGuestOSTypeSelectionButton_h___
    2020
    21 /* VBox includes */
     21/* Qt includes: */
     22#include <QPushButton>
     23
     24/* GUI includes: */
    2225#include "QIWithRetranslateUI.h"
    2326
    24 /* Qt includes */
    25 #include <QPushButton>
    26 
     27/* Forward declarations: */
     28class QMenu;
    2729class QSignalMapper;
    2830
    29 class VBoxOSTypeSelectorButton: public QIWithRetranslateUI<QPushButton>
     31/** QPushButton sub-class for choosing guest OS family/type inside appliance editor widget. */
     32class UIGuestOSTypeSelectionButton : public QIWithRetranslateUI<QPushButton>
    3033{
    3134    Q_OBJECT;
    3235
    3336public:
    34     VBoxOSTypeSelectorButton (QWidget *aParent);
    35     QString osTypeId() const { return mOSTypeId; }
    3637
     38    /** Constructs a button passing @a pParent to the base-class. */
     39    UIGuestOSTypeSelectionButton(QWidget *pParent);
     40
     41    /** Returns whether the menu is shown. */
    3742    bool isMenuShown() const;
    3843
    39     void retranslateUi();
     44    /** Returns current guest OS type ID. */
     45    QString osTypeId() const { return m_strOSTypeId; }
    4046
    4147public slots:
    42     void setOSTypeId (const QString& aOSTypeId);
     48
     49    /** Defines current guest @a strOSTypeId. */
     50    void setOSTypeId(const QString &strOSTypeId);
     51
     52protected:
     53
     54    /** Handles translation event. */
     55    virtual void retranslateUi() /* override */;
    4356
    4457private:
     58
     59    /** Populates menu. */
    4560    void populateMenu();
    4661
    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;
    5169};
    5270
    53 #endif /* __VBoxOSTypeSelectorButton_h__ */
    54 
     71#endif /* !___UIGuestOSTypeSelectionButton_h___ */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette