VirtualBox

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

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

FE/Qt4: new core: partly reverted r58316

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.8 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 27008 2010-03-04 09:58:43Z 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 /* Prepare connections: */
56 prepareConnections();
57
58 /* Retranslate normal window finally: */
59 retranslateUi();
60
61 /* Prepare machine view container: */
62 prepareMachineViewContainer();
63
64 /* Prepare normal machine view: */
65 prepareMachineView();
66
67 /* Load normal window settings: */
68 loadWindowSettings();
69
70 /* Update all the elements: */
71 updateAppearanceOf(UIVisualElement_AllStuff);
72
73 /* Show window: */
74// show();
75}
76
77UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
78{
79 /* Save normal window settings: */
80 saveWindowSettings();
81
82 /* Cleanup normal machine view: */
83 cleanupMachineView();
84}
85
86void UIMachineWindowFullscreen::sltMachineStateChanged()
87{
88 UIMachineWindow::sltMachineStateChanged();
89}
90
91void UIMachineWindowFullscreen::sltMediumChange(const CMediumAttachment &attachment)
92{
93 KDeviceType type = attachment.GetType();
94 if (type == KDeviceType_HardDisk)
95 updateAppearanceOf(UIVisualElement_HDStuff);
96 if (type == KDeviceType_DVD)
97 updateAppearanceOf(UIVisualElement_CDStuff);
98 if (type == KDeviceType_Floppy)
99 updateAppearanceOf(UIVisualElement_FDStuff);
100}
101
102void UIMachineWindowFullscreen::sltUSBControllerChange()
103{
104 updateAppearanceOf(UIVisualElement_USBStuff);
105}
106
107void UIMachineWindowFullscreen::sltUSBDeviceStateChange()
108{
109 updateAppearanceOf(UIVisualElement_USBStuff);
110}
111
112void UIMachineWindowFullscreen::sltNetworkAdapterChange()
113{
114 updateAppearanceOf(UIVisualElement_NetworkStuff);
115}
116
117void UIMachineWindowFullscreen::sltSharedFolderChange()
118{
119 updateAppearanceOf(UIVisualElement_SharedFolderStuff);
120}
121
122void UIMachineWindowFullscreen::sltTryClose()
123{
124 UIMachineWindow::sltTryClose();
125}
126
127void UIMachineWindowFullscreen::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */)
128{
129}
130
131void UIMachineWindowFullscreen::retranslateUi()
132{
133 /* Translate parent class: */
134 UIMachineWindow::retranslateUi();
135
136#ifdef Q_WS_MAC
137 // TODO_NEW_CORE
138// m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
139// m_pDockDisablePreview->setText(tr("Show Application Icon"));
140// m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
141#endif /* Q_WS_MAC */
142}
143
144void UIMachineWindowFullscreen::updateAppearanceOf(int iElement)
145{
146 /* Update parent-class window: */
147 UIMachineWindow::updateAppearanceOf(iElement);
148}
149
150bool UIMachineWindowFullscreen::event(QEvent *pEvent)
151{
152 return QIWithRetranslateUI<QIMainDialog>::event(pEvent);
153 // TODO_NEW_CORE
154 switch (pEvent->type())
155 {
156 case QEvent::Resize:
157 {
158 QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
159 if (!isMaximized())
160 {
161 m_normalGeometry.setSize(pResizeEvent->size());
162#ifdef VBOX_WITH_DEBUGGER_GUI
163 // TODO: Update debugger window size!
164 //dbgAdjustRelativePos();
165#endif
166 }
167 break;
168 }
169 case QEvent::Move:
170 {
171 if (!isMaximized())
172 {
173 m_normalGeometry.moveTo(geometry().x(), geometry().y());
174#ifdef VBOX_WITH_DEBUGGER_GUI
175 // TODO: Update debugger window position!
176 //dbgAdjustRelativePos();
177#endif
178 }
179 break;
180 }
181 default:
182 break;
183 }
184 return QIWithRetranslateUI<QIMainDialog>::event(pEvent);
185}
186
187#ifdef Q_WS_X11
188bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent)
189{
190 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
191 * WindowActivate and WindowDeactivate Qt events are not properly sent
192 * on top level window (i.e. this) deactivation. The fix is to substiute
193 * the mode in FocusOut X11 event structure to NotifyNormal to cause
194 * Qt to process it as desired. */
195 if (pEvent->type == FocusOut)
196 {
197 if (pEvent->xfocus.mode == NotifyWhileGrabbed &&
198 (pEvent->xfocus.detail == NotifyAncestor ||
199 pEvent->xfocus.detail == NotifyInferior ||
200 pEvent->xfocus.detail == NotifyNonlinear))
201 {
202 pEvent->xfocus.mode = NotifyNormal;
203 }
204 }
205 return false;
206}
207#endif
208
209void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent)
210{
211 return UIMachineWindow::closeEvent(pEvent);
212}
213
214void UIMachineWindowFullscreen::prepareConsoleConnections()
215{
216 /* Base-class connections: */
217 UIMachineWindow::prepareConsoleConnections();
218
219 /* Medium change updater: */
220 connect(machineLogic()->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment &)),
221 this, SLOT(sltMediumChange(const CMediumAttachment &)));
222
223 /* USB controller change updater: */
224 connect(machineLogic()->uisession(), SIGNAL(sigUSBControllerChange()),
225 this, SLOT(sltUSBControllerChange()));
226
227 /* USB device state-change updater: */
228 connect(machineLogic()->uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)),
229 this, SLOT(sltUSBDeviceStateChange()));
230
231 /* Network adapter change updater: */
232 connect(machineLogic()->uisession(), SIGNAL(sigNetworkAdapterChange(const CNetworkAdapter &)),
233 this, SLOT(sltNetworkAdapterChange()));
234
235 /* Shared folder change updater: */
236 connect(machineLogic()->uisession(), SIGNAL(sigSharedFolderChange()),
237 this, SLOT(sltSharedFolderChange()));
238}
239
240void UIMachineWindowFullscreen::prepareMenu()
241{
242 setMenuBar(uisession()->newMenuBar());
243 /* Menubar is always hidden in fullscreen */
244 menuBar()->hide();
245}
246
247void UIMachineWindowFullscreen::prepareConnections()
248{
249 /* Setup global settings change updater: */
250 connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
251 this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));
252}
253
254void UIMachineWindowFullscreen::prepareMachineView()
255{
256#ifdef VBOX_WITH_VIDEOHWACCEL
257 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
258 bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
259#endif
260
261 /* Set central widget: */
262 setCentralWidget(new QWidget(this));
263
264 /* Set central widget layout: */
265 centralWidget()->setLayout(m_pMachineViewContainer);
266
267 m_pMachineView = UIMachineView::create( this
268 , vboxGlobal().vmRenderMode()
269#ifdef VBOX_WITH_VIDEOHWACCEL
270 , bAccelerate2DVideo
271#endif
272 , machineLogic()->visualStateType()
273 , m_uScreenId);
274
275 /* Add machine view into layout: */
276 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
277}
278
279//#include "UIMachineViewFullscreen.h"
280void UIMachineWindowFullscreen::loadWindowSettings()
281{
282 /* Load normal window settings: */
283// CMachine machine = session().GetMachine();
284
285 /* Toggle console to manual resize mode. */
286// m_pMachineView->setMachineWindowResizeIgnored(true);
287 m_pMachineView->setFrameBufferResizeIgnored(true);
288
289 /* The background has to go black */
290 QPalette palette(centralWidget()->palette());
291 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
292 centralWidget()->setPalette (palette);
293 centralWidget()->setAutoFillBackground (true);
294 setAutoFillBackground (true);
295
296 /* Here we are going really fullscreen */
297 setWindowState(windowState() | Qt::WindowFullScreen);
298
299 /* Show the window */
300 show();
301 /* Make sure it is really on the right place (especially on the Mac) */
302 move(0, 0);
303
304// m_pMachineView->normalizeGeometry(true);
305// ((UIMachineViewFullscreen*)m_pMachineView)->sltPerformGuestResize(maximumSize());
306
307// QRect r = geometry();
308 /* Load global settings: */
309 {
310// VBoxGlobalSettings settings = vboxGlobal().settings();
311// menuBar()->setHidden(settings.isFeatureActive("noMenuBar"));
312 }
313}
314
315void UIMachineWindowFullscreen::saveWindowSettings()
316{
317// CMachine machine = session().GetMachine();
318
319 /* Save extra-data settings: */
320 {
321 }
322}
323
324void UIMachineWindowFullscreen::cleanupMachineView()
325{
326 /* Do not cleanup machine view if it is not present: */
327 if (!machineView())
328 return;
329
330 UIMachineView::destroy(m_pMachineView);
331 m_pMachineView = 0;
332}
333
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