VirtualBox

Changeset 71632 in vbox


Ignore:
Timestamp:
Apr 3, 2018 4:58:07 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9150 Implementing GUI elements for the 'move vm' API

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r71459 r71632  
    841841                          "confirmStartMultipleMachines" /* auto-confirm id */);
    842842}
     843
     844void UIMessageCenter::cannotMoveMachine(const CMachine &machine, QWidget *pParent /* = 0 */) const
     845{
     846    error(pParent, MessageType_Error,
     847          tr("Failed to move the virtual machine <b>%1</b>.")
     848          .arg(CMachine(machine).GetName()),
     849          UIErrorString::formatErrorInfo(machine));
     850}
     851
     852void UIMessageCenter::cannotMoveMachine(const CProgress &progress, const QString &strMachineName, QWidget *pParent /* = 0 */) const
     853{
     854    error(pParent, MessageType_Error,
     855          tr("Failed to move the virtual machine <b>%1</b>.")
     856          .arg(strMachineName),
     857          UIErrorString::formatErrorInfo(progress));
     858}
     859
    843860
    844861int UIMessageCenter::confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const
     
    28082825    return iResultCode;
    28092826}
    2810 
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r71630 r71632  
    282282    void cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const;
    283283    bool confirmStartMultipleMachines(const QString &strNames) const;
     284    void cannotMoveMachine(const CMachine &machine, QWidget *pParent = 0) const;
     285    void cannotMoveMachine(const CProgress &progress, const QString &strMachineName, QWidget *pParent = 0) const;
    284286
    285287    /* API: Snapshot warnings: */
     
    536538
    537539#endif /* !___UIMessageCenter_h___ */
    538 
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp

    r71625 r71632  
    653653        setName(QApplication::translate("UIActionPool", "Cl&one..."));
    654654        setStatusTip(QApplication::translate("UIActionPool", "Clone selected virtual machine"));
     655    }
     656};
     657
     658/** Simple action extension, used as 'Perform Move Machine' action class. */
     659class UIActionSimpleSelectorMachinePerformMove : public UIActionSimple
     660{
     661    Q_OBJECT;
     662
     663public:
     664
     665    /** Constructs action passing @a pParent to the base-class. */
     666    UIActionSimpleSelectorMachinePerformMove(UIActionPool *pParent)
     667        : UIActionSimple(pParent, ":/vm_clone_16px.png", ":/vm_clone_disabled_16px.png")
     668    {}
     669
     670protected:
     671
     672    /** Returns shortcut extra-data ID. */
     673    virtual QString shortcutExtraDataID() const /* override */
     674    {
     675        return QString("MoveVM");
     676    }
     677
     678    /** Returns default shortcut. */
     679    virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
     680    {
     681        return QKeySequence("Ctrl+M");
     682    }
     683
     684    /** Handles translation event. */
     685    virtual void retranslateUi() /* override */
     686    {
     687        setName(QApplication::translate("UIActionPool", "&Move..."));
     688        setStatusTip(QApplication::translate("UIActionPool", "Move selected virtual machine"));
    655689    }
    656690};
     
    15711605    m_pool[UIActionIndexST_M_Machine_S_Settings] = new UIActionSimpleSelectorMachineShowSettings(this);
    15721606    m_pool[UIActionIndexST_M_Machine_S_Clone] = new UIActionSimpleSelectorMachinePerformClone(this);
     1607    m_pool[UIActionIndexST_M_Machine_S_Move] = new UIActionSimpleSelectorMachinePerformMove(this);
    15731608    m_pool[UIActionIndexST_M_Machine_S_Remove] = new UIActionSimpleSelectorMachinePerformRemove(this);
    15741609    m_pool[UIActionIndexST_M_Machine_S_AddGroup] = new UIActionSimpleSelectorMachinePerformGroup(this);
     
    16401675
    16411676#include "UIActionPoolSelector.moc"
    1642 
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h

    r71630 r71632  
    7474    UIActionIndexST_M_Machine_S_Settings,
    7575    UIActionIndexST_M_Machine_S_Clone,
     76    UIActionIndexST_M_Machine_S_Move,
    7677    UIActionIndexST_M_Machine_S_Remove,
    7778    UIActionIndexST_M_Machine_S_AddGroup,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r71461 r71632  
    671671}
    672672
    673 void UISelectorWindow::sltOpenCloneMachineWizard()
     673void UISelectorWindow::sltOpenCLonemachinewizard()
    674674{
    675675    /* Get current item: */
     
    691691    /* Unlock the action allowing further calls: */
    692692    actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(true);
     693}
     694
     695void UISelectorWindow::sltPerformMoveMachine()
     696{
     697    UIVMItem *pItem = currentItem();
     698    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     699
     700    /* Open a session thru which we will modify the machine: */
     701    CSession session = vboxGlobal().openSession(pItem->id(), KLockType_Write);
     702    if (session.isNull())
     703        return;
     704
     705    /* Get session machine: */
     706    CMachine machine = session.GetMachine();
     707    AssertMsgReturnVoid(!machine.isNull(), ("Invalid Machine!\n"));
     708
     709    /* Open a file dialog for the user to select a destination folder. Start with the default machine folder: */
     710    CVirtualBox vbox = vboxGlobal().virtualBox();
     711    QString strBaseFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
     712    QString strTitle = tr("Select a destination folder to move the selected virtual machine");
     713    QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle);
     714    if (strDestinationFolder.isEmpty())
     715    {
     716        session.UnlockMachine();
     717        return;
     718    }
     719    CProgress progress = machine.MoveTo(strDestinationFolder, "basic");
     720
     721    if (machine.isOk())
     722    {
     723        /* Show machine move progress: */
     724        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_clone_90px.png");
     725        if (!progress.isOk() || progress.GetResultCode() != 0)
     726            msgCenter().cannotMoveMachine(progress, machine.GetName());
     727    }
     728    else
     729        msgCenter().cannotMoveMachine(machine);
     730    session.UnlockMachine();
    693731}
    694732
     
    16621700    addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings));
    16631701    addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Clone));
     1702    addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Move));
    16641703    addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Remove));
    16651704    addAction(actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup));
     
    16801719    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings));
    16811720    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Clone));
     1721    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Move));
    16821722    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Remove));
    16831723    pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup));
     
    17021742                     << actionPool()->action(UIActionIndexST_M_Machine_S_Settings)
    17031743                     << actionPool()->action(UIActionIndexST_M_Machine_S_Clone)
     1744                     << actionPool()->action(UIActionIndexST_M_Machine_S_Move)
    17041745                     << actionPool()->action(UIActionIndexST_M_Machine_S_Remove)
    17051746                     << actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup)
     
    20702111    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), SIGNAL(triggered()), this, SLOT(sltOpenMachineSettingsDialog()));
    20712112    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Clone), SIGNAL(triggered()), this, SLOT(sltOpenCloneMachineWizard()));
     2113    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Move), SIGNAL(triggered()), this, SLOT(sltPerformMoveMachine()));
    20722114    connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowMachine()));
    20732115    connect(actionPool()->action(UIActionIndexST_M_Machine_T_Pause), SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseOrResumeMachine(bool)));
     
    23652407    actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Settings, items));
    23662408    actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Clone, items));
     2409    actionPool()->action(UIActionIndexST_M_Machine_S_Move)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Move, items));
    23672410    actionPool()->action(UIActionIndexST_M_Machine_S_Remove)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Remove, items));
    23682411    actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_AddGroup, items));
     
    24762519        }
    24772520        case UIActionIndexST_M_Machine_S_Clone:
     2521        case UIActionIndexST_M_Machine_S_Move:
    24782522        {
    24792523            return !m_pPaneChooser->isGroupSavingInProgress() &&
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r70185 r71632  
    157157        /** Handles call to open Clone Machine wizard. */
    158158        void sltOpenCloneMachineWizard();
     159        /** Handles the Move Machine action. */
     160        void sltPerformMoveMachine();
    159161        /** Handles call to start or show machine. */
    160162        void sltPerformStartOrShowMachine();
     
    387389
    388390#endif /* !___UISelectorWindow_h___ */
    389 
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r71438 r71632  
    12691269    m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings));
    12701270    m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Clone));
     1271    m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Move));
    12711272    m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Remove));
    12721273    m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup));
     
    22392240    COMBase::CleanupCOM();
    22402241}
    2241 
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