UIMachineWindowFullscreen.cpp revision 8d1ef2acf41d1d8a0f69bfe0ac1f41638160399c
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMachineWindowFullscreen class implementation
*/
/*
* Copyright (C) 2010-2012 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.
*/
/* Global includes */
#include <QDesktopWidget>
#include <QTimer>
#ifdef Q_WS_MAC
# include <QMenuBar>
#endif /* Q_WS_MAC */
/* Local includes */
#include "VBoxGlobal.h"
#include "VBoxMiniToolBar.h"
#include "UISession.h"
#include "UIActionPoolRuntime.h"
#include "UIMachineLogicFullscreen.h"
#include "UIMachineWindowFullscreen.h"
#include "UIMachineView.h"
UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
, m_pMainMenu(0)
, m_pMiniToolBar(0)
{
/* Set the main window in VBoxGlobal: */
if (uScreenId == 0)
vboxGlobal().setMainWindow(this);
/* Prepare fullscreen window icon: */
/* Prepare console connections: */
/* Prepare fullscreen menu: */
prepareMenu();
/* Prepare machine view container: */
/* Prepare fullscreen machine view: */
/* Prepare handlers: */
/* Prepare mini tool-bar: */
/* Retranslate fullscreen window finally: */
/* Update all the elements: */
/* Show fullscreen window: */
}
{
/* Save window settings: */
/* Cleanup mini tool-bar: */
/* Prepare handlers: */
/* Cleanup machine view: */
/* Cleanup menu: */
cleanupMenu();
}
{
/* Get corresponding screen: */
int iScreen = static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
/* Calculate working area: */
/* Move to the appropriate position: */
/* Resize to the appropriate size: */
/* Process pending move & resize events: */
qApp->processEvents();
}
{
/* Popup main menu if present: */
{
}
}
void UIMachineWindowFullscreen::prepareMenu()
{
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
}
{
/* Get current machine: */
/* Check if mini tool-bar should present: */
if (fIsActive)
{
/* Get the mini tool-bar alignment: */
/* Get the mini tool-bar auto-hide feature availability: */
true, fIsAutoHide);
m_pMiniToolBar->updateDisplay(true, true);
*m_pMiniToolBar << menus;
}
}
{
#ifdef VBOX_WITH_VIDEOHWACCEL
/* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
#endif
/* Set central widget: */
setCentralWidget(new QWidget);
/* Set central widget layout: */
, machineLogic()->visualStateType()
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
);
/* Add machine view into layout: */
/* The background has to go black: */
centralWidget()->setAutoFillBackground(true);
setAutoFillBackground(true);
}
{
/* Get machine: */
/* Save extra-data settings: */
{
/* Save mini tool-bar settings: */
if (m_pMiniToolBar)
machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, m_pMiniToolBar->isAutoHide() ? QString() : "off");
}
}
{
/* Do not cleanup machine view if it is not present: */
if (!machineView())
return;
m_pMachineView = 0;
}
{
if (m_pMiniToolBar)
{
delete m_pMiniToolBar;
m_pMiniToolBar = 0;
}
}
void UIMachineWindowFullscreen::cleanupMenu()
{
delete m_pMainMenu;
m_pMainMenu = 0;
}
{
/* Base class update: */
/* If mini tool-bar is present: */
if (m_pMiniToolBar)
{
/* Get machine: */
/* Get snapshot(s): */
if (machine.GetSnapshotCount() > 0)
{
}
/* Update mini tool-bar text: */
}
}
{
/* Make sure we really have to show window: */
session().GetMachine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
if (fEnabled)
{
/* Make sure the window is placed on valid screen
* before we are show fullscreen window: */
/* Show window fullscreen: */
/* Make sure the window is placed on valid screen again
* after window is shown & window's decorations applied.
* That is required due to X11 Window Geometry Rules. */
#ifdef Q_WS_MAC
/* Make sure it is really on the right place (especially on the Mac): */
QRect r = QApplication::desktop()->screenGeometry(static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
#endif /* Q_WS_MAC */
}
}