VirtualBox

Changeset 72279 in vbox


Ignore:
Timestamp:
May 22, 2018 9:22:09 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:6769: Replacing the combined name/path selector widget in new vm wizard with seperate widgets

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.cpp

    r71901 r72279  
    176176}
    177177
     178void UIFilePathSelector::setDefaultPath(const QString &strDefaultPath)
     179{
     180    if (m_strDefaultPath == strDefaultPath)
     181        return;
     182    m_strDefaultPath = strDefaultPath;
     183    if (currentIndex() == ResetId)
     184        setPath(m_strDefaultPath);
     185}
     186
     187const QString& UIFilePathSelector::defaultPath() const
     188{
     189    return m_strDefaultPath;
     190}
     191
    178192void UIFilePathSelector::setPath(const QString &strPath, bool fRefreshText /* = true */)
    179193{
     
    321335        case ResetId:
    322336        {
    323             changePath(QString::null);
     337            if (m_strDefaultPath.isEmpty())
     338                changePath(QString::null);
     339            else
     340                changePath(m_strDefaultPath);
    324341            break;
    325342        }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h

    r71901 r72279  
    112112    void setToolTip(const QString &strToolTip);
    113113
     114    void setDefaultPath(const QString &strDefaultPath);
     115    const QString& defaultPath() const;
     116
    114117public slots:
    115118
     
    204207    /** Holds the copy action instance. */
    205208    QAction *m_pCopyAction;
     209
     210    /** Path is set to m_strDefaultPath when it is reset. */
     211    QString m_strDefaultPath;
    206212};
    207213
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r72226 r72279  
    2424# include <QGridLayout>
    2525# include <QLabel>
    26 # include <QLineEdit>
    2726# include <QVBoxLayout>
    2827
    2928/* GUI includes: */
     29# include "QILineEdit.h"
    3030# include "VBoxGlobal.h"
    3131# include "UIFilePathSelector.h"
    3232# include "UINameAndSystemEditor.h"
    33 # include "UIVMNamePathSelector.h"
    3433
    3534/* COM includes: */
     
    5453    , m_pLabelType(0)
    5554    , m_pIconType(0)
    56     , m_pNamePathLabel(0)
    57     , m_pNamePathSelector(0)
     55    , m_pNameLabel(0)
     56    , m_pPathLabel(0)
     57    , m_pNameLineEdit(0)
     58    , m_pPathSelector(0)
    5859    , m_pComboFamily(0)
    5960    , m_pComboType(0)
     
    6566QString UINameAndSystemEditor::name() const
    6667{
    67     if (!m_pNamePathSelector)
     68    if (!m_pNameLineEdit)
    6869        return QString();
    69     return m_pNamePathSelector->name();
     70    return m_pNameLineEdit->text();
    7071}
    7172
    7273QString UINameAndSystemEditor::path() const
    7374{
    74     if (!m_pNamePathSelector)
     75    if (!m_pPathSelector)
    7576        return vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    76     return m_pNamePathSelector->path();
     77    return m_pPathSelector->path();
    7778}
    7879
    7980void UINameAndSystemEditor::setName(const QString &strName)
    8081{
    81     if (!m_pNamePathSelector)
     82    if (!m_pNameLineEdit)
    8283        return;
    83     m_pNamePathSelector->setName(strName);
     84    m_pNameLineEdit->setText(strName);
    8485}
    8586
     
    119120    m_pLabelFamily->setText(tr("&Type:"));
    120121    m_pLabelType->setText(tr("&Version:"));
    121     m_pNamePathLabel->setText(tr("Path/Name:"));
     122    m_pNameLabel->setText(tr("Name:"));
     123    m_pPathLabel->setText(tr("Path:"));
    122124
    123125    m_pComboFamily->setWhatsThis(tr("Selects the operating system family that "
     
    229231        pMainLayout->setContentsMargins(0, 0, 0, 0);
    230232
    231         m_pNamePathLabel = new QLabel;
    232         if (m_pNamePathLabel)
    233         {
    234             m_pNamePathLabel->setAlignment(Qt::AlignRight);
    235             m_pNamePathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    236             pMainLayout->addWidget(m_pNamePathLabel, 0, 0, 1, 1);
    237         }
    238         m_pNamePathSelector = new UIVMNamePathSelector;
    239         if (m_pNamePathSelector)
    240         {
    241             m_pNamePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    242             m_pNamePathSelector->setPath(vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder());
    243             pMainLayout->addWidget(m_pNamePathSelector, 0, 1, 1, 2);
    244             setFocusProxy(m_pNamePathSelector);
     233        m_pNameLabel = new QLabel;
     234        if (m_pNameLabel)
     235        {
     236            m_pNameLabel->setAlignment(Qt::AlignRight);
     237            m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     238            pMainLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     239        }
     240        m_pNameLineEdit = new QILineEdit;
     241        if (m_pNameLineEdit)
     242        {
     243            pMainLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     244        }
     245
     246        m_pPathLabel = new QLabel;
     247        if (m_pPathLabel)
     248        {
     249            m_pPathLabel->setAlignment(Qt::AlignRight);
     250            pMainLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     251        }
     252
     253        m_pPathSelector = new UIFilePathSelector;
     254        if (m_pPathSelector)
     255        {
     256            pMainLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     257            QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     258            m_pPathSelector->setPath(strDefaultMachineFolder);
     259            m_pPathSelector->setDefaultPath(strDefaultMachineFolder);
    245260        }
    246261
     
    253268            m_pLabelFamily->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    254269            /* Add VM OS family label into main-layout: */
    255             pMainLayout->addWidget(m_pLabelFamily, 1, 0);
     270            pMainLayout->addWidget(m_pLabelFamily, 2, 0);
    256271        }
    257272
     
    264279            m_pLabelFamily->setBuddy(m_pComboFamily);
    265280            /* Add VM OS family combo into main-layout: */
    266             pMainLayout->addWidget(m_pComboFamily, 1, 1);
     281            pMainLayout->addWidget(m_pComboFamily, 2, 1);
    267282        }
    268283
     
    275290            m_pLabelType->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    276291            /* Add VM OS type label into main-layout: */
    277             pMainLayout->addWidget(m_pLabelType, 2, 0);
     292            pMainLayout->addWidget(m_pLabelType, 3, 0);
    278293        }
    279294
     
    286301            m_pLabelType->setBuddy(m_pComboType);
    287302            /* Add VM OS type combo into main-layout: */
    288             pMainLayout->addWidget(m_pComboType, 2, 1);
     303            pMainLayout->addWidget(m_pComboType, 3, 1);
    289304        }
    290305
     
    305320            pLayoutIcon->addStretch();
    306321            /* Add sub-layout into main-layout: */
    307             pMainLayout->addLayout(pLayoutIcon, 1, 2, 2, 1);
     322            pMainLayout->addLayout(pLayoutIcon, 2, 2, 2, 1);
    308323        }
    309324    }
     
    334349{
    335350    /* Prepare connections: */
    336     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged,
     351    connect(m_pNameLineEdit, &QILineEdit::textChanged,
    337352            this, &UINameAndSystemEditor::sigNameChanged);
    338     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged,
     353    connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
    339354            this, &UINameAndSystemEditor::sigPathChanged);
    340355    connect(m_pComboFamily, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     
    346361void UINameAndSystemEditor::setNameFieldValidator(const QString &strValidatorString)
    347362{
    348     if (!m_pNamePathSelector)
     363    if (!m_pNameLineEdit)
    349364        return;
    350     m_pNamePathSelector->setNameFieldValidator(strValidatorString);
    351 }
    352 
    353 void UINameAndSystemEditor::setMachineFolder(const QString &strPath)
    354 {
    355     if (!m_pNamePathSelector)
    356         return;
    357     m_pNamePathSelector->setToolTipText(strPath);
    358 }
     365    m_pNameLineEdit->setValidator(new QRegExpValidator(QRegExp(strValidatorString), this));
     366}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r72199 r72279  
    3333class QComboBox;
    3434class QLabel;
    35 class QLineEdit;
     35class QILineEdit;
    3636class QString;
    3737class UIFilePathSelector;
    38 class UIVMNamePathSelector;
    3938
    4039/** QWidget subclass providing complex editor for basic VM parameters. */
     
    7473
    7574    void setNameFieldValidator(const QString &strValidatorString);
    76 
    77     /** Forwards the machine name to UIVMNamePathSelector member instance. */
    78     void setMachineFolder(const QString &strPath);
    7975
    8076protected:
     
    125121    QLabel                 *m_pIconType;
    126122
    127     QLabel                 *m_pNamePathLabel;
    128     UIVMNamePathSelector   *m_pNamePathSelector;
     123    QLabel                 *m_pNameLabel;
     124    QLabel                 *m_pPathLabel;
     125    QILineEdit             *m_pNameLineEdit;
     126    UIFilePathSelector     *m_pPathSelector;
    129127    /** Holds the VM OS family combo instance. */
    130128    QComboBox              *m_pComboFamily;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r72226 r72279  
    234234    m_strMachineFolder = fileInfo.absolutePath();
    235235    m_strMachineBaseName = fileInfo.completeBaseName();
    236 
    237     if (m_pNameAndSystemEditor)
    238         m_pNameAndSystemEditor->setMachineFolder(m_strMachineFolder);
    239236}
    240237
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