83
85
, m_fIsGuestResizeIgnored(false)
84
86
, m_fIsSeamlessModeRequested(false)
85
87
, m_fIsAutoCaptureDisabled(false)
88
, m_fReconfigurable(false)
86
89
/* Guest additions flags: */
87
90
, m_ulGuestAdditionsRunLevel(0)
88
91
, m_fIsGuestSupportsGraphics(false)
284
290
emit sigMachineStarted();
293
bool UISession::save()
295
/* Prepare the save-state progress: */
296
CMachine machine = m_session.GetMachine();
297
CConsole console = m_session.GetConsole();
298
CProgress progress = console.SaveState();
301
/* Show the save-state progress: */
302
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png", mainMachineWindow(), true);
303
if (!progress.isOk() || progress.GetResultCode() != 0)
305
/* Failed in progress: */
306
msgCenter().cannotSaveMachineState(progress);
312
/* Failed in console: */
313
msgCenter().cannotSaveMachineState(console);
320
bool UISession::shutdown()
322
/* Send ACPI shutdown signal if possible: */
323
CConsole console = m_session.GetConsole();
324
console.PowerButton();
327
/* Failed in console: */
328
msgCenter().cannotACPIShutdownMachine(console);
335
bool UISession::powerOff(bool fDiscardState, bool &fServerCrashed)
337
/* Prepare the power-off progress: */
338
CMachine machine = m_session.GetMachine();
339
CConsole console = m_session.GetConsole();
340
CProgress progress = console.PowerDown();
343
/* Show the power-off progress: */
344
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png", mainMachineWindow(), true);
345
if (progress.isOk() && progress.GetResultCode() == 0)
347
/* Discard the current state if requested: */
350
/* Prepare the discard-state progress: */
351
CSnapshot snapshot = machine.GetCurrentSnapshot();
352
CProgress progress = console.RestoreSnapshot(snapshot);
355
/* Show the discard-state progress: */
356
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png", mainMachineWindow(), true);
357
if (!progress.isOk() || progress.GetResultCode() != 0)
359
/* Failed in progress: */
360
msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName());
366
/* Failed in console: */
367
msgCenter().cannotRestoreSnapshot(console, snapshot.GetName());
374
/* Failed in progress: */
375
msgCenter().cannotStopMachine(progress);
381
/* Failed in console: */
382
COMResult res(console);
383
/* This can happen if VBoxSVC is not running: */
384
if (FAILED_DEAD_INTERFACE(res.rc()))
385
fServerCrashed = true;
387
msgCenter().cannotStopMachine(console);
287
394
UIMachineLogic* UISession::machineLogic() const
289
396
return uimachine()->machineLogic();
591
701
emit sigVRDEChange();
704
void UISession::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
706
/* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
707
if (changeType == KGuestMonitorChangedEventType_NewOrigin)
709
/* Ignore KGuestMonitorChangedEventType_Disabled event if there is only one window visible: */
710
AssertMsg(countOfVisibleWindows() > 0, ("All machine windows are hidden!"));
711
if ( changeType == KGuestMonitorChangedEventType_Disabled
712
&& countOfVisibleWindows() == 1
713
&& isScreenVisible(uScreenId))
716
/* Process KGuestMonitorChangedEventType_Enabled change event: */
717
if ( !isScreenVisible(uScreenId)
718
&& changeType == KGuestMonitorChangedEventType_Enabled)
719
setScreenVisible(uScreenId, true);
720
/* Process KGuestMonitorChangedEventType_Disabled change event: */
721
else if ( isScreenVisible(uScreenId)
722
&& changeType == KGuestMonitorChangedEventType_Disabled)
723
setScreenVisible(uScreenId, false);
725
/* Notify listeners about the change: */
726
emit sigGuestMonitorChange(changeType, uScreenId, screenGeo);
594
729
void UISession::sltAdditionsChange()
596
731
/* Get our guest: */
669
804
this, SIGNAL(sigCPUExecutionCapChange()));
671
806
connect(gConsoleEvents, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
672
this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
807
this, SLOT(sltGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
810
void UISession::prepareConnections()
812
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)),
813
this, SIGNAL(sigHostScreenCountChanged(int)));
675
816
void UISession::prepareScreens()
735
876
QAction *pGuestAutoresizeSwitch = gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize);
736
877
pGuestAutoresizeSwitch->setChecked(strSettings != "off");
879
/* Should we allow reconfiguration? */
880
m_fReconfigurable = VBoxGlobal::shouldWeAllowMachineReconfiguration(machine);
881
updateSessionSettings();
738
883
#if 0 /* Disabled for now! */
740
885
/* Disable host screen-saver if requested: */
801
946
UIConsoleEventHandler::destroy();
949
void UISession::updateSessionSettings()
951
bool fAllowReconfiguration = m_machineState != KMachineState_Stuck && m_fReconfigurable;
952
gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)->setEnabled(fAllowReconfiguration);
953
gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersDialog)->setEnabled(fAllowReconfiguration);
954
gActionPool->action(UIActionIndexRuntime_Simple_NetworkAdaptersDialog)->setEnabled(fAllowReconfiguration);
804
957
WId UISession::winId() const
806
959
return mainMachineWindow()->winId();