VirtualBox

Changeset 88149 in vbox for trunk


Ignore:
Timestamp:
Mar 17, 2021 11:06:53 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143298
Message:

FE/Qt: bugref:9515: Name and OS Type editor: Proper init order according to widget layout; Proper names and doxy.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r86275 r88149  
    891891    {
    892892        /* Prepare editor: */
    893         UINameAndSystemEditor *pEditor = new UINameAndSystemEditor(pPopup, fChooseName, fChoosePath, fChooseType);
     893        UINameAndSystemEditor *pEditor = new UINameAndSystemEditor(pPopup,
     894                                                                   fChooseName,
     895                                                                   fChoosePath,
     896                                                                   false /* image? */,
     897                                                                   fChooseType);
    894898        if (pEditor)
    895899        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r88148 r88149  
    55
    66/*
    7  * Copyright (C) 2008-2020 Oracle Corporation
     7 * Copyright (C) 2008-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4242                                             bool fChooseName /* = true */,
    4343                                             bool fChoosePath /* = false */,
    44                                              bool fChooseType /* = true */,
    45                                              bool fChooseISOFile /* = false */)
     44                                             bool fChooseImage /* = false */,
     45                                             bool fChooseType /* = true */)
    4646    : QIWithRetranslateUI<QWidget>(pParent)
    4747    , m_fChooseName(fChooseName)
    4848    , m_fChoosePath(fChoosePath)
    49     , m_fChooseISOFile(fChooseISOFile)
     49    , m_fChooseImage(fChooseImage)
    5050    , m_fChooseType(fChooseType)
    5151    , m_fSupportsHWVirtEx(false)
     
    5454    , m_pNameLabel(0)
    5555    , m_pPathLabel(0)
    56     , m_pISOFileSelectorLabel(0)
     56    , m_pImageLabel(0)
    5757    , m_pLabelFamily(0)
    5858    , m_pLabelType(0)
     
    6060    , m_pNameLineEdit(0)
    6161    , m_pPathSelector(0)
    62     , m_pISOFileSelector(0)
     62    , m_pImageSelector(0)
    6363    , m_pComboFamily(0)
    6464    , m_pComboType(0)
     
    103103}
    104104
    105 void UINameAndSystemEditor::setFileSelectorDialogFilters(const QString &strFilters)
    106 {
    107     if (m_pISOFileSelector)
    108         m_pISOFileSelector->setFileDialogFilters(strFilters);
    109 }
    110 
    111105void UINameAndSystemEditor::setName(const QString &strName)
    112106{
     
    135129        return uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    136130    return m_pPathSelector->path();
     131}
     132
     133QString UINameAndSystemEditor::image() const
     134{
     135    if (!m_pImageSelector)
     136        return QString();
     137    return m_pImageSelector->path();
    137138}
    138139
     
    239240}
    240241
    241 QString UINameAndSystemEditor::ISOFilePath() const
    242 {
    243     if (!m_pISOFileSelector)
    244         return QString();
    245     return m_pISOFileSelector->path();
    246 }
    247 
    248242void UINameAndSystemEditor::setType(const CGuestOSType &enmType)
    249243{
     
    271265}
    272266
    273 void UINameAndSystemEditor::markNameLineEdit(bool fError)
     267void UINameAndSystemEditor::markNameEditor(bool fError)
    274268{
    275269    if (m_pNameLineEdit)
     
    277271}
    278272
    279 void UINameAndSystemEditor::markISOFileSelector(bool fError, const QString &strErrorMessage)
    280 {
    281     if (m_pISOFileSelector)
    282         m_pISOFileSelector->mark(fError, strErrorMessage);
     273void UINameAndSystemEditor::markImageEditor(bool fError, const QString &strErrorMessage)
     274{
     275    if (m_pImageSelector)
     276        m_pImageSelector->mark(fError, strErrorMessage);
    283277}
    284278
     
    289283    if (m_pPathLabel)
    290284        m_pPathLabel->setText(tr("&Folder:"));
    291     if (m_pISOFileSelectorLabel)
    292         m_pISOFileSelectorLabel->setText(tr("&Image:"));
     285    if (m_pImageLabel)
     286        m_pImageLabel->setText(tr("&Image:"));
    293287    if (m_pLabelFamily)
    294288        m_pLabelFamily->setText(tr("&Type:"));
     
    475469        }
    476470
    477         if (m_fChooseISOFile)
     471        if (m_fChooseImage)
    478472        {
    479             /* Prepare ISO label: */
    480             m_pISOFileSelectorLabel = new QLabel(this);
    481             if (m_pISOFileSelectorLabel)
    482             {
    483                 m_pISOFileSelectorLabel->setAlignment(Qt::AlignRight);
    484                 m_pISOFileSelectorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    485 
    486                 m_pMainLayout->addWidget(m_pISOFileSelectorLabel, iRow, 0);
    487             }
    488             /* Prepare ISO selector: */
    489             m_pISOFileSelector = new UIFilePathSelector(this);
    490             if (m_pISOFileSelector)
    491             {
    492                 m_pISOFileSelector->setResetEnabled(false);
    493                 m_pISOFileSelector->setMode(UIFilePathSelector::Mode_File_Open);
    494                 m_pISOFileSelector->setFileDialogFilters("*.iso *.ISO");
    495                 m_pISOFileSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    496                 m_pISOFileSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
    497                 m_pISOFileSelectorLabel->setBuddy(m_pISOFileSelector);
    498 
    499                 m_pMainLayout->addWidget(m_pISOFileSelector, iRow, 1, 1, 2);
     473            /* Prepare image label: */
     474            m_pImageLabel = new QLabel(this);
     475            if (m_pImageLabel)
     476            {
     477                m_pImageLabel->setAlignment(Qt::AlignRight);
     478                m_pImageLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     479
     480                m_pMainLayout->addWidget(m_pImageLabel, iRow, 0);
     481            }
     482            /* Prepare image selector: */
     483            m_pImageSelector = new UIFilePathSelector(this);
     484            if (m_pImageSelector)
     485            {
     486                m_pImageSelector->setResetEnabled(false);
     487                m_pImageSelector->setMode(UIFilePathSelector::Mode_File_Open);
     488                m_pImageSelector->setFileDialogFilters("*.iso *.ISO");
     489                m_pImageSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     490                m_pImageSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
     491                m_pImageLabel->setBuddy(m_pImageSelector);
     492
     493                m_pMainLayout->addWidget(m_pImageSelector, iRow, 1, 1, 2);
    500494            }
    501495
     
    623617        connect(m_pComboType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    624618                this, &UINameAndSystemEditor::sltTypeChanged);
    625     if (m_pISOFileSelector)
    626         connect(m_pISOFileSelector, &UIFilePathSelector::pathChanged,
    627                 this, &UINameAndSystemEditor::sigISOPathChanged);
    628 }
     619    if (m_pImageSelector)
     620        connect(m_pImageSelector, &UIFilePathSelector::pathChanged,
     621                this, &UINameAndSystemEditor::sigImageChanged);
     622}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r88107 r88149  
    55
    66/*
    7  * Copyright (C) 2008-2020 Oracle Corporation
     7 * Copyright (C) 2008-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6060    /** Notifies listeners about VM name change. */
    6161    void sigNameChanged(const QString &strNewName);
    62     void sigPathChanged(const QString &strName);
     62
     63    /** Notifies listeners about VM path change. */
     64    void sigPathChanged(const QString &strPath);
     65
     66    /** Notifies listeners about VM image change. */
     67    void sigImageChanged(const QString &strImage);
    6368
    6469    /** Notifies listeners about VM OS type change. */
     
    6671    /** Notifies listeners about VM OS family change. */
    6772    void sigOSFamilyChanged();
    68     void sigISOPathChanged(const QString &strISOPath);
    6973
    7074public:
    7175
    7276    /** Constructs VM parameters editor passing @a pParent to the base-class.
    73      * @param  fChooseName    Controls whether we should propose to choose name.
    74      * @param  fChoosePath    Controls whether we should propose to choose path.
    75      * @param  fChooseType    Controls whether we should propose to choose type.
    76      * @param  fChooseISOFile Controls whether we should have a ISO file selector. */
     77     * @param  fChooseName   Controls whether we should propose to choose name.
     78     * @param  fChoosePath   Controls whether we should propose to choose path.
     79     * @param  fChooseImage  Controls whether we should propose to choose image.
     80     * @param  fChooseType   Controls whether we should propose to choose type. */
    7781    UINameAndSystemEditor(QWidget *pParent,
    7882                          bool fChooseName = true,
    7983                          bool fChoosePath = false,
    80                           bool fChooseType = true,
    81                           bool fChooseISOFile = false);
     84                          bool fChooseImage = false,
     85                          bool fChooseType = true);
    8286
    8387    /** Defines minimum layout @a iIndent. */
     
    9195    void setOSTypeStuffEnabled(bool fEnabled);
    9296
    93     void setFileSelectorDialogFilters(const QString &strFilters);
    94 
    9597    /** Defines the VM @a strName. */
    9698    void setName(const QString &strName);
     
    102104    /** Returns path string selected by the user. */
    103105    QString path() const;
     106
     107    /** Returns image string selected by the user. */
     108    QString image() const;
    104109
    105110    /** Defines the VM OS @a strTypeId and @a strFamilyId if passed. */
     
    110115    QString familyId() const;
    111116
    112     QString ISOFilePath() const;
    113 
    114117    /** Defines the VM OS @a enmType. */
    115118    void setType(const CGuestOSType &enmType);
     
    121124
    122125    /** Passes the @p fError to QILineEdit::mark(bool) effectively changing the background color. */
    123     void markNameLineEdit(bool fError);
    124 
    125     void markISOFileSelector(bool fError, const QString &strErrorMessage);
     126    void markNameEditor(bool fError);
     127    /** Passes the @p fError and @a strErrorMessage to UIFilePathSelector::mark(bool)
     128      *  effectively changing the background color and error-text. */
     129    void markImageEditor(bool fError, const QString &strErrorMessage);
    126130
    127131protected:
     
    171175    /** Holds whether we should propose to choose a path. */
    172176    bool  m_fChoosePath;
    173     /** Holds whether we should propose a file selector. */
    174     bool  m_fChooseISOFile;
     177    /** Holds whether we should propose to choose an image. */
     178    bool  m_fChooseImage;
    175179    /** Holds whether we should propose to choose a type. */
    176180    bool  m_fChooseType;
     
    187191    /** Holds the VM path label instance. */
    188192    QLabel *m_pPathLabel;
    189     QLabel *m_pISOFileSelectorLabel;
     193    /** Holds the VM image label instance. */
     194    QLabel *m_pImageLabel;
    190195    /** Holds the VM OS family label instance. */
    191196    QLabel *m_pLabelFamily;
     
    199204    /** Holds the VM path editor instance. */
    200205    UIFilePathSelector *m_pPathSelector;
    201     /** Holds the ISO file selector instance. */
    202     UIFilePathSelector    *m_pISOFileSelector;
     206    /** Holds the VM image editor instance. */
     207    UIFilePathSelector *m_pImageSelector;
    203208    /** Holds the VM OS family combo instance. */
    204209    QComboBox          *m_pComboFamily;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r88148 r88149  
    249249                                                               true /* fChooseName? */,
    250250                                                               true /* fChoosePath? */,
    251                                                                true /* fChooseType? */,
    252                                                                true /* fChooseISOFile? */);
     251                                                               true /* fChooseImage? */,
     252                                                               true /* fChooseType? */);
    253253            if (m_pNameAndSystemEditor)
    254254                pLayout->addWidget(m_pNameAndSystemEditor);
     
    363363    if (m_pNameAndSystemEditor)
    364364    {
    365         m_pNameAndSystemEditor->markNameLineEdit(m_pNameAndSystemEditor->name().isEmpty());
    366         m_pNameAndSystemEditor->markISOFileSelector(!checkISOFile(), UIWizardNewVM::tr("Invalid file path or unreadable file"));
     365        m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
     366        m_pNameAndSystemEditor->markImageEditor(!checkISOFile(), UIWizardNewVM::tr("Invalid file path or unreadable file"));
    367367    }
    368368}
     
    383383    if (!m_pNameAndSystemEditor)
    384384        return QString();
    385     return m_pNameAndSystemEditor->ISOFilePath();
     385    return m_pNameAndSystemEditor->image();
    386386}
    387387
     
    390390    if (!m_pNameAndSystemEditor)
    391391        return false;
    392     const QString &strPath = m_pNameAndSystemEditor->ISOFilePath();
     392    const QString &strPath = m_pNameAndSystemEditor->image();
    393393    if (strPath.isNull() || strPath.isEmpty())
    394394        return false;
     
    429429    if (!m_pNameAndSystemEditor)
    430430        return true;
    431     const QString &strPath = m_pNameAndSystemEditor->ISOFilePath();
     431    const QString &strPath = m_pNameAndSystemEditor->image();
    432432    if (strPath.isNull() || strPath.isEmpty())
    433433        return true;
     
    444444    if (m_pNameAndSystemEditor)
    445445    {
    446         const QString &strPath = m_pNameAndSystemEditor->ISOFilePath();
     446        const QString &strPath = m_pNameAndSystemEditor->image();
    447447        m_pSkipUnattendedCheckBox->setEnabled(!strPath.isNull() && !strPath.isEmpty());
    448448    }
     
    502502        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
    503503        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
    504         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigISOPathChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
     504        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
    505505    }
    506506}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r88147 r88149  
    207207        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
    208208                this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
    209         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigISOPathChanged,
     209        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
    210210                this, &UIWizardNewVMPageExpert::sltISOPathChanged);
    211211    }
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