VirtualBox

Changeset 90669 in vbox


Ignore:
Timestamp:
Aug 12, 2021 7:04:04 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146281
Message:

FE/Qt: bugref:9996. Misc. fixes.

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

Legend:

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

    r90661 r90669  
    135135bool UIWizardCloneVM::cloneVM()
    136136{
    137     // /* Get the clone name: */
    138     // QString strName = field("cloneName").toString();
    139     // /* Get the clone setting file path: */
    140     // QString strSettingsFile = field("cloneFilePath").toString();
    141 
    142     // /* Should we create linked clone? */
    143     // bool fLinked = field("linkedClone").toBool();
    144     // /* Get clone mode: */
    145     // KCloneMode cloneMode = (mode() == WizardMode_Basic && page(Page3)) ||
    146     //                        (mode() == WizardMode_Expert && page(PageExpert)) ?
    147     //                        field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState;
    148 
    149     // /* Get VBox object: */
    150     // CVirtualBox vbox = uiCommon().virtualBox();
    151 
    152     // /* Prepare machine for cloning: */
    153     // CMachine srcMachine = m_machine;
    154 
    155     // /* If the user like to create a linked clone from the current machine, we
    156     //  * have to take a little bit more action. First we create an snapshot, so
    157     //  * that new differencing images on the source VM are created. Based on that
    158     //  * we could use the new snapshot machine for cloning. */
    159     // if (fLinked && m_snapshot.isNull())
    160     // {
    161     //     /* Open session: */
    162     //     CSession session = uiCommon().openSession(m_machine.GetId());
    163     //     if (session.isNull())
    164     //         return false;
    165 
    166     //     /* Prepare machine: */
    167     //     CMachine machine = session.GetMachine();
    168 
    169     //     /* Take the snapshot: */
    170     //     QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(strName);
    171     //     QUuid uSnapshotId;
    172     //     CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true, uSnapshotId);
    173 
    174     //     if (machine.isOk())
    175     //     {
    176     //         /* Show the "Taking Snapshot" progress dialog: */
    177     //         msgCenter().showModalProgressDialog(progress, m_machine.GetName(), ":/progress_snapshot_create_90px.png", this);
    178 
    179     //         if (!progress.isOk() || progress.GetResultCode() != 0)
    180     //         {
    181     //             msgCenter().cannotTakeSnapshot(progress, m_machine.GetName(), this);
    182     //             return false;
    183     //         }
    184     //     }
    185     //     else
    186     //     {
    187     //         msgCenter().cannotTakeSnapshot(machine, m_machine.GetName(), this);
    188     //         return false;
    189     //     }
    190 
    191     //     /* Unlock machine finally: */
    192     //     session.UnlockMachine();
    193 
    194     //     /* Get the new snapshot and the snapshot machine. */
    195     //     const CSnapshot &newSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
    196     //     if (newSnapshot.isNull())
    197     //     {
    198     //         msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
    199     //         return false;
    200     //     }
    201     //     srcMachine = newSnapshot.GetMachine();
    202     // }
    203 
    204     // /* Create a new machine object. */
    205     // CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString(), QString());
    206     // if (!vbox.isOk())
    207     // {
    208     //     msgCenter().cannotCreateMachine(vbox, this);
    209     //     return false;
    210     // }
    211 
    212     // /* Clone options vector to pass to cloning: */
    213     // QVector<KCloneOptions> options;
    214     // /* Set the selected MAC address policy: */
    215     // switch (field("macAddressClonePolicy").value<MACAddressClonePolicy>())
    216     // {
    217     //     case MACAddressClonePolicy_KeepAllMACs:
    218     //         options.append(KCloneOptions_KeepAllMACs);
    219     //         break;
    220     //     case MACAddressClonePolicy_KeepNATMACs:
    221     //         options.append(KCloneOptions_KeepNATMACs);
    222     //         break;
    223     //     default:
    224     //         break;
    225     // }
    226 
    227     // if (field("keepDiskNames").value<bool>())
    228     //     options.append(KCloneOptions_KeepDiskNames);
    229     // if (field("keepHWUUIDs").value<bool>())
    230     //     options.append(KCloneOptions_KeepHwUUIDs);
    231 
    232     // /* Linked clones requested? */
    233     // if (fLinked)
    234     //     options.append(KCloneOptions_Link);
    235 
    236     // /* Clone VM: */
    237     // UINotificationProgressMachineCopy *pNotification = new UINotificationProgressMachineCopy(srcMachine,
    238     //                                                                                          cloneMachine,
    239     //                                                                                          cloneMode,
    240     //                                                                                          options);
    241     // connect(pNotification, &UINotificationProgressMachineCopy::sigMachineCopied,
    242     //         &uiCommon(), &UICommon::sltHandleMachineCreated);
    243     // gpNotificationCenter->append(pNotification);
     137    /* Get VBox object: */
     138    CVirtualBox vbox = uiCommon().virtualBox();
     139
     140    /* Prepare machine for cloning: */
     141    CMachine srcMachine = m_machine;
     142
     143    /* If the user like to create a linked clone from the current machine, we
     144     * have to take a little bit more action. First we create an snapshot, so
     145     * that new differencing images on the source VM are created. Based on that
     146     * we could use the new snapshot machine for cloning. */
     147    if (m_fLinkedClone && m_snapshot.isNull())
     148    {
     149
     150        /* Open session: */
     151        CSession session = uiCommon().openSession(m_machine.GetId());
     152        if (session.isNull())
     153            return false;
     154
     155        /* Prepare machine: */
     156        CMachine machine = session.GetMachine();
     157
     158        /* Take the snapshot: */
     159        QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(m_strCloneName);
     160        QUuid uSnapshotId;
     161        CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true, uSnapshotId);
     162
     163        if (machine.isOk())
     164        {
     165            /* Show the "Taking Snapshot" progress dialog: */
     166            msgCenter().showModalProgressDialog(progress, m_machine.GetName(), ":/progress_snapshot_create_90px.png", this);
     167
     168            if (!progress.isOk() || progress.GetResultCode() != 0)
     169            {
     170                msgCenter().cannotTakeSnapshot(progress, m_machine.GetName(), this);
     171                return false;
     172            }
     173        }
     174        else
     175        {
     176            msgCenter().cannotTakeSnapshot(machine, m_machine.GetName(), this);
     177            return false;
     178        }
     179
     180        /* Unlock machine finally: */
     181        session.UnlockMachine();
     182
     183        /* Get the new snapshot and the snapshot machine. */
     184        const CSnapshot &newSnapshot = m_machine.FindSnapshot(uSnapshotId.toString());
     185        if (newSnapshot.isNull())
     186        {
     187            msgCenter().cannotFindSnapshotByName(m_machine, strSnapshotName, this);
     188            return false;
     189        }
     190        srcMachine = newSnapshot.GetMachine();
     191    }
     192
     193    /* Create a new machine object. */
     194    CMachine cloneMachine = vbox.CreateMachine(m_strCloneFilePath, m_strCloneName, QVector<QString>(), QString(), QString());
     195    if (!vbox.isOk())
     196    {
     197        msgCenter().cannotCreateMachine(vbox, this);
     198        return false;
     199    }
     200
     201    /* Clone options vector to pass to cloning: */
     202    QVector<KCloneOptions> options;
     203    /* Set the selected MAC address policy: */
     204    switch (m_enmMACAddressClonePolicy)
     205    {
     206        case MACAddressClonePolicy_KeepAllMACs:
     207            options.append(KCloneOptions_KeepAllMACs);
     208            break;
     209        case MACAddressClonePolicy_KeepNATMACs:
     210            options.append(KCloneOptions_KeepNATMACs);
     211            break;
     212        default:
     213            break;
     214    }
     215
     216    if (m_fKeepDiskNames)
     217        options.append(KCloneOptions_KeepDiskNames);
     218    if (m_fKeepHardwareUUIDs)
     219        options.append(KCloneOptions_KeepHwUUIDs);
     220
     221    /* Linked clones requested? */
     222    if (m_fLinkedClone)
     223        options.append(KCloneOptions_Link);
     224
     225    /* Clone VM: */
     226    UINotificationProgressMachineCopy *pNotification = new UINotificationProgressMachineCopy(srcMachine,
     227                                                                                             cloneMachine,
     228                                                                                             m_enmCloneMode,
     229                                                                                             options);
     230    connect(pNotification, &UINotificationProgressMachineCopy::sigMachineCopied,
     231            &uiCommon(), &UICommon::sltHandleMachineCreated);
     232    gpNotificationCenter->append(pNotification);
    244233
    245234    return true;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h

    r90661 r90669  
    101101        bool m_fKeepHardwareUUIDs;
    102102        bool m_fLinkedClone;
    103        KCloneMode m_enmCloneMode;
     103        KCloneMode m_enmCloneMode;
    104104    /** @} */
    105105};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r90661 r90669  
    7171void UIWizardCloneVMPageBasic1::initializePage()
    7272{
    73     /* Translate page: */
    74     // retranslateUi();
    75     // if (m_pNameLineEdit)
    76     //     m_pNameLineEdit->setFocus();
     73    retranslateUi();
     74    if (m_pNamePathEditor)
     75        m_pNamePathEditor->setFocus();
     76    if (m_pNamePathEditor)
     77    {
     78        if (!m_userModifiedParameters.contains("CloneName"))
     79            cloneVMWizardPropertySet(CloneName, m_pNamePathEditor->cloneName());
     80            if (!m_userModifiedParameters.contains("CloneFilePath"))
     81                cloneVMWizardPropertySet(CloneFilePath,
     82                             UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathEditor->cloneName(), m_strGroup, m_pNamePathEditor->clonePath()));
     83    }
     84    if (m_pAdditionalOptionsEditor)
     85    {
     86        if (!m_userModifiedParameters.contains("MacAddressPolicy"))
     87            cloneVMWizardPropertySet(MacAddressPolicy, m_pAdditionalOptionsEditor->macAddressClonePolicy());
     88        if (!m_userModifiedParameters.contains("KeepDiskNames"))
     89            cloneVMWizardPropertySet(KeepDiskNames, m_pAdditionalOptionsEditor->keepDiskNames());
     90        if (!m_userModifiedParameters.contains("KeepHardwareUUIDs"))
     91            cloneVMWizardPropertySet(KeepHardwareUUIDs, m_pAdditionalOptionsEditor->keepHardwareUUIDs());
     92    }
    7793}
    7894
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp

    r90661 r90669  
    9191void UIWizardCloneVMPageBasic2::initializePage()
    9292{
    93     /* Translate page: */
    9493    retranslateUi();
     94    if (m_pCloneTypeGroupBox && !m_userModifiedParameters.contains("LinkedClone"))
     95        cloneVMWizardPropertySet(LinkedClone, !m_pCloneTypeGroupBox->isFullClone());
    9596}
    9697
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.h

    r90661 r90669  
    5454    bool m_fAdditionalInfo;
    5555    UICloneVMCloneTypeGroupBox *m_pCloneTypeGroupBox;
    56 
    5756    QSet<QString> m_userModifiedParameters;
    5857};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp

    r90661 r90669  
    121121void UIWizardCloneVMPageBasic3::initializePage()
    122122{
    123     /* Translate page: */
     123
     124    if (m_pCloneModeGroupBox && !m_userModifiedParameters.contains("CloneMode"))
     125        cloneVMWizardPropertySet(CloneMode, m_pCloneModeGroupBox->cloneMode());
     126
    124127    retranslateUi();
    125128}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

    r90661 r90669  
    205205}
    206206
     207bool UICloneVMAdditionalOptionsEditor::keepHardwareUUIDs() const
     208{
     209    if (m_pKeepHWUUIDsCheckBox)
     210        return m_pKeepHWUUIDsCheckBox->isChecked();
     211    return false;
     212}
     213
     214bool UICloneVMAdditionalOptionsEditor::keepDiskNames() const
     215{
     216    if (m_pKeepDiskNamesCheckBox)
     217        m_pKeepDiskNamesCheckBox->isChecked();
     218    return false;
     219}
     220
    207221void UICloneVMAdditionalOptionsEditor::prepare()
    208222{
     
    225239                this, &UICloneVMAdditionalOptionsEditor::sltMACAddressClonePolicyChanged);
    226240    }
     241    m_pMACComboBox->blockSignals(true);
    227242    populateMACAddressClonePolicies();
    228 
     243    m_pMACComboBox->blockSignals(false);
    229244
    230245    /* Load currently supported clone options: */
     
    377392}
    378393
     394bool UICloneVMCloneTypeGroupBox::isFullClone() const
     395{
     396    if (m_pFullCloneRadio)
     397        return m_pFullCloneRadio->isChecked();
     398    return true;
     399}
     400
    379401void UICloneVMCloneTypeGroupBox::prepare()
    380402{
     
    496518void UICloneVMCloneModeGroupBox::sltButtonClicked()
    497519{
     520    emit sigCloneModeChanged(cloneMode());
     521}
     522
     523KCloneMode UICloneVMCloneModeGroupBox::cloneMode() const
     524{
    498525    KCloneMode enmCloneMode = KCloneMode_MachineState;
    499526    if (m_pMachineAndChildsRadio && m_pMachineAndChildsRadio->isChecked())
     
    501528    else if (m_pAllRadio && m_pAllRadio->isChecked())
    502529        enmCloneMode = KCloneMode_AllStates;
    503     emit sigCloneModeChanged(enmCloneMode);
    504 }
     530    return enmCloneMode;
     531}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h

    r90661 r90669  
    129129    int firstColumnWidth() const;
    130130
     131    bool keepHardwareUUIDs() const;
     132    bool keepDiskNames() const;
     133
    131134private slots:
    132135
     
    159162
    160163    UICloneVMCloneTypeGroupBox(QWidget *pParent = 0);
     164    bool isFullClone() const;
    161165
    162166private slots:
     
    186190
    187191    UICloneVMCloneModeGroupBox(bool fShowChildsOption, QWidget *pParent = 0);
     192    KCloneMode cloneMode() const;
    188193
    189194private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h

    r90430 r90669  
    6565    void updateDiskWidgetsAfterMediumFormatChange();
    6666
    67 
    6867    /* Widgets: */
    6968    UIMediumSizeAndPathGroupBox *m_pSizeAndPathGroup;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette