VirtualBox

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


Ignore:
Timestamp:
Jun 15, 2011 1:39:42 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72283
Message:

FE/Qt4: clone VM UI

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
10 added
14 edited
1 copied

Legend:

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

    r37331 r37468  
    178178        ./src/settings/global \
    179179        ./src/settings/machine \
     180        ./src/wizards/clonevm \
    180181        ./src/wizards/newvm \
    181182        ./src/wizards/newhd \
     
    319320        src/settings/machine/UIMachineSettingsSF.h \
    320321        src/settings/machine/UIMachineSettingsSFDetails.h \
     322        src/wizards/clonevm/UICloneVMWizard.h \
    321323        src/wizards/newvm/UINewVMWzd.h \
    322324        src/wizards/newhd/UINewHDWizard.h \
     
    485487        src/settings/machine/UIMachineSettingsSF.cpp \
    486488        src/settings/machine/UIMachineSettingsSFDetails.cpp \
     489        src/wizards/clonevm/UICloneVMWizard.cpp \
    487490        src/wizards/newvm/UINewVMWzd.cpp \
    488491        src/wizards/newhd/UINewHDWizard.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r37331 r37468  
    4848    src/settings/machine/UIMachineSettingsSF.ui \
    4949    src/settings/machine/UIMachineSettingsSFDetails.ui \
     50    src/wizards/clonevm/UICloneVMWizardPage1.ui \
     51    src/wizards/clonevm/UICloneVMWizardPage2.ui \
    5052    src/wizards/newvm/UINewVMWzdPage1.ui \
    5153    src/wizards/newvm/UINewVMWzdPage2.ui \
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc

    r34498 r37468  
    1414    <file alias="vm_settings_32px.png">images/vm_settings_32px.png</file>
    1515    <file alias="vm_settings_disabled_32px.png">images/vm_settings_disabled_32px.png</file>
     16    <file alias="vm_clone_16px.png">images/vm_clone_16px.png</file>
     17    <file alias="vm_clone_disabled_16px.png">images/vm_clone_disabled_16px.png</file>
    1618    <file alias="vm_show_logs_32px.png">images/vm_show_logs_32px.png</file>
    1719    <file alias="vm_show_logs_disabled_32px.png">images/vm_show_logs_disabled_32px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc

    r35894 r37468  
    161161    <file alias="progress_snapshot_restore_90px.png">images/progress_snapshot_restore_90px.png</file>
    162162    <file alias="progress_snapshot_discard_90px.png">images/progress_snapshot_discard_90px.png</file>
     163    <file alias="progress_clone_90px.png">images/progress_clone_90px.png</file>
    163164    <file alias="status_check_16px.png">images/status_check_16px.png</file>
    164165    <file alias="status_check_32px.png">images/status_check_32px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBoxMac.qrc

    r26190 r37468  
    77    <file alias="vmw_ovf_import_bg.png">images/vmw_ovf_import_bg.png</file>
    88    <file alias="vmw_ovf_export_bg.png">images/vmw_ovf_export_bg.png</file>
     9    <file alias="vmw_clone_bg.png">images/vmw_clone_bg.png</file>
    910    <file alias="monitor.png">images/monitor.png</file>
    1011    <file alias="monitor_glossy.png">images/monitor_glossy.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBoxOther.qrc

    r26537 r37468  
    77    <file alias="vmw_ovf_export.png">images/vmw_ovf_export.png</file>
    88    <file alias="vmw_ovf_import.png">images/vmw_ovf_import.png</file>
     9    <file alias="vmw_clone.png">images/vmw_clone.png</file>
    910 </qresource>
    1011 </RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r37143 r37468  
    665665}
    666666
     667void VBoxProblemReporter::cannotRegisterMachine(const CVirtualBox &vbox,
     668                                                const CMachine &machine,
     669                                                QWidget *pParent)
     670{
     671    message(pParent ? pParent : mainWindowShown(),
     672            Error,
     673            tr("Failed to register the virtual machine <b>%1</b>.")
     674            .arg(machine.GetName()),
     675            formatErrorInfo(vbox));
     676}
     677
    667678void VBoxProblemReporter::cannotReregisterMachine(QWidget *pParent, const QString &strMachinePath, const QString &strMachineName)
    668679{
     
    814825            .arg (console.GetMachine().GetName()),
    815826        formatErrorInfo (progress.GetErrorInfo())
     827    );
     828}
     829
     830void VBoxProblemReporter::cannotCreateClone(const CMachine &machine,
     831                                            QWidget *pParent /* = 0 */)
     832{
     833    message(
     834        pParent ? pParent : mainWindowShown(),
     835        Error,
     836        tr ("Failed to clone the virtual machine <b>%1</b>.")
     837            .arg(machine.GetName()),
     838        formatErrorInfo(machine)
     839    );
     840}
     841
     842void VBoxProblemReporter::cannotCreateClone(const CMachine &machine,
     843                                            const CProgress &progress,
     844                                            QWidget *pParent /* = 0 */)
     845{
     846    AssertWrapperOk(progress);
     847
     848    message(
     849        pParent ? pParent : mainWindowShown(),
     850        Error,
     851        tr ("Failed to clone the virtual machine <b>%1</b>.")
     852            .arg(machine.GetName()),
     853        formatErrorInfo(progress.GetErrorInfo())
    816854    );
    817855}
     
    26542692}
    26552693
     2694void VBoxProblemReporter::showGenericError(COMBaseWithEI *object, QWidget *pParent /* = 0 */)
     2695{
     2696    if (   !object
     2697        || object->lastRC() == S_OK)
     2698        return;
     2699
     2700    message(pParent ? pParent : mainWindowShown(),
     2701            Error,
     2702            tr("Sorry, some generic error happens."),
     2703            formatErrorInfo(*object));
     2704}
     2705
     2706// Public slots
     2707/////////////////////////////////////////////////////////////////////////////
     2708
    26562709void VBoxProblemReporter::remindAboutUnsupportedUSB2(const QString &strExtPackName, QWidget *pParent)
    26572710{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r37143 r37468  
    193193
    194194    void cannotOpenMachine(QWidget *pParent, const QString &strMachinePath, const CVirtualBox &vbox);
     195    void cannotRegisterMachine(const CVirtualBox &vbox, const CMachine &machine, QWidget *pParent);
    195196    void cannotReregisterMachine(QWidget *pParent, const QString &strMachinePath, const QString &strMachineName);
    196 
    197197    void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
    198198    void cannotSaveMachineSettings (const CMachine &machine,
     
    211211    void cannotSaveMachineState (const CConsole &console);
    212212    void cannotSaveMachineState (const CProgress &progress);
     213    void cannotCreateClone(const CMachine &machine, QWidget *pParent = 0);
     214    void cannotCreateClone(const CMachine &machine, const CProgress &progress, QWidget *pParent = 0);
    213215    void cannotTakeSnapshot (const CConsole &console);
    214216    void cannotTakeSnapshot (const CProgress &progress);
     
    396398        return formatErrorInfo (aRC.errorInfo(), aRC.rc());
    397399    }
     400
     401    void showGenericError(COMBaseWithEI *object, QWidget *pParent = 0);
    398402
    399403    /* Stuff supporting interthreading: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.cpp

    r35634 r37468  
    3434    m_Shortcuts[AddVMShortcut]               = UIKeySequence("AddVM",               "Ctrl+A");
    3535    m_Shortcuts[SettingsVMShortcut]          = UIKeySequence("SettingsVM",          "Ctrl+S");
     36    m_Shortcuts[CloneVMShortcut]             = UIKeySequence("CloneVM",             "Ctrl+C");
    3637    m_Shortcuts[RemoveVMShortcut]            = UIKeySequence("RemoveVM",            "Ctrl+R");
    3738    m_Shortcuts[StartVMShortcut]             = UIKeySequence("StartVM");
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h

    r35634 r37468  
    3636        AddVMShortcut,
    3737        SettingsVMShortcut,
     38        CloneVMShortcut,
    3839        RemoveVMShortcut,
    3940        StartVMShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r37109 r37468  
    2626#include "UIIconPool.h"
    2727#include "UIImportApplianceWzd.h"
     28#include "UICloneVMWizard.h"
    2829#include "UINewVMWzd.h"
    2930#include "UIVMDesktop.h"
     
    141142        ":/vm_settings_32px.png", ":/settings_16px.png",
    142143        ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png"));
     144    mVmCloneAction = new QAction(this);
     145    mVmCloneAction->setIcon(UIIconPool::iconSet(
     146        ":/vm_clone_16px.png", ":/vm_clone_disabled_16px.png"));
    143147    mVmDeleteAction = new QAction(this);
    144148    mVmDeleteAction->setIcon(UIIconPool::iconSetFull(
     
    288292    mVMMenu->addAction(mVmAddAction);
    289293    mVMMenu->addAction(mVmConfigAction);
     294    mVMMenu->addAction(mVmCloneAction);
    290295    mVMMenu->addAction(mVmDeleteAction);
    291296    mVMMenu->addSeparator();
     
    306311    mVMCtxtMenu = new QMenu(this);
    307312    mVMCtxtMenu->addAction(mVmConfigAction);
     313    mVMCtxtMenu->addAction(mVmCloneAction);
    308314    mVMCtxtMenu->addAction(mVmDeleteAction);
    309315    mVMCtxtMenu->addSeparator();
     
    435441
    436442    connect(mVmConfigAction, SIGNAL(triggered()), this, SLOT(vmSettings()));
     443    connect(mVmCloneAction, SIGNAL(triggered()), this, SLOT(vmClone()));
    437444    connect(mVmDeleteAction, SIGNAL(triggered()), this, SLOT(vmDelete()));
    438445    connect(mVmStartAction, SIGNAL(triggered()), this, SLOT(vmStart()));
     
    725732    UISettingsDialogMachine dlg(this, pItem->id(), strCategory, strControl);
    726733    dlg.execute();
     734}
     735
     736void VBoxSelectorWnd::vmClone(const QString &aUuid /* = QString::null */)
     737{
     738    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(aUuid);
     739
     740    AssertMsgReturnVoid(item, ("Item must be always selected here"));
     741
     742    CMachine machine = item->machine();
     743
     744    UICloneVMWizard wzd(this, machine, false);
     745    wzd.exec();
    727746}
    728747
     
    12011220        (mVmConfigAction->shortcut().toString().isEmpty() ? "" : QString(" (%1)").arg(mVmConfigAction->shortcut().toString())));
    12021221
     1222    mVmCloneAction->setText(tr("&Clone"));
     1223    mVmCloneAction->setShortcut(gSS->keySequence(UISelectorShortcuts::CloneVMShortcut));
     1224    mVmCloneAction->setStatusTip(tr("Clone the selected virtual machine"));
     1225
    12031226    mVmDeleteAction->setText(tr("&Remove"));
    12041227    mVmDeleteAction->setShortcut(gSS->keySequence(UISelectorShortcuts::RemoveVMShortcut));
     
    13081331        /* enable/disable modify actions */
    13091332        mVmConfigAction->setEnabled(modifyEnabled);
     1333        mVmCloneAction->setEnabled(!running);
    13101334        mVmDeleteAction->setEnabled(!running);
    13111335        mVmDiscardAction->setEnabled(state == KMachineState_Saved && !running);
     
    14381462        /* disable modify actions */
    14391463        mVmConfigAction->setEnabled(false);
     1464        mVmCloneAction->setEnabled(false);
    14401465        mVmDeleteAction->setEnabled(item != NULL);
    14411466        mVmDiscardAction->setEnabled(false);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h

    r35415 r37468  
    7171    void vmAdd(const QString &strFile = "");
    7272    void vmSettings(const QString &aCategory = QString::null, const QString &aControl = QString::null, const QString & = QString::null);
     73    void vmClone(const QString & = QString::null);
    7374    void vmDelete(const QString & = QString::null);
    7475    void vmStart(const QString & = QString::null);
     
    9596    const QAction *vmAddAction() const { return mVmAddAction; }
    9697    const QAction *vmConfigAction() const { return mVmConfigAction; }
     98    const QAction *vmCloneAction() const { return mVmCloneAction; }
    9799    const QAction *vmDeleteAction() const { return mVmDeleteAction; }
    98100    const QAction *vmStartAction() const { return mVmStartAction; }
     
    165167    QAction *mVmAddAction;
    166168    QAction *mVmConfigAction;
     169    QAction *mVmCloneAction;
    167170    QAction *mVmDeleteAction;
    168171    QAction *mVmStartAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r36011 r37468  
    2727#include "VBoxSnapshotsWgt.h"
    2828#include "VBoxTakeSnapshotDlg.h"
     29#include "UICloneVMWizard.h"
    2930#include "UIToolBar.h"
    3031#include "UIVirtualBoxEventHandler.h"
     32#include "UISelectorShortcuts.h"
    3133
    3234/* Global includes */
     
    136138    }
    137139
     140    CMachine machine() const { return mMachine; }
    138141    CSnapshot snapshot() const { return mSnapshot; }
    139142    QString snapshotId() const { return mId; }
     
    330333    , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup))
    331334    , mTakeSnapshotAction (new QAction (mCurStateActionGroup))
     335    , mCloneSnapshotAction(new QAction(mCurStateActionGroup))
    332336{
    333337    /* Apply UI decorations */
     
    359363    toolBar->addAction (mRestoreSnapshotAction);
    360364    toolBar->addAction (mDeleteSnapshotAction);
     365    toolBar->addSeparator();
     366    toolBar->addAction(mCloneSnapshotAction);
    361367    toolBar->addSeparator();
    362368    toolBar->addAction (mShowSnapshotDetailsAction);
     
    381387        ":/take_snapshot_22px.png", ":/take_snapshot_16px.png",
    382388        ":/take_snapshot_dis_22px.png", ":/take_snapshot_dis_16px.png"));
     389    mCloneSnapshotAction->setIcon(UIIconPool::iconSet(
     390        ":/vm_clone_16px.png", ":/vm_clone_disabled_16px.png"));
    383391
    384392    mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R"));
     
    386394    mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space"));
    387395    mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S"));
     396    mCloneSnapshotAction->setShortcut(QString ("Ctrl+Shift+C"));
    388397
    389398    mAgeUpdateTimer.setSingleShot (true);
     
    401410    connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (sltDeleteSnapshot()));
    402411    connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (sltShowSnapshotDetails()));
     412    connect (mCloneSnapshotAction, SIGNAL(triggered()), this, SLOT(sltCloneSnapshot()));
    403413
    404414    connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
     
    441451    mShowSnapshotDetailsAction->setText (tr ("S&how Details"));
    442452    mTakeSnapshotAction->setText (tr ("Take &Snapshot"));
     453    mCloneSnapshotAction->setText(tr("&Clone"));
     454
    443455
    444456    mRestoreSnapshotAction->setStatusTip (tr ("Restore the selected snapshot of the virtual machine"));
     
    446458    mShowSnapshotDetailsAction->setStatusTip (tr ("Show the details of the selected snapshot"));
    447459    mTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the current virtual machine state"));
     460    mCloneSnapshotAction->setStatusTip(tr("Clone the selected virtual machine"));
    448461
    449462    mRestoreSnapshotAction->setToolTip (mRestoreSnapshotAction->text().remove ('&').remove ('.') +
     
    455468    mTakeSnapshotAction->setToolTip (mTakeSnapshotAction->text().remove ('&').remove ('.') +
    456469        QString (" (%1)").arg (mTakeSnapshotAction->shortcut().toString()));
     470    mCloneSnapshotAction->setToolTip(mCloneSnapshotAction->text().remove('&').remove('.') +
     471        QString(" (%1)").arg(mCloneSnapshotAction->shortcut().toString()));
    457472}
    458473
     
    498513                                         && mCurSnapshotItem && item && item->isCurrentStateItem())
    499514                                     || (item && !mCurSnapshotItem));
     515
     516    /* Enable/disable cloning snapshots */
     517    mCloneSnapshotAction->setEnabled(!busy && item);
    500518}
    501519
     
    514532        menu.addAction (mDeleteSnapshotAction);
    515533        menu.addSeparator();
     534        menu.addAction(mCloneSnapshotAction);
     535        menu.addSeparator();
    516536        menu.addAction (mShowSnapshotDetailsAction);
    517537    }
    518538    else
     539    {
    519540        menu.addAction (mTakeSnapshotAction);
     541        menu.addSeparator();
     542        menu.addAction(mCloneSnapshotAction);
     543    }
    520544
    521545    menu.exec (mTreeWidget->viewport()->mapToGlobal (aPoint));
     
    653677    if (dlg.exec() == QDialog::Accepted)
    654678        dlg.putBackToSnapshot();
     679}
     680
     681void VBoxSnapshotsWgt::sltCloneSnapshot()
     682{
     683    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
     684        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
     685    AssertReturn (item, (void) 0);
     686
     687    CMachine machine;
     688    bool fShowChildsOption = false;
     689    if (item->isCurrentStateItem())
     690        machine = item->machine();
     691    else
     692    {
     693        const CSnapshot &snap = item->snapshot();
     694        AssertReturn(!snap.isNull(), (void)0);
     695        machine = snap.GetMachine();
     696        if (snap.GetChildrenCount() > 0)
     697            fShowChildsOption = true;
     698    }
     699    AssertReturn(!machine.isNull(), (void)0);
     700
     701    UICloneVMWizard wzd(this, machine, fShowChildsOption);
     702    wzd.exec();
    655703}
    656704
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h

    r36011 r37468  
    6767    void sltDeleteSnapshot();
    6868    void sltShowSnapshotDetails();
     69    void sltCloneSnapshot();
    6970
    7071    /* Main API event handlers: */
     
    102103    QAction         *mShowSnapshotDetailsAction;
    103104    QAction         *mTakeSnapshotAction;
     105    QAction         *mCloneSnapshotAction;
    104106
    105107    QTimer          mAgeUpdateTimer;
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