VirtualBox

Changeset 90869 in vbox for trunk/src


Ignore:
Timestamp:
Aug 25, 2021 10:21:27 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Reworking r145997; UINotificationProgressMachinePowerDown should now be usable from within Runtime UI as well.

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

Legend:

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

    r90855 r90869  
    18211821            /* Powering VM down: */
    18221822            UINotificationProgressMachinePowerDown *pNotification =
    1823                 new UINotificationProgressMachinePowerDown(pItem->id());
     1823                new UINotificationProgressMachinePowerDown(pItem->toLocal()->machine());
    18241824            gpNotificationCenter->append(pNotification);
    18251825        }
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90856 r90869  
    976976*********************************************************************************************************************************/
    977977
    978 UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const QUuid &uId)
    979     : m_uId(uId)
     978UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const CMachine &comMachine)
     979    : m_comMachine(comMachine)
    980980{
    981981    connect(this, &UINotificationProgress::sigProgressFinished,
     
    983983}
    984984
     985UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const CConsole &comConsole)
     986    : m_comConsole(comConsole)
     987{
     988    connect(this, &UINotificationProgress::sigProgressFinished,
     989            this, &UINotificationProgressMachinePowerDown::sltHandleProgressFinished);
     990}
     991
    985992QString UINotificationProgressMachinePowerDown::name() const
    986993{
     
    9951002CProgress UINotificationProgressMachinePowerDown::createProgress(COMResult &comResult)
    9961003{
    997     /* Open a session thru which we will modify the machine: */
    998     m_comSession = uiCommon().openExistingSession(m_uId);
    999     if (m_comSession.isNull())
    1000         return CProgress();
    1001 
    1002     /* Get session machine: */
    1003     CMachine comMachine = m_comSession.GetMachine();
    1004     if (!m_comSession.isOk())
    1005     {
    1006         comResult = m_comSession;
    1007         m_comSession.UnlockMachine();
     1004    /* Prepare machine to power off: */
     1005    CMachine comMachine = m_comMachine;
     1006
     1007    /* For Runtime UI: */
     1008    switch (uiCommon().uiType())
     1009    {
     1010        case UICommon::UIType_RuntimeUI:
     1011        {
     1012            /* Acquire VM: */
     1013            AssertReturn(m_comConsole.isNotNull(), CProgress());
     1014            comMachine = m_comConsole.GetMachine();
     1015            if (!m_comConsole.isOk())
     1016            {
     1017                comResult = m_comConsole;
     1018                return CProgress();
     1019            }
     1020
     1021            break;
     1022        }
     1023        default:
     1024            break;
     1025    }
     1026
     1027    /* Acquire VM id: */
     1028    const QUuid uId = comMachine.GetId();
     1029    if (!comMachine.isOk())
     1030    {
     1031        comResult = comMachine;
    10081032        return CProgress();
    10091033    }
     
    10141038    {
    10151039        comResult = comMachine;
     1040        return CProgress();
     1041    }
     1042
     1043    /* Prepare console to power off: */
     1044    CConsole comConsole = m_comConsole;
     1045
     1046    /* For Manager UI: */
     1047    switch (uiCommon().uiType())
     1048    {
     1049        case UICommon::UIType_SelectorUI:
     1050        {
     1051            /* Open a session thru which we will modify the machine: */
     1052            m_comSession = uiCommon().openExistingSession(uId);
     1053            if (m_comSession.isNull())
     1054                return CProgress();
     1055
     1056            /* Get session machine: */
     1057            comMachine = m_comSession.GetMachine();
     1058            if (!m_comSession.isOk())
     1059            {
     1060                comResult = m_comSession;
     1061                m_comSession.UnlockMachine();
     1062                return CProgress();
     1063            }
     1064
     1065            /* Get session console: */
     1066            comConsole = m_comSession.GetConsole();
     1067            if (!m_comSession.isOk())
     1068            {
     1069                comResult = m_comSession;
     1070                m_comSession.UnlockMachine();
     1071                return CProgress();
     1072            }
     1073
     1074            break;
     1075        }
     1076        default:
     1077            break;
     1078    }
     1079
     1080    /* Initialize progress-wrapper: */
     1081    CProgress comProgress = comConsole.PowerDown();
     1082    /* Store COM result: */
     1083    comResult = comConsole;
     1084    /* Return progress-wrapper: */
     1085    return comProgress;
     1086}
     1087
     1088void UINotificationProgressMachinePowerDown::sltHandleProgressFinished()
     1089{
     1090    /* Unlock session finally: */
     1091    if (m_comSession.isNotNull())
    10161092        m_comSession.UnlockMachine();
    1017         return CProgress();
    1018     }
    1019 
    1020     /* Get session console: */
    1021     CConsole comConsole = m_comSession.GetConsole();
    1022     if (!m_comSession.isOk())
    1023     {
    1024         comResult = m_comSession;
    1025         m_comSession.UnlockMachine();
    1026         return CProgress();
    1027     }
    1028 
    1029     /* Initialize progress-wrapper: */
    1030     CProgress comProgress = comConsole.PowerDown();
    1031     /* Store COM result: */
    1032     comResult = comConsole;
    1033     /* Return progress-wrapper: */
    1034     return comProgress;
    1035 }
    1036 
    1037 void UINotificationProgressMachinePowerDown::sltHandleProgressFinished()
    1038 {
    1039     /* Unlock session finally: */
    1040     m_comSession.UnlockMachine();
    10411093}
    10421094
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90856 r90869  
    3434#include "CCloudClient.h"
    3535#include "CCloudMachine.h"
     36#include "CConsole.h"
    3637#include "CExtPackFile.h"
    3738#include "CExtPackManager.h"
     
    4748/* Forward declarations: */
    4849class CAudioAdapter;
    49 class CConsole;
    5050class CEmulatedUSB;
    5151class CNetworkAdapter;
     
    567567
    568568    /** Constructs machine power-down notification-progress.
    569       * @param  uId  Brings the machine id. */
    570     UINotificationProgressMachinePowerDown(const QUuid &uId);
    571 
    572 protected:
    573 
    574     /** Returns object name. */
    575     virtual QString name() const /* override final */;
    576     /** Returns object details. */
    577     virtual QString details() const /* override final */;
    578     /** Creates and returns started progress-wrapper. */
    579     virtual CProgress createProgress(COMResult &comResult) /* override final */;
    580 
    581 private slots:
    582 
    583     /** Handles signal about progress being finished. */
    584     void sltHandleProgressFinished();
    585 
    586 private:
    587 
    588     /** Holds the machine id. */
    589     QUuid     m_uId;
     569      * @param  comMachine  Brings the machine being powered off. */
     570    UINotificationProgressMachinePowerDown(const CMachine &comMachine);
     571    /** Constructs machine power-down notification-progress.
     572      * @param  comConsole  Brings the console of machine being powered off. */
     573    UINotificationProgressMachinePowerDown(const CConsole &comConsole);
     574
     575protected:
     576
     577    /** Returns object name. */
     578    virtual QString name() const /* override final */;
     579    /** Returns object details. */
     580    virtual QString details() const /* override final */;
     581    /** Creates and returns started progress-wrapper. */
     582    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     583
     584private slots:
     585
     586    /** Handles signal about progress being finished. */
     587    void sltHandleProgressFinished();
     588
     589private:
     590
     591    /** Holds the machine being powered off. */
     592    CMachine  m_comMachine;
     593    /** Holds the console of machine being powered off. */
     594    CConsole  m_comConsole;
    590595    /** Holds the session being opened. */
    591596    CSession  m_comSession;
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