VirtualBox

Changeset 90702 in vbox


Ignore:
Timestamp:
Aug 17, 2021 3:40:19 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. isComplete stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r90696 r90702  
    2929#include "CVirtualBox.h"
    3030
    31 
    32 
    3331QString UIWizardCloneVMNamePage::composeCloneFilePath(const QString &strCloneName, const QString &strGroup, const QString &strFolderPath)
    3432{
    3533    CVirtualBox vbox = uiCommon().virtualBox();
    3634    QString strCloneFilePath = vbox.ComposeMachineFilename(strCloneName, strGroup, QString(), strFolderPath);
    37     return QDir::toNativeSeparators(QFileInfo(strCloneFilePath).absolutePath());
     35    return QDir::toNativeSeparators(strCloneFilePath);
    3836}
    39 
    4037
    4138UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
     
    7370    retranslateUi();
    7471    if (m_pNamePathEditor)
     72    {
    7573        m_pNamePathEditor->setFocus();
    76     if (m_pNamePathEditor)
    77     {
    7874        if (!m_userModifiedParameters.contains("CloneName"))
    7975            cloneVMWizardPropertySet(CloneName, m_pNamePathEditor->cloneName());
     
    135131bool UIWizardCloneVMPageBasic1::isComplete() const
    136132{
    137     // if (!m_pPathSelector)
    138     //     return false;
    139 
    140     // QString path = m_pPathSelector->path();
    141     // if (path.isEmpty())
    142     //     return false;
    143     // /* Make sure VM name feat the rules: */
    144     // QString strName = m_pNameLineEdit->text().trimmed();
    145     // return !strName.isEmpty() && strName != m_strOriginalName;
    146     return true;
     133    return m_pNamePathEditor && m_pNamePathEditor->isComplete(m_strGroup);
    147134}
    148135
     
    155142    cloneVMWizardPropertySet(CloneFilePath,
    156143                             UIWizardCloneVMNamePage::composeCloneFilePath(strCloneName, m_strGroup, m_pNamePathEditor->clonePath()));
     144    emit completeChanged();
    157145}
    158146
     
    163151    cloneVMWizardPropertySet(CloneFilePath,
    164152                             UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathEditor->cloneName(), m_strGroup, strClonePath));
     153    emit completeChanged();
    165154}
    166155
     
    169158    m_userModifiedParameters << "MacAddressPolicy";
    170159    cloneVMWizardPropertySet(MacAddressPolicy, enmMACAddressClonePolicy);
     160    emit completeChanged();
    171161}
    172162
     
    175165    m_userModifiedParameters << "KeepDiskNames";
    176166    cloneVMWizardPropertySet(KeepDiskNames, fKeepDiskNames);
     167    emit completeChanged();
    177168}
    178169
     
    181172    m_userModifiedParameters << "KeepHardwareUUIDs";
    182173    cloneVMWizardPropertySet(KeepHardwareUUIDs, fKeepHardwareUUIDs);
     174    emit completeChanged();
    183175}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp

    r90696 r90702  
    3030#include "UIWizardCloneVMPageExpert.h"
    3131#include "UIWizardCloneVM.h"
     32#include "UIWizardCloneVMPageBasic1.h"
    3233
    3334/* COM includes: */
     
    3637
    3738UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, const QString &strDefaultPath,
    38                                                      bool /*fAdditionalInfo*/, bool fShowChildsOption, const QString &/*strGroup*/)
     39                                                     bool /*fAdditionalInfo*/, bool fShowChildsOption, const QString &strGroup)
    3940    : m_pMainLayout(0)
    4041    , m_pNamePathGroupBox(0)
    4142    , m_pCloneTypeGroupBox(0)
    4243    , m_pCloneModeGroupBox(0)
    43     , m_pAdditionalOptionsroupBox(0)
     44    , m_pAdditionalOptionsGroupBox(0)
     45    , m_strGroup(strGroup)
    4446{
    4547    prepare(strOriginalName, strDefaultPath, fShowChildsOption);
     
    5254    m_pNamePathGroupBox = new UICloneVMNamePathEditor(strOriginalName, strDefaultPath);
    5355    if (m_pNamePathGroupBox)
     56    {
    5457        m_pMainLayout->addWidget(m_pNamePathGroupBox, 0, 0, 3, 2);
     58        connect(m_pNamePathGroupBox, &UICloneVMNamePathEditor::sigCloneNameChanged,
     59                this, &UIWizardCloneVMPageExpert::sltCloneNameChanged);
     60        connect(m_pNamePathGroupBox, &UICloneVMNamePathEditor::sigClonePathChanged,
     61                this, &UIWizardCloneVMPageExpert::sltClonePathChanged);
     62    }
    5563
    5664    m_pCloneTypeGroupBox = new UICloneVMCloneTypeGroupBox;
     
    6270        m_pMainLayout->addWidget(m_pCloneModeGroupBox, 3, 1, 2, 1);
    6371
    64     m_pAdditionalOptionsroupBox = new UICloneVMAdditionalOptionsEditor;
    65     if (m_pAdditionalOptionsroupBox)
    66         m_pMainLayout->addWidget(m_pAdditionalOptionsroupBox, 5, 0, 2, 2);
     72    m_pAdditionalOptionsGroupBox = new UICloneVMAdditionalOptionsEditor;
     73    if (m_pAdditionalOptionsGroupBox)
     74    {
     75        m_pMainLayout->addWidget(m_pAdditionalOptionsGroupBox, 5, 0, 2, 2);
     76        connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigMACAddressClonePolicyChanged,
     77                this, &UIWizardCloneVMPageExpert::sltMACAddressClonePolicyChanged);
     78        connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigKeepDiskNamesToggled,
     79                this, &UIWizardCloneVMPageExpert::sltKeepDiskNamesToggled);
     80        connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigKeepHardwareUUIDsToggled,
     81                this, &UIWizardCloneVMPageExpert::sltKeepHardwareUUIDsToggled);
     82    }
     83
    6784    retranslateUi();
    6885}
     
    7794    if (m_pCloneModeGroupBox)
    7895        m_pCloneModeGroupBox->setTitle(UIWizardCloneVM::tr("Snapshots"));
    79     if (m_pAdditionalOptionsroupBox)
    80         m_pAdditionalOptionsroupBox->setTitle(UIWizardCloneVM::tr("Additional options"));
     96    if (m_pAdditionalOptionsGroupBox)
     97        m_pAdditionalOptionsGroupBox->setTitle(UIWizardCloneVM::tr("Additional options"));
    8198}
    8299
    83100void UIWizardCloneVMPageExpert::initializePage()
    84101{
     102    if (m_pNamePathGroupBox)
     103    {
     104        m_pNamePathGroupBox->setFocus();
     105        cloneVMWizardPropertySet(CloneName, m_pNamePathGroupBox->cloneName());
     106        cloneVMWizardPropertySet(CloneFilePath,
     107                                 UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathGroupBox->cloneName(), m_strGroup, m_pNamePathGroupBox->clonePath()));
     108    }
     109    if (m_pAdditionalOptionsGroupBox)
     110    {
     111        cloneVMWizardPropertySet(MacAddressPolicy, m_pAdditionalOptionsGroupBox->macAddressClonePolicy());
     112        cloneVMWizardPropertySet(KeepDiskNames, m_pAdditionalOptionsGroupBox->keepDiskNames());
     113        cloneVMWizardPropertySet(KeepHardwareUUIDs, m_pAdditionalOptionsGroupBox->keepHardwareUUIDs());
     114    }
     115    if (m_pCloneTypeGroupBox)
     116        cloneVMWizardPropertySet(LinkedClone, !m_pCloneTypeGroupBox->isFullClone());
     117    if (m_pCloneModeGroupBox)
     118        cloneVMWizardPropertySet(CloneMode, m_pCloneModeGroupBox->cloneMode());
     119
    85120    retranslateUi();
    86121}
     
    88123bool UIWizardCloneVMPageExpert::isComplete() const
    89124{
    90     // if (!m_pPathSelector)
    91     //     return false;
    92 
    93     // QString path = m_pPathSelector->path();
    94     // if (path.isEmpty())
    95     //     return false;
    96     // /* Make sure VM name feat the rules: */
    97     // QString strName = m_pNameLineEdit->text().trimmed();
    98     // return !strName.isEmpty() && strName != m_strOriginalName;
    99     return true;
     125    return m_pNamePathGroupBox && m_pNamePathGroupBox->isComplete(m_strGroup);
    100126}
    101127
    102128bool UIWizardCloneVMPageExpert::validatePage()
    103129{
    104     /* Initial result: */
    105     bool fResult = true;
    106 
    107     // /* Lock finish button: */
    108     // startProcessing();
    109 
    110     // /* Trying to clone VM: */
    111     // if (fResult)
    112     //     fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    113 
    114     // /* Unlock finish button: */
    115     // endProcessing();
    116 
    117     /* Return result: */
    118     return fResult;
     130    return qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();;
    119131}
    120132
    121 //void UIWizardCloneVMPageExpert::sltNameChanged()
    122 //{
    123     //composeCloneFilePath();
    124 //}
     133void UIWizardCloneVMPageExpert::sltCloneNameChanged(const QString &strCloneName)
     134{
     135    AssertReturnVoid(m_pNamePathGroupBox);
     136    cloneVMWizardPropertySet(CloneName, strCloneName);
     137    cloneVMWizardPropertySet(CloneFilePath,
     138                             UIWizardCloneVMNamePage::composeCloneFilePath(strCloneName, m_strGroup, m_pNamePathGroupBox->clonePath()));
     139}
    125140
    126 //void UIWizardCloneVMPageExpert::sltPathChanged()
    127 //{
    128     //composeCloneFilePath();
    129 //}
     141void UIWizardCloneVMPageExpert::sltClonePathChanged(const QString &strClonePath)
     142{
     143    AssertReturnVoid(m_pNamePathGroupBox);
     144    cloneVMWizardPropertySet(CloneFilePath,
     145                             UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathGroupBox->cloneName(), m_strGroup, strClonePath));
     146}
     147
     148void UIWizardCloneVMPageExpert::sltMACAddressClonePolicyChanged(MACAddressClonePolicy enmMACAddressClonePolicy)
     149{
     150    cloneVMWizardPropertySet(MacAddressPolicy, enmMACAddressClonePolicy);
     151}
     152
     153void UIWizardCloneVMPageExpert::sltKeepDiskNamesToggled(bool fKeepDiskNames)
     154{
     155    cloneVMWizardPropertySet(KeepDiskNames, fKeepDiskNames);
     156}
     157
     158void UIWizardCloneVMPageExpert::sltKeepHardwareUUIDsToggled(bool fKeepHardwareUUIDs)
     159{
     160    cloneVMWizardPropertySet(KeepHardwareUUIDs, fKeepHardwareUUIDs);
     161}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h

    r90696 r90702  
    2424/* Local includes: */
    2525#include "UINativeWizardPage.h"
     26#include "UIWizardCloneVMEditors.h"
    2627
    2728/* Forward declarations: */
     
    5455private slots:
    5556
    56     /* Button toggle handler: */
    57     // void sltButtonToggled(QAbstractButton *pButton, bool fChecked);
    58     // void sltNameChanged();
    59     // void sltPathChanged();
     57    void sltCloneNameChanged(const QString &strCloneName);
     58    void sltClonePathChanged(const QString &strClonePath);
     59    void sltMACAddressClonePolicyChanged(MACAddressClonePolicy enmMACAddressClonePolicy);
     60    void sltKeepDiskNamesToggled(bool fKeepDiskNames);
     61    void sltKeepHardwareUUIDsToggled(bool fKeepHardwareUUIDs);
    6062
    6163private:
     
    7678    UICloneVMCloneTypeGroupBox *m_pCloneTypeGroupBox;
    7779    UICloneVMCloneModeGroupBox *m_pCloneModeGroupBox;
    78     UICloneVMAdditionalOptionsEditor *m_pAdditionalOptionsroupBox;
     80    UICloneVMAdditionalOptionsEditor *m_pAdditionalOptionsGroupBox;
     81    QString m_strGroup;
    7982};
    8083
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

    r90696 r90702  
    2020#include <QCheckBox>
    2121#include <QComboBox>
    22 // #include <QDir>
    23 // #include <QFileInfo>
     22#include <QDir>
    2423#include <QLabel>
    2524#include <QRadioButton>
     
    2827/* GUI includes: */
    2928#include "QILineEdit.h"
    30 // #include "QIToolButton.h"
    31 // #include "QIRichTextLabel.h"
    3229#include "UICommon.h"
    33 // #include "UIConverter.h"
    3430#include "UIFilePathSelector.h"
    35 // #include "UIHostnameDomainNameEditor.h"
    36 // #include "UIIconPool.h"
    37 // #include "UIMediumSizeEditor.h"
    38 // #include "UIUserNamePasswordEditor.h"
    39 // #include "UIWizardDiskEditors.h"
    40 // #include "UIWizardNewVM.h"
    41 // #include "UIWizardNewVMDiskPageBasic.h"
    4231#include "UIWizardCloneVMEditors.h"
    4332
    4433/* Other VBox includes: */
    4534#include "iprt/assert.h"
    46 // #include "iprt/fs.h"
    4735#include "COMEnums.h"
    4836#include "CSystemProperties.h"
     
    6452{
    6553    prepare();
     54}
     55
     56bool UICloneVMNamePathEditor::isComplete(const QString &strMachineGroup)
     57{
     58    AssertReturn(m_pNameLineEdit && m_pPathSelector, false);
     59
     60    bool fInvalidName = m_pNameLineEdit->text().isEmpty();
     61    m_pNameLineEdit->mark(fInvalidName, tr("Clone name cannot be empty"));
     62
     63    const QString &strPath = m_pPathSelector->path();
     64    QDir dir(strPath);
     65    bool fInvalidPath = strPath.isEmpty() || !dir.exists() || !dir.isReadable();
     66    m_pPathSelector->mark(fInvalidPath, tr("Path is invalid"));
     67
     68    /* Check if there is already a machine folder for this name and path: */
     69    bool fExists = false;
     70    if (!fInvalidName)
     71    {
     72        CVirtualBox vbox = uiCommon().virtualBox();
     73        QString strCloneFilePath =
     74            vbox.ComposeMachineFilename(m_pNameLineEdit->text(), strMachineGroup, QString(), m_pPathSelector->path());
     75        fExists = QDir(QDir::toNativeSeparators(QFileInfo(strCloneFilePath).absolutePath())).exists();
     76        m_pNameLineEdit->mark(fExists, tr("The clone name is not unique"));
     77    }
     78
     79    return !fInvalidName && !fInvalidPath && !fExists;
    6680}
    6781
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h

    r90696 r90702  
    7777    void setClonePath(const QString &strPath);
    7878
    79     bool isComplete();
     79    bool isComplete(const QString &strMachineGroup);
    8080
    8181private:
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