VirtualBox

Changeset 90589 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 10, 2021 10:07:26 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Initial refactoring of the clone vm wizard.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
13 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r90586 r90589  
    653653        src/wizards/editors/UIHostnameDomainNameEditor.h \
    654654        src/wizards/editors/UIUserNamePasswordEditor.h \
     655        src/wizards/editors/UIWizardCloneVMEditors.h \
    655656        src/wizards/editors/UIWizardNewVMEditors.h \
    656657        src/wizards/newcloudvm/UIWizardNewCloudVM.h \
     
    11591160        src/wizards/editors/UIHostnameDomainNameEditor.cpp \
    11601161        src/wizards/editors/UIUserNamePasswordEditor.cpp \
     1162        src/wizards/editors/UIWizardCloneVMEditors.cpp \
    11611163        src/wizards/editors/UIWizardNewVMEditors.cpp \
    11621164        src/wizards/newcloudvm/UIWizardNewCloudVM.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r90564 r90589  
    11381138    const QStringList &machineGroupNames = pItemLocal->groups();
    11391139    const QString strGroup = !machineGroupNames.isEmpty() ? machineGroupNames.at(0) : QString();
    1140     UISafePointerWizard pWizard = new UIWizardCloneVM(pWizardParent, pItemLocal->machine(), strGroup);
     1140    QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(pWizardParent, pItemLocal->machine(), strGroup);
    11411141    windowManager().registerNewParent(pWizard, pWizardParent);
    1142     pWizard->prepare();
    11431142    pWizard->exec();
    11441143    delete pWizard;
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp

    r90564 r90589  
    16661666
    16671667    /* Show Clone VM wizard: */
    1668     UISafePointerWizard pWizard = new UIWizardCloneVM(this, comMachine, QString(), comSnapshot);
    1669     pWizard->prepare();
     1668    QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(this, comMachine, QString(), comSnapshot);
    16701669    pWizard->exec();
    16711670    if (pWizard)
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.cpp

    r90069 r90589  
    162162    /* Translate Help button: */
    163163    QPushButton *pButtonHelp = wizardButton(WizardButtonType_Help);
    164     AssertMsgReturnVoid(pButtonHelp, ("No Help wizard button found!\n"));
    165     pButtonHelp->setText(tr("&Help"));
    166     pButtonHelp->setToolTip(tr("Open corresponding Help topic."));
     164    if (pButtonHelp)
     165    {
     166        pButtonHelp->setText(tr("&Help"));
     167        pButtonHelp->setToolTip(tr("Open corresponding Help topic."));
     168    }
    167169
    168170    /* Translate basic/expert button: */
     
    456458                for (int i = WizardButtonType_Invalid + 1; i < WizardButtonType_Max; ++i)
    457459                {
     460                    /* Create the help button only if the help hash tag is set: */
     461                    if (m_strHelpHashtag.isEmpty() && i == WizardButtonType_Help)
     462                        continue;
    458463                    const WizardButtonType enmType = (WizardButtonType)i;
    459464                    m_buttons[enmType] = new QPushButton(pWidgetBottom);
     
    468473                }
    469474                /* Connect buttons: */
    470                 connect(wizardButton(WizardButtonType_Help), &QPushButton::pressed,
    471                         &(msgCenter()), &UIMessageCenter::sltHandleHelpRequest);
    472                 wizardButton(WizardButtonType_Help)->setShortcut(QKeySequence::HelpContents);
    473                 uiCommon().setHelpKeyword(wizardButton(WizardButtonType_Help), m_strHelpHashtag);
     475                if (wizardButton(WizardButtonType_Help))
     476                {
     477                    connect(wizardButton(WizardButtonType_Help), &QPushButton::pressed,
     478                            &(msgCenter()), &UIMessageCenter::sltHandleHelpRequest);
     479                    wizardButton(WizardButtonType_Help)->setShortcut(QKeySequence::HelpContents);
     480                    uiCommon().setHelpKeyword(wizardButton(WizardButtonType_Help), m_strHelpHashtag);
     481                }
    474482                connect(wizardButton(WizardButtonType_Expert), &QPushButton::pressed,
    475483                        this, &UINativeWizard::sltExpert);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r90564 r90589  
    3333UIWizardCloneVM::UIWizardCloneVM(QWidget *pParent, const CMachine &machine,
    3434                                 const QString &strGroup, CSnapshot snapshot /* = CSnapshot() */)
    35     : UIWizard(pParent, WizardType_CloneVM)
     35    : UINativeWizard(pParent, WizardType_CloneVM)
    3636    , m_machine(machine)
    3737    , m_snapshot(snapshot)
     
    4040#ifndef VBOX_WS_MAC
    4141    /* Assign watermark: */
    42     assignWatermark(":/wizard_clone.png");
     42    setPixmapName(":/wizard_clone.png");
    4343#else /* VBOX_WS_MAC */
    4444    /* Assign background image: */
    45     assignBackground(":/wizard_clone_bg.png");
     45    setPixmapName(":/wizard_clone_bg.png");
    4646#endif /* VBOX_WS_MAC */
    4747}
     
    4949bool UIWizardCloneVM::cloneVM()
    5050{
    51     /* Get the clone name: */
    52     QString strName = field("cloneName").toString();
    53     /* Get the clone setting file path: */
    54     QString strSettingsFile = field("cloneFilePath").toString();
    55 
    56     /* Should we create linked clone? */
    57     bool fLinked = field("linkedClone").toBool();
    58     /* Get clone mode: */
    59     KCloneMode cloneMode = (mode() == WizardMode_Basic && page(Page3)) ||
    60                            (mode() == WizardMode_Expert && page(PageExpert)) ?
    61                            field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState;
    62 
    63     /* Get VBox object: */
    64     CVirtualBox vbox = uiCommon().virtualBox();
    65 
    66     /* Prepare machine for cloning: */
    67     CMachine srcMachine = m_machine;
    68 
    69     /* If the user like to create a linked clone from the current machine, we
    70     * have to take a little bit more action. First we create an snapshot, so
    71     * that new differencing images on the source VM are created. Based on that
    72     * we could use the new snapshot machine for cloning. */
    73     if (fLinked && m_snapshot.isNull())
    74     {
    75         /* Open session: */
    76         CSession session = uiCommon().openSession(m_machine.GetId());
    77         if (session.isNull())
    78             return false;
    79 
    80         /* Prepare machine: */
    81         CMachine machine = session.GetMachine();
    82 
    83         /* Take the snapshot: */
    84         QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(strName);
    85         QUuid uSnapshotId;
    86         CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true, uSnapshotId);
    87 
    88         if (machine.isOk())
    89         {
    90             /* Show the "Taking Snapshot" progress dialog: */
    91             msgCenter().showModalProgressDialog(progress, m_machine.GetName(), ":/progress_snapshot_create_90px.png", this);
    92 
    93             if (!progress.isOk() || progress.GetResultCode() != 0)
    94             {
    95                 msgCenter().cannotTakeSnapshot(progress, m_machine.GetName(), this);
    96                 return false;
    97             }
    98         }
    99         else
    100         {
    101             msgCenter().cannotTakeSnapshot(machine, m_machine.GetName(), this);
    102             return false;
    103         }
    104 
    105         /* Unlock machine finally: */
    106         session.UnlockMachine();
    107 
    108         /* Get the new snapshot and the snapshot machine. */
    109         const CSnapshot &newSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
    110         if (newSnapshot.isNull())
    111         {
    112             msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
    113             return false;
    114         }
    115         srcMachine = newSnapshot.GetMachine();
    116     }
    117 
    118     /* Create a new machine object. */
    119     CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString(), QString());
    120     if (!vbox.isOk())
    121     {
    122         msgCenter().cannotCreateMachine(vbox, this);
    123         return false;
    124     }
    125 
    126     /* Clone options vector to pass to cloning: */
    127     QVector<KCloneOptions> options;
    128     /* Set the selected MAC address policy: */
    129     switch (field("macAddressClonePolicy").value<MACAddressClonePolicy>())
    130     {
    131         case MACAddressClonePolicy_KeepAllMACs:
    132             options.append(KCloneOptions_KeepAllMACs);
    133             break;
    134         case MACAddressClonePolicy_KeepNATMACs:
    135             options.append(KCloneOptions_KeepNATMACs);
    136             break;
    137         default:
    138             break;
    139     }
    140 
    141     if (field("keepDiskNames").value<bool>())
    142         options.append(KCloneOptions_KeepDiskNames);
    143     if (field("keepHWUUIDs").value<bool>())
    144         options.append(KCloneOptions_KeepHwUUIDs);
    145 
    146     /* Linked clones requested? */
    147     if (fLinked)
    148         options.append(KCloneOptions_Link);
    149 
    150     /* Clone VM: */
    151     UINotificationProgressMachineCopy *pNotification = new UINotificationProgressMachineCopy(srcMachine,
    152                                                                                              cloneMachine,
    153                                                                                              cloneMode,
    154                                                                                              options);
    155     connect(pNotification, &UINotificationProgressMachineCopy::sigMachineCopied,
    156             &uiCommon(), &UICommon::sltHandleMachineCreated);
    157     gpNotificationCenter->append(pNotification);
     51    // /* Get the clone name: */
     52    // QString strName = field("cloneName").toString();
     53    // /* Get the clone setting file path: */
     54    // QString strSettingsFile = field("cloneFilePath").toString();
     55
     56    // /* Should we create linked clone? */
     57    // bool fLinked = field("linkedClone").toBool();
     58    // /* Get clone mode: */
     59    // KCloneMode cloneMode = (mode() == WizardMode_Basic && page(Page3)) ||
     60    //                        (mode() == WizardMode_Expert && page(PageExpert)) ?
     61    //                        field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState;
     62
     63    // /* Get VBox object: */
     64    // CVirtualBox vbox = uiCommon().virtualBox();
     65
     66    // /* Prepare machine for cloning: */
     67    // CMachine srcMachine = m_machine;
     68
     69    // /* If the user like to create a linked clone from the current machine, we
     70    // * have to take a little bit more action. First we create an snapshot, so
     71    // * that new differencing images on the source VM are created. Based on that
     72    // * we could use the new snapshot machine for cloning. */
     73    // if (fLinked && m_snapshot.isNull())
     74    // {
     75    //     /* Open session: */
     76    //     CSession session = uiCommon().openSession(m_machine.GetId());
     77    //     if (session.isNull())
     78    //         return false;
     79
     80    //     /* Prepare machine: */
     81    //     CMachine machine = session.GetMachine();
     82
     83    //     /* Take the snapshot: */
     84    //     QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(strName);
     85    //     QUuid uSnapshotId;
     86    //     CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true, uSnapshotId);
     87
     88    //     if (machine.isOk())
     89    //     {
     90    //         /* Show the "Taking Snapshot" progress dialog: */
     91    //         msgCenter().showModalProgressDialog(progress, m_machine.GetName(), ":/progress_snapshot_create_90px.png", this);
     92
     93    //         if (!progress.isOk() || progress.GetResultCode() != 0)
     94    //         {
     95    //             msgCenter().cannotTakeSnapshot(progress, m_machine.GetName(), this);
     96    //             return false;
     97    //         }
     98    //     }
     99    //     else
     100    //     {
     101    //         msgCenter().cannotTakeSnapshot(machine, m_machine.GetName(), this);
     102    //         return false;
     103    //     }
     104
     105    //     /* Unlock machine finally: */
     106    //     session.UnlockMachine();
     107
     108    //     /* Get the new snapshot and the snapshot machine. */
     109    //     const CSnapshot &newSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
     110    //     if (newSnapshot.isNull())
     111    //     {
     112    //         msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
     113    //         return false;
     114    //     }
     115    //     srcMachine = newSnapshot.GetMachine();
     116    // }
     117
     118    // /* Create a new machine object. */
     119    // CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString(), QString());
     120    // if (!vbox.isOk())
     121    // {
     122    //     msgCenter().cannotCreateMachine(vbox, this);
     123    //     return false;
     124    // }
     125
     126    // /* Clone options vector to pass to cloning: */
     127    // QVector<KCloneOptions> options;
     128    // /* Set the selected MAC address policy: */
     129    // switch (field("macAddressClonePolicy").value<MACAddressClonePolicy>())
     130    // {
     131    //     case MACAddressClonePolicy_KeepAllMACs:
     132    //         options.append(KCloneOptions_KeepAllMACs);
     133    //         break;
     134    //     case MACAddressClonePolicy_KeepNATMACs:
     135    //         options.append(KCloneOptions_KeepNATMACs);
     136    //         break;
     137    //     default:
     138    //         break;
     139    // }
     140
     141    // if (field("keepDiskNames").value<bool>())
     142    //     options.append(KCloneOptions_KeepDiskNames);
     143    // if (field("keepHWUUIDs").value<bool>())
     144    //     options.append(KCloneOptions_KeepHwUUIDs);
     145
     146    // /* Linked clones requested? */
     147    // if (fLinked)
     148    //     options.append(KCloneOptions_Link);
     149
     150    // /* Clone VM: */
     151    // UINotificationProgressMachineCopy *pNotification = new UINotificationProgressMachineCopy(srcMachine,
     152    //                                                                                          cloneMachine,
     153    //                                                                                          cloneMode,
     154    //                                                                                          options);
     155    // connect(pNotification, &UINotificationProgressMachineCopy::sigMachineCopied,
     156    //         &uiCommon(), &UICommon::sltHandleMachineCreated);
     157    // gpNotificationCenter->append(pNotification);
    158158
    159159    return true;
     
    163163{
    164164    /* Call to base-class: */
    165     UIWizard::retranslateUi();
     165    UINativeWizard::retranslateUi();
    166166
    167167    /* Translate wizard: */
    168168    setWindowTitle(tr("Clone Virtual Machine"));
    169     setButtonText(QWizard::FinishButton, tr("Clone"));
    170 }
    171 
    172 void UIWizardCloneVM::prepare()
    173 {
    174     enableHelpButton("clone");
     169    //setButtonText(QWizard::FinishButton, tr("Clone"));
     170}
     171
     172void UIWizardCloneVM::populatePages()
     173{
    175174    QString strDefaultMachineFolder = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    176175    /* Create corresponding pages: */
     
    178177    {
    179178        case WizardMode_Basic:
     179        case WizardMode_Expert:
    180180        {
    181             setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName(), strDefaultMachineFolder, m_strGroup));
    182             setPage(Page2, new UIWizardCloneVMPageBasic2(m_snapshot.isNull()));
    183             if (m_machine.GetSnapshotCount() > 0)
    184                 setPage(Page3, new UIWizardCloneVMPageBasic3(m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0));
     181            addPage(new UIWizardCloneVMPageBasic1(m_machine.GetName(), strDefaultMachineFolder, m_strGroup));
     182    //         setPage(Page2, new UIWizardCloneVMPageBasic2(m_snapshot.isNull()));
     183    //         if (m_machine.GetSnapshotCount() > 0)
     184    //             setPage(Page3, new UIWizardCloneVMPageBasic3(m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0));
    185185            break;
    186186        }
    187         case WizardMode_Expert:
     187
    188188        {
    189             setPage(PageExpert, new UIWizardCloneVMPageExpert(m_machine.GetName(),
    190                                                               strDefaultMachineFolder,
    191                                                               m_snapshot.isNull(),
    192                                                               m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0,
    193                                                               m_strGroup));
     189    //         setPage(PageExpert, new UIWizardCloneVMPageExpert(m_machine.GetName(),
     190    //                                                           strDefaultMachineFolder,
     191    //                                                           m_snapshot.isNull(),
     192    //                                                           m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0,
     193    //                                                           m_strGroup));
    194194            break;
    195195        }
     
    201201    }
    202202    /* Call to base-class: */
    203     UIWizard::prepare();
    204 }
     203    //UINativeWizard::prepare();
     204}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h

    r82968 r90589  
    2323
    2424/* GUI includes: */
    25 #include "UIWizard.h"
     25#include "UINativeWizard.h"
    2626
    2727/* COM includes: */
     
    3131
    3232/* Clone VM wizard: */
    33 class UIWizardCloneVM : public UIWizard
     33class UIWizardCloneVM : public UINativeWizard
    3434{
    3535    Q_OBJECT;
     
    3737public:
    3838
    39     /* Page IDs: */
    40     enum
    41     {
    42         Page1,
    43         Page2,
    44         Page3
    45     };
    4639
    47     /* Page IDs: */
    48     enum
    49     {
    50         PageExpert
    51     };
    5240
    5341    /* Constructor: */
     
    5947    /* CLone VM stuff: */
    6048    bool cloneVM();
    61 
    62     /* Who will be able to clone virtual-machine: */
    63     friend class UIWizardCloneVMPageBasic2;
    64     friend class UIWizardCloneVMPageBasic3;
    65     friend class UIWizardCloneVMPageExpert;
     49    virtual void populatePages() /* final override */;
    6650
    6751private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r88446 r90589  
    1717
    1818/* Qt includes: */
    19 #include <QCheckBox>
    20 #include <QComboBox>
    21 #include <QGridLayout>
    22 #include <QLabel>
     19// #include <QCheckBox>
     20// #include <QComboBox>
     21// #include <QGridLayout>
     22// #include <QLabel>
    2323#include <QVBoxLayout>
    2424
    2525/* GUI includes: */
     26#include "UIWizardCloneVMEditors.h"
    2627#include "QIRichTextLabel.h"
    27 #include "QILineEdit.h"
    28 #include "UIFilePathSelector.h"
     28// #include "QILineEdit.h"
     29// #include "UIFilePathSelector.h"
    2930#include "UIWizardCloneVM.h"
    3031#include "UIWizardCloneVMPageBasic1.h"
    31 #include "UICommon.h"
     32//#include "UICommon.h"
    3233
    3334/* COM includes: */
    34 #include "CSystemProperties.h"
    35 #include "CVirtualBox.h"
    36 
    37 
    38 UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
    39     : m_strOriginalName(strOriginalName)
     35// #include "CSystemProperties.h"
     36// #include "CVirtualBox.h"
     37
     38
     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// }
     53
     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// }
     187
     188
     189UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
     190    : m_pNamePathEditor(0)
     191    , m_pAdditionalOptionsEditor(0)
     192    , m_strOriginalName(strOriginalName)
    40193    , m_strDefaultPath(strDefaultPath)
    41194    , m_strGroup(strGroup)
    42     , m_pNameLineEdit(0)
    43     , m_pPathSelector(0)
    44     , m_pNameLabel(0)
    45     , m_pPathLabel(0)
    46     , m_pMACComboBoxLabel(0)
    47     , m_pMACComboBox(0)
    48     , m_pKeepDiskNamesCheckBox(0)
    49     , m_pKeepHWUUIDsCheckBox(0)
    50 {
    51 }
    52 
    53 QString UIWizardCloneVMPage1::cloneName() const
    54 {
    55     if (!m_pNameLineEdit)
    56         return QString();
    57     return m_pNameLineEdit->text();
    58 }
    59 
    60 void UIWizardCloneVMPage1::setCloneName(const QString &strName)
    61 {
    62     if (!m_pNameLineEdit)
    63         return;
    64     m_pNameLineEdit->setText(strName);
    65 }
    66 
    67 QString UIWizardCloneVMPage1::clonePath() const
    68 {
    69     if (!m_pPathSelector)
    70         return QString();
    71     return m_pPathSelector->path();
    72 }
    73 
    74 void UIWizardCloneVMPage1::setClonePath(const QString &strPath)
    75 {
    76     if (!m_pPathSelector)
    77         m_pPathSelector->setPath(strPath);
    78 }
    79 
    80 QString UIWizardCloneVMPage1::cloneFilePath() const
    81 {
    82     return m_strCloneFilePath;
    83 }
    84 
    85 void UIWizardCloneVMPage1::setCloneFilePath(const QString &path)
    86 {
    87     if (m_strCloneFilePath == path)
    88         return;
    89     m_strCloneFilePath = path;
    90 }
    91 
    92 void UIWizardCloneVMPage1::composeCloneFilePath()
    93 {
    94     CVirtualBox vbox = uiCommon().virtualBox();
    95     setCloneFilePath(vbox.ComposeMachineFilename(m_pNameLineEdit ? m_pNameLineEdit->text() : QString(),
    96                                                  m_strGroup,
    97                                                  QString(),
    98                                                  m_pPathSelector ? m_pPathSelector->path() : QString()));
    99     const QFileInfo fileInfo(m_strCloneFilePath);
    100     m_strCloneFolder = fileInfo.absolutePath();
    101 }
    102 
    103 void UIWizardCloneVMPage1::updateMACAddressClonePolicyComboToolTip()
    104 {
    105     const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString();
    106     AssertMsg(!strCurrentToolTip.isEmpty(), ("Tool-tip data not found!"));
    107     m_pMACComboBox->setToolTip(strCurrentToolTip);
    108 }
    109 
    110 MACAddressClonePolicy UIWizardCloneVMPage1::macAddressClonePolicy() const
    111 {
    112     return m_pMACComboBox->currentData().value<MACAddressClonePolicy>();
    113 }
    114 
    115 void UIWizardCloneVMPage1::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy)
    116 {
    117     const int iIndex = m_pMACComboBox->findData(enmMACAddressClonePolicy);
    118     AssertMsg(iIndex != -1, ("Data not found!"));
    119     m_pMACComboBox->setCurrentIndex(iIndex);
    120 }
    121 
    122 void UIWizardCloneVMPage1::populateMACAddressClonePolicies()
    123 {
    124     AssertReturnVoid(m_pMACComboBox->count() == 0);
    125 
    126     /* Map known clone options to known MAC address export policies: */
    127     QMap<KCloneOptions, MACAddressClonePolicy> knownOptions;
    128     knownOptions[KCloneOptions_KeepAllMACs] = MACAddressClonePolicy_KeepAllMACs;
    129     knownOptions[KCloneOptions_KeepNATMACs] = MACAddressClonePolicy_KeepNATMACs;
    130 
    131     /* Load currently supported clone options: */
    132     CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    133     const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
    134 
    135     /* Check which of supported options/policies are known: */
    136     QList<MACAddressClonePolicy> supportedPolicies;
    137     foreach (const KCloneOptions &enmOption, supportedOptions)
    138         if (knownOptions.contains(enmOption))
    139             supportedPolicies << knownOptions.value(enmOption);
    140 
    141     /* Add supported policies first: */
    142     foreach (const MACAddressClonePolicy &enmPolicy, supportedPolicies)
    143         m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy));
    144 
    145     /* Add hardcoded policy finally: */
    146     m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressClonePolicy_StripAllMACs));
    147 
    148     /* Set default: */
    149     if (supportedPolicies.contains(MACAddressClonePolicy_KeepNATMACs))
    150         setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs);
    151     else
    152         setMACAddressClonePolicy(MACAddressClonePolicy_StripAllMACs);
    153 }
    154 
    155 bool UIWizardCloneVMPage1::keepDiskNames() const
    156 {
    157     if (!m_pKeepDiskNamesCheckBox)
    158         return false;
    159     return m_pKeepDiskNamesCheckBox->isChecked();
    160 }
    161 
    162 void UIWizardCloneVMPage1::setKeepDiskNames(bool fKeepDiskNames)
    163 {
    164     if (!m_pKeepDiskNamesCheckBox)
    165         return;
    166     if (m_pKeepDiskNamesCheckBox->isChecked() == fKeepDiskNames)
    167         return;
    168     m_pKeepDiskNamesCheckBox->setChecked(fKeepDiskNames);
    169 }
    170 
    171 bool UIWizardCloneVMPage1::keepHWUUIDs() const
    172 {
    173     if (!m_pKeepHWUUIDsCheckBox)
    174         return false;
    175     return m_pKeepHWUUIDsCheckBox->isChecked();
    176 }
    177 
    178 void UIWizardCloneVMPage1::setKeepHWUUIDs(bool fKeepHWUUIDs)
    179 {
    180     if (!m_pKeepHWUUIDsCheckBox)
    181         return;
    182     if (m_pKeepHWUUIDsCheckBox->isChecked() == fKeepHWUUIDs)
    183         return;
    184     m_pKeepHWUUIDsCheckBox->setChecked(fKeepHWUUIDs);
    185 }
    186 
    187 
    188 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)
    189     : UIWizardCloneVMPage1(strOriginalName, strDefaultPath, strGroup)
    190     , m_pMainLabel(0)
    191     , m_pContainerLayout(0)
    192     , m_pAdditionalOptionsLabel(0)
    193 {
    194     /* Create widgets: */
    195     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    196     if (!pMainLayout)
    197         return;
    198 
    199     m_pMainLabel = new QIRichTextLabel(this);
    200     if (m_pMainLabel)
    201     {
    202         pMainLayout->addWidget(m_pMainLabel);
    203     }
    204 
    205     QWidget *pContainerWidget = new QWidget(this);
    206     if (pContainerWidget)
    207     {
    208         pMainLayout->addWidget(pContainerWidget);
    209         m_pContainerLayout = new QGridLayout(pContainerWidget);
    210         m_pContainerLayout->setContentsMargins(0, 0, 0, 0);
    211 
    212         m_pNameLabel = new QLabel;
    213         if (m_pNameLabel)
    214         {
    215             m_pNameLabel->setAlignment(Qt::AlignRight);
    216             m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    217             m_pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
    218         }
    219 
    220         m_pNameLineEdit = new QILineEdit();
    221         if (m_pNameLineEdit)
    222         {
    223             m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
    224             m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
    225         }
    226 
    227         m_pPathLabel = new QLabel(this);
    228         if (m_pPathLabel)
    229         {
    230             m_pPathLabel->setAlignment(Qt::AlignRight);
    231             m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    232             m_pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
    233         }
    234 
    235         m_pPathSelector = new UIFilePathSelector(this);
    236         if (m_pPathSelector)
    237         {
    238             m_pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
    239             m_pPathSelector->setPath(m_strDefaultPath);
    240         }
    241 
    242         /* Create MAC policy combo-box: */
    243         m_pMACComboBox = new QComboBox;
    244         if (m_pMACComboBox)
    245         {
    246             /* Add into layout: */
    247             m_pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1);
    248         }
    249 
    250         /* Create format combo-box label: */
    251         m_pMACComboBoxLabel = new QLabel;
    252         if (m_pMACComboBoxLabel)
    253         {
    254             m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    255             m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
    256             /* Add into layout: */
    257             m_pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1);
    258         }
    259 
    260         /* Load currently supported clone options: */
    261         CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    262         const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
    263         /* Check whether we support additional clone options at all: */
    264         int iVerticalPosition = 3;
    265         const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
    266         const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
    267         if (fSupportedKeepDiskNames || fSupportedKeepHWUUIDs)
    268         {
    269             m_pAdditionalOptionsLabel = new QLabel;
    270             if (m_pAdditionalOptionsLabel)
    271             {
    272                 m_pAdditionalOptionsLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    273                 m_pContainerLayout->addWidget(m_pAdditionalOptionsLabel, iVerticalPosition, 0, 1, 1);
    274             }
    275         }
    276         if (fSupportedKeepDiskNames)
    277         {
    278             m_pKeepDiskNamesCheckBox = new QCheckBox;
    279             if (m_pKeepDiskNamesCheckBox)
    280                 m_pContainerLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
    281         }
    282         if (fSupportedKeepHWUUIDs)
    283         {
    284             m_pKeepHWUUIDsCheckBox = new QCheckBox;
    285             if (m_pKeepHWUUIDsCheckBox)
    286                 m_pContainerLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
    287         }
    288     }
    289     pMainLayout->addStretch();
    290 
    291     /* Populate MAC address policies: */
    292     populateMACAddressClonePolicies();
    293 
    294     /* Register fields: */
    295     registerField("cloneName", this, "cloneName");
    296     registerField("cloneFilePath", this, "cloneFilePath");
    297     registerField("macAddressClonePolicy", this, "macAddressClonePolicy");
    298     registerField("keepDiskNames", this, "keepDiskNames");
    299     registerField("keepHWUUIDs", this, "keepHWUUIDs");
    300 
    301     composeCloneFilePath();
    302 
    303     /* Setup connections: */
    304     connect(m_pNameLineEdit, &QILineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
    305     connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardCloneVMPageBasic1::completeChanged);
    306 
    307     connect(m_pNameLineEdit, &QILineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::sltNameChanged);
    308     connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardCloneVMPageBasic1::sltPathChanged);
    309     connect(m_pMACComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    310             this, &UIWizardCloneVMPageBasic1::sltHandleMACAddressClonePolicyComboChange);
     195{
     196    prepare();
    311197}
    312198
    313199void UIWizardCloneVMPageBasic1::retranslateUi()
    314200{
    315     /* Translate page: */
     201    // /* Translate page: */
    316202    setTitle(UIWizardCloneVM::tr("New machine name and path"));
    317203
    318     /* Translate widgets: */
    319204    if (m_pMainLabel)
    320205        m_pMainLabel->setText(UIWizardCloneVM::tr("<p>Please choose a name and optionally a folder for the new virtual machine. "
    321206                                                  "The new machine will be a clone of the machine <b>%1</b>.</p>")
    322207                              .arg(m_strOriginalName));
    323 
    324     if (m_pNameLabel)
    325         m_pNameLabel->setText(UIWizardCloneVM::tr("Name:"));
    326 
    327     if (m_pPathLabel)
    328         m_pPathLabel->setText(UIWizardCloneVM::tr("Path:"));
    329 
    330     /* Translate MAC address policy combo-box: */
    331     m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:"));
    332     for (int i = 0; i < m_pMACComboBox->count(); ++i)
     208}
     209
     210void UIWizardCloneVMPageBasic1::initializePage()
     211{
     212    /* Translate page: */
     213    // retranslateUi();
     214    // if (m_pNameLineEdit)
     215    //     m_pNameLineEdit->setFocus();
     216}
     217
     218void UIWizardCloneVMPageBasic1::prepare()
     219{
     220    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     221
     222    AssertReturnVoid(pMainLayout);
     223
     224    m_pMainLabel = new QIRichTextLabel(this);
     225    if (m_pMainLabel)
     226        pMainLayout->addWidget(m_pMainLabel);
     227
     228    m_pNamePathEditor = new UICloneVMNamePathEditor(m_strOriginalName, m_strDefaultPath);
     229    if (m_pNamePathEditor)
    333230    {
    334         const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
    335         switch (enmPolicy)
    336         {
    337             case MACAddressClonePolicy_KeepAllMACs:
    338             {
    339                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
    340                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    341                 break;
    342             }
    343             case MACAddressClonePolicy_KeepNATMACs:
    344             {
    345                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
    346                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    347                 break;
    348             }
    349             case MACAddressClonePolicy_StripAllMACs:
    350             {
    351                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
    352                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
    353                 break;
    354             }
    355             default:
    356                 break;
    357         }
     231        m_pNamePathEditor->setFlat(true);
     232        pMainLayout->addWidget(m_pNamePathEditor);
    358233    }
    359234
    360     if (m_pAdditionalOptionsLabel)
    361         m_pAdditionalOptionsLabel->setText(UIWizardCloneVM::tr("Additional Options:"));
    362     if (m_pKeepDiskNamesCheckBox)
     235    m_pAdditionalOptionsEditor = new UICloneVMAdditionalOptionsEditor;
     236    if (m_pAdditionalOptionsEditor)
    363237    {
    364         m_pKeepDiskNamesCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change the disk names during cloning."));
    365         m_pKeepDiskNamesCheckBox->setText(UIWizardCloneVM::tr("Keep &Disk Names"));
     238        m_pAdditionalOptionsEditor->setFlat(true);
     239        pMainLayout->addWidget(m_pAdditionalOptionsEditor);
    366240    }
    367     if (m_pKeepHWUUIDsCheckBox)
    368     {
    369         m_pKeepHWUUIDsCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change hardware UUIDs during cloning."));
    370         m_pKeepHWUUIDsCheckBox->setText(UIWizardCloneVM::tr("Keep &Hardware UUIDs"));
    371     }
    372 }
    373 
    374 void UIWizardCloneVMPageBasic1::initializePage()
    375 {
    376     /* Translate page: */
     241
     242    pMainLayout->addStretch();
     243
    377244    retranslateUi();
    378     if (m_pNameLineEdit)
    379         m_pNameLineEdit->setFocus();
    380245}
    381246
    382247bool UIWizardCloneVMPageBasic1::isComplete() const
    383248{
    384     if (!m_pPathSelector)
    385         return false;
    386 
    387     QString path = m_pPathSelector->path();
    388     if (path.isEmpty())
    389         return false;
    390     /* Make sure VM name feat the rules: */
    391     QString strName = m_pNameLineEdit->text().trimmed();
    392     return !strName.isEmpty() && strName != m_strOriginalName;
     249    // if (!m_pPathSelector)
     250    //     return false;
     251
     252    // QString path = m_pPathSelector->path();
     253    // if (path.isEmpty())
     254    //     return false;
     255    // /* Make sure VM name feat the rules: */
     256    // QString strName = m_pNameLineEdit->text().trimmed();
     257    // return !strName.isEmpty() && strName != m_strOriginalName;
     258    return true;
    393259}
    394260
    395261void UIWizardCloneVMPageBasic1::sltNameChanged()
    396262{
    397     composeCloneFilePath();
     263    //composeCloneFilePath();
    398264}
    399265
    400266void UIWizardCloneVMPageBasic1::sltPathChanged()
    401267{
    402     composeCloneFilePath();
     268    //composeCloneFilePath();
    403269}
    404270
     
    406272{
    407273    /* Update tool-tip: */
    408     updateMACAddressClonePolicyComboToolTip();
    409 }
     274    //updateMACAddressClonePolicyComboToolTip();
     275}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h

    r82968 r90589  
    2323
    2424/* Local includes: */
    25 #include "UIWizardPage.h"
     25#include "UINativeWizardPage.h"
    2626
    2727/* Forward declarations: */
    28 class QILineEdit;
    29 class QCheckBox;
    30 class QComboBox;
    31 class QGridLayout;
    32 class QLabel;
     28class UICloneVMAdditionalOptionsEditor;
     29class UICloneVMNamePathEditor;
     30// class QILineEdit;
     31// class QCheckBox;
     32// class QComboBox;
     33// class QGridLayout;
     34// class QLabel;
    3335class QIRichTextLabel;
    34 class UIFilePathSelector;
     36// class UIFilePathSelector;
    3537
    36 /** MAC address policies. */
    37 enum MACAddressClonePolicy
    38 {
    39     MACAddressClonePolicy_KeepAllMACs,
    40     MACAddressClonePolicy_KeepNATMACs,
    41     MACAddressClonePolicy_StripAllMACs,
    42     MACAddressClonePolicy_MAX
    43 };
    44 Q_DECLARE_METATYPE(MACAddressClonePolicy);
     38//Q_DECLARE_METATYPE(MACAddressClonePolicy);
    4539
    46 /* 1st page of the Clone Virtual Machine wizard (base part): */
    47 class UIWizardCloneVMPage1 : public UIWizardPageBase
    48 {
    49 protected:
     40// /* 1st page of the Clone Virtual Machine wizard (base part): */
     41// class UIWizardCloneVMPage1 : public UIWizardPageBase
     42// {
     43// protected:
    5044
    51     UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup);
     45//     UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup);
    5246
    53     QString cloneName() const;
    54     void    setCloneName(const QString &strName);
     47//     QString cloneName() const;
     48//     void    setCloneName(const QString &strName);
    5549
    56     QString clonePath() const;
    57     void     setClonePath(const QString &strName);
     50//     QString clonePath() const;
     51//     void     setClonePath(const QString &strName);
    5852
    59     QString cloneFilePath() const;
    60     void setCloneFilePath(const QString &path);
     53//     QString cloneFilePath() const;
     54//     void setCloneFilePath(const QString &path);
    6155
    62     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    63     void composeCloneFilePath();
    64     /** Populates MAC address policies. */
    65     void populateMACAddressClonePolicies();
     56//     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
     57//     void composeCloneFilePath();
     58//     /** Populates MAC address policies. */
     59//     void populateMACAddressClonePolicies();
    6660
    67     /** Updates MAC address policy combo tool-tips. */
    68     void updateMACAddressClonePolicyComboToolTip();
    69     /** Returns MAC address clone policy. */
    70     MACAddressClonePolicy macAddressClonePolicy() const;
    71     /** Defines @a enmMACAddressClonePolicy. */
    72     void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy);
     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);
    7367
    74     bool keepDiskNames() const;
    75     void setKeepDiskNames(bool fKeepDiskNames);
     68//     bool keepDiskNames() const;
     69//     void setKeepDiskNames(bool fKeepDiskNames);
    7670
    77     bool keepHWUUIDs() const;
    78     void setKeepHWUUIDs(bool bKeepHWUUIDs);
     71//     bool keepHWUUIDs() const;
     72//     void setKeepHWUUIDs(bool bKeepHWUUIDs);
    7973
    80     QString      m_strOriginalName;
    81     QString      m_strDefaultPath;
    82     QString      m_strGroup;
    83     /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */
    84     QString      m_strCloneFilePath;
    85     /** The full path of the folder where clone machine's settings file is located.
    86      * Generated from the m_strCloneFilePath by removing base file name */
    87     QString      m_strCloneFolder;
    88     QILineEdit  *m_pNameLineEdit;
    89     UIFilePathSelector *m_pPathSelector;
    90     QLabel      *m_pNameLabel;
    91     QLabel      *m_pPathLabel;
    92     QLabel      *m_pMACComboBoxLabel;
    93     QComboBox   *m_pMACComboBox;
    94     QCheckBox   *m_pKeepDiskNamesCheckBox;
    95     QCheckBox   *m_pKeepHWUUIDsCheckBox;
    96 };
     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//     QCheckBox   *m_pKeepDiskNamesCheckBox;
     82//     QCheckBox   *m_pKeepHWUUIDsCheckBox;
     83// };
    9784
    9885/* 1st page of the Clone Virtual Machine wizard (basic extension): */
    99 class UIWizardCloneVMPageBasic1 : public UIWizardPage, public UIWizardCloneVMPage1
     86class UIWizardCloneVMPageBasic1 : public UINativeWizardPage
    10087{
    10188    Q_OBJECT;
    102     Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
    103     Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);
    104     Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);
    105     Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);
    106     Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);
     89    // Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
     90    // Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);
     91    // Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);
     92    // Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);
     93    // Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);
    10794
    10895
     
    122109    void retranslateUi();
    123110    void initializePage();
    124 
     111    void prepare();
    125112    /* Validation stuff: */
    126113    bool isComplete() const;
    127114
    128115    QIRichTextLabel *m_pMainLabel;
    129     QGridLayout     *m_pContainerLayout;
    130     QLabel          *m_pAdditionalOptionsLabel;
     116    // QGridLayout     *m_pContainerLayout;
     117    // QLabel          *m_pAdditionalOptionsLabel;
     118
     119    UICloneVMNamePathEditor *m_pNamePathEditor;
     120    UICloneVMAdditionalOptionsEditor *m_pAdditionalOptionsEditor;
     121    QString      m_strOriginalName;
     122    QString      m_strDefaultPath;
     123    QString      m_strGroup;
    131124};
    132125
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp

    r82968 r90589  
    146146{
    147147    /* This page could be final: */
    148     if (isFinalPage())
    149     {
    150         /* Initial result: */
    151         bool fResult = true;
     148    // if (isFinalPage())
     149    // {
     150    //     /* Initial result: */
     151    //     bool fResult = true;
    152152
    153         /* Lock finish button: */
    154         startProcessing();
     153    //     /* Lock finish button: */
     154    //     startProcessing();
    155155
    156         /* Trying to clone VM: */
    157         if (fResult)
    158             fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     156    //     /* Trying to clone VM: */
     157    //     if (fResult)
     158    //         fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    159159
    160         /* Unlock finish button: */
    161         endProcessing();
     160    //     /* Unlock finish button: */
     161    //     endProcessing();
    162162
    163         /* Return result: */
    164         return fResult;
    165     }
    166     else
     163    //     /* Return result: */
     164    //     return fResult;
     165    // }
     166    // else
    167167        return true;
    168168}
    169169
    170 int UIWizardCloneVMPageBasic2::nextId() const
    171 {
    172     return m_pFullCloneRadio->isChecked() && wizard()->page(UIWizardCloneVM::Page3) ? UIWizardCloneVM::Page3 : -1;
    173 }
    174 
     170// int UIWizardCloneVMPageBasic2::nextId() const
     171// {
     172//     return m_pFullCloneRadio->isChecked() && wizard()->page(UIWizardCloneVM::Page3) ? UIWizardCloneVM::Page3 : -1;
     173// }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.h

    r82968 r90589  
    7777    bool validatePage();
    7878
    79     /* Navigation stuff: */
    80     int nextId() const;
    81 
    8279    /* Widgets: */
    8380    QIRichTextLabel *m_pLabel;
     
    8582
    8683#endif /* !FEQT_INCLUDED_SRC_wizards_clonevm_UIWizardCloneVMPageBasic2_h */
    87 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp

    r82968 r90589  
    133133    bool fResult = true;
    134134
    135     /* Lock finish button: */
    136     startProcessing();
     135    // /* Lock finish button: */
     136    // startProcessing();
    137137
    138138    /* Try to clone VM: */
    139     if (fResult)
    140         fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     139    // if (fResult)
     140    //     fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    141141
    142     /* Unlock finish button: */
    143     endProcessing();
     142    // /* Unlock finish button: */
     143    // endProcessing();
    144144
    145145    /* Return result: */
    146146    return fResult;
    147147}
    148 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp

    r82968 r90589  
    3535
    3636
    37 UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, const QString &strDefaultPath,
    38                                                      bool fAdditionalInfo, bool fShowChildsOption, const QString &strGroup)
    39     : UIWizardCloneVMPage1(strOriginalName, strDefaultPath, strGroup)
    40     , UIWizardCloneVMPage2(fAdditionalInfo)
     37UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &/*strOriginalName*/, const QString &/*strDefaultPath*/,
     38                                                     bool fAdditionalInfo, bool fShowChildsOption, const QString &/*strGroup*/)
     39    : UIWizardCloneVMPage2(fAdditionalInfo)
    4140    , UIWizardCloneVMPage3(fShowChildsOption)
    4241{
    4342    /* Create widgets: */
    44     QGridLayout *pMainLayout = new QGridLayout(this);
    45     {
    46         m_pNameCnt = new QGroupBox(this);
    47         {
    48             QGridLayout *pNameCntLayout = new QGridLayout(m_pNameCnt);
    49             {
    50                 //pNameCntLayout->setContentsMargins(0, 0, 0, 0);
    51                 m_pNameLabel = new QLabel;
    52                 if (m_pNameLabel)
    53                 {
    54                     m_pNameLabel->setAlignment(Qt::AlignRight);
    55                     m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    56                     pNameCntLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
    57 
    58                 }
    59                 m_pNameLineEdit = new QILineEdit(m_pNameCnt);
    60                 if (m_pNameLineEdit)
    61                 {
    62                     m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
    63                     pNameCntLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
    64                 }
    65 
    66                 m_pPathLabel = new QLabel(this);
    67                 if (m_pPathLabel)
    68                 {
    69                     m_pPathLabel->setAlignment(Qt::AlignRight);
    70                     m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    71                     pNameCntLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
    72                 }
    73 
    74                 m_pPathSelector = new UIFilePathSelector(this);
    75                 if (m_pPathSelector)
    76                 {
    77                     pNameCntLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
    78                     m_pPathSelector->setPath(m_strDefaultPath);
    79                 }
    80             }
    81         }
    82         /* Prepare clone-type options container: */
    83         m_pCloneTypeCnt = new QGroupBox(this);
    84         if (m_pCloneTypeCnt)
    85         {
    86             /* Prepare clone-type options button-group: */
    87             m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt);
    88             if (m_pButtonGroup)
    89             {
    90                 /* Prepare clone-type options layout: */
    91                 QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt);
    92                 {
    93                     /* Prepare full clone option radio-button: */
    94                     m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt);
    95                     if (m_pFullCloneRadio)
    96                     {
    97                         m_pFullCloneRadio->setChecked(true);
    98                         m_pButtonGroup->addButton(m_pFullCloneRadio);
    99                         pCloneTypeCntLayout->addWidget(m_pFullCloneRadio);
    100                     }
    101 
    102                     /* Load currently supported clone options: */
    103                     CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    104                     const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
    105                     /* Check whether we support linked clone option at all: */
    106                     const bool fSupportedLinkedClone = supportedOptions.contains(KCloneOptions_Link);
    107 
    108                     /* Prepare linked clone option radio-button: */
    109                     if (fSupportedLinkedClone)
    110                     {
    111                         m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt);
    112                         if (m_pLinkedCloneRadio)
    113                         {
    114                             m_pButtonGroup->addButton(m_pLinkedCloneRadio);
    115                             pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio);
    116                         }
    117                     }
    118                 }
    119             }
    120         }
    121         m_pCloneModeCnt = new QGroupBox(this);
    122         {
    123             QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt);
    124             {
    125                 m_pMachineRadio = new QRadioButton(m_pCloneModeCnt);
    126                 {
    127                     m_pMachineRadio->setChecked(true);
    128                 }
    129                 m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt);
    130                 {
    131                     if (!m_fShowChildsOption)
    132                        m_pMachineAndChildsRadio->hide();
    133                 }
    134                 m_pAllRadio = new QRadioButton(m_pCloneModeCnt);
    135                 pCloneModeCntLayout->addWidget(m_pMachineRadio);
    136                 pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio);
    137                 pCloneModeCntLayout->addWidget(m_pAllRadio);
    138             }
    139         }
    140         m_pCloneOptionsCnt = new QGroupBox(this);
    141         if (m_pCloneOptionsCnt)
    142         {
    143             m_pCloneOptionsLayout = new QGridLayout(m_pCloneOptionsCnt);
    144             /* Create MAC policy combo-box: */
    145             m_pMACComboBox = new QComboBox;
    146             if (m_pMACComboBox)
    147             {
    148                 /* Add into layout: */
    149                 m_pCloneOptionsLayout->addWidget(m_pMACComboBox, 0, 1, 1, 1);
    150             }
    151 
    152             /* Create format combo-box label: */
    153             m_pMACComboBoxLabel = new QLabel;
    154             if (m_pMACComboBoxLabel)
    155             {
    156                 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    157                 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
    158                 /* Add into layout: */
    159                 m_pCloneOptionsLayout->addWidget(m_pMACComboBoxLabel, 0, 0, 1, 1);
    160             }
    161 
    162             /* Load currently supported clone options: */
    163             CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    164             const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
    165             /* Check whether we support additional clone options at all: */
    166             int iVerticalPosition = 3;
    167             const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
    168             const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
    169             if (fSupportedKeepDiskNames)
    170             {
    171                 m_pKeepDiskNamesCheckBox = new QCheckBox;
    172                 if (m_pKeepDiskNamesCheckBox)
    173                     m_pCloneOptionsLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
    174             }
    175             if (fSupportedKeepHWUUIDs)
    176             {
    177                 m_pKeepHWUUIDsCheckBox = new QCheckBox;
    178                 if (m_pKeepHWUUIDsCheckBox)
    179                     m_pCloneOptionsLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
    180             }
    181         }
    182 
    183         pMainLayout->addWidget(m_pNameCnt, 0, 0, 1, 2);
    184         pMainLayout->addWidget(m_pCloneTypeCnt, 1, 0, Qt::AlignTop);
    185         pMainLayout->addWidget(m_pCloneModeCnt, 1, 1, Qt::AlignTop);
    186         pMainLayout->addWidget(m_pCloneOptionsCnt, 2, 0, 1, 2, Qt::AlignTop);
    187         pMainLayout->setRowStretch(3, 1);
    188     }
    189 
    190     /* Setup connections: */
    191     connect(m_pNameLineEdit, &QILineEdit::textChanged,
    192             this, &UIWizardCloneVMPageExpert::completeChanged);
    193     connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
    194             this, &UIWizardCloneVMPageExpert::completeChanged);
    195     connect(m_pNameLineEdit, &QILineEdit::textChanged,
    196             this, &UIWizardCloneVMPageExpert::sltNameChanged);
    197     connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
    198             this, &UIWizardCloneVMPageExpert::sltPathChanged);
    199     connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled),
    200             this, &UIWizardCloneVMPageExpert::sltButtonToggled);
    201 
    202     /* Register classes: */
    203     qRegisterMetaType<KCloneMode>();
    204 
    205     /* Populate MAC address policies: */
    206     populateMACAddressClonePolicies();
     43    // QGridLayout *pMainLayout = new QGridLayout(this);
     44    // {
     45    //     m_pNameCnt = new QGroupBox(this);
     46    //     {
     47    //         QGridLayout *pNameCntLayout = new QGridLayout(m_pNameCnt);
     48    //         {
     49    //             //pNameCntLayout->setContentsMargins(0, 0, 0, 0);
     50    //             m_pNameLabel = new QLabel;
     51    //             if (m_pNameLabel)
     52    //             {
     53    //                 m_pNameLabel->setAlignment(Qt::AlignRight);
     54    //                 m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     55    //                 pNameCntLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     56
     57    //             }
     58    //             m_pNameLineEdit = new QILineEdit(m_pNameCnt);
     59    //             if (m_pNameLineEdit)
     60    //             {
     61    //                 m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     62    //                 pNameCntLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     63    //             }
     64
     65    //             m_pPathLabel = new QLabel(this);
     66    //             if (m_pPathLabel)
     67    //             {
     68    //                 m_pPathLabel->setAlignment(Qt::AlignRight);
     69    //                 m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     70    //                 pNameCntLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     71    //             }
     72
     73    //             m_pPathSelector = new UIFilePathSelector(this);
     74    //             if (m_pPathSelector)
     75    //             {
     76    //                 pNameCntLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     77    //                 m_pPathSelector->setPath(m_strDefaultPath);
     78    //             }
     79    //         }
     80    //     }
     81    //     /* Prepare clone-type options container: */
     82    //     m_pCloneTypeCnt = new QGroupBox(this);
     83    //     if (m_pCloneTypeCnt)
     84    //     {
     85    //         /* Prepare clone-type options button-group: */
     86    //         m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt);
     87    //         if (m_pButtonGroup)
     88    //         {
     89    //             /* Prepare clone-type options layout: */
     90    //             QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt);
     91    //             {
     92    //                 /* Prepare full clone option radio-button: */
     93    //                 m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     94    //                 if (m_pFullCloneRadio)
     95    //                 {
     96    //                     m_pFullCloneRadio->setChecked(true);
     97    //                     m_pButtonGroup->addButton(m_pFullCloneRadio);
     98    //                     pCloneTypeCntLayout->addWidget(m_pFullCloneRadio);
     99    //                 }
     100
     101    //                 /* Load currently supported clone options: */
     102    //                 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     103    //                 const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
     104    //                 /* Check whether we support linked clone option at all: */
     105    //                 const bool fSupportedLinkedClone = supportedOptions.contains(KCloneOptions_Link);
     106
     107    //                 /* Prepare linked clone option radio-button: */
     108    //                 if (fSupportedLinkedClone)
     109    //                 {
     110    //                     m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     111    //                     if (m_pLinkedCloneRadio)
     112    //                     {
     113    //                         m_pButtonGroup->addButton(m_pLinkedCloneRadio);
     114    //                         pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio);
     115    //                     }
     116    //                 }
     117    //             }
     118    //         }
     119    //     }
     120    //     m_pCloneModeCnt = new QGroupBox(this);
     121    //     {
     122    //         QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt);
     123    //         {
     124    //             m_pMachineRadio = new QRadioButton(m_pCloneModeCnt);
     125    //             {
     126    //                 m_pMachineRadio->setChecked(true);
     127    //             }
     128    //             m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt);
     129    //             {
     130    //                 if (!m_fShowChildsOption)
     131    //                    m_pMachineAndChildsRadio->hide();
     132    //             }
     133    //             m_pAllRadio = new QRadioButton(m_pCloneModeCnt);
     134    //             pCloneModeCntLayout->addWidget(m_pMachineRadio);
     135    //             pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio);
     136    //             pCloneModeCntLayout->addWidget(m_pAllRadio);
     137    //         }
     138    //     }
     139    //     m_pCloneOptionsCnt = new QGroupBox(this);
     140    //     if (m_pCloneOptionsCnt)
     141    //     {
     142    //         m_pCloneOptionsLayout = new QGridLayout(m_pCloneOptionsCnt);
     143    //         /* Create MAC policy combo-box: */
     144    //         m_pMACComboBox = new QComboBox;
     145    //         if (m_pMACComboBox)
     146    //         {
     147    //             /* Add into layout: */
     148    //             m_pCloneOptionsLayout->addWidget(m_pMACComboBox, 0, 1, 1, 1);
     149    //         }
     150
     151    //         /* Create format combo-box label: */
     152    //         m_pMACComboBoxLabel = new QLabel;
     153    //         if (m_pMACComboBoxLabel)
     154    //         {
     155    //             m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     156    //             m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
     157    //             /* Add into layout: */
     158    //             m_pCloneOptionsLayout->addWidget(m_pMACComboBoxLabel, 0, 0, 1, 1);
     159    //         }
     160
     161    //         /* Load currently supported clone options: */
     162    //         CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     163    //         const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
     164    //         /* Check whether we support additional clone options at all: */
     165    //         int iVerticalPosition = 3;
     166    //         const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
     167    //         const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
     168    //         if (fSupportedKeepDiskNames)
     169    //         {
     170    //             m_pKeepDiskNamesCheckBox = new QCheckBox;
     171    //             if (m_pKeepDiskNamesCheckBox)
     172    //                 m_pCloneOptionsLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
     173    //         }
     174    //         if (fSupportedKeepHWUUIDs)
     175    //         {
     176    //             m_pKeepHWUUIDsCheckBox = new QCheckBox;
     177    //             if (m_pKeepHWUUIDsCheckBox)
     178    //                 m_pCloneOptionsLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
     179    //         }
     180    //     }
     181
     182    //     pMainLayout->addWidget(m_pNameCnt, 0, 0, 1, 2);
     183    //     pMainLayout->addWidget(m_pCloneTypeCnt, 1, 0, Qt::AlignTop);
     184    //     pMainLayout->addWidget(m_pCloneModeCnt, 1, 1, Qt::AlignTop);
     185    //     pMainLayout->addWidget(m_pCloneOptionsCnt, 2, 0, 1, 2, Qt::AlignTop);
     186    //     pMainLayout->setRowStretch(3, 1);
     187    // }
     188
     189    // /* Setup connections: */
     190    // connect(m_pNameLineEdit, &QILineEdit::textChanged,
     191    //         this, &UIWizardCloneVMPageExpert::completeChanged);
     192    // connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
     193    //         this, &UIWizardCloneVMPageExpert::completeChanged);
     194    // connect(m_pNameLineEdit, &QILineEdit::textChanged,
     195    //         this, &UIWizardCloneVMPageExpert::sltNameChanged);
     196    // connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
     197    //         this, &UIWizardCloneVMPageExpert::sltPathChanged);
     198    // connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled),
     199    //         this, &UIWizardCloneVMPageExpert::sltButtonToggled);
     200
     201    // /* Register classes: */
     202    // qRegisterMetaType<KCloneMode>();
     203
     204    // /* Populate MAC address policies: */
     205    // populateMACAddressClonePolicies();
    207206
    208207    /* Register fields: */
    209     registerField("cloneName", this, "cloneName");
    210     registerField("cloneFilePath", this, "cloneFilePath");
    211     registerField("linkedClone", this, "linkedClone");
    212     registerField("cloneMode", this, "cloneMode");
    213     registerField("macAddressClonePolicy", this, "macAddressClonePolicy");
    214     registerField("keepDiskNames", this, "keepDiskNames");
    215     registerField("keepHWUUIDs", this, "keepHWUUIDs");
    216 
    217     composeCloneFilePath();
     208    // registerField("cloneName", this, "cloneName");
     209    // registerField("cloneFilePath", this, "cloneFilePath");
     210    // registerField("linkedClone", this, "linkedClone");
     211    // registerField("cloneMode", this, "cloneMode");
     212    // registerField("macAddressClonePolicy", this, "macAddressClonePolicy");
     213    // registerField("keepDiskNames", this, "keepDiskNames");
     214    // registerField("keepHWUUIDs", this, "keepHWUUIDs");
     215
     216    //composeCloneFilePath();
    218217}
    219218
     
    233232void UIWizardCloneVMPageExpert::retranslateUi()
    234233{
    235     /* Translate widgets: */
    236     m_pNameCnt->setTitle(UIWizardCloneVM::tr("New machine &name and path"));
    237     m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("Clone type"));
    238     m_pFullCloneRadio->setText(UIWizardCloneVM::tr("&Full Clone"));
    239     if (m_pLinkedCloneRadio)
    240         m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("&Linked Clone"));
    241     m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("Snapshots"));
    242     m_pMachineRadio->setText(UIWizardCloneVM::tr("Current &machine state"));
    243     m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current &snapshot tree branch"));
    244     m_pAllRadio->setText(UIWizardCloneVM::tr("&Everything"));
    245     m_pNameLabel->setText(UIWizardCloneVM::tr("Name:"));
    246     m_pPathLabel->setText(UIWizardCloneVM::tr("Path:"));
    247     m_pCloneOptionsCnt->setTitle(UIWizardCloneVM::tr("Additional options"));
    248 
    249     /* Translate MAC address policy combo-box: */
    250     m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:"));
    251     for (int i = 0; i < m_pMACComboBox->count(); ++i)
    252     {
    253         const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
    254         switch (enmPolicy)
    255         {
    256             case MACAddressClonePolicy_KeepAllMACs:
    257             {
    258                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
    259                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    260                 break;
    261             }
    262             case MACAddressClonePolicy_KeepNATMACs:
    263             {
    264                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
    265                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    266                 break;
    267             }
    268             case MACAddressClonePolicy_StripAllMACs:
    269             {
    270                 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
    271                 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
    272                 break;
    273             }
    274             default:
    275                 break;
    276         }
    277     }
    278 
    279     if (m_pKeepDiskNamesCheckBox)
    280     {
    281         m_pKeepDiskNamesCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change the disk names during cloning."));
    282         m_pKeepDiskNamesCheckBox->setText(UIWizardCloneVM::tr("Keep &Disk Names"));
    283     }
    284     if (m_pKeepHWUUIDsCheckBox)
    285     {
    286         m_pKeepHWUUIDsCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change hardware UUIDs during cloning."));
    287         m_pKeepHWUUIDsCheckBox->setText(UIWizardCloneVM::tr("Keep &Hardware UUIDs"));
    288     }
     234    // /* Translate widgets: */
     235    // m_pNameCnt->setTitle(UIWizardCloneVM::tr("New machine &name and path"));
     236    // m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("Clone type"));
     237    // m_pFullCloneRadio->setText(UIWizardCloneVM::tr("&Full Clone"));
     238    // if (m_pLinkedCloneRadio)
     239    //     m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("&Linked Clone"));
     240    // m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("Snapshots"));
     241    // m_pMachineRadio->setText(UIWizardCloneVM::tr("Current &machine state"));
     242    // m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current &snapshot tree branch"));
     243    // m_pAllRadio->setText(UIWizardCloneVM::tr("&Everything"));
     244    // m_pNameLabel->setText(UIWizardCloneVM::tr("Name:"));
     245    // m_pPathLabel->setText(UIWizardCloneVM::tr("Path:"));
     246    // m_pCloneOptionsCnt->setTitle(UIWizardCloneVM::tr("Additional options"));
     247
     248    // /* Translate MAC address policy combo-box: */
     249    // m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:"));
     250    // for (int i = 0; i < m_pMACComboBox->count(); ++i)
     251    // {
     252    //     const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
     253    //     switch (enmPolicy)
     254    //     {
     255    //         case MACAddressClonePolicy_KeepAllMACs:
     256    //         {
     257    //             m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
     258    //             m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     259    //             break;
     260    //         }
     261    //         case MACAddressClonePolicy_KeepNATMACs:
     262    //         {
     263    //             m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
     264    //             m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     265    //             break;
     266    //         }
     267    //         case MACAddressClonePolicy_StripAllMACs:
     268    //         {
     269    //             m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
     270    //             m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
     271    //             break;
     272    //         }
     273    //         default:
     274    //             break;
     275    //     }
     276    // }
     277
     278    // if (m_pKeepDiskNamesCheckBox)
     279    // {
     280    //     m_pKeepDiskNamesCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change the disk names during cloning."));
     281    //     m_pKeepDiskNamesCheckBox->setText(UIWizardCloneVM::tr("Keep &Disk Names"));
     282    // }
     283    // if (m_pKeepHWUUIDsCheckBox)
     284    // {
     285    //     m_pKeepHWUUIDsCheckBox->setToolTip(UIWizardCloneVM::tr("Don't change hardware UUIDs during cloning."));
     286    //     m_pKeepHWUUIDsCheckBox->setText(UIWizardCloneVM::tr("Keep &Hardware UUIDs"));
     287    // }
    289288}
    290289
     
    297296bool UIWizardCloneVMPageExpert::isComplete() const
    298297{
    299     if (!m_pPathSelector)
    300         return false;
    301 
    302     QString path = m_pPathSelector->path();
    303     if (path.isEmpty())
    304         return false;
    305     /* Make sure VM name feat the rules: */
    306     QString strName = m_pNameLineEdit->text().trimmed();
    307     return !strName.isEmpty() && strName != m_strOriginalName;
     298    // if (!m_pPathSelector)
     299    //     return false;
     300
     301    // QString path = m_pPathSelector->path();
     302    // if (path.isEmpty())
     303    //     return false;
     304    // /* Make sure VM name feat the rules: */
     305    // QString strName = m_pNameLineEdit->text().trimmed();
     306    // return !strName.isEmpty() && strName != m_strOriginalName;
     307    return true;
    308308}
    309309
     
    313313    bool fResult = true;
    314314
    315     /* Lock finish button: */
    316     startProcessing();
    317 
    318     /* Trying to clone VM: */
    319     if (fResult)
    320         fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    321 
    322     /* Unlock finish button: */
    323     endProcessing();
     315    // /* Lock finish button: */
     316    // startProcessing();
     317
     318    // /* Trying to clone VM: */
     319    // if (fResult)
     320    //     fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     321
     322    // /* Unlock finish button: */
     323    // endProcessing();
    324324
    325325    /* Return result: */
     
    329329void UIWizardCloneVMPageExpert::sltNameChanged()
    330330{
    331     composeCloneFilePath();
     331    //composeCloneFilePath();
    332332}
    333333
    334334void UIWizardCloneVMPageExpert::sltPathChanged()
    335335{
    336     composeCloneFilePath();
    337 }
     336    //composeCloneFilePath();
     337}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h

    r82968 r90589  
    2929/* Forward declarations: */
    3030class QGroupBox;
     31class QGridLayout;
    3132
    3233/* Expert page of the Clone Virtual Machine wizard: */
    3334class UIWizardCloneVMPageExpert : public UIWizardPage,
    34                                   public UIWizardCloneVMPage1,
    3535                                  public UIWizardCloneVMPage2,
    3636                                  public UIWizardCloneVMPage3
    3737{
    3838    Q_OBJECT;
    39     Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
    40     Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);
    41     Q_PROPERTY(bool linkedClone READ linkedClone);
    42     Q_PROPERTY(KCloneMode cloneMode READ cloneMode WRITE setCloneMode);
    43     Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);
    44     Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);
    45     Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);
     39    // Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
     40    // Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);
     41    // Q_PROPERTY(bool linkedClone READ linkedClone);
     42    // Q_PROPERTY(KCloneMode cloneMode READ cloneMode WRITE setCloneMode);
     43    // Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);
     44    // Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);
     45    // Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);
    4646
    4747public:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

    r90578 r90589  
    1717
    1818/* Qt includes: */
    19 #include <QButtonGroup>
    20 #include <QCheckBox>
    21 #include <QDir>
    22 #include <QFileInfo>
     19// #include <QButtonGroup>
     20// #include <QCheckBox>
     21#include <QComboBox>
     22// #include <QDir>
     23// #include <QFileInfo>
    2324#include <QLabel>
    24 #include <QRadioButton>
    25 #include <QVBoxLayout>
     25// #include <QRadioButton>
     26#include <QGridLayout>
    2627
    2728/* GUI includes: */
    2829#include "QILineEdit.h"
    29 #include "QIToolButton.h"
    30 #include "QIRichTextLabel.h"
     30// #include "QIToolButton.h"
     31// #include "QIRichTextLabel.h"
    3132#include "UICommon.h"
    32 #include "UIConverter.h"
     33// #include "UIConverter.h"
    3334#include "UIFilePathSelector.h"
    34 #include "UIHostnameDomainNameEditor.h"
    35 #include "UIIconPool.h"
    36 #include "UIMediumSizeEditor.h"
    37 #include "UIUserNamePasswordEditor.h"
    38 #include "UIWizardDiskEditors.h"
    39 #include "UIWizardNewVM.h"
    40 #include "UIWizardNewVMDiskPageBasic.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"
     42#include "UIWizardCloneVMEditors.h"
    4143
    4244/* Other VBox includes: */
    4345#include "iprt/assert.h"
    44 #include "iprt/fs.h"
     46// #include "iprt/fs.h"
     47#include "COMEnums.h"
    4548#include "CSystemProperties.h"
    4649
    4750
    4851/*********************************************************************************************************************************
    49 *   UIDiskEditorGroupBox implementation.                                                                                   *
     52*   UICloneVMNamePathEditor implementation.                                                                                      *
    5053*********************************************************************************************************************************/
    5154
    52 UIDiskEditorGroupBox::UIDiskEditorGroupBox(bool fExpertMode, QWidget *pParent /* = 0 */)
    53     : QIWithRetranslateUI<QGroupBox>(pParent)
    54     , m_fExpertMode(fExpertMode)
    55 {
    56     if (!m_fExpertMode)
    57         setFlat(true);
    58 }
    59 
    60 /* static */
    61 QString UIDiskEditorGroupBox::appendExtension(const QString &strName, const QString &strExtension)
    62 {
    63     /* Convert passed name to native separators: */
    64     QString strFileName = QDir::toNativeSeparators(strName);
    65 
    66     /* Remove all trailing dots to avoid multiple dots before extension: */
    67     int iLen;
    68     while (iLen = strFileName.length(), iLen > 0 && strFileName[iLen - 1] == '.')
    69         strFileName.truncate(iLen - 1);
    70 
    71     /* Add passed extension if its not done yet: */
    72     if (QFileInfo(strFileName).suffix().toLower() != strExtension)
    73         strFileName += QString(".%1").arg(strExtension);
    74 
    75     /* Return result: */
    76     return strFileName;
    77 }
    78 
    79 /* static */
    80 QString UIDiskEditorGroupBox::constructMediumFilePath(const QString &strFileName, const QString &strPath)
    81 {
    82     /* Wrap file-info around received file name: */
    83     QFileInfo fileInfo(strFileName);
    84     /* If path-info is relative or there is no path-info at all: */
    85     if (fileInfo.fileName() == strFileName || fileInfo.isRelative())
    86     {
    87         /* Resolve path on the basis of  path we have: */
    88         fileInfo = QFileInfo(strPath, strFileName);
    89     }
    90     /* Return full absolute hard disk file path: */
    91     return QDir::toNativeSeparators(fileInfo.absoluteFilePath());
    92 }
    93 
    94 /* static */
    95 QString UIDiskEditorGroupBox::defaultExtensionForMediumFormat(const CMediumFormat &mediumFormatRef)
    96 {
    97     if (!mediumFormatRef.isNull())
    98     {
    99         /* Load extension / device list: */
    100         QVector<QString> fileExtensions;
    101         QVector<KDeviceType> deviceTypes;
    102         CMediumFormat mediumFormat(mediumFormatRef);
    103         mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    104         for (int i = 0; i < fileExtensions.size(); ++i)
    105             if (deviceTypes[i] == KDeviceType_HardDisk)
    106                 return fileExtensions[i].toLower();
    107     }
    108     AssertMsgFailed(("Extension can't be NULL!\n"));
    109     return QString();
    110 }
    111 
    112 /* static */
    113 bool UIDiskEditorGroupBox::checkFATSizeLimitation(const qulonglong uVariant, const QString &strMediumPath, const qulonglong uSize)
    114 {
    115     /* If the hard disk is split into 2GB parts then no need to make further checks: */
    116     if (uVariant & KMediumVariant_VmdkSplit2G)
    117         return true;
    118     RTFSTYPE enmType;
    119     int rc = RTFsQueryType(QFileInfo(strMediumPath).absolutePath().toLatin1().constData(), &enmType);
    120     if (RT_SUCCESS(rc))
    121     {
    122         if (enmType == RTFSTYPE_FAT)
     55UICloneVMNamePathEditor::UICloneVMNamePathEditor(const QString &strOriginalName, const QString &strDefaultPath, QWidget *pParent /* = 0 */)
     56    :QIWithRetranslateUI<QGroupBox>(pParent)
     57    , m_pNameLineEdit(0)
     58    , m_pPathSelector(0)
     59    , m_pNameLabel(0)
     60    , m_pPathLabel(0)
     61    , m_strOriginalName(strOriginalName)
     62    , m_strDefaultPath(strDefaultPath)
     63{
     64    prepare();
     65}
     66
     67void UICloneVMNamePathEditor::prepare()
     68{
     69    QGridLayout *pContainerLayout = new QGridLayout(this);
     70    pContainerLayout->setContentsMargins(0, 0, 0, 0);
     71
     72    m_pNameLabel = new QLabel;
     73    if (m_pNameLabel)
     74    {
     75        m_pNameLabel->setAlignment(Qt::AlignRight);
     76        m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     77        pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     78    }
     79
     80    m_pNameLineEdit = new QILineEdit();
     81    if (m_pNameLineEdit)
     82    {
     83        pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     84        m_pNameLineEdit->setText(tr("%1 Clone").arg(m_strOriginalName));
     85    }
     86
     87    m_pPathLabel = new QLabel(this);
     88    if (m_pPathLabel)
     89    {
     90        m_pPathLabel->setAlignment(Qt::AlignRight);
     91        m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     92        pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     93    }
     94
     95    m_pPathSelector = new UIFilePathSelector(this);
     96    if (m_pPathSelector)
     97    {
     98        pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     99        m_pPathSelector->setPath(m_strDefaultPath);
     100    }
     101    retranslateUi();
     102}
     103
     104void UICloneVMNamePathEditor::retranslateUi()
     105{
     106    if (m_pNameLabel)
     107        m_pNameLabel->setText(tr("Name:"));
     108
     109    if (m_pPathLabel)
     110        m_pPathLabel->setText(tr("Path:"));
     111}
     112
     113
     114/*********************************************************************************************************************************
     115*   UICloneVMAdditionalOptionsEditor implementation.                                                                             *
     116*********************************************************************************************************************************/
     117
     118
     119UICloneVMAdditionalOptionsEditor::UICloneVMAdditionalOptionsEditor(QWidget *pParent /* = 0 */)
     120    :QIWithRetranslateUI<QGroupBox>(pParent)
     121    , m_pMACComboBoxLabel(0)
     122    , m_pMACComboBox(0)
     123{
     124    prepare();
     125}
     126
     127MACAddressClonePolicy UICloneVMAdditionalOptionsEditor::macAddressClonePolicy() const
     128{
     129    return m_pMACComboBox->currentData().value<MACAddressClonePolicy>();
     130}
     131
     132void UICloneVMAdditionalOptionsEditor::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy)
     133{
     134    const int iIndex = m_pMACComboBox->findData(enmMACAddressClonePolicy);
     135    AssertMsg(iIndex != -1, ("Data not found!"));
     136    m_pMACComboBox->setCurrentIndex(iIndex);
     137}
     138
     139void UICloneVMAdditionalOptionsEditor::prepare()
     140{
     141    QGridLayout *pContainerLayout = new QGridLayout(this);
     142    pContainerLayout->setContentsMargins(0, 0, 0, 0);
     143
     144    m_pMACComboBoxLabel = new QLabel;
     145    if (m_pMACComboBoxLabel)
     146    {
     147        m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     148        m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
     149        pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1);
     150    }
     151
     152    m_pMACComboBox = new QComboBox;
     153    if (m_pMACComboBox)
     154        pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1);
     155    populateMACAddressClonePolicies();
     156    retranslateUi();
     157}
     158
     159void UICloneVMAdditionalOptionsEditor::retranslateUi()
     160{
     161    m_pMACComboBoxLabel->setText(tr("MAC Address &Policy:"));
     162    for (int i = 0; i < m_pMACComboBox->count(); ++i)
     163    {
     164        const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
     165        switch (enmPolicy)
    123166        {
    124             /* Limit the medium size to 4GB. minus 128 MB for file overhead: */
    125             qulonglong fatLimit = _4G - _128M;
    126             if (uSize >= fatLimit)
    127                 return false;
     167            case MACAddressClonePolicy_KeepAllMACs:
     168            {
     169                m_pMACComboBox->setItemText(i, tr("Include all network adapter MAC addresses"));
     170                m_pMACComboBox->setItemData(i, tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     171                break;
     172            }
     173            case MACAddressClonePolicy_KeepNATMACs:
     174            {
     175                m_pMACComboBox->setItemText(i, tr("Include only NAT network adapter MAC addresses"));
     176                m_pMACComboBox->setItemData(i, tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     177                break;
     178            }
     179            case MACAddressClonePolicy_StripAllMACs:
     180            {
     181                m_pMACComboBox->setItemText(i, tr("Generate new MAC addresses for all network adapters"));
     182                m_pMACComboBox->setItemData(i, tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
     183                break;
     184            }
     185            default:
     186                break;
    128187        }
    129188    }
    130     return true;
    131 }
    132 
    133 
    134 
    135 /*********************************************************************************************************************************
    136 *   UIDiskFormatsGroupBox implementation.                                                                                   *
    137 *********************************************************************************************************************************/
    138 
    139 UIDiskFormatsGroupBox::UIDiskFormatsGroupBox(bool fExpertMode, QWidget *pParent /* = 0 */)
    140     : UIDiskEditorGroupBox(fExpertMode, pParent)
    141     , m_pFormatButtonGroup(0)
    142 {
    143     prepare();
    144 }
    145 
    146 CMediumFormat UIDiskFormatsGroupBox::mediumFormat() const
    147 {
    148     return m_pFormatButtonGroup && m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat();
    149 }
    150 
    151 void UIDiskFormatsGroupBox::setMediumFormat(const CMediumFormat &mediumFormat)
    152 {
    153     int iPosition = m_formats.indexOf(mediumFormat);
    154     if (iPosition >= 0)
    155     {
    156         m_pFormatButtonGroup->button(iPosition)->click();
    157         m_pFormatButtonGroup->button(iPosition)->setFocus();
    158     }
    159 }
    160 
    161 const CMediumFormat &UIDiskFormatsGroupBox::VDIMediumFormat() const
    162 {
    163     return m_comVDIMediumFormat;
    164 }
    165 
    166 void UIDiskFormatsGroupBox::prepare()
    167 {
    168     QVBoxLayout *pContainerLayout = new QVBoxLayout(this);
    169 
    170     m_pFormatButtonGroup = new QButtonGroup;
    171     AssertReturnVoid(m_pFormatButtonGroup);
    172     /* Enumerate medium formats in special order: */
    173     CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
    174     const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
    175     QMap<QString, CMediumFormat> vdi, preferred, others;
    176     foreach (const CMediumFormat &format, formats)
    177     {
    178         if (format.GetName() == "VDI")
    179         {
    180             vdi[format.GetId()] = format;
    181             m_comVDIMediumFormat = format;
    182         }
    183         else
    184         {
    185             const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
    186             if (capabilities.contains(KMediumFormatCapabilities_Preferred))
    187                 preferred[format.GetId()] = format;
    188             else
    189                 others[format.GetId()] = format;
    190         }
    191     }
    192 
    193     /* Create buttons for VDI, preferred and others: */
    194     foreach (const QString &strId, vdi.keys())
    195         addFormatButton(pContainerLayout, vdi.value(strId), true);
    196     foreach (const QString &strId, preferred.keys())
    197         addFormatButton(pContainerLayout, preferred.value(strId), true);
    198 
    199     if (m_fExpertMode)
    200     {
    201         foreach (const QString &strId, others.keys())
    202             addFormatButton(pContainerLayout, others.value(strId));
    203     }
    204 
    205     /* Select VDI: */
    206     if (!m_pFormatButtonGroup->buttons().isEmpty())
    207     {
    208         m_pFormatButtonGroup->button(0)->click();
    209         m_pFormatButtonGroup->button(0)->setFocus();
    210     }
    211 
    212     connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
    213             this, &UIDiskFormatsGroupBox::sigMediumFormatChanged);
    214 
    215     retranslateUi();
    216 }
    217 
    218 void UIDiskFormatsGroupBox::retranslateUi()
    219 {
    220     if (m_fExpertMode)
    221         setTitle(tr("Hard Disk File &Type"));
    222 
    223     QList<QAbstractButton*> buttons = m_pFormatButtonGroup ? m_pFormatButtonGroup->buttons() : QList<QAbstractButton*>();
    224     for (int i = 0; i < buttons.size(); ++i)
    225     {
    226         QAbstractButton *pButton = buttons[i];
    227         UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]);
    228         pButton->setText(gpConverter->toString(enmFormat));
    229     }
    230 }
    231 
    232 void UIDiskFormatsGroupBox::addFormatButton(QVBoxLayout *pFormatLayout, CMediumFormat medFormat, bool fPreferred /* = false */)
    233 {
    234     /* Check that medium format supports creation: */
    235     ULONG uFormatCapabilities = 0;
    236     QVector<KMediumFormatCapabilities> capabilities;
    237     capabilities = medFormat.GetCapabilities();
    238     for (int i = 0; i < capabilities.size(); i++)
    239         uFormatCapabilities |= capabilities[i];
    240 
    241     if (!(uFormatCapabilities & KMediumFormatCapabilities_CreateFixed ||
    242           uFormatCapabilities & KMediumFormatCapabilities_CreateDynamic))
    243         return;
    244 
    245     /* Check that medium format supports creation of virtual hard-disks: */
    246     QVector<QString> fileExtensions;
    247     QVector<KDeviceType> deviceTypes;
    248     medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    249     if (!deviceTypes.contains(KDeviceType_HardDisk))
    250         return;
    251 
    252     /* Create/add corresponding radio-button: */
    253     QRadioButton *pFormatButton = new QRadioButton;
    254     AssertPtrReturnVoid(pFormatButton);
    255     {
    256         /* Make the preferred button font bold: */
    257         if (fPreferred && m_fExpertMode)
    258         {
    259             QFont font = pFormatButton->font();
    260             font.setBold(true);
    261             pFormatButton->setFont(font);
    262         }
    263         pFormatLayout->addWidget(pFormatButton);
    264         m_formats << medFormat;
    265         m_formatNames << medFormat.GetName();
    266         m_pFormatButtonGroup->addButton(pFormatButton, m_formatNames.size() - 1);
    267         m_formatExtensions << defaultExtension(medFormat);
    268     }
    269 }
    270 
    271 const QStringList UIDiskFormatsGroupBox::formatExtensions() const
    272 {
    273     return m_formatExtensions;
    274 }
    275 
    276 /* static */
    277 QString UIDiskFormatsGroupBox::defaultExtension(const CMediumFormat &mediumFormatRef)
    278 {
    279     if (!mediumFormatRef.isNull())
    280     {
    281         /* Load extension / device list: */
    282         QVector<QString> fileExtensions;
    283         QVector<KDeviceType> deviceTypes;
    284         CMediumFormat mediumFormat(mediumFormatRef);
    285         mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    286         for (int i = 0; i < fileExtensions.size(); ++i)
    287             if (deviceTypes[i] == KDeviceType_HardDisk)
    288                 return fileExtensions[i].toLower();
    289     }
    290     AssertMsgFailed(("Extension can't be NULL!\n"));
    291     return QString();
    292 }
    293 
    294 
    295 /*********************************************************************************************************************************
    296 *   UIDiskVariantGroupBox implementation.                                                                                   *
    297 *********************************************************************************************************************************/
    298 
    299 
    300 UIDiskVariantGroupBox::UIDiskVariantGroupBox(bool fExpertMode, QWidget *pParent /* = 0 */)
    301     : UIDiskEditorGroupBox(fExpertMode, pParent)
    302     , m_pFixedCheckBox(0)
    303     , m_pSplitBox(0)
    304 {
    305     prepare();
    306 }
    307 
    308 void UIDiskVariantGroupBox::prepare()
    309 {
    310     QVBoxLayout *pVariantLayout = new QVBoxLayout(this);
    311     AssertReturnVoid(pVariantLayout);
    312     m_pFixedCheckBox = new QCheckBox;
    313     m_pSplitBox = new QCheckBox;
    314     connect(m_pFixedCheckBox, &QCheckBox::toggled, this, &UIDiskVariantGroupBox::sltVariantChanged);
    315     connect(m_pSplitBox, &QCheckBox::toggled, this, &UIDiskVariantGroupBox::sltVariantChanged);
    316     pVariantLayout->addWidget(m_pFixedCheckBox);
    317     pVariantLayout->addWidget(m_pSplitBox);
    318     pVariantLayout->addStretch();
    319     retranslateUi();
    320 }
    321 
    322 void UIDiskVariantGroupBox::retranslateUi()
    323 {
    324     if (m_fExpertMode)
    325         setTitle(tr("Storage on Physical Hard Disk"));
    326     if (m_pFixedCheckBox)
    327     {
    328         m_pFixedCheckBox->setText(tr("Pre-allocate &Full Size"));
    329         m_pFixedCheckBox->setToolTip(tr("<p>When checked, the virtual disk image will be fully allocated at "
    330                                                        "VM creation time, rather than being allocated dynamically at VM run-time.</p>"));
    331     }
    332     if (m_pSplitBox)
    333     {
    334         m_pSplitBox->setText(tr("&Split into files of less than 2GB"));
    335         m_pSplitBox->setToolTip(tr("&When checked the virtual disk file will be splitted into 2GB parts in the host storage."));
    336     }
    337 }
    338 
    339 qulonglong UIDiskVariantGroupBox::mediumVariant() const
    340 {
    341     /* Initial value: */
    342     qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
    343 
    344     /* Exclusive options: */
    345     if (m_pFixedCheckBox && m_pFixedCheckBox->isChecked())
    346         uMediumVariant = (qulonglong)KMediumVariant_Fixed;
     189}
     190
     191void UICloneVMAdditionalOptionsEditor::populateMACAddressClonePolicies()
     192{
     193    AssertReturnVoid(m_pMACComboBox && m_pMACComboBox->count() == 0);
     194
     195    /* Map known clone options to known MAC address export policies: */
     196    QMap<KCloneOptions, MACAddressClonePolicy> knownOptions;
     197    knownOptions[KCloneOptions_KeepAllMACs] = MACAddressClonePolicy_KeepAllMACs;
     198    knownOptions[KCloneOptions_KeepNATMACs] = MACAddressClonePolicy_KeepNATMACs;
     199
     200    /* Load currently supported clone options: */
     201    CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     202    const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
     203
     204    /* Check which of supported options/policies are known: */
     205    QList<MACAddressClonePolicy> supportedPolicies;
     206    foreach (const KCloneOptions &enmOption, supportedOptions)
     207        if (knownOptions.contains(enmOption))
     208            supportedPolicies << knownOptions.value(enmOption);
     209
     210    /* Add supported policies first: */
     211    foreach (const MACAddressClonePolicy &enmPolicy, supportedPolicies)
     212        m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy));
     213
     214    /* Add hardcoded policy finally: */
     215    m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressClonePolicy_StripAllMACs));
     216
     217    /* Set default: */
     218    if (supportedPolicies.contains(MACAddressClonePolicy_KeepNATMACs))
     219        setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs);
    347220    else
    348         uMediumVariant = (qulonglong)KMediumVariant_Standard;
    349 
    350     /* Additional options: */
    351     if (m_pSplitBox && m_pSplitBox->isChecked())
    352         uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
    353 
    354     /* Return options: */
    355     return uMediumVariant;
    356 }
    357 
    358 void UIDiskVariantGroupBox::setMediumVariant(qulonglong uMediumVariant)
    359 {
    360     /* Exclusive options: */
    361     if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
    362     {
    363         m_pFixedCheckBox->click();
    364         m_pFixedCheckBox->setFocus();
    365     }
    366 
    367     /* Additional options: */
    368     m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
    369 }
    370 
    371 void UIDiskVariantGroupBox::setWidgetVisibility(CMediumFormat &mediumFormat)
    372 {
    373     ULONG uCapabilities = 0;
    374     QVector<KMediumFormatCapabilities> capabilities;
    375     capabilities = mediumFormat.GetCapabilities();
    376     for (int i = 0; i < capabilities.size(); i++)
    377         uCapabilities |= capabilities[i];
    378 
    379     bool m_fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
    380     bool m_fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
    381     bool m_fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
    382     if (m_pFixedCheckBox)
    383     {
    384         if (!m_fIsCreateDynamicPossible)
    385         {
    386             m_pFixedCheckBox->setChecked(true);
    387             m_pFixedCheckBox->setEnabled(false);
    388         }
    389         if (!m_fIsCreateFixedPossible)
    390         {
    391             m_pFixedCheckBox->setChecked(false);
    392             m_pFixedCheckBox->setEnabled(false);
    393         }
    394     }
    395     if (m_pFixedCheckBox)
    396         m_pFixedCheckBox->setHidden(!m_fIsCreateFixedPossible);
    397     if (m_pSplitBox)
    398         m_pSplitBox->setHidden(!m_fIsCreateSplitPossible);
    399 }
    400 
    401 void UIDiskVariantGroupBox::updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat,
    402                                                                         bool fHideDisabled /* = false */)
    403 {
    404     ULONG uCapabilities = 0;
    405     QVector<KMediumFormatCapabilities> capabilities;
    406     capabilities = mediumFormat.GetCapabilities();
    407     for (int i = 0; i < capabilities.size(); i++)
    408         uCapabilities |= capabilities[i];
    409 
    410     m_fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
    411     m_fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
    412     m_fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
    413 
    414     if (m_pFixedCheckBox)
    415     {
    416         m_pFixedCheckBox->setEnabled(m_fIsCreateDynamicPossible || m_fIsCreateFixedPossible);
    417         if (!m_fIsCreateDynamicPossible)
    418             m_pFixedCheckBox->setChecked(true);
    419         if (!m_fIsCreateFixedPossible)
    420             m_pFixedCheckBox->setChecked(false);
    421     }
    422     m_pSplitBox->setEnabled(m_fIsCreateSplitPossible);
    423 
    424     if (fHideDisabled)
    425     {
    426         m_pFixedCheckBox->setHidden(!m_pFixedCheckBox->isEnabled());
    427         m_pSplitBox->setHidden(!m_pSplitBox->isEnabled());
    428     }
    429     emit sigMediumVariantChanged(mediumVariant());
    430 }
    431 
    432 bool UIDiskVariantGroupBox::isComplete() const
    433 {
    434     /* Make sure medium variant is correct: */
    435     return mediumVariant() != (qulonglong)KMediumVariant_Max;
    436 }
    437 
    438 bool UIDiskVariantGroupBox::isCreateDynamicPossible() const
    439 {
    440     return m_fIsCreateDynamicPossible;
    441 }
    442 
    443 bool UIDiskVariantGroupBox::isCreateFixedPossible() const
    444 {
    445     return m_fIsCreateFixedPossible;
    446 }
    447 
    448 bool UIDiskVariantGroupBox::isCreateSplitPossible() const
    449 {
    450     return m_fIsCreateSplitPossible;
    451 }
    452 
    453 void UIDiskVariantGroupBox::sltVariantChanged()
    454 {
    455     emit sigMediumVariantChanged(mediumVariant());
    456 }
    457 
    458 
    459 /*********************************************************************************************************************************
    460 *   UIMediumSizeAndPathGroupBox implementation.                                                                                  *
    461 *********************************************************************************************************************************/
    462 
    463 UIMediumSizeAndPathGroupBox::UIMediumSizeAndPathGroupBox(bool fExpertMode, QWidget *pParent /* = 0 */)
    464     : UIDiskEditorGroupBox(fExpertMode, pParent)
    465     , m_pLocationEditor(0)
    466     , m_pLocationOpenButton(0)
    467     , m_pMediumSizeEditor(0)
    468     , m_pLocationLabel(0)
    469     , m_pSizeLabel(0)
    470 {
    471     prepare();
    472 }
    473 
    474 void UIMediumSizeAndPathGroupBox::prepare()
    475 {
    476     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    477     /* Location widgets: */
    478     if (!m_fExpertMode)
    479         m_pLocationLabel = new QIRichTextLabel;
    480     QHBoxLayout *pLocationLayout = new QHBoxLayout;
    481     m_pLocationEditor = new QILineEdit;
    482     m_pLocationOpenButton = new QIToolButton;
    483     if (m_pLocationOpenButton)
    484     {
    485         m_pLocationOpenButton->setAutoRaise(true);
    486         m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png"));
    487     }
    488     pLocationLayout->addWidget(m_pLocationEditor);
    489     pLocationLayout->addWidget(m_pLocationOpenButton);
    490 
    491     /* Size widgets: */
    492     if (!m_fExpertMode)
    493         m_pSizeLabel = new QIRichTextLabel;
    494     m_pMediumSizeEditor = new UIMediumSizeEditor;
    495 
    496     /* Add widgets to main layout: */
    497     if (m_pLocationLabel)
    498         pMainLayout->addWidget(m_pLocationLabel);
    499     pMainLayout->addLayout(pLocationLayout);
    500 
    501     if (m_pSizeLabel)
    502         pMainLayout->addWidget(m_pSizeLabel);
    503     pMainLayout->addWidget(m_pMediumSizeEditor);
    504 
    505     connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    506             this, &UIMediumSizeAndPathGroupBox::sigMediumSizeChanged);
    507 
    508     connect(m_pLocationEditor, &QILineEdit::textChanged,
    509             this, &UIMediumSizeAndPathGroupBox::sigMediumPathChanged);
    510 
    511     connect(m_pLocationOpenButton, &QIToolButton::clicked,
    512             this, &UIMediumSizeAndPathGroupBox::sigMediumLocationButtonClicked);
    513 
    514     retranslateUi();
    515 }
    516 void UIMediumSizeAndPathGroupBox::retranslateUi()
    517 {
    518     if (m_fExpertMode)
    519         setTitle(tr("Hard Disk File Location and Size"));
    520     if (m_pLocationOpenButton)
    521         m_pLocationOpenButton->setToolTip(tr("Choose a location for new virtual hard disk file..."));
    522 
    523     if (!m_fExpertMode && m_pLocationLabel)
    524         m_pLocationLabel->setText(tr("Please type the name of the new virtual hard disk file into the box below or "
    525                                                     "click on the folder icon to select a different folder to create the file in."));
    526     if (!m_fExpertMode && m_pSizeLabel)
    527         m_pSizeLabel->setText(tr("Select the size of the virtual hard disk in megabytes. "
    528                                                 "This size is the limit on the amount of file data "
    529                                                 "that a virtual machine will be able to store on the hard disk."));
    530 }
    531 
    532 QString UIMediumSizeAndPathGroupBox::mediumPath() const
    533 {
    534     if (m_pLocationEditor)
    535         return m_pLocationEditor->text();
    536     return QString();
    537 }
    538 
    539 void UIMediumSizeAndPathGroupBox::setMediumPath(const QString &strMediumPath)
    540 {
    541     if (!m_pLocationEditor)
    542         return;
    543     m_pLocationEditor->setText(strMediumPath);
    544 }
    545 
    546 void UIMediumSizeAndPathGroupBox::updateMediumPath(const CMediumFormat &mediumFormat, const QStringList &formatExtensions)
    547 {
    548     /* Compose virtual-disk extension: */
    549     QString strDefaultExtension = UIDiskFormatsGroupBox::defaultExtension(mediumFormat);
    550     /* Update m_pLocationEditor's text if necessary: */
    551     if (!m_pLocationEditor->text().isEmpty() && !strDefaultExtension.isEmpty())
    552     {
    553         QFileInfo fileInfo(m_pLocationEditor->text());
    554         if (fileInfo.suffix() != strDefaultExtension)
    555         {
    556             QFileInfo newFileInfo(QDir(fileInfo.absolutePath()),
    557                                   QString("%1.%2").
    558                                   arg(stripFormatExtension(fileInfo.fileName(), formatExtensions)).
    559                                   arg(strDefaultExtension));
    560             setMediumPath(newFileInfo.absoluteFilePath());
    561         }
    562     }
    563 }
    564 
    565 qulonglong UIMediumSizeAndPathGroupBox::mediumSize() const
    566 {
    567     if (m_pMediumSizeEditor)
    568         return m_pMediumSizeEditor->mediumSize();
    569     return 0;
    570 }
    571 
    572 void UIMediumSizeAndPathGroupBox::setMediumSize(qulonglong uSize)
    573 {
    574     if (m_pMediumSizeEditor)
    575         return m_pMediumSizeEditor->setMediumSize(uSize);
    576 }
    577 
    578 /* static */
    579 QString UIMediumSizeAndPathGroupBox::stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions)
    580 {
    581     QString result(strFileName);
    582     foreach (const QString &strExtension, formatExtensions)
    583     {
    584         if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))
    585         {
    586             /* Add the dot to extenstion: */
    587             QString strExtensionWithDot(strExtension);
    588             strExtensionWithDot.prepend('.');
    589             int iIndex = strFileName.lastIndexOf(strExtensionWithDot, -1, Qt::CaseInsensitive);
    590             result.remove(iIndex, strExtensionWithDot.length());
    591         }
    592     }
    593     return result;
    594 }
     221        setMACAddressClonePolicy(MACAddressClonePolicy_StripAllMACs);
     222}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h

    r90578 r90589  
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h
    19 #define FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_editors_UIWizardCloneVMEditors_h
     19#define FEQT_INCLUDED_SRC_wizards_editors_UIWizardCloneVMEditors_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2323
    2424/* Qt includes: */
    25 #include <QIcon>
     25// #include <QIcon>
    2626#include <QGroupBox>
    2727
     
    3131
    3232/* Forward declarations: */
    33 class CMediumFormat;
    34 class QButtonGroup;
    35 class QCheckBox;
    36 class QGridLayout;
     33// class CMediumFormat;
     34// class QButtonGroup;
     35// class QCheckBox;
     36// class QGridLayout;
     37class QComboBox;
    3738class QLabel;
    38 class QVBoxLayout;
    39 class QIRichTextLabel;
     39// class QVBoxLayout;
     40// class QIRichTextLabel;
    4041class QILineEdit;
    41 class QIToolButton;
     42// class QIToolButton;
    4243class UIFilePathSelector;
    43 class UIHostnameDomainNameEditor;
    44 class UIPasswordLineEdit;
    45 class UIUserNamePasswordEditor;
    46 class UIMediumSizeEditor;
     44// class UIHostnameDomainNameEditor;
     45// class UIPasswordLineEdit;
     46// class UIUserNamePasswordEditor;
     47// class UIMediumSizeEditor;
    4748
    4849/* Other VBox includes: */
    49 #include "COMEnums.h"
    50 #include "CMediumFormat.h"
     50// #include "COMEnums.h"
     51// #include "CMediumFormat.h"
    5152
    52 class SHARED_LIBRARY_STUFF UIDiskEditorGroupBox : public QIWithRetranslateUI<QGroupBox>
     53/** MAC address policies. */
     54enum MACAddressClonePolicy
    5355{
    54     Q_OBJECT;
     56    MACAddressClonePolicy_KeepAllMACs,
     57    MACAddressClonePolicy_KeepNATMACs,
     58    MACAddressClonePolicy_StripAllMACs,
     59    MACAddressClonePolicy_MAX
     60};
     61Q_DECLARE_METATYPE(MACAddressClonePolicy);
    5562
    56 public:
    57 
    58     UIDiskEditorGroupBox(bool fExpertMode, QWidget *pParent = 0);
    59 
    60     static QString appendExtension(const QString &strName, const QString &strExtension);
    61     static QString constructMediumFilePath(const QString &strFileName, const QString &strPath);
    62     static QString defaultExtensionForMediumFormat(const CMediumFormat &mediumFormatRef);
    63     static bool checkFATSizeLimitation(const qulonglong uVariant, const QString &strMediumPath, const qulonglong uSize);
    64 
    65 protected:
    66 
    67     bool m_fExpertMode;
    68 };
    69 
    70 class SHARED_LIBRARY_STUFF UIDiskFormatsGroupBox : public UIDiskEditorGroupBox
     63class UICloneVMNamePathEditor : public QIWithRetranslateUI<QGroupBox>
    7164{
    7265    Q_OBJECT;
     
    7467signals:
    7568
    76     void sigMediumFormatChanged();
     69    // void sigNameChanged(const QString &strUserName);
     70    // void sigPathChanged(const QString &strPassword);
    7771
    7872public:
    7973
    80     UIDiskFormatsGroupBox(bool fExpertMode, QWidget *pParent = 0);
    81     CMediumFormat mediumFormat() const;
    82     void setMediumFormat(const CMediumFormat &mediumFormat);
    83     const CMediumFormat &VDIMediumFormat() const;
    84     const QStringList formatExtensions() const;
    85     static QString defaultExtension(const CMediumFormat &mediumFormatRef);
     74    UICloneVMNamePathEditor(const QString &strOriginalName, const QString &strDefaultPath, QWidget *pParent = 0);
    8675
    87 private:
     76    QString name() const;
     77    void setName(const QString &strName);
    8878
    89     void prepare();
    90     void addFormatButton(QVBoxLayout *pFormatLayout, CMediumFormat medFormat, bool fPreferred = false);
    91 
    92     virtual void retranslateUi() /* override final */;
    93 
    94     QList<CMediumFormat>  m_formats;
    95     CMediumFormat m_comVDIMediumFormat;
    96     QStringList           m_formatNames;
    97     QStringList m_formatExtensions;
    98     QButtonGroup *m_pFormatButtonGroup;
    99 };
    100 
    101 class SHARED_LIBRARY_STUFF UIDiskVariantGroupBox : public UIDiskEditorGroupBox
    102 {
    103     Q_OBJECT;
    104 
    105 signals:
    106 
    107     void sigMediumVariantChanged(qulonglong uVariant);
    108 
    109 public:
    110 
    111     UIDiskVariantGroupBox(bool fExpertMode, QWidget *pParent = 0);
    112     void updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat, bool fHideDisabled = false);
    113     qulonglong mediumVariant() const;
    114     void setMediumVariant(qulonglong uMediumVariant);
    115     void setWidgetVisibility(CMediumFormat &mediumFormat);
    116     bool isComplete() const;
    117 
    118     bool isCreateDynamicPossible() const;
    119     bool isCreateFixedPossible() const;
    120     bool isCreateSplitPossible() const;
    121 
    122 private slots:
    123 
    124     void sltVariantChanged();
     79    QString path() const;
     80    void setPath(const QString &strPath);
     81    bool isComplete();
    12582
    12683private:
     
    12986    virtual void retranslateUi() /* override final */;
    13087
    131     QCheckBox *m_pFixedCheckBox;
    132     QCheckBox *m_pSplitBox;
    133     bool m_fIsCreateDynamicPossible;
    134     bool m_fIsCreateFixedPossible;
    135     bool m_fIsCreateSplitPossible;
     88    QILineEdit  *m_pNameLineEdit;
     89    UIFilePathSelector *m_pPathSelector;
     90    QLabel      *m_pNameLabel;
     91    QLabel      *m_pPathLabel;
     92
     93    QString      m_strOriginalName;
     94    QString      m_strDefaultPath;
    13695};
    13796
    13897
    139 class SHARED_LIBRARY_STUFF UIMediumSizeAndPathGroupBox : public UIDiskEditorGroupBox
     98class UICloneVMAdditionalOptionsEditor : public QIWithRetranslateUI<QGroupBox>
    14099{
    141100    Q_OBJECT;
     
    143102signals:
    144103
    145     void sigMediumSizeChanged(qulonglong uSize);
    146     void sigMediumPathChanged(const QString &strPath);
    147     void sigMediumLocationButtonClicked();
    148104
    149105public:
    150106
    151     UIMediumSizeAndPathGroupBox(bool fExpertMode, QWidget *pParent = 0);
    152     QString mediumPath() const;
    153     void setMediumPath(const QString &strMediumPath);
    154     void updateMediumPath(const CMediumFormat &mediumFormat, const QStringList &formatExtensions);
    155     qulonglong mediumSize() const;
    156     void setMediumSize(qulonglong uSize);
     107    UICloneVMAdditionalOptionsEditor(QWidget *pParent = 0);
     108
     109    bool isComplete();
     110
     111    MACAddressClonePolicy macAddressClonePolicy() const;
     112    void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy);
    157113
    158114private:
     
    160116    void prepare();
    161117    virtual void retranslateUi() /* override final */;
    162     static QString stripFormatExtension(const QString &strFileName,
    163                                         const QStringList &formatExtensions);
     118    void populateMACAddressClonePolicies();
    164119
    165     QILineEdit *m_pLocationEditor;
    166     QIToolButton *m_pLocationOpenButton;
    167     UIMediumSizeEditor *m_pMediumSizeEditor;
    168     QIRichTextLabel *m_pLocationLabel;
    169     QIRichTextLabel *m_pSizeLabel;
     120    QLabel *m_pMACComboBoxLabel;
     121    QComboBox *m_pMACComboBox;
     122
    170123};
    171124
    172 #endif /* !FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h */
     125
     126#endif /* !FEQT_INCLUDED_SRC_wizards_editors_UIWizardCloneVMEditors_h */
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