VirtualBox

Ignore:
Timestamp:
Mar 30, 2023 12:09:03 PM (22 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6669: VirtualBox Manager: Move Clone VM wizard onto non-modal rails.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.cpp

    r98103 r99218  
    342342bool UIToolPaneMachine::isCurrentStateItemSelected() const
    343343{
    344     if (!m_pPaneSnapshots)
    345         return false;
    346     return m_pPaneSnapshots->isCurrentStateItemSelected();
     344    return m_pPaneSnapshots ? m_pPaneSnapshots->isCurrentStateItemSelected() : false;
     345}
     346
     347QUuid UIToolPaneMachine::currentSnapshotId()
     348{
     349    return m_pPaneSnapshots ? m_pPaneSnapshots->currentSnapshotId() : QUuid();
    347350}
    348351
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.h

    r98103 r99218  
    3333
    3434/* Qt includes: */
     35#include <QUuid>
    3536#include <QWidget>
    3637
     
    108109    bool isCurrentStateItemSelected() const;
    109110
     111    /** Returns currently selected snapshot ID if any. */
     112    QUuid currentSnapshotId();
     113
    110114    /** Returns the help keyword of the current tool's widget. */
    111115    QString currentHelpKeyword() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r99207 r99218  
    470470    , m_pWidget(0)
    471471    , m_iGeometrySaveTimerId(-1)
     472    , m_fSnapshotCloneByDefault(false)
    472473    , m_fImportFromOCI(false)
    473474    , m_fExportToOCI(false)
     
    990991                m_wizards[enmType] = new UIWizardNewVM(this, actionPool(), m_pWidget->fullGroupName(), m_strISOFilePath);
    991992                break;
     993            case WizardType_CloneVM:
     994            {
     995                UIVirtualMachineItem *pItem = currentItem();
     996                UIVirtualMachineItemLocal *pItemLocal = pItem ? pItem->toLocal() : 0;
     997                CMachine comMachine = pItemLocal ? pItemLocal->machine() : CMachine();
     998                CSnapshot comSnapshot;
     999                if (m_fSnapshotCloneByDefault)
     1000                {
     1001                    const QUuid uId = m_pWidget->currentSnapshotId();
     1002                    if (!uId.isNull() && comMachine.isNotNull())
     1003                    {
     1004                        printf("Looking for snapshot with ID = {%s}\n", uId.toString().toUtf8().constData());
     1005                        comSnapshot = comMachine.FindSnapshot(uId.toString());
     1006                        if (comSnapshot.isNotNull())
     1007                        {
     1008                            printf("Snapshot found, acquiring machine ..\n");
     1009                            const CMachine comSnapshotMachine = comSnapshot.GetMachine();
     1010                            if (comSnapshotMachine.isNotNull())
     1011                                comMachine = comSnapshotMachine;
     1012                        }
     1013                    }
     1014                }
     1015                m_wizards[enmType] = new UIWizardCloneVM(this,
     1016                                                         comMachine,
     1017                                                         pItemLocal->groups().value(0),
     1018                                                         comSnapshot);
     1019                break;
     1020            }
    9921021            case WizardType_ExportAppliance:
    9931022                m_wizards[enmType] = new UIWizardExportApp(this, m_names, m_fExportToOCI);
     
    11691198void UIVirtualBoxManager::sltOpenCloneMachineWizard()
    11701199{
    1171     /* Get current item: */
    1172     UIVirtualMachineItem *pItem = currentItem();
    1173     AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    1174     /* Make sure current item is local one: */
    1175     UIVirtualMachineItemLocal *pItemLocal = pItem->toLocal();
    1176     AssertMsgReturnVoid(pItemLocal, ("Current item should be local one!\n"));
    1177 
    1178     /* Use the "safe way" to open stack of Mac OS X Sheets: */
    1179     QWidget *pWizardParent = windowManager().realParentWindow(this);
    1180     const QStringList &machineGroupNames = pItemLocal->groups();
    1181     const QString strGroup = !machineGroupNames.isEmpty() ? machineGroupNames.at(0) : QString();
    1182     QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(pWizardParent, pItemLocal->machine(), strGroup, CSnapshot());
    1183     windowManager().registerNewParent(pWizard, pWizardParent);
    1184     pWizard->exec();
    1185     delete pWizard;
     1200    /* Configure wizard variables: */
     1201    m_fSnapshotCloneByDefault = false;
     1202    QAction *pAction = qobject_cast<QAction*>(sender());
     1203    if (   pAction
     1204        && pAction == actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone))
     1205        m_fSnapshotCloneByDefault = true;
     1206
     1207    /* Open Clone VM Wizard: */
     1208    sltOpenWizard(WizardType_CloneVM);
    11861209}
    11871210
     
    23272350    connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Clone), &UIAction::triggered,
    23282351            this, &UIVirtualBoxManager::sltOpenCloneMachineWizard);
     2352    connect(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone), &UIAction::triggered,
     2353            this, &UIVirtualBoxManager::sltOpenCloneMachineWizard);
    23292354    connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Move), &UIAction::triggered,
    23302355            this, &UIVirtualBoxManager::sltPerformMachineMove);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r99207 r99218  
    525525    QString  m_strISOFilePath;
    526526
     527    /** Holds whether snapshot clone should be done by clone VM wizard. */
     528    bool  m_fSnapshotCloneByDefault;
     529
    527530    /** Holds whether OCI importing should be started by default. */
    528531    bool     m_fImportFromOCI;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r98103 r99218  
    274274{
    275275    return m_pPaneToolsMachine->isCurrentStateItemSelected();
     276}
     277
     278QUuid UIVirtualBoxManagerWidget::currentSnapshotId()
     279{
     280    return m_pPaneToolsMachine->currentSnapshotId();
    276281}
    277282
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r98103 r99218  
    3333
    3434/* Qt includes: */
     35#include <QUuid>
    3536#include <QWidget>
    3637
     
    214215        /** Returns whether current-state item of Snapshot pane is selected. */
    215216        bool isCurrentStateItemSelected() const;
     217
     218        /** Returns currently selected snapshot ID if any. */
     219        QUuid currentSnapshotId();
    216220    /** @} */
    217221
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp

    r98779 r99218  
    6363/* COM includes: */
    6464#include "CConsole.h"
     65#include "CSnapshot.h"
    6566
    6667
     
    585586    UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    586587    return m_currentStateItems.values().contains(pSnapshotItem);
     588}
     589
     590QUuid UISnapshotPane::currentSnapshotId()
     591{
     592    UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
     593    CSnapshot comSnapshot = pSnapshotItem ? pSnapshotItem->snapshot() : CSnapshot();
     594    return comSnapshot.isNotNull() ? comSnapshot.GetId() : QUuid();
    587595}
    588596
     
    13031311    connect(m_pActionPool->action(UIActionIndexMN_M_Snapshot_T_Properties), &UIAction::toggled,
    13041312            this, &UISnapshotPane::sltToggleSnapshotDetailsVisibility);
    1305     connect(m_pActionPool->action(UIActionIndexMN_M_Snapshot_S_Clone), &UIAction::triggered,
    1306             this, &UISnapshotPane::sltCloneSnapshot);
    13071313}
    13081314
     
    17391745}
    17401746
    1741 void UISnapshotPane::cloneSnapshot()
    1742 {
    1743     /* Acquire "current snapshot" item: */
    1744     const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    1745     AssertReturnVoid(pSnapshotItem);
    1746 
    1747     /* Get desired machine/snapshot: */
    1748     CMachine comMachine;
    1749     CSnapshot comSnapshot;
    1750     if (pSnapshotItem->isCurrentStateItem())
    1751         comMachine = pSnapshotItem->machine();
    1752     else
    1753     {
    1754         comSnapshot = pSnapshotItem->snapshot();
    1755         AssertReturnVoid(!comSnapshot.isNull());
    1756         comMachine = comSnapshot.GetMachine();
    1757     }
    1758     AssertReturnVoid(!comMachine.isNull());
    1759 
    1760     /* Show Clone VM wizard: */
    1761     QPointer<UINativeWizard> pWizard = new UIWizardCloneVM(this, comMachine, QString(), comSnapshot);
    1762     pWizard->exec();
    1763     if (pWizard)
    1764         delete pWizard;
    1765 }
    1766 
    17671747void UISnapshotPane::adjustTreeWidget()
    17681748{
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h

    r98103 r99218  
    3232#endif
    3333
     34/* Qt includes: */
     35#include <QUuid>
     36
    3437/* GUI includes: */
    3538#include "QIWithRetranslateUI.h"
     
    3740
    3841/* COM includes: */
     42#include "COMEnums.h"
    3943#include "CMachine.h"
    4044
     
    5256class UISnapshotTree;
    5357class UIVirtualMachineItem;
     58class CSnapshot;
    5459
    5560
     
    9095    /** Returns whether "current state" item selected. */
    9196    bool isCurrentStateItemSelected() const;
     97
     98    /** Returns currently selected snapshot ID if any. */
     99    QUuid currentSnapshotId();
    92100
    93101protected:
     
    145153        /** Handles command to apply snapshot details changes. */
    146154        void sltApplySnapshotDetailsChanges();
    147         /** Proposes to clone the snapshot. */
    148         void sltCloneSnapshot() { cloneSnapshot(); }
    149155    /** @} */
    150156
     
    202208        /** Proposes to restore the snapshot. */
    203209        bool restoreSnapshot(bool fAutomatically = false);
    204         /** Proposes to clone the snapshot. */
    205         void cloneSnapshot();
    206210    /** @} */
    207211
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