VirtualBox

Changeset 83055 in vbox for trunk


Ignore:
Timestamp:
Feb 11, 2020 8:29:39 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Update cloud machine state on current item change.

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

Legend:

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

    r83024 r83055  
    3232#include "UITabBar.h"
    3333#include "UIToolBar.h"
     34#include "UIVirtualMachineItemCloud.h"
    3435#include "UIVirtualMachineItemLocal.h"
    3536#include "UITools.h"
     
    731732        if (pItem->itemType() == UIVirtualMachineItem::ItemType_Local)
    732733            m_pPaneToolsMachine->setMachine(pItem->toLocal()->machine());
     734        /* Update current cloud machine state: */
     735        if (pItem->itemType() == UIVirtualMachineItem::ItemType_CloudReal)
     736            pItem->toCloud()->updateState(this);
    733737    }
    734738    else
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp

    r83050 r83055  
    2121#include "UIConverter.h"
    2222#include "UIIconPool.h"
     23#include "UIMessageCenter.h"
    2324#include "UIVirtualMachineItemCloud.h"
     25
     26/* COM includes: */
     27#include "CAppliance.h"
     28#include "CVirtualBox.h"
     29#include "CVirtualSystemDescription.h"
    2430
    2531
     
    4551}
    4652
     53void UIVirtualMachineItemCloud::updateState(QWidget *pParent)
     54{
     55    /* Make sure item is of real cloud type: */
     56    AssertReturnVoid(itemType() == ItemType_CloudReal);
     57
     58    /* Update state: */
     59    const QString strState = acquireInstanceInfo(KVirtualSystemDescriptionType_CloudInstanceState, pParent);
     60    QMap<QString, KMachineState> states;
     61    states["RUNNING"] = KMachineState_Running;
     62    states["STOPPED"] = KMachineState_Paused;
     63    m_enmMachineState = states.value(strState, KMachineState_PoweredOff);
     64
     65    /* Recache finally: */
     66    recache();
     67}
     68
     69QString UIVirtualMachineItemCloud::acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent)
     70{
     71    /* Make sure item is of real cloud type and is initialized: */
     72    AssertReturn(itemType() == ItemType_CloudReal, QString());
     73    AssertPtrReturn(m_pCloudMachine, QString());
     74
     75    /* Get VirtualBox object: */
     76    CVirtualBox comVBox = uiCommon().virtualBox();
     77
     78    /* Create appliance: */
     79    CAppliance comAppliance = comVBox.CreateAppliance();
     80    if (!comVBox.isOk())
     81        msgCenter().cannotCreateAppliance(comVBox);
     82    else
     83    {
     84        /* Append it with one (1) description we need: */
     85        comAppliance.CreateVirtualSystemDescriptions(1);
     86        if (!comAppliance.isOk())
     87            msgCenter().cannotCreateVirtualSystemDescription(comAppliance);
     88        else
     89        {
     90            /* Get received description: */
     91            QVector<CVirtualSystemDescription> descriptions = comAppliance.GetVirtualSystemDescriptions();
     92            AssertReturn(!descriptions.isEmpty(), QString());
     93            CVirtualSystemDescription comDescription = descriptions.at(0);
     94
     95            /* Acquire cloud client: */
     96            CCloudClient comCloudClient = m_pCloudMachine->client();
     97
     98            /* Now execute GetInstanceInfo async method: */
     99            CProgress comProgress = comCloudClient.GetInstanceInfo(m_strId, comDescription);
     100            if (!comCloudClient.isOk())
     101                msgCenter().cannotAcquireCloudClientParameter(comCloudClient);
     102            else
     103            {
     104                /* Show "Acquire instance info" progress: */
     105                msgCenter().showModalProgressDialog(comProgress, UICommon::tr("Acquire instance info ..."),
     106                                                    ":/progress_reading_appliance_90px.png", pParent, 0);
     107                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     108                    msgCenter().cannotAcquireCloudClientParameter(comProgress);
     109                else
     110                {
     111                    /* Now acquire description of certain type: */
     112                    QVector<KVirtualSystemDescriptionType> types;
     113                    QVector<QString> refs, origValues, configValues, extraConfigValues;
     114                    comDescription.GetDescriptionByType(enmType, types, refs, origValues, configValues, extraConfigValues);
     115
     116                    /* Return first config value if we have one: */
     117                    AssertReturn(!configValues.isEmpty(), QString());
     118                    return configValues.at(0);
     119                }
     120            }
     121        }
     122    }
     123
     124    /* Return null string by default: */
     125    return QString();
     126}
    47127void UIVirtualMachineItemCloud::recache()
    48128{
     
    66146
    67147        /* Determine VM states: */
    68         m_enmMachineState = KMachineState_PoweredOff;
     148        if (   itemType() == ItemType_CloudFake
     149            || m_enmMachineState == KMachineState_Null)
     150            m_enmMachineState = KMachineState_PoweredOff;
    69151        m_strMachineStateName = gpConverter->toString(m_enmMachineState);
    70152        if (itemType() == ItemType_CloudFake)
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h

    r83050 r83055  
    3333    Q_OBJECT;
    3434
     35signals:
     36
     37    /** Notifies listeners about state change. */
     38    void sigStateChange();
     39
    3540public:
    3641
     
    5661        /** Returns fake cloud item state. */
    5762        FakeCloudItemState fakeCloudItemState() const { return m_enmFakeCloudItemState; }
     63
     64        /** Updates cloud VM state.
     65          * @param  pWidget  Brings parent widget to show messages according to. */
     66        void updateState(QWidget *pParent);
     67        /** Acquires instance info of certain @a enmType.
     68          * @param  pWidget  Brings parent widget to show messages according to. */
     69        QString acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent);
    5870    /** @} */
    5971
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp

    r83050 r83055  
    4141    , m_pCache(new UIVirtualMachineItemCloud(guiCloudMachine))
    4242{
     43    /* Cloud VM item can notify machine node only directly (no console), we have to setup listener: */
     44    connect(static_cast<UIVirtualMachineItemCloud*>(m_pCache), &UIVirtualMachineItemCloud::sigStateChange,
     45            this, &UIChooserNodeMachine::sltHandleStateChange);
    4346    if (parentNode())
    4447        parentNode()->addNode(this, iPosition);
     
    209212        item()->updateItem();
    210213}
     214
     215void UIChooserNodeMachine::sltHandleStateChange()
     216{
     217    /* Update machine-item: */
     218    if (item())
     219        item()->updateItem();
     220}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.h

    r83050 r83055  
    117117    virtual void retranslateUi() /* override */;
    118118
     119private slots:
     120
     121    /** Handles machine state change. */
     122    void sltHandleStateChange();
     123
    119124private:
    120125
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