VirtualBox

Changeset 45736 in vbox


Ignore:
Timestamp:
Apr 25, 2013 3:59:59 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85294
Message:

FE/Qt: Added 'save-state' and 'power-off' Runtime UI actions; Added a possibility to predefine close-action through the extra-data 'GUI/DefaultCloseAction' string flag; Performed a lot of related functionality cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc

    r45605 r45736  
    245245        <file alias="ok_16px.png">images/ok_16px.png</file>
    246246        <file alias="cancel_16px.png">images/cancel_16px.png</file>
     247        <file alias="save_state_16px.png">images/save_state_16px.png</file>
     248        <file alias="save_state_disabled_16px.png">images/save_state_disabled_16px.png</file>
    247249    </qresource>
    248250</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r45402 r45736  
    6464const char* UIDefs::GUI_SaveMountedAtRuntime = "GUI/SaveMountedAtRuntime";
    6565const char* UIDefs::GUI_PassCAD = "GUI/PassCAD";
     66const char* UIDefs::GUI_DefaultCloseAction = "GUI/DefaultCloseAction";
    6667
    6768/* Mini tool-bar definitions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r45402 r45736  
    141141    extern const char* GUI_SaveMountedAtRuntime;
    142142    extern const char* GUI_PassCAD;
     143    extern const char* GUI_DefaultCloseAction;
    143144
    144145    /* Mini tool-bar declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r44448 r45736  
    343343};
    344344
     345class UIActionSimplePerformSave : public UIActionSimple
     346{
     347    Q_OBJECT;
     348
     349public:
     350
     351    UIActionSimplePerformSave(UIActionPool *pParent)
     352        : UIActionSimple(pParent, ":/save_state_16px.png", ":/save_state_disabled_16px.png")
     353    {
     354        retranslateUi();
     355    }
     356
     357protected:
     358
     359    QString shortcutExtraDataID() const
     360    {
     361        return QString("Save");
     362    }
     363
     364    void retranslateUi()
     365    {
     366        setName(QApplication::translate("UIActionPool", "Save State"));
     367        setStatusTip(QApplication::translate("UIActionPool", "Save the machine state of the virtual machine"));
     368    }
     369};
     370
    345371class UIActionSimplePerformShutdown : public UIActionSimple
    346372{
     
    375401        setName(QApplication::translate("UIActionPool", "ACPI Sh&utdown"));
    376402        setStatusTip(QApplication::translate("UIActionPool", "Send the ACPI Power Button press event to the virtual machine"));
     403    }
     404};
     405
     406class UIActionSimplePerformPowerOff : public UIActionSimple
     407{
     408    Q_OBJECT;
     409
     410public:
     411
     412    UIActionSimplePerformPowerOff(UIActionPool *pParent)
     413        : UIActionSimple(pParent, ":/poweroff_16px.png", ":/poweroff_disabled_16px.png")
     414    {
     415        retranslateUi();
     416    }
     417
     418protected:
     419
     420    QString shortcutExtraDataID() const
     421    {
     422        return QString("PowerOff");
     423    }
     424
     425    void retranslateUi()
     426    {
     427        setName(QApplication::translate("UIActionPool", "Po&wer Off"));
     428        setStatusTip(QApplication::translate("UIActionPool", "Power off the virtual machine"));
    377429    }
    378430};
     
    10771129    m_pool[UIActionIndexRuntime_Toggle_Pause] = new UIActionTogglePause(this);
    10781130    m_pool[UIActionIndexRuntime_Simple_Reset] = new UIActionSimplePerformReset(this);
     1131    m_pool[UIActionIndexRuntime_Simple_Save] = new UIActionSimplePerformSave(this);
    10791132    m_pool[UIActionIndexRuntime_Simple_Shutdown] = new UIActionSimplePerformShutdown(this);
     1133    m_pool[UIActionIndexRuntime_Simple_PowerOff] = new UIActionSimplePerformPowerOff(this);
    10801134    m_pool[UIActionIndexRuntime_Simple_Close] = new UIActionSimplePerformClose(this);
    10811135
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r44448 r45736  
    4040    UIActionIndexRuntime_Toggle_Pause,
    4141    UIActionIndexRuntime_Simple_Reset,
     42    UIActionIndexRuntime_Simple_Save,
    4243    UIActionIndexRuntime_Simple_Shutdown,
     44    UIActionIndexRuntime_Simple_PowerOff,
    4345    UIActionIndexRuntime_Simple_Close,
    4446
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r45432 r45736  
    297297#endif /* Q_WS_MAC */
    298298
     299void UIMachineLogic::saveState()
     300{
     301    /* Prevent auto-closure: */
     302    setPreventAutoClose(true);
     303
     304    /* Was the step successful? */
     305    bool fSuccess = true;
     306    /* If VM is not paused, we should pause it: */
     307    bool fWasPaused = uisession()->isPaused();
     308    if (fSuccess && !fWasPaused)
     309        fSuccess = uisession()->pause();
     310    /* Save-state: */
     311    if (fSuccess)
     312        fSuccess = uisession()->saveState();
     313
     314    /* Allow auto-closure: */
     315    setPreventAutoClose(false);
     316
     317    /* Manually close Runtime UI: */
     318    if (fSuccess)
     319        uisession()->closeRuntimeUI();
     320}
     321
     322void UIMachineLogic::shutdown()
     323{
     324    /* Warn the user about ACPI is not available if so: */
     325    CConsole console = session().GetConsole();
     326    if (!console.GetGuestEnteredACPIMode())
     327        return msgCenter().cannotSendACPIToMachine();
     328
     329    /* Shutdown: */
     330    uisession()->shutdown();
     331}
     332
     333void UIMachineLogic::powerOff(bool fDiscardingState)
     334{
     335    /* Prevent auto-closure: */
     336    setPreventAutoClose(true);
     337
     338    /* Was the step successful? */
     339    bool fSuccess = true;
     340    /* Power-off: */
     341    bool fServerCrashed = false;
     342    fSuccess = uisession()->powerOff(fDiscardingState, fServerCrashed) || fServerCrashed;
     343
     344    /* Allow auto-closure: */
     345    setPreventAutoClose(false);
     346
     347    /* Manually close Runtime UI: */
     348    if (fSuccess)
     349        uisession()->closeRuntimeUI();
     350}
     351
    299352void UIMachineLogic::sltMachineStateChanged()
    300353{
     
    305358    m_pRunningActions->setEnabled(uisession()->isRunning());
    306359    m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused());
     360    m_pRunningOrPausedOrStackedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused() || uisession()->isStuck());
    307361
    308362    switch (state)
    309363    {
    310         case KMachineState_Stuck: // TODO: Test it!
    311         {
    312             /* Prevent machine view from resizing: */
     364        case KMachineState_Stuck:
     365        {
     366            /* Prevent machine-view from resizing: */
    313367            uisession()->setGuestResizeIgnored(true);
    314 
    315             /* Get variables: */
    316             CConsole console = session().GetConsole();
    317             CMachine machine = console.GetMachine();
    318             QString strMachineName = machine.GetName();
    319             QString strLogFolder = machine.GetLogFolder();
    320 
     368            /* Get log-folder: */
     369            QString strLogFolder = session().GetMachine().GetLogFolder();
    321370            /* Take the screenshot for debugging purposes: */
    322371            takeScreenshot(strLogFolder + "/VBox.png", "png");
    323 
    324372            /* Warn the user about GURU meditation: */
    325373            if (msgCenter().remindAboutGuruMeditation(QDir::toNativeSeparators(strLogFolder)))
    326             {
    327                 /* Prepare machine power down progress: */
    328                 CProgress progress = console.PowerDown();
    329                 if (console.isOk())
    330                 {
    331                     /* Show machine power down progress: */
    332                     msgCenter().showModalProgressDialog(progress, strMachineName, ":/progress_poweroff_90px.png");
    333                     if (!progress.isOk() || progress.GetResultCode() != 0)
    334                         msgCenter().cannotPowerDownMachine(progress, strMachineName);
    335                 }
    336                 else
    337                     msgCenter().cannotPowerDownMachine(console);
    338             }
     374                powerOff(session().GetMachine().GetSnapshotCount() > 0);
    339375            break;
    340376        }
     
    480516    , m_pRunningActions(0)
    481517    , m_pRunningOrPausedActions(0)
     518    , m_pRunningOrPausedOrStackedActions(0)
    482519    , m_pSharedClipboardActions(0)
    483520    , m_pDragAndDropActions(0)
     
    631668    m_pRunningOrPausedActions->setExclusive(false);
    632669
     670    /* Create group for all actions that are enabled when the VM is running or paused or stucked.
     671     * Note that only actions whose enabled state depends exclusively on the
     672     * execution state of the VM are added to this group. */
     673    m_pRunningOrPausedOrStackedActions = new QActionGroup(this);
     674    m_pRunningOrPausedOrStackedActions->setExclusive(false);
     675
    633676    /* Move actions into running actions group: */
    634677    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));
     
    645688
    646689    /* Move actions into running-n-paused actions group: */
     690    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Save));
    647691    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    648692    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
     
    663707    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));
    664708    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));
     709
     710    /* Move actions into running-n-paused-n-stucked actions group: */
     711    m_pRunningOrPausedOrStackedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_PowerOff));
    665712}
    666713
     
    688735    connect(gActionPool->action(UIActionIndexRuntime_Simple_Reset), SIGNAL(triggered()),
    689736            this, SLOT(sltReset()));
     737    connect(gActionPool->action(UIActionIndexRuntime_Simple_Save), SIGNAL(triggered()),
     738            this, SLOT(sltSaveState()));
    690739    connect(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown), SIGNAL(triggered()),
    691             this, SLOT(sltACPIShutdown()));
     740            this, SLOT(sltShutdown()));
     741    connect(gActionPool->action(UIActionIndexRuntime_Simple_PowerOff), SIGNAL(triggered()),
     742            this, SLOT(sltPowerOff()));
    692743    connect(gActionPool->action(UIActionIndexRuntime_Simple_Close), SIGNAL(triggered()),
    693744            this, SLOT(sltClose()));
     
    11511202}
    11521203
    1153 void UIMachineLogic::sltACPIShutdown()
    1154 {
    1155     /* Get console: */
    1156     CConsole console = session().GetConsole();
    1157 
    1158     /* Warn the user about ACPI is not available if so: */
    1159     if (!console.GetGuestEnteredACPIMode())
    1160         return msgCenter().cannotSendACPIToMachine();
    1161 
    1162     /* Send ACPI shutdown signal, warn if failed: */
    1163     console.PowerButton();
    1164     if (!console.isOk())
    1165         msgCenter().cannotACPIShutdownMachine(console);
     1204void UIMachineLogic::sltSaveState()
     1205{
     1206    /* Make sure machine is in one of the allowed states: */
     1207    if (!uisession()->isRunning() && !uisession()->isPaused())
     1208    {
     1209        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     1210        return;
     1211    }
     1212
     1213    saveState();
     1214}
     1215
     1216void UIMachineLogic::sltShutdown()
     1217{
     1218    /* Make sure machine is in one of the allowed states: */
     1219    if (!uisession()->isRunning())
     1220    {
     1221        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     1222        return;
     1223    }
     1224
     1225    shutdown();
     1226}
     1227
     1228void UIMachineLogic::sltPowerOff()
     1229{
     1230    /* Make sure machine is in one of the allowed states: */
     1231    if (!uisession()->isRunning() && !uisession()->isPaused() && !uisession()->isStuck())
     1232    {
     1233        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     1234        return;
     1235    }
     1236
     1237    powerOff(session().GetMachine().GetSnapshotCount() > 0);
    11661238}
    11671239
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r44982 r45736  
    8989#endif /* Q_WS_MAC */
    9090
     91    /* API: Close actions: */
     92    void saveState();
     93    void shutdown();
     94    void powerOff(bool fDiscardingState);
     95
    9196protected slots:
    9297
     
    175180    void sltReset();
    176181    void sltPause(bool fOn);
    177     void sltACPIShutdown();
     182    void sltSaveState();
     183    void sltShutdown();
     184    void sltPowerOff();
    178185    void sltClose();
    179186
     
    224231    QActionGroup *m_pRunningActions;
    225232    QActionGroup *m_pRunningOrPausedActions;
     233    QActionGroup *m_pRunningOrPausedOrStackedActions;
    226234    QActionGroup *m_pSharedClipboardActions;
    227235    QActionGroup *m_pDragAndDropActions;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r44529 r45736  
    208208    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
    209209    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
     210    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Save));
    210211    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
     212    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_PowerOff));
    211213#ifndef Q_WS_MAC
    212214    pMenu->addSeparator();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r45432 r45736  
    244244void UIMachineWindow::closeEvent(QCloseEvent *pEvent)
    245245{
    246     /* Always ignore close-event: */
     246    /* Always ignore close-event first: */
    247247    pEvent->ignore();
    248248
    249     /* Should we close Runtime UI? */
    250     bool fCloseRuntimeUI = false;
    251 
    252249    /* Make sure machine is in one of the allowed states: */
    253     KMachineState machineState = uisession()->machineState();
    254     if (   machineState != KMachineState_Running
    255         && machineState != KMachineState_Paused
    256         && machineState != KMachineState_Stuck
    257         && machineState != KMachineState_LiveSnapshotting
    258         && machineState != KMachineState_Teleporting
    259         && machineState != KMachineState_TeleportingPausedVM)
     250    if (!uisession()->isRunning() && !uisession()->isPaused() && !uisession()->isStuck())
    260251        return;
    261252
    262     /* Get the machine: */
    263     CMachine machineCopy = machine();
    264 
    265253    /* If there is a close hook script defined: */
    266     const QString& strScript = machineCopy.GetExtraData(GUI_CloseActionHook);
     254    QString strScript = machine().GetExtraData(GUI_CloseActionHook);
    267255    if (!strScript.isEmpty())
    268256    {
    269257        /* Execute asynchronously and leave: */
    270         QProcess::startDetached(strScript, QStringList() << machineCopy.GetId());
     258        QProcess::startDetached(strScript, QStringList() << machine().GetId());
    271259        return;
    272260    }
    273261
    274     /* Prepare close-dialog: */
    275     QWidget *pParentDlg = windowManager().realParentWindow(this);
    276     QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, machineCopy, session());
    277     windowManager().registerNewParent(pCloseDlg, pParentDlg);
    278 
    279     /* Makes sure the dialog is valid: */
    280     if (!pCloseDlg->isValid())
    281     {
    282         /* Destroy and leave: */
     262    /* Choose the close action: */
     263    UIVMCloseDialog::ResultCode closeAction = UIVMCloseDialog::ResultCode_Cancel;
     264
     265    /* If there IS default close-action defined: */
     266    QString strDefaultAction = machine().GetExtraData(GUI_DefaultCloseAction);
     267    if (!strDefaultAction.isEmpty())
     268    {
     269        /* Parse the close-action which was defined: */
     270        closeAction = UIVMCloseDialog::parseResultCode(strDefaultAction);
     271        /* If VM is stuck, and the default close-action is not 'power-off',
     272         * we should ask the user about what to do: */
     273        if (uisession()->isStuck() &&
     274            closeAction != UIVMCloseDialog::ResultCode_PowerOff)
     275            closeAction = UIVMCloseDialog::ResultCode_Cancel;
     276        /* If the default-action is 'power-off',
     277         * we should check if its possible to discard machine-state: */
     278        if (closeAction == UIVMCloseDialog::ResultCode_PowerOff &&
     279            machine().GetSnapshotCount() > 0)
     280            closeAction = UIVMCloseDialog::ResultCode_PowerOff_With_Discarding;
     281    }
     282
     283    /* If the close-action still undefined: */
     284    if (closeAction == UIVMCloseDialog::ResultCode_Cancel)
     285    {
     286        /* Prepare close-dialog: */
     287        QWidget *pParentDlg = windowManager().realParentWindow(this);
     288        QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, machine(), session());
     289
     290        /* Make sure close-dialog is valid: */
     291        if (pCloseDlg->isValid())
     292        {
     293            /* If VM is not paused and not stuck, we should pause it first: */
     294            bool fWasPaused = uisession()->isPaused() || uisession()->isStuck();
     295            if (fWasPaused || uisession()->pause())
     296            {
     297                /* Show close-dialog to let the user make the choice: */
     298                windowManager().registerNewParent(pCloseDlg, pParentDlg);
     299                closeAction = (UIVMCloseDialog::ResultCode)pCloseDlg->exec();
     300
     301                /* Make sure the dialog still valid: */
     302                if (!pCloseDlg)
     303                    return;
     304
     305                /* If VM was not paused before but paused now,
     306                 * we should resume it if user canceled dialog or chosen shutdown: */
     307                if (!fWasPaused && uisession()->isPaused() &&
     308                    (closeAction == UIVMCloseDialog::ResultCode_Cancel ||
     309                     closeAction == UIVMCloseDialog::ResultCode_Shutdown))
     310                {
     311                    /* If we unable to resume VM, cancel closing: */
     312                    if (!uisession()->unpause())
     313                        closeAction = UIVMCloseDialog::ResultCode_Cancel;
     314                }
     315            }
     316        }
     317        else
     318        {
     319            /* Else user misconfigured .vbox file, 'power-off' will be the action: */
     320            closeAction = UIVMCloseDialog::ResultCode_PowerOff;
     321        }
     322
     323        /* Cleanup close-dialog: */
    283324        delete pCloseDlg;
    284         return;
    285     }
    286 
    287     /* This flag will keep the status of every further logical operation: */
    288     bool fSuccess = true;
    289     /* This flag determines if VM was paused before we called for close-event: */
    290     bool fWasPaused = uisession()->isPaused();
    291 
    292     if (fSuccess)
    293     {
    294         /* Pause VM if necessary: */
    295         if (!fWasPaused)
    296             fSuccess = uisession()->pause();
    297     }
    298 
    299     if (fSuccess)
    300     {
    301         /* Preventing auto-closure: */
    302         machineLogic()->setPreventAutoClose(true);
    303 
    304         /* Show the close-dialog: */
    305         UIVMCloseDialog::ResultCode dialogResult = (UIVMCloseDialog::ResultCode)pCloseDlg->exec();
    306 
    307         /* Destroy the dialog early: */
    308         delete pCloseDlg;
    309 
    310         /* Was the dialog accepted? */
    311         if (dialogResult != UIVMCloseDialog::ResultCode_Cancel)
    312         {
    313             switch (dialogResult)
    314             {
    315                 case UIVMCloseDialog::ResultCode_Save:
    316                 {
    317                     fSuccess = uisession()->saveState();
    318                     fCloseRuntimeUI = fSuccess;
    319                     break;
    320                 }
    321                 case UIVMCloseDialog::ResultCode_Shutdown:
    322                 {
    323                     fSuccess = uisession()->shutDown();
    324                     if (fSuccess)
    325                         fWasPaused = true;
    326                     break;
    327                 }
    328                 case UIVMCloseDialog::ResultCode_PowerOff:
    329                 case UIVMCloseDialog::ResultCode_PowerOff_With_Discarding:
    330                 {
    331                     bool fServerCrashed = false;
    332                     fSuccess = uisession()->powerOff(dialogResult == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding,
    333                                                      fServerCrashed);
    334                     fCloseRuntimeUI = fSuccess || fServerCrashed;
    335                     break;
    336                 }
    337                 default:
    338                     break;
    339             }
    340         }
    341 
    342         /* Restore the running state if needed: */
    343         if (fSuccess && !fCloseRuntimeUI && !fWasPaused && uisession()->machineState() == KMachineState_Paused)
    344             uisession()->unpause();
    345 
    346         /* Allowing auto-closure: */
    347         machineLogic()->setPreventAutoClose(false);
    348     }
    349 
    350     /* We've received a request to close Runtime UI: */
    351     if (fCloseRuntimeUI)
    352         uisession()->closeRuntimeUI();
     325    }
     326
     327    /* Depending on chosen result: */
     328    switch (closeAction)
     329    {
     330        case UIVMCloseDialog::ResultCode_Save:
     331        {
     332            /* Save VM state: */
     333            machineLogic()->saveState();
     334            break;
     335        }
     336        case UIVMCloseDialog::ResultCode_Shutdown:
     337        {
     338            /* Shutdown VM: */
     339            machineLogic()->shutdown();
     340            break;
     341        }
     342        case UIVMCloseDialog::ResultCode_PowerOff:
     343        case UIVMCloseDialog::ResultCode_PowerOff_With_Discarding:
     344        {
     345            /* Power VM off: */
     346            machineLogic()->powerOff(closeAction == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding);
     347            break;
     348        }
     349        default:
     350            break;
     351    }
    353352}
    354353
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r45425 r45736  
    338338}
    339339
    340 bool UISession::shutDown()
    341 {
    342     /* Resume VM to let it grab the ACPI shutdown signal: */
    343     if (!unpause())
    344     {
    345         /* Failed in console: */
    346         return false;
    347     }
     340bool UISession::shutdown()
     341{
    348342    /* Send ACPI shutdown signal if possible: */
    349343    CConsole console = m_session.GetConsole();
     
    369363        /* Show the power-off progress: */
    370364        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png");
    371         if (progress.GetResultCode() == 0)
     365        if (progress.isOk() && progress.GetResultCode() == 0)
    372366        {
    373367            /* Discard the current state if requested: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r45224 r45736  
    9090    void powerUp();
    9191    bool saveState();
    92     bool shutDown();
     92    bool shutdown();
    9393    bool powerOff(bool fIncludingDiscard, bool &fServerCrashed);
    9494    void closeRuntimeUI();
     
    113113                                    machineState() == KMachineState_Teleporting ||
    114114                                    machineState() == KMachineState_LiveSnapshotting; }
     115    bool isStuck() const { return machineState() == KMachineState_Stuck; }
    115116    bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
    116117    bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRuntimeMediumsChanging; }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r45226 r45736  
    6262    /* Retranslate finally: */
    6363    retranslateUi();
     64}
     65
     66/* static */
     67UIVMCloseDialog::ResultCode UIVMCloseDialog::parseResultCode(const QString &strCloseAction)
     68{
     69    ResultCode resultCode = ResultCode_Cancel;
     70    if (!strCloseAction.compare("Save", Qt::CaseInsensitive))
     71        resultCode = ResultCode_Save;
     72    else if (!strCloseAction.compare("Shutdown", Qt::CaseInsensitive))
     73        resultCode = ResultCode_Shutdown;
     74    else if (!strCloseAction.compare("PowerOff", Qt::CaseInsensitive))
     75        resultCode = ResultCode_PowerOff;
     76    return resultCode;
    6477}
    6578
     
    210223                        /* Configure icon: */
    211224                        m_pSaveIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    212                         m_pSaveIcon->setPixmap(QPixmap(":/state_saved_16px.png"));
     225                        m_pSaveIcon->setPixmap(QPixmap(":/save_state_16px.png"));
    213226                    }
    214227                    /* Prepare 'save' radio-button: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r45212 r45736  
    5656    /* API: Validation stuff: */
    5757    bool isValid() const { return m_fValid; }
     58
     59    /* Static API: Parse string containing result-code: */
     60    static ResultCode parseResultCode(const QString &strCloseAction);
    5861
    5962private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp

    r44583 r45736  
    889889
    890890    UIActionSimpleSave(UIActionPool *pParent)
    891         : UIActionSimple(pParent, ":/state_saved_16px.png")
     891        : UIActionSimple(pParent, ":/save_state_16px.png", ":/save_state_disabled_16px.png")
    892892    {
    893893        retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r45377 r45736  
    603603        /* Get session console: */
    604604        CConsole console = session.GetConsole();
    605         /* Prepare machine state saving: */
    606         CProgress progress = console.SaveState();
     605        /* Pause VM first: */
     606        console.Pause();
    607607        if (console.isOk())
    608608        {
    609             /* Show machine state saving progress: */
    610             CMachine machine = session.GetMachine();
    611             msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png");
    612             if (!progress.isOk() || progress.GetResultCode() != 0)
    613                 msgCenter().cannotSaveMachineState(progress, machine.GetName());
     609            /* Prepare machine state saving: */
     610            CProgress progress = console.SaveState();
     611            if (console.isOk())
     612            {
     613                /* Show machine state saving progress: */
     614                CMachine machine = session.GetMachine();
     615                msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png");
     616                if (!progress.isOk() || progress.GetResultCode() != 0)
     617                    msgCenter().cannotSaveMachineState(progress, machine.GetName());
     618            }
     619            else
     620                msgCenter().cannotSaveMachineState(console);
    614621        }
    615622        else
    616             msgCenter().cannotSaveMachineState(console);
     623            msgCenter().cannotPauseMachine(console);
    617624
    618625        /* Unlock machine finally: */
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