UIMachine.cpp revision a9b62afc62b28da7a1a77f34259f8013892d9664
/* $Id$ */
/** @file
* VBox Qt GUI - UIMachine class implementation.
*/
/*
* Copyright (C) 2010-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
# include <precomp.h>
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Local includes: */
# include "VBoxGlobal.h"
# include "UIExtraDataManager.h"
# include "UIMachine.h"
# include "UISession.h"
# include "UIActionPoolRuntime.h"
# include "UIMachineLogic.h"
# include "UIMachineWindow.h"
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Visual state interface: */
class UIVisualState : public QObject
{
public:
/* Constructor: */
, m_pMachineLogic(0)
{
}
/* Destructor: */
{
if (m_pMachineLogic)
{
/* Cleanup the logic object: */
/* Destroy the logic object: */
}
}
/* Visual state type getter: */
/* Machine logic getter: */
/* Method to prepare change one visual state to another: */
bool prepareChange()
{
return m_pMachineLogic->checkAvailability();
}
/* Method to change one visual state to another: */
void change()
{
/* Prepare the logic object: */
}
protected:
/* Variables: */
};
: QObject(0)
, m_pSession(0)
, m_pVisualState(0)
{
/* Store self pointer: */
if (m_ppThis)
*m_ppThis = this;
/* Create UI session: */
/* Preventing application from closing in case of window(s) closed: */
qApp->setQuitOnLastWindowClosed(false);
/* Cache medium data only if really necessary: */
/* Load machine settings: */
/* Prepare async visual-state change handler: */
/* Enter default (normal) state */
}
{
/* Save machine settings: */
/* Delete visual state: */
delete m_pVisualState;
m_pVisualState = 0;
/* Delete UI session: */
delete m_pSession;
m_pSession = 0;
/* Free session finally: */
/* Clear self pointer: */
*m_ppThis = 0;
/* Quit application: */
QApplication::quit();
}
{
/* Null if machine-logic not yet created: */
if (!machineLogic())
return 0;
/* Active machine-window otherwise: */
return machineLogic()->activeMachineWindow();
}
{
}
{
/* Create new state: */
/* First we have to check if the selected mode is available at all.
* Only then we delete the old mode and switch to the new mode. */
if (pNewVisualState->prepareChange())
{
/* Delete previous state: */
delete m_pVisualState;
/* Set the new mode as current mode: */
m_pVisualState->change();
}
else
{
/* Discard the temporary created new state: */
delete pNewVisualState;
/* If there is no state currently created => we have to exit: */
if (!m_pVisualState)
deleteLater();
}
}
void UIMachine::enterInitialVisualState()
{
}
{
return m_pVisualState->machineLogic();
return 0;
}
void UIMachine::loadMachineSettings()
{
/* Load 'visual state' option: */
{
/* Load restricted visual states: */
UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid());
/* Acquire allowed visual states: */
m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates);
/* Load requested visual state: */
UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid());
/* Check if requested visual state type allowed: */
{
switch (requestedVisualState)
{
/* Direct transition to scale/fullscreen mode allowed: */
/* While to seamless is not, so we have to request transition on GA capability-change event: */
case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break;
default: break;
}
}
}
}
void UIMachine::saveMachineSettings()
{
/* Save 'visual state' option: */
{
/* Get requested visual state: */
/* If requested state is invalid: */
{
/* Get current if still exists or normal otherwise: */
requestedVisualState = m_pVisualState ? m_pVisualState->visualStateType() : UIVisualStateType_Normal;
}
/* Save requested visual state: */
}
}
#include "UIMachine.moc"