VirtualBox

Changeset 90406 in vbox for trunk/src


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

FE/Qt: bugref:10067: Notification signature for virtual machine power-down 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

    r90405 r90406  
    18641864        if (pItem->itemType() == UIVirtualMachineItemType_Local)
    18651865        {
    1866             /* Open a session to modify VM state: */
    1867             CSession comSession = uiCommon().openExistingSession(pItem->id());
    1868             if (comSession.isNull())
    1869                 break;
    1870 
    1871             /* Get session console: */
    1872             CConsole comConsole = comSession.GetConsole();
    1873             /* Prepare machine power down: */
    1874             CProgress comProgress = comConsole.PowerDown();
    1875             if (!comConsole.isOk())
    1876                 msgCenter().cannotPowerDownMachine(comConsole);
    1877             else
    1878             {
    1879                 /* Show machine power down progress: */
    1880                 msgCenter().showModalProgressDialog(comProgress, pItem->name(), ":/progress_poweroff_90px.png");
    1881                 if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1882                     msgCenter().cannotPowerDownMachine(comProgress, pItem->name());
    1883                 else
    1884                 {
    1885                     /* Sanity check: */
    1886                     AssertPtrReturnVoid(pItem->toLocal());
    1887                     /* Restore snapshot if requested: */
    1888                     const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(pItem->id());
    1889                     if (fDiscardStateOnPowerOff && pItem->toLocal()->snapshotCount() > 0)
    1890                         uiCommon().restoreCurrentSnapshot(pItem->id());
    1891                 }
    1892             }
    1893 
    1894             /* Unlock machine finally: */
    1895             comSession.UnlockMachine();
     1866            /* Powering VM down: */
     1867            UINotificationProgressMachinePowerDown *pNotification = new UINotificationProgressMachinePowerDown(pItem->id());
     1868            notificationCenter().append(pNotification);
    18961869        }
    18971870        /* For real cloud machine: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90405 r90406  
    397397
    398398/*********************************************************************************************************************************
     399*   Class UINotificationProgressMachinePowerDown implementation.                                                                 *
     400*********************************************************************************************************************************/
     401
     402UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const QUuid &uId)
     403    : m_uId(uId)
     404{
     405    connect(this, &UINotificationProgress::sigProgressFinished,
     406            this, &UINotificationProgressMachinePowerDown::sltHandleProgressFinished);
     407}
     408
     409QString UINotificationProgressMachinePowerDown::name() const
     410{
     411    return UINotificationProgress::tr("Powering VM down ...");
     412}
     413
     414QString UINotificationProgressMachinePowerDown::details() const
     415{
     416    return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName);
     417}
     418
     419CProgress UINotificationProgressMachinePowerDown::createProgress(COMResult &comResult)
     420{
     421    /* Open a session thru which we will modify the machine: */
     422    m_comSession = uiCommon().openExistingSession(m_uId);
     423    if (m_comSession.isNull())
     424        return CProgress();
     425
     426    /* Get session machine: */
     427    CMachine comMachine = m_comSession.GetMachine();
     428    if (!m_comSession.isOk())
     429    {
     430        comResult = m_comSession;
     431        m_comSession.UnlockMachine();
     432        return CProgress();
     433    }
     434
     435    /* Acquire VM name: */
     436    m_strName = comMachine.GetName();
     437    if (!comMachine.isOk())
     438    {
     439        comResult = comMachine;
     440        m_comSession.UnlockMachine();
     441        return CProgress();
     442    }
     443
     444    /* Get session console: */
     445    CConsole comConsole = m_comSession.GetConsole();
     446    if (!m_comSession.isOk())
     447    {
     448        comResult = m_comSession;
     449        m_comSession.UnlockMachine();
     450        return CProgress();
     451    }
     452
     453    /* Initialize progress-wrapper: */
     454    CProgress comProgress = comConsole.PowerDown();
     455    /* Store COM result: */
     456    comResult = comConsole;
     457    /* Return progress-wrapper: */
     458    return comProgress;
     459}
     460
     461void UINotificationProgressMachinePowerDown::sltHandleProgressFinished()
     462{
     463    /* Unlock session finally: */
     464    m_comSession.UnlockMachine();
     465}
     466
     467
     468/*********************************************************************************************************************************
    399469*   Class UINotificationProgressMachineMediaRemove implementation.                                                               *
    400470*********************************************************************************************************************************/
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90405 r90406  
    298298};
    299299
     300/** UINotificationProgress extension for machine power-down functionality. */
     301class SHARED_LIBRARY_STUFF UINotificationProgressMachinePowerDown : public UINotificationProgress
     302{
     303    Q_OBJECT;
     304
     305public:
     306
     307    /** Constructs machine power-down notification-progress.
     308      * @param  comMachine  Brings the machine being powered-down. */
     309    UINotificationProgressMachinePowerDown(const QUuid &uId);
     310
     311protected:
     312
     313    /** Returns object name. */
     314    virtual QString name() const /* override final */;
     315    /** Returns object details. */
     316    virtual QString details() const /* override final */;
     317    /** Creates and returns started progress-wrapper. */
     318    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     319
     320private slots:
     321
     322    /** Handles signal about progress being finished. */
     323    void sltHandleProgressFinished();
     324
     325private:
     326
     327    /** Holds the machine id. */
     328    QUuid     m_uId;
     329    /** Holds the session being opened. */
     330    CSession  m_comSession;
     331    /** Holds the machine name. */
     332    QString   m_strName;
     333};
     334
    300335/** UINotificationProgress extension for machine media remove functionality. */
    301336class SHARED_LIBRARY_STUFF UINotificationProgressMachineMediaRemove : public UINotificationProgress
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette