VirtualBox

Changeset 90628 in vbox


Ignore:
Timestamp:
Aug 11, 2021 1:21:17 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Adding clone path and clone name connections

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

Legend:

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

    r90619 r90628  
    3838    , m_strGroup(strGroup)
    3939    , m_iCloneModePageIndex(-1)
     40    , m_strCloneName(!machine.isNull() ? machine.GetName() : QString())
    4041{
    4142#ifndef VBOX_WS_MAC
     
    6061        return true;
    6162    return isPageVisible(m_iCloneModePageIndex);
     63}
     64
     65void UIWizardCloneVM::setCloneName(const QString &strCloneName)
     66{
     67    m_strCloneName = strCloneName;
     68}
     69
     70const QString &UIWizardCloneVM::cloneName() const
     71{
     72    return m_strCloneName;
     73}
     74
     75void UIWizardCloneVM::setCloneFilePath(const QString &strCloneFilePath)
     76{
     77    m_strCloneFilePath = strCloneFilePath;
     78}
     79
     80const QString &UIWizardCloneVM::cloneFilePath() const
     81{
     82    return m_strCloneFilePath;
    6283}
    6384
     
    182203    /* Translate wizard: */
    183204    setWindowTitle(tr("Clone Virtual Machine"));
    184     //setButtonText(QWizard::FinishButton, tr("Clone"));
    185205}
    186206
     
    194214        case WizardMode_Expert:
    195215        {
    196             addPage(new UIWizardCloneVMPageBasic1(m_machine.GetName(), strDefaultMachineFolder, m_strGroup));
     216            addPage(new UIWizardCloneVMPageBasic1(m_strCloneName, strDefaultMachineFolder, m_strGroup));
    197217            addPage(new UIWizardCloneVMPageBasic2(m_snapshot.isNull()));
    198218            if (m_machine.GetSnapshotCount() > 0)
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h

    r90621 r90628  
    3030#include "CSnapshot.h"
    3131
     32#define cloneVMWizardPropertySet(functionName, value)                   \
     33    do                                                                  \
     34    {                                                                   \
     35        UIWizardCloneVM *pWizard = qobject_cast<UIWizardCloneVM*>(wizard()); \
     36        if (pWizard)                                                    \
     37            pWizard->set##functionName(value);                          \
     38    }                                                                   \
     39    while(0)
     40
     41
    3242/* Clone VM wizard: */
    3343class UIWizardCloneVM : public UINativeWizard
     
    4454    bool cloneVM();
    4555
     56    void setCloneName(const QString &strCloneName);
     57    const QString &cloneName() const;
     58
     59    void setCloneFilePath(const QString &strCloneFilePath);
     60    const QString &cloneFilePath() const;
     61
    4662protected:
    4763
     
    5773    QString   m_strGroup;
    5874    int m_iCloneModePageIndex;
     75
     76    /** @name Parameters needed during machine cloning
     77      * @{ */
     78        QString m_strCloneName;
     79        QString m_strCloneFilePath;
     80    /** @} */
     81
     82
    5983};
    6084
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r90599 r90628  
    1717
    1818/* Qt includes: */
    19 // #include <QCheckBox>
    20 // #include <QComboBox>
    21 // #include <QGridLayout>
    22 // #include <QLabel>
     19#include <QDir>
    2320#include <QVBoxLayout>
    2421
     
    2623#include "UIWizardCloneVMEditors.h"
    2724#include "QIRichTextLabel.h"
    28 // #include "QILineEdit.h"
    29 // #include "UIFilePathSelector.h"
    3025#include "UIWizardCloneVM.h"
    3126#include "UIWizardCloneVMPageBasic1.h"
    32 //#include "UICommon.h"
     27#include "UICommon.h"
    3328
    3429/* COM includes: */
    35 // #include "CSystemProperties.h"
    36 // #include "CVirtualBox.h"
     30#include "CVirtualBox.h"
    3731
    3832
    39 // UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
    40 //     : m_strOriginalName(strOriginalName)
    41 //     , m_strDefaultPath(strDefaultPath)
    42 //     , m_strGroup(strGroup)
    43 //     , m_pNameLineEdit(0)
    44 //     , m_pPathSelector(0)
    45 //     , m_pNameLabel(0)
    46 //     , m_pPathLabel(0)
    47 //     , m_pMACComboBoxLabel(0)
    48 //     , m_pMACComboBox(0)
    49 //     , m_pKeepDiskNamesCheckBox(0)
    50 //     , m_pKeepHWUUIDsCheckBox(0)
    51 // {
    52 // }
    5333
    54 // QString UIWizardCloneVMPage1::cloneName() const
    55 // {
    56 //     if (!m_pNameLineEdit)
    57 //         return QString();
    58 //     return m_pNameLineEdit->text();
    59 // }
    60 
    61 // void UIWizardCloneVMPage1::setCloneName(const QString &strName)
    62 // {
    63 //     if (!m_pNameLineEdit)
    64 //         return;
    65 //     m_pNameLineEdit->setText(strName);
    66 // }
    67 
    68 // QString UIWizardCloneVMPage1::clonePath() const
    69 // {
    70 //     if (!m_pPathSelector)
    71 //         return QString();
    72 //     return m_pPathSelector->path();
    73 // }
    74 
    75 // void UIWizardCloneVMPage1::setClonePath(const QString &strPath)
    76 // {
    77 //     if (!m_pPathSelector)
    78 //         m_pPathSelector->setPath(strPath);
    79 // }
    80 
    81 // QString UIWizardCloneVMPage1::cloneFilePath() const
    82 // {
    83 //     return m_strCloneFilePath;
    84 // }
    85 
    86 // void UIWizardCloneVMPage1::setCloneFilePath(const QString &path)
    87 // {
    88 //     if (m_strCloneFilePath == path)
    89 //         return;
    90 //     m_strCloneFilePath = path;
    91 // }
    92 
    93 // void UIWizardCloneVMPage1::composeCloneFilePath()
    94 // {
    95 //     CVirtualBox vbox = uiCommon().virtualBox();
    96 //     setCloneFilePath(vbox.ComposeMachineFilename(m_pNameLineEdit ? m_pNameLineEdit->text() : QString(),
    97 //                                                  m_strGroup,
    98 //                                                  QString(),
    99 //                                                  m_pPathSelector ? m_pPathSelector->path() : QString()));
    100 //     const QFileInfo fileInfo(m_strCloneFilePath);
    101 //     m_strCloneFolder = fileInfo.absolutePath();
    102 // }
    103 
    104 // void UIWizardCloneVMPage1::updateMACAddressClonePolicyComboToolTip()
    105 // {
    106 //     const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString();
    107 //     AssertMsg(!strCurrentToolTip.isEmpty(), ("Tool-tip data not found!"));
    108 //     m_pMACComboBox->setToolTip(strCurrentToolTip);
    109 // }
    110 
    111 // MACAddressClonePolicy UIWizardCloneVMPage1::macAddressClonePolicy() const
    112 // {
    113 //     return m_pMACComboBox->currentData().value<MACAddressClonePolicy>();
    114 // }
    115 
    116 // void UIWizardCloneVMPage1::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy)
    117 // {
    118 //     const int iIndex = m_pMACComboBox->findData(enmMACAddressClonePolicy);
    119 //     AssertMsg(iIndex != -1, ("Data not found!"));
    120 //     m_pMACComboBox->setCurrentIndex(iIndex);
    121 // }
    122 
    123 // void UIWizardCloneVMPage1::populateMACAddressClonePolicies()
    124 // {
    125 //     AssertReturnVoid(m_pMACComboBox->count() == 0);
    126 
    127 //     /* Map known clone options to known MAC address export policies: */
    128 //     QMap<KCloneOptions, MACAddressClonePolicy> knownOptions;
    129 //     knownOptions[KCloneOptions_KeepAllMACs] = MACAddressClonePolicy_KeepAllMACs;
    130 //     knownOptions[KCloneOptions_KeepNATMACs] = MACAddressClonePolicy_KeepNATMACs;
    131 
    132 //     /* Load currently supported clone options: */
    133 //     CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    134 //     const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
    135 
    136 //     /* Check which of supported options/policies are known: */
    137 //     QList<MACAddressClonePolicy> supportedPolicies;
    138 //     foreach (const KCloneOptions &enmOption, supportedOptions)
    139 //         if (knownOptions.contains(enmOption))
    140 //             supportedPolicies << knownOptions.value(enmOption);
    141 
    142 //     /* Add supported policies first: */
    143 //     foreach (const MACAddressClonePolicy &enmPolicy, supportedPolicies)
    144 //         m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy));
    145 
    146 //     /* Add hardcoded policy finally: */
    147 //     m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressClonePolicy_StripAllMACs));
    148 
    149 //     /* Set default: */
    150 //     if (supportedPolicies.contains(MACAddressClonePolicy_KeepNATMACs))
    151 //         setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs);
    152 //     else
    153 //         setMACAddressClonePolicy(MACAddressClonePolicy_StripAllMACs);
    154 // }
    155 
    156 // bool UIWizardCloneVMPage1::keepDiskNames() const
    157 // {
    158 //     if (!m_pKeepDiskNamesCheckBox)
    159 //         return false;
    160 //     return m_pKeepDiskNamesCheckBox->isChecked();
    161 // }
    162 
    163 // void UIWizardCloneVMPage1::setKeepDiskNames(bool fKeepDiskNames)
    164 // {
    165 //     if (!m_pKeepDiskNamesCheckBox)
    166 //         return;
    167 //     if (m_pKeepDiskNamesCheckBox->isChecked() == fKeepDiskNames)
    168 //         return;
    169 //     m_pKeepDiskNamesCheckBox->setChecked(fKeepDiskNames);
    170 // }
    171 
    172 // bool UIWizardCloneVMPage1::keepHWUUIDs() const
    173 // {
    174 //     if (!m_pKeepHWUUIDsCheckBox)
    175 //         return false;
    176 //     return m_pKeepHWUUIDsCheckBox->isChecked();
    177 // }
    178 
    179 // void UIWizardCloneVMPage1::setKeepHWUUIDs(bool fKeepHWUUIDs)
    180 // {
    181 //     if (!m_pKeepHWUUIDsCheckBox)
    182 //         return;
    183 //     if (m_pKeepHWUUIDsCheckBox->isChecked() == fKeepHWUUIDs)
    184 //         return;
    185 //     m_pKeepHWUUIDsCheckBox->setChecked(fKeepHWUUIDs);
    186 // }
     34QString UIWizardCloneVMNamePage::composeCloneFilePath(const QString &strCloneName, const QString &strGroup, const QString &strFolderPath)
     35{
     36    CVirtualBox vbox = uiCommon().virtualBox();
     37    QString strCloneFilePath = vbox.ComposeMachineFilename(strCloneName, strGroup, QString(), strFolderPath);
     38    return QDir::toNativeSeparators(QFileInfo(strCloneFilePath).absolutePath());
     39}
    18740
    18841
     
    19144    , m_pAdditionalOptionsEditor(0)
    19245    , m_strOriginalName(strOriginalName)
    193     , m_strDefaultPath(strDefaultPath)
    19446    , m_strGroup(strGroup)
    19547{
    196     prepare();
     48    prepare(strDefaultPath);
    19749}
    19850
     
    22678}
    22779
    228 void UIWizardCloneVMPageBasic1::prepare()
     80void UIWizardCloneVMPageBasic1::prepare(const QString &strDefaultClonePath)
    22981{
    23082    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     
    23688        pMainLayout->addWidget(m_pMainLabel);
    23789
    238     m_pNamePathEditor = new UICloneVMNamePathEditor(m_strOriginalName, m_strDefaultPath);
     90    m_pNamePathEditor = new UICloneVMNamePathEditor(m_strOriginalName, strDefaultClonePath);
    23991    if (m_pNamePathEditor)
    24092    {
    24193        m_pNamePathEditor->setFlat(true);
    24294        pMainLayout->addWidget(m_pNamePathEditor);
     95        connect(m_pNamePathEditor, &UICloneVMNamePathEditor::sigCloneNameChanged,
     96                this, &UIWizardCloneVMPageBasic1::sltCloneNameChanged);
     97        connect(m_pNamePathEditor, &UICloneVMNamePathEditor::sigClonePathChanged,
     98                this, &UIWizardCloneVMPageBasic1::sltClonePathChanged);
    24399    }
    244100
     
    269125}
    270126
    271 void UIWizardCloneVMPageBasic1::sltNameChanged()
     127void UIWizardCloneVMPageBasic1::sltCloneNameChanged(const QString &strCloneName)
    272128{
    273     //composeCloneFilePath();
     129    AssertReturnVoid(m_pNamePathEditor);
     130    m_userModifiedParameters << "CloneName";
     131    m_userModifiedParameters << "CloneFilePath";
     132    cloneVMWizardPropertySet(CloneName, strCloneName);
     133    cloneVMWizardPropertySet(CloneFilePath,
     134                             UIWizardCloneVMNamePage::composeCloneFilePath(strCloneName, m_strGroup, m_pNamePathEditor->clonePath()));
    274135}
    275136
    276 void UIWizardCloneVMPageBasic1::sltPathChanged()
     137void UIWizardCloneVMPageBasic1::sltClonePathChanged(const QString &strClonePath)
    277138{
    278     //composeCloneFilePath();
     139    AssertReturnVoid(m_pNamePathEditor);
     140    m_userModifiedParameters << "CloneFilePath";
     141    cloneVMWizardPropertySet(CloneFilePath,
     142                             UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathEditor->cloneName(), m_strGroup, strClonePath));
    279143}
    280144
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h

    r90599 r90628  
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QSet>
     26
    2427/* Local includes: */
    2528#include "UINativeWizardPage.h"
     
    2831class UICloneVMAdditionalOptionsEditor;
    2932class UICloneVMNamePathEditor;
    30 // class QILineEdit;
    31 // class QCheckBox;
    32 // class QComboBox;
    33 // class QGridLayout;
    34 // class QLabel;
    3533class QIRichTextLabel;
    36 // class UIFilePathSelector;
    3734
    38 //Q_DECLARE_METATYPE(MACAddressClonePolicy);
     35namespace UIWizardCloneVMNamePage
     36{
     37    QString composeCloneFilePath(const QString &strCloneName, const QString &strGroup, const QString &strFolderPath);
    3938
    40 // /* 1st page of the Clone Virtual Machine wizard (base part): */
    41 // class UIWizardCloneVMPage1 : public UIWizardPageBase
    42 // {
    43 // protected:
    4439
    45 //     UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup);
     40}
    4641
    47 //     QString cloneName() const;
    48 //     void    setCloneName(const QString &strName);
    49 
    50 //     QString clonePath() const;
    51 //     void     setClonePath(const QString &strName);
    52 
    53 //     QString cloneFilePath() const;
    54 //     void setCloneFilePath(const QString &path);
    55 
    56 //     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    57 //     void composeCloneFilePath();
    58 //     /** Populates MAC address policies. */
    59 //     void populateMACAddressClonePolicies();
    60 
    61 //     /** Updates MAC address policy combo tool-tips. */
    62 //     void updateMACAddressClonePolicyComboToolTip();
    63 //     /** Returns MAC address clone policy. */
    64 //     MACAddressClonePolicy macAddressClonePolicy() const;
    65 //     /** Defines @a enmMACAddressClonePolicy. */
    66 //     void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy);
    67 
    68 //     bool keepDiskNames() const;
    69 //     void setKeepDiskNames(bool fKeepDiskNames);
    70 
    71 //     bool keepHWUUIDs() const;
    72 //     void setKeepHWUUIDs(bool bKeepHWUUIDs);
    73 
    74 //     /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */
    75 //     QString      m_strCloneFilePath;
    76 //     /** The full path of the folder where clone machine's settings file is located.
    77 //      * Generated from the m_strCloneFilePath by removing base file name */
    78 //     QString      m_strCloneFolder;
    79 //     QLabel      *m_pMACComboBoxLabel;
    80 //     QComboBox   *m_pMACComboBox;
    81 // };
    82 
    83 /* 1st page of the Clone Virtual Machine wizard (basic extension): */
    8442class UIWizardCloneVMPageBasic1 : public UINativeWizardPage
    8543{
    8644    Q_OBJECT;
    87     // Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
    88     // Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);
    89     // Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);
    90     // Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);
    91     // Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);
    92 
    9345
    9446public:
     
    9850private slots:
    9951
    100     void sltNameChanged();
    101     void sltPathChanged();
     52    void sltCloneNameChanged(const QString &strCloneName);
     53    void sltClonePathChanged(const QString &strClonePath);
    10254    /** Handles change in MAC address policy combo-box. */
    10355    void sltHandleMACAddressClonePolicyComboChange();
     
    10759    void retranslateUi();
    10860    void initializePage();
    109     void prepare();
     61    void prepare(const QString &strDefaultClonePath);
    11062    /* Validation stuff: */
    11163    bool isComplete() const;
     
    11769    UICloneVMAdditionalOptionsEditor *m_pAdditionalOptionsEditor;
    11870    QString      m_strOriginalName;
    119     QString      m_strDefaultPath;
    12071    QString      m_strGroup;
     72    QSet<QString> m_userModifiedParameters;
    12173};
    12274
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

    r90620 r90628  
    6666}
    6767
     68QString UICloneVMNamePathEditor::cloneName() const
     69{
     70    if (m_pNameLineEdit)
     71        return m_pNameLineEdit->text();
     72    return QString();
     73}
     74
     75void UICloneVMNamePathEditor::setCloneName(const QString &strName)
     76{
     77    if (m_pNameLineEdit)
     78        m_pNameLineEdit->setText(strName);
     79}
     80
     81QString UICloneVMNamePathEditor::clonePath() const
     82{
     83    if (m_pPathSelector)
     84        return m_pPathSelector->path();
     85    return QString();
     86}
     87
     88void UICloneVMNamePathEditor::setClonePath(const QString &strPath)
     89{
     90    if (m_pPathSelector)
     91        m_pPathSelector->setPath(strPath);
     92}
     93
    6894void UICloneVMNamePathEditor::setFirstColumnWidth(int iWidth)
    6995{
     
    100126        m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
    101127        m_pNameLineEdit->setText(tr("%1 Clone").arg(m_strOriginalName));
     128        connect(m_pNameLineEdit, &QILineEdit::textChanged,
     129                this, &UICloneVMNamePathEditor::sigCloneNameChanged);
    102130    }
    103131
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h

    r90617 r90628  
    6969signals:
    7070
    71     // void sigNameChanged(const QString &strUserName);
    72     // void sigPathChanged(const QString &strPassword);
     71    void sigCloneNameChanged(const QString &strCloneName);
     72    void sigClonePathChanged(const QString &strClonePath);
    7373
    7474public:
     
    7979    int firstColumnWidth() const;
    8080
    81     QString name() const;
    82     void setName(const QString &strName);
     81    QString cloneName() const;
     82    void setCloneName(const QString &strName);
    8383
    84     QString path() const;
    85     void setPath(const QString &strPath);
     84    QString clonePath() const;
     85    void setClonePath(const QString &strPath);
     86
    8687    bool isComplete();
    8788
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