VirtualBox

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


Ignore:
Timestamp:
Apr 15, 2020 4:53:18 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137216
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Implementing cloud VM unregistration routine.

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

Legend:

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

    r83690 r83709  
    605605
    606606void UIMessageCenter::cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent /* = 0 */) const
     607{
     608    /* Show the error: */
     609    error(pParent, MessageType_Error,
     610          tr("Failed to acquire machine parameter."), UIErrorString::formatErrorInfo(comMachine));
     611}
     612
     613void UIMessageCenter::cannotAcquireMachineParameter(const CCloudMachine &comMachine, QWidget *pParent /* = 0 */) const
    607614{
    608615    /* Show the error: */
     
    758765}
    759766
     767bool UIMessageCenter::confirmCloudMachineRemoval(const QList<CCloudMachine> &machines) const
     768{
     769    /* Enumerate the machines: */
     770    QStringList machineNames;
     771    foreach (const CCloudMachine &comMachine, machines)
     772    {
     773        /* Append machine name to the full name string: */
     774        if (comMachine.GetAccessible())
     775            machineNames << QString("<b>%1</b>").arg(comMachine.GetName());
     776    }
     777
     778    /* Prepare message text: */
     779    QString strText = tr("<p>You are about to remove following cloud virtual machines from the machine list:</p>"
     780                         "<p>%1</p>")
     781                         .arg(machineNames.join(", "));
     782
     783    /* Prepare message itself: */
     784    return questionBinary(0, MessageType_Question,
     785                          strText,
     786                          0 /* auto-confirm id */,
     787                          tr("Remove"));
     788}
     789
    760790void UIMessageCenter::cannotRemoveMachine(const CMachine &machine) const
    761791{
     
    772802             .arg(CMachine(machine).GetName()),
    773803          UIErrorString::formatErrorInfo(progress));
     804}
     805
     806void UIMessageCenter::cannotRemoveCloudMachine(const CCloudMachine &comMachine) const
     807{
     808    error(0, MessageType_Error,
     809          tr("Failed to remove the cloud virtual machine <b>%1</b>.")
     810             .arg(CCloudMachine(comMachine).GetName()),
     811          UIErrorString::formatErrorInfo(comMachine));
     812}
     813
     814void UIMessageCenter::cannotRemoveCloudMachine(const CCloudMachine &comMachine, const CProgress &comProgress) const
     815{
     816    error(0, MessageType_Error,
     817          tr("Failed to remove the cloud virtual machine <b>%1</b>.")
     818             .arg(CCloudMachine(comMachine).GetName()),
     819          UIErrorString::formatErrorInfo(comProgress));
    774820}
    775821
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r83690 r83709  
    265265    void cannotAcquireVirtualBoxParameter(const CVirtualBox &comVBox, QWidget *pParent = 0) const;
    266266    void cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent = 0) const;
     267    void cannotAcquireMachineParameter(const CCloudMachine &comMachine, QWidget *pParent = 0) const;
    267268
    268269    /* API: Global cloud warnings: */
     
    277278    bool confirmMachineItemRemoval(const QStringList &names) const;
    278279    int confirmMachineRemoval(const QList<CMachine> &machines) const;
     280    bool confirmCloudMachineRemoval(const QList<CCloudMachine> &machines) const;
    279281    void cannotRemoveMachine(const CMachine &machine) const;
    280282    void cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const;
     283    void cannotRemoveCloudMachine(const CCloudMachine &comMachine) const;
     284    void cannotRemoveCloudMachine(const CCloudMachine &comMachine, const CProgress &comProgress) const;
    281285    bool warnAboutInaccessibleMedia() const;
    282286    bool confirmDiscardSavedState(const QString &strNames) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r83674 r83709  
    19531953        {
    19541954            return !isGroupSavingInProgress() &&
    1955                    isAtLeastOneItemRemovable(items) &&
    1956                    isItemsLocal(items);
     1955                   isAtLeastOneItemRemovable(items);
    19571956        }
    19581957        case UIActionIndexST_M_Machine_S_AddGroup:
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r83705 r83709  
    11561156    QList<UIChooserItem*> itemsToRemove;
    11571157    QList<CMachine> localMachinesToUnregister;
     1158    QList<CCloudMachine> cloudMachinesToUnregister;
    11581159
    11591160    /* For each selected machine-item: */
     
    11881189        verdicts.insert(uId, fVerdict);
    11891190        if (fVerdict)
    1190             localMachinesToUnregister.append(pItem->node()->toMachineNode()->cache()->toLocal()->machine());
     1191        {
     1192            if (pItem->node()->toMachineNode()->cache()->itemType() == UIVirtualMachineItem::ItemType_Local)
     1193                localMachinesToUnregister.append(pItem->node()->toMachineNode()->cache()->toLocal()->machine());
     1194            else if (pItem->node()->toMachineNode()->cache()->itemType() == UIVirtualMachineItem::ItemType_CloudReal)
     1195                cloudMachinesToUnregister.append(pItem->node()->toMachineNode()->cache()->toCloud()->machine());
     1196        }
    11911197        else
    11921198            itemsToRemove << pItem;
     
    11991205    if (!localMachinesToUnregister.isEmpty())
    12001206        unregisterLocalMachines(localMachinesToUnregister);
     1207    /* If we have something cloud to unregister: */
     1208    if (!cloudMachinesToUnregister.isEmpty())
     1209        unregisterCloudMachines(cloudMachinesToUnregister);
    12011210}
    12021211
     
    17211730}
    17221731
     1732void UIChooserModel::unregisterCloudMachines(const QList<CCloudMachine> &machines)
     1733{
     1734    /* Confirm machine removal: */
     1735    if (!msgCenter().confirmCloudMachineRemoval(machines))
     1736        return;
     1737
     1738    /* Change selection to some close by item: */
     1739    setSelectedItem(findClosestUnselectedItem());
     1740
     1741    /* For every selected machine: */
     1742    foreach (CCloudMachine comMachine, machines)
     1743    {
     1744        /* Remember machine ID: */
     1745        const QUuid uId = comMachine.GetId();
     1746        if (!comMachine.isOk())
     1747        {
     1748            msgCenter().cannotAcquireMachineParameter(comMachine);
     1749            continue;
     1750        }
     1751        /* Prepare unregister progress: */
     1752        CProgress comProgress = comMachine.Unregister();
     1753        if (!comMachine.isOk())
     1754        {
     1755            msgCenter().cannotRemoveCloudMachine(comMachine);
     1756            continue;
     1757        }
     1758        /* And show unregister progress finally: */
     1759        msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_delete_90px.png");
     1760        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     1761        {
     1762            msgCenter().cannotRemoveCloudMachine(comMachine, comProgress);
     1763            continue;
     1764        }
     1765
     1766        // WORKAROUND:
     1767        // Hehey! Now we have to remove deleted VM nodes and then update tree for the main root node
     1768        // ourselves cause there is no corresponding event yet. So we are calling actual handler to do that.
     1769        sltCloudMachineRegistered(QString() /* provider name */,
     1770                                  QString() /* profile name */,
     1771                                  uId /* machine ID */,
     1772                                  false /* registered? */);
     1773    }
     1774}
     1775
    17231776bool UIChooserModel::processDragMoveEvent(QGraphicsSceneDragDropEvent *pEvent)
    17241777{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r83705 r83709  
    3131/* COM includes: */
    3232#include "COMEnums.h"
     33#include "CCloudMachine.h"
    3334#include "CMachine.h"
    3435
     
    370371        /** Unregisters a list of local virtual @a machines. */
    371372        void unregisterLocalMachines(const QList<CMachine> &machines);
     373        /** Unregisters a list of cloud virtual @a machines. */
     374        void unregisterCloudMachines(const QList<CCloudMachine> &machines);
    372375
    373376        /** Processes drag move @a pEvent. */
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