VirtualBox

Changeset 72288 in vbox for trunk/src


Ignore:
Timestamp:
May 22, 2018 2:29:53 PM (7 years ago)
Author:
vboxsync
Message:

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

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

Legend:

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

    r72279 r72288  
    248248        {
    249249            m_pPathLabel->setAlignment(Qt::AlignRight);
     250            m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    250251            pMainLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
    251252        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r72243 r72288  
    2121
    2222/* Qt includes: */
     23# include <QCheckBox>
     24# include <QLabel>
    2325# include <QVBoxLayout>
    24 # include <QLineEdit>
    25 # include <QCheckBox>
    2626
    2727/* GUI includes: */
    2828# include "QIRichTextLabel.h"
    29 # include "UIVMNamePathSelector.h"
     29# include "QILineEdit.h"
     30# include "UIFilePathSelector.h"
    3031# include "UIWizardCloneVM.h"
    3132# include "UIWizardCloneVMPageBasic1.h"
     
    4243    , m_strDefaultPath(strDefaultPath)
    4344    , m_strGroup(strGroup)
     45    , m_pReinitMACsCheckBox(0)
     46    , m_pNameLineEdit(0)
     47    , m_pPathSelector(0)
     48    , m_pNameLabel(0)
     49    , m_pPathLabel(0)
    4450{
    4551}
     
    4753QString UIWizardCloneVMPage1::cloneName() const
    4854{
    49     return m_pNamePathSelector->name();
     55    if (!m_pNameLineEdit)
     56        return QString();
     57    return m_pNameLineEdit->text();
    5058}
    5159
    5260void UIWizardCloneVMPage1::setCloneName(const QString &strName)
    5361{
    54     m_pNamePathSelector->setName(strName);
     62    if (!m_pNameLineEdit)
     63        return;
     64    m_pNameLineEdit->setText(strName);
    5565}
    5666
    5767QString UIWizardCloneVMPage1::clonePath() const
    5868{
    59     if (!m_pNamePathSelector)
     69    if (!m_pPathSelector)
    6070        return QString();
    61     return m_pNamePathSelector->path();
     71    return m_pPathSelector->path();
    6272}
    6373
    6474void UIWizardCloneVMPage1::setClonePath(const QString &strPath)
    6575{
    66     m_pNamePathSelector->setPath(strPath);
     76    if (!m_pPathSelector)
     77        m_pPathSelector->setPath(strPath);
    6778}
    6879
     
    8293bool UIWizardCloneVMPage1::isReinitMACsChecked() const
    8394{
     95    if (!m_pReinitMACsCheckBox)
     96        return false;
    8497    return m_pReinitMACsCheckBox->isChecked();
    8598}
     
    88101{
    89102    CVirtualBox vbox = vboxGlobal().virtualBox();
    90     setCloneFilePath(vbox.ComposeMachineFilename(m_pNamePathSelector->name(),
     103    setCloneFilePath(vbox.ComposeMachineFilename(m_pNameLineEdit ? m_pNameLineEdit->text() : QString(),
    91104                                                 m_strGroup,
    92105                                                 QString::null,
    93                                                  m_pNamePathSelector->path()));
     106                                                 m_pPathSelector ? m_pPathSelector->path() : QString()));
    94107    const QFileInfo fileInfo(m_strCloneFilePath);
    95108    m_strCloneFolder = fileInfo.absolutePath();
    96     if (m_pNamePathSelector)
    97         m_pNamePathSelector->setToolTipText(m_strCloneFolder);
    98109}
    99110
    100111UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
    101112    : UIWizardCloneVMPage1(strOriginalName, strDefaultPath, strGroup)
     113    , m_pMainLabel(0)
    102114{
    103115    /* Create widgets: */
    104116    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     117    if (!pMainLayout)
     118        return;
     119
     120    m_pMainLabel = new QIRichTextLabel(this);
     121    if (m_pMainLabel)
    105122    {
    106         m_pLabel = new QIRichTextLabel(this);
    107         if (m_pLabel)
    108         {
    109             pMainLayout->addWidget(m_pLabel);
    110         }
    111 
    112         m_pNamePathSelector = new UIVMNamePathSelector(this);
    113         if (m_pNamePathSelector)
    114         {
    115             pMainLayout->addWidget(m_pNamePathSelector);
    116             m_pNamePathSelector->setName(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
    117             m_pNamePathSelector->setPath(m_strDefaultPath);
    118         }
    119 
    120         m_pReinitMACsCheckBox = new QCheckBox(this);
    121 
    122         if (m_pReinitMACsCheckBox)
    123         {
    124             pMainLayout->addWidget(m_pReinitMACsCheckBox);
    125         }
    126         pMainLayout->addStretch();
     123        pMainLayout->addWidget(m_pMainLabel);
    127124    }
    128125
     126    QWidget *pContainerWidget = new QWidget(this);
     127    if (pContainerWidget)
     128    {
     129        pMainLayout->addWidget(pContainerWidget);
     130        QGridLayout *pContainerLayout = new QGridLayout(pContainerWidget);
     131        pContainerLayout->setContentsMargins(0, 0, 0, 0);
     132
     133        m_pNameLabel = new QLabel;
     134        if (m_pNameLabel)
     135        {
     136            m_pNameLabel->setAlignment(Qt::AlignRight);
     137            m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     138            pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     139        }
     140
     141        m_pNameLineEdit = new QILineEdit();
     142        if (m_pNameLineEdit)
     143        {
     144            pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     145            m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     146        }
     147
     148        m_pPathLabel = new QLabel(this);
     149        if (m_pPathLabel)
     150        {
     151            m_pPathLabel->setAlignment(Qt::AlignRight);
     152            m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     153            pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     154        }
     155
     156        m_pPathSelector = new UIFilePathSelector(this);
     157        if (m_pPathSelector)
     158        {
     159            pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     160            m_pPathSelector->setPath(m_strDefaultPath);
     161
     162        }
     163
     164         m_pReinitMACsCheckBox = new QCheckBox(this);
     165         if (m_pReinitMACsCheckBox)
     166         {
     167             pContainerLayout->addWidget(m_pReinitMACsCheckBox, 2, 0, 1, 2);
     168         }
     169    }
     170    pMainLayout->addStretch();
     171
    129172    /* Setup connections: */
    130     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
    131     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
    132 
    133     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, this, &UIWizardCloneVMPageBasic1::sltNameChanged);
    134     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, this, &UIWizardCloneVMPageBasic1::sltPathChanged);
     173    connect(m_pNameLineEdit, &QILineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
     174    connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
     175
     176    connect(m_pNameLineEdit, &QILineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::sltNameChanged);
     177    connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardCloneVMPageBasic1::sltPathChanged);
    135178
    136179    /* Register fields: */
     
    147190
    148191    /* Translate widgets: */
    149     m_pLabel->setText(UIWizardCloneVM::tr("<p>Please choose a folder and a name for the new virtual machine. "
    150                                           "The new machine will be a clone of the machine <b>%1</b>.</p>")
    151                                           .arg(m_strOriginalName));
    152     m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));
    153     m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));
     192    if (m_pMainLabel)
     193        m_pMainLabel->setText(UIWizardCloneVM::tr("<p>Please choose a name and optionally a folder for the new virtual machine. "
     194                                                  "The new machine will be a clone of the machine <b>%1</b>.</p>")
     195                              .arg(m_strOriginalName));
     196
     197    if (m_pNameLabel)
     198        m_pNameLabel->setText(UIWizardCloneVM::tr("Name:"));
     199
     200    if (m_pPathLabel)
     201        m_pPathLabel->setText(UIWizardCloneVM::tr("Path:"));
     202    if (m_pReinitMACsCheckBox)
     203    {
     204        m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));
     205        m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));
     206    }
    154207}
    155208
     
    158211    /* Translate page: */
    159212    retranslateUi();
    160     if (m_pNamePathSelector)
    161         m_pNamePathSelector->setFocus();
     213    if (m_pNameLineEdit)
     214        m_pNameLineEdit->setFocus();
    162215}
    163216
    164217bool UIWizardCloneVMPageBasic1::isComplete() const
    165218{
    166     if (!m_pNamePathSelector)
     219    if (!m_pPathSelector)
    167220        return false;
    168221
    169     QString path = m_pNamePathSelector->path();
     222    QString path = m_pPathSelector->path();
    170223    if (path.isEmpty())
    171224        return false;
    172225    /* Make sure VM name feat the rules: */
    173     QString strName = m_pNamePathSelector->name().trimmed();
     226    QString strName = m_pNameLineEdit->text().trimmed();
    174227    return !strName.isEmpty() && strName != m_strOriginalName;
    175228}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h

    r72215 r72288  
    2323
    2424/* Forward declarations: */
    25 class QLineEdit;
     25class QILineEdit;
    2626class QCheckBox;
     27class QLabel;
    2728class QIRichTextLabel;
    28 class UIVMNamePathSelector;
     29class UIFilePathSelector;
    2930
    3031/* 1st page of the Clone Virtual Machine wizard (base part): */
     
    4849    void composeCloneFilePath();
    4950
    50     QString    m_strOriginalName;
    51     QString    m_strDefaultPath;
    52     QString    m_strGroup;
     51    QString     m_strOriginalName;
     52    QString     m_strDefaultPath;
     53    QString     m_strGroup;
    5354    /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */
    54     QString    m_strCloneFilePath;
     55    QString     m_strCloneFilePath;
    5556    /** The full path of the folder where clone machine's settings file is located.
    5657     * Generated from the m_strCloneFilePath by removing base file name */
    57     QString    m_strCloneFolder;
    58     QCheckBox *m_pReinitMACsCheckBox;
    59     UIVMNamePathSelector *m_pNamePathSelector;
     58    QString     m_strCloneFolder;
     59    QCheckBox  *m_pReinitMACsCheckBox;
     60    QILineEdit *m_pNameLineEdit;
     61    UIFilePathSelector *m_pPathSelector;
     62    QLabel     *m_pNameLabel;
     63    QLabel     *m_pPathLabel;
    6064
    6165};
     
    8690    bool isComplete() const;
    8791
    88     QIRichTextLabel *m_pLabel;
     92    QIRichTextLabel *m_pMainLabel;
    8993};
    9094
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp

    r72215 r72288  
    2121
    2222/* Global includes: */
     23# include <QButtonGroup>
     24# include <QCheckBox>
    2325# include <QGridLayout>
    24 # include <QButtonGroup>
    2526# include <QGroupBox>
    26 # include <QLineEdit>
    27 # include <QCheckBox>
     27# include <QLabel>
    2828# include <QRadioButton>
    2929
    3030/* Local includes: */
    31 # include "UIVMNamePathSelector.h"
     31# include "QILineEdit.h"
     32# include "UIFilePathSelector.h"
    3233# include "UIWizardCloneVMPageExpert.h"
    3334# include "UIWizardCloneVM.h"
     
    4748        m_pNameCnt = new QGroupBox(this);
    4849        {
    49             QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt);
     50            QGridLayout *pNameCntLayout = new QGridLayout(m_pNameCnt);
    5051            {
    51                 m_pNamePathSelector = new UIVMNamePathSelector(m_pNameCnt);
    52                 {
    53                     m_pNamePathSelector->setName(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
    54                 }
    55                 pNameCntLayout->addWidget(m_pNamePathSelector);
     52                pNameCntLayout->setContentsMargins(0, 0, 0, 0);
     53
     54                m_pNameLabel = new QLabel;
     55                if (m_pNameLabel)
     56                {
     57                    m_pNameLabel->setAlignment(Qt::AlignRight);
     58                    m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     59                    pNameCntLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     60
     61                }
     62                m_pNameLineEdit = new QILineEdit(m_pNameCnt);
     63                if (m_pNameLineEdit)
     64                {
     65                    m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     66                    pNameCntLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     67                }
     68
     69                m_pPathLabel = new QLabel(this);
     70                if (m_pPathLabel)
     71                {
     72                    m_pPathLabel->setAlignment(Qt::AlignRight);
     73                    m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     74                    pNameCntLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     75                }
     76
     77                m_pPathSelector = new UIFilePathSelector(this);
     78                if (m_pPathSelector)
     79                {
     80                    pNameCntLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     81                    m_pPathSelector->setPath(m_strDefaultPath);
     82                }
    5683            }
    5784        }
     
    103130
    104131    /* Setup connections: */
    105     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged,
     132    connect(m_pNameLineEdit, &QILineEdit::textChanged,
    106133            this, &UIWizardCloneVMPageExpert::completeChanged);
    107     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged,
     134    connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
    108135            this, &UIWizardCloneVMPageExpert::completeChanged);
    109     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged,
     136    connect(m_pNameLineEdit, &QILineEdit::textChanged,
    110137            this, &UIWizardCloneVMPageExpert::sltNameChanged);
    111     connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged,
     138    connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
    112139            this, &UIWizardCloneVMPageExpert::sltPathChanged);
    113140    connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     
    134161{
    135162    /* Translate widgets: */
    136     m_pNameCnt->setTitle(UIWizardCloneVM::tr("New machine &name"));
     163    m_pNameCnt->setTitle(UIWizardCloneVM::tr("New machine &name and path"));
    137164    m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("Clone type"));
    138165    m_pFullCloneRadio->setText(UIWizardCloneVM::tr("&Full Clone"));
     
    144171    m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));
    145172    m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));
     173    m_pNameLabel->setText(UIWizardCloneVM::tr("Name:"));
     174    m_pPathLabel->setText(UIWizardCloneVM::tr("Path:"));
    146175}
    147176
     
    154183bool UIWizardCloneVMPageExpert::isComplete() const
    155184{
    156     if (!m_pNamePathSelector)
     185    if (!m_pPathSelector)
    157186        return false;
    158187
    159     QString path = m_pNamePathSelector->path();
     188    QString path = m_pPathSelector->path();
    160189    if (path.isEmpty())
    161190        return false;
    162191    /* Make sure VM name feat the rules: */
    163     QString strName = m_pNamePathSelector->name().trimmed();
     192    QString strName = m_pNameLineEdit->text().trimmed();
    164193    return !strName.isEmpty() && strName != m_strOriginalName;
    165194}
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