VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp@ 27018

Last change on this file since 27018 was 27018, checked in by vboxsync, 15 years ago

FE/Qt4: New running VM core: fullscreen code partial cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 27018 2010-03-04 12:39:01Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * UIMachineWindowFullscreen class implementation
6 */
7
8/*
9 * Copyright (C) 2010 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24/* Global includes */
25#include <QDesktopWidget>
26#include <QMenuBar>
27#include <QTimer>
28#include <QContextMenuEvent>
29
30/* Local includes */
31#include "VBoxGlobal.h"
32
33#include "UISession.h"
34#include "UIActionsPool.h"
35#include "UIMachineLogic.h"
36#include "UIMachineView.h"
37#include "UIMachineWindowFullscreen.h"
38
39UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
40 : QIWithRetranslateUI<QIMainDialog>(0)
41 , UIMachineWindow(pMachineLogic, uScreenId)
42{
43 /* "This" is machine window: */
44 m_pMachineWindow = this;
45
46 /* Prepare window icon: */
47 prepareWindowIcon();
48
49 /* Prepare console connections: */
50 prepareConsoleConnections();
51
52 /* Prepare menu: */
53 prepareMenu();
54
55 /* Retranslate normal window finally: */
56 retranslateUi();
57
58 /* Prepare machine view container: */
59 prepareMachineViewContainer();
60
61 /* Prepare normal machine view: */
62 prepareMachineView();
63
64 /* Load normal window settings: */
65 loadWindowSettings();
66
67 /* Update all the elements: */
68 updateAppearanceOf(UIVisualElement_AllStuff);
69
70 /* Show window: */
71// show();
72}
73
74UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
75{
76 /* Save normal window settings: */
77 saveWindowSettings();
78
79 /* Cleanup normal machine view: */
80 cleanupMachineView();
81}
82
83void UIMachineWindowFullscreen::sltMachineStateChanged()
84{
85 UIMachineWindow::sltMachineStateChanged();
86}
87
88void UIMachineWindowFullscreen::sltTryClose()
89{
90 UIMachineWindow::sltTryClose();
91}
92
93void UIMachineWindowFullscreen::retranslateUi()
94{
95 /* Translate parent class: */
96 UIMachineWindow::retranslateUi();
97
98#ifdef Q_WS_MAC
99 // TODO_NEW_CORE
100// m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
101// m_pDockDisablePreview->setText(tr("Show Application Icon"));
102// m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
103#endif /* Q_WS_MAC */
104}
105
106#ifdef Q_WS_X11
107bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent)
108{
109 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
110 * WindowActivate and WindowDeactivate Qt events are not properly sent
111 * on top level window (i.e. this) deactivation. The fix is to substiute
112 * the mode in FocusOut X11 event structure to NotifyNormal to cause
113 * Qt to process it as desired. */
114 if (pEvent->type == FocusOut)
115 {
116 if (pEvent->xfocus.mode == NotifyWhileGrabbed &&
117 (pEvent->xfocus.detail == NotifyAncestor ||
118 pEvent->xfocus.detail == NotifyInferior ||
119 pEvent->xfocus.detail == NotifyNonlinear))
120 {
121 pEvent->xfocus.mode = NotifyNormal;
122 }
123 }
124 return false;
125}
126#endif
127
128void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent)
129{
130 return UIMachineWindow::closeEvent(pEvent);
131}
132
133void UIMachineWindowFullscreen::prepareMenu()
134{
135 setMenuBar(uisession()->newMenuBar());
136 /* Menubar is always hidden in fullscreen */
137 menuBar()->hide();
138}
139
140void UIMachineWindowFullscreen::prepareMachineView()
141{
142#ifdef VBOX_WITH_VIDEOHWACCEL
143 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
144 bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
145#endif
146
147 /* Set central widget: */
148 setCentralWidget(new QWidget(this));
149
150 /* Set central widget layout: */
151 centralWidget()->setLayout(m_pMachineViewContainer);
152
153 m_pMachineView = UIMachineView::create( this
154 , vboxGlobal().vmRenderMode()
155#ifdef VBOX_WITH_VIDEOHWACCEL
156 , bAccelerate2DVideo
157#endif
158 , machineLogic()->visualStateType()
159 , m_uScreenId);
160
161 /* Add machine view into layout: */
162 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
163}
164
165void UIMachineWindowFullscreen::loadWindowSettings()
166{
167 /* Toggle console to manual resize mode. */
168 m_pMachineView->setFrameBufferResizeIgnored(true);
169
170 /* The background has to go black */
171 QPalette palette(centralWidget()->palette());
172 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
173 centralWidget()->setPalette(palette);
174 centralWidget()->setAutoFillBackground(true);
175 setAutoFillBackground(true);
176
177 /* Here we are going really fullscreen */
178 setWindowState(windowState() | Qt::WindowFullScreen);
179
180 /* Show the window */
181 show();
182 /* Make sure it is really on the right place (especially on the Mac) */
183 move(0, 0);
184}
185
186void UIMachineWindowFullscreen::saveWindowSettings()
187{
188}
189
190void UIMachineWindowFullscreen::cleanupMachineView()
191{
192 /* Do not cleanup machine view if it is not present: */
193 if (!machineView())
194 return;
195
196 UIMachineView::destroy(m_pMachineView);
197 m_pMachineView = 0;
198}
199
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette