VirtualBox

Changeset 90405 in vbox


Ignore:
Timestamp:
Jul 29, 2021 1:02:54 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145993
Message:

FE/Qt: bugref:10067: Notification signature for virtual machine save-state progress (in UIVirtualBoxManager) which should now go to center instead of modal dialogs.

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

Legend:

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

    r90394 r90405  
    17071707            continue;
    17081708
    1709         /* Open a session to modify VM state: */
    1710         CSession comSession = uiCommon().openExistingSession(pItem->id());
    1711         if (comSession.isNull())
    1712             return;
    1713 
    1714         /* Get session console: */
    1715         CConsole comConsole = comSession.GetConsole();
    1716         /* Get session machine: */
    1717         CMachine comMachine = comSession.GetMachine();
    1718 
    1719         /* Get local machine item state: */
    1720         UIVirtualMachineItemLocal *pLocalItem = pItem->toLocal();
    1721         AssertPtrReturnVoid(pLocalItem);
    1722         const KMachineState enmState = pLocalItem->machineState();
    1723 
    1724         /* Pause VM first if necessary: */
    1725         if (enmState != KMachineState_Paused)
    1726             comConsole.Pause();
    1727         if (comConsole.isOk())
    1728         {
    1729             /* Prepare machine state saving progress: */
    1730             CProgress comProgress = comMachine.SaveState();
    1731             if (comMachine.isOk())
    1732             {
    1733                 /* Show machine state saving progress: */
    1734                 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_state_save_90px.png");
    1735                 if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1736                     msgCenter().cannotSaveMachineState(comProgress, comMachine.GetName());
    1737             }
    1738             else
    1739                 msgCenter().cannotSaveMachineState(comMachine);
    1740         }
    1741         else
    1742             msgCenter().cannotPauseMachine(comConsole);
    1743 
    1744         /* Unlock machine finally: */
    1745         comSession.UnlockMachine();
     1709        /* Saving VM state: */
     1710        UINotificationProgressMachineSaveState *pNotification = new UINotificationProgressMachineSaveState(pItem->id());
     1711        notificationCenter().append(pNotification);
    17461712    }
    17471713}
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90394 r90405  
    2424#include "UINotificationObjects.h"
    2525
     26/* COM includes: */
     27#include "CConsole.h"
     28
    2629
    2730/*********************************************************************************************************************************
     
    295298
    296299void UINotificationProgressMachineMove::sltHandleProgressFinished()
     300{
     301    /* Unlock session finally: */
     302    m_comSession.UnlockMachine();
     303}
     304
     305
     306/*********************************************************************************************************************************
     307*   Class UINotificationProgressMachineSaveState implementation.                                                                 *
     308*********************************************************************************************************************************/
     309
     310UINotificationProgressMachineSaveState::UINotificationProgressMachineSaveState(const QUuid &uId)
     311    : m_uId(uId)
     312{
     313    connect(this, &UINotificationProgress::sigProgressFinished,
     314            this, &UINotificationProgressMachineSaveState::sltHandleProgressFinished);
     315}
     316
     317QString UINotificationProgressMachineSaveState::name() const
     318{
     319    return UINotificationProgress::tr("Saving VM state ...");
     320}
     321
     322QString UINotificationProgressMachineSaveState::details() const
     323{
     324    return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName);
     325}
     326
     327CProgress UINotificationProgressMachineSaveState::createProgress(COMResult &comResult)
     328{
     329    /* Open a session thru which we will modify the machine: */
     330    m_comSession = uiCommon().openExistingSession(m_uId);
     331    if (m_comSession.isNull())
     332        return CProgress();
     333
     334    /* Get session machine: */
     335    CMachine comMachine = m_comSession.GetMachine();
     336    if (!m_comSession.isOk())
     337    {
     338        comResult = m_comSession;
     339        m_comSession.UnlockMachine();
     340        return CProgress();
     341    }
     342
     343    /* Acquire VM name: */
     344    m_strName = comMachine.GetName();
     345    if (!comMachine.isOk())
     346    {
     347        comResult = comMachine;
     348        m_comSession.UnlockMachine();
     349        return CProgress();
     350    }
     351
     352    /* Get machine state: */
     353    const KMachineState enmState = comMachine.GetState();
     354    if (!comMachine.isOk())
     355    {
     356        comResult = comMachine;
     357        m_comSession.UnlockMachine();
     358        return CProgress();
     359    }
     360
     361    /* If VM isn't yet paused: */
     362    if (enmState != KMachineState_Paused)
     363    {
     364        /* Get session console: */
     365        CConsole comConsole = m_comSession.GetConsole();
     366        if (!m_comSession.isOk())
     367        {
     368            comResult = m_comSession;
     369            m_comSession.UnlockMachine();
     370            return CProgress();
     371        }
     372
     373        /* Pause VM first: */
     374        comConsole.Pause();
     375        if (!comConsole.isOk())
     376        {
     377            comResult = comConsole;
     378            m_comSession.UnlockMachine();
     379            return CProgress();
     380        }
     381    }
     382
     383    /* Initialize progress-wrapper: */
     384    CProgress comProgress = comMachine.SaveState();
     385    /* Store COM result: */
     386    comResult = comMachine;
     387    /* Return progress-wrapper: */
     388    return comProgress;
     389}
     390
     391void UINotificationProgressMachineSaveState::sltHandleProgressFinished()
    297392{
    298393    /* Unlock session finally: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90394 r90405  
    180180public:
    181181
    182     /** Constructs medium move notification-progress.
     182    /** Constructs machine copy notification-progress.
    183183      * @param  comSource     Brings the machine being copied.
    184184      * @param  comTarget     Brings the machine being the target.
     
    263263};
    264264
     265/** UINotificationProgress extension for machine save-state functionality. */
     266class SHARED_LIBRARY_STUFF UINotificationProgressMachineSaveState : public UINotificationProgress
     267{
     268    Q_OBJECT;
     269
     270public:
     271
     272    /** Constructs machine save-state notification-progress.
     273      * @param  comMachine  Brings the machine being saved. */
     274    UINotificationProgressMachineSaveState(const QUuid &uId);
     275
     276protected:
     277
     278    /** Returns object name. */
     279    virtual QString name() const /* override final */;
     280    /** Returns object details. */
     281    virtual QString details() const /* override final */;
     282    /** Creates and returns started progress-wrapper. */
     283    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     284
     285private slots:
     286
     287    /** Handles signal about progress being finished. */
     288    void sltHandleProgressFinished();
     289
     290private:
     291
     292    /** Holds the machine id. */
     293    QUuid     m_uId;
     294    /** Holds the session being opened. */
     295    CSession  m_comSession;
     296    /** Holds the machine name. */
     297    QString   m_strName;
     298};
     299
    265300/** UINotificationProgress extension for machine media remove functionality. */
    266301class SHARED_LIBRARY_STUFF UINotificationProgressMachineMediaRemove : public UINotificationProgress
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