VirtualBox

Changeset 98675 in vbox


Ignore:
Timestamp:
Feb 21, 2023 3:12:32 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155975
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Snapshot related stuff and close VM dialog finally.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98674 r98675  
    349349{
    350350    return uisession()->setPause(fPause);
     351}
     352
     353bool UIMachine::acquireSnapshotCount(ulong &uCount)
     354{
     355    return uisession()->acquireSnapshotCount(uCount);
     356}
     357
     358bool UIMachine::acquireCurrentSnapshotName(QString &strName)
     359{
     360    return uisession()->acquireCurrentSnapshotName(strName);
    351361}
    352362
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98674 r98675  
    246246    /** @} */
    247247
     248    /** @name Snapshot stuff.
     249     ** @{ */
     250        /** Acquires snapshot count. */
     251        bool acquireSnapshotCount(ulong &uCount);
     252        /** Acquires current snapshot name. */
     253        bool acquireCurrentSnapshotName(QString &strName);
     254    /** @} */
     255
    248256    /** @name Host-screen stuff.
    249257     ** @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98669 r98675  
    17941794
    17951795    LogRel(("GUI: User requested to power VM off.\n"));
     1796    ulong uSnapshotCount = 0;
     1797    uimachine()->acquireSnapshotCount(uSnapshotCount);
    17961798    const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid());
    1797     uimachine()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
     1799    uimachine()->powerOff(uSnapshotCount > 0 && fDiscardStateOnPowerOff);
    17981800}
    17991801
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r98669 r98675  
    272272
    273273        /* Append snapshot name: */
    274         if (machine().GetSnapshotCount() > 0)
    275         {
    276             const CSnapshot comSnapshot = machine().GetCurrentSnapshot();
    277             strMachineName += " (" + comSnapshot.GetName() + ")";
     274        ulong uSnapshotCount = 0;
     275        uimachine()->acquireSnapshotCount(uSnapshotCount);
     276        if (uSnapshotCount > 0)
     277        {
     278            QString strCurrentSnapshotName;
     279            uimachine()->acquireCurrentSnapshotName(strCurrentSnapshotName);
     280            strMachineName += " (" + strCurrentSnapshotName + ")";
    278281        }
    279282
     
    423426        bool fInACPIMode = false;
    424427        uimachine()->acquireWhetherGuestEnteredACPIMode(fInACPIMode);
    425         QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, machine(),
     428        QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, uimachine(),
    426429                                                                  fInACPIMode,
    427430                                                                  restrictedCloseActions);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98674 r98675  
    295295        else
    296296            UINotificationMessage::cannotResumeMachine(comConsole);
     297    }
     298    return fSuccess;
     299}
     300
     301bool UISession::acquireSnapshotCount(ulong &uCount)
     302{
     303    CMachine comMachine = machine();
     304    const ULONG uSnapshotCount = comMachine.GetSnapshotCount();
     305    const bool fSuccess = comMachine.isOk();
     306    if (!fSuccess)
     307        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     308    else
     309        uCount = uSnapshotCount;
     310    return fSuccess;
     311}
     312
     313bool UISession::acquireCurrentSnapshotName(QString &strName)
     314{
     315    CMachine comMachine = machine();
     316    CSnapshot comSnapshot = comMachine.GetCurrentSnapshot();
     317    bool fSuccess = comMachine.isOk();
     318    if (!fSuccess)
     319        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     320    {
     321        const QString strSnapshotName = comSnapshot.GetName();
     322        fSuccess = comSnapshot.isOk();
     323        if (!fSuccess)
     324            UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
     325        else
     326            strName = strSnapshotName;
    297327    }
    298328    return fSuccess;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98674 r98675  
    243243    /** @} */
    244244
     245    /** @name Snapshot stuff.
     246     ** @{ */
     247        /** Acquires snapshot count. */
     248        bool acquireSnapshotCount(ulong &uCount);
     249        /** Acquires current snapshot name. */
     250        bool acquireCurrentSnapshotName(QString &strName);
     251    /** @} */
     252
    245253    /** @name Keyboard stuff.
    246254     ** @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r98524 r98675  
    3838
    3939/* GUI includes: */
     40#include "QIDialogButtonBox.h"
     41#include "UICommon.h"
     42#include "UIConverter.h"
     43#include "UIExtraDataManager.h"
    4044#include "UIIconPool.h"
     45#include "UIMachine.h"
     46#include "UIMessageCenter.h"
    4147#include "UIVMCloseDialog.h"
    42 #include "UIExtraDataManager.h"
    43 #include "UIMessageCenter.h"
    44 #include "UIConverter.h"
    45 #include "UICommon.h"
    46 #include "QIDialogButtonBox.h"
    47 
    48 /* COM includes: */
    49 #include "CMachine.h"
    50 #include "CSession.h"
    51 #include "CConsole.h"
    52 #include "CSnapshot.h"
    53 
    54 
    55 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &comMachine,
     48
     49
     50UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, UIMachine *pMachine,
    5651                                 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions)
    5752    : QIWithRetranslateUI<QIDialog>(pParent)
    58     , m_comMachine(comMachine)
     53    , m_pMachine(pMachine)
    5954    , m_fIsACPIEnabled(fIsACPIEnabled)
    6055    , m_restictedCloseActions(restictedCloseActions)
     
    543538{
    544539    /* Get actual machine-state: */
    545     KMachineState machineState = m_comMachine.GetState();
     540    KMachineState enmActualState = KMachineState_Null;
     541    m_pMachine->acquireLiveMachineState(enmActualState);
    546542
    547543    /* Check which close-actions are resticted: */
     
    555551    setButtonVisibleDetach(fIsDetachAllowed);
    556552    /* Make 'Detach' button enabled/disabled depending on machine-state: */
    557     setButtonEnabledDetach(machineState != KMachineState_Stuck);
     553    setButtonEnabledDetach(enmActualState != KMachineState_Stuck);
    558554
    559555    /* Make 'Save state' button visible/hidden depending on restriction: */
    560556    setButtonVisibleSave(fIsStateSavingAllowed);
    561557    /* Make 'Save state' button enabled/disabled depending on machine-state: */
    562     setButtonEnabledSave(machineState != KMachineState_Stuck);
     558    setButtonEnabledSave(enmActualState != KMachineState_Stuck);
    563559
    564560    /* Make 'Shutdown' button visible/hidden depending on restriction: */
    565561    setButtonVisibleShutdown(fIsACPIShutdownAllowed);
    566562    /* Make 'Shutdown' button enabled/disabled depending on console and machine-state: */
    567     setButtonEnabledShutdown(m_fIsACPIEnabled && machineState != KMachineState_Stuck);
     563    setButtonEnabledShutdown(m_fIsACPIEnabled && enmActualState != KMachineState_Stuck);
    568564
    569565    /* Make 'Power off' button visible/hidden depending on restriction: */
    570566    setButtonVisiblePowerOff(fIsPowerOffAllowed);
    571567    /* Make the Restore Snapshot checkbox visible/hidden depending on snapshot count & restrictions: */
    572     setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && m_comMachine.GetSnapshotCount() > 0);
     568    ulong uSnapshotCount = 0;
     569    m_pMachine->acquireSnapshotCount(uSnapshotCount);
     570    setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && uSnapshotCount > 0);
    573571    /* Assign Restore Snapshot checkbox text: */
    574     if (!m_comMachine.GetCurrentSnapshot().isNull())
    575         m_strDiscardCheckBoxText = m_comMachine.GetCurrentSnapshot().GetName();
     572    if (uSnapshotCount > 0)
     573    {
     574        QString strCurrentSnapshotName;
     575        m_pMachine->acquireCurrentSnapshotName(strCurrentSnapshotName);
     576        m_strDiscardCheckBoxText = strCurrentSnapshotName;
     577    }
    576578
    577579    /* Check which radio-button should be initially chosen: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r98524 r98675  
    4747class QRadioButton;
    4848class QVBoxLayout;
    49 class CMachine;
     49class UIMachine;
    5050
    5151/** QIDialog extension to handle Runtime UI close-event. */
     
    5757
    5858    /** Constructs close dialog passing @a pParent to the base-class.
    59       * @param  comMachine             Brings the machine dialog created for.
     59      * @param  pMachine               Brings the machine UI dialog created for.
    6060      * @param  fIsACPIEnabled         Brings whether ACPI is enabled.
    6161      * @param  restictedCloseActions  Brings a set of restricted actions. */
    62     UIVMCloseDialog(QWidget *pParent, CMachine &comMachine,
     62    UIVMCloseDialog(QWidget *pParent, UIMachine *pMachine,
    6363                    bool fIsACPIEnabled, MachineCloseAction restictedCloseActions);
    6464
     
    137137    void updatePixmaps();
    138138
    139     /** Holds the live machine reference. */
    140     CMachine                 &m_comMachine;
     139    /** Holds the machine UI reference. */
     140    UIMachine                *m_pMachine;
    141141    /** Holds whether ACPI is enabled. */
    142142    bool                      m_fIsACPIEnabled;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r98452 r98675  
    566566            /* Get snapshot(s): */
    567567            QString strSnapshotName;
    568             if (machine().GetSnapshotCount() > 0)
     568            ulong uSnapshotCount = 0;
     569            uimachine()->acquireSnapshotCount(uSnapshotCount);
     570            if (uSnapshotCount > 0)
    569571            {
    570                 CSnapshot snapshot = machine().GetCurrentSnapshot();
    571                 strSnapshotName = " (" + snapshot.GetName() + ")";
     572                QString strCurrentSnapshotName;
     573                uimachine()->acquireCurrentSnapshotName(strCurrentSnapshotName);
     574                strSnapshotName = " (" + strCurrentSnapshotName + ")";
    572575            }
    573576            /* Update mini-toolbar text: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r98419 r98675  
    311311            /* Get snapshot(s): */
    312312            QString strSnapshotName;
    313             if (machine().GetSnapshotCount() > 0)
     313            ulong uSnapshotCount = 0;
     314            uimachine()->acquireSnapshotCount(uSnapshotCount);
     315            if (uSnapshotCount > 0)
    314316            {
    315                 CSnapshot snapshot = machine().GetCurrentSnapshot();
    316                 strSnapshotName = " (" + snapshot.GetName() + ")";
     317                QString strCurrentSnapshotName;
     318                uimachine()->acquireCurrentSnapshotName(strCurrentSnapshotName);
     319                strSnapshotName = " (" + strCurrentSnapshotName + ")";
    317320            }
    318321            /* Update mini-toolbar text: */
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