VirtualBox

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

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

FE/Qt4: new core: this is Mac specific only

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 27027 2010-03-04 13:55:05Z 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#ifdef Q_WS_MAC
53 /* Prepare menu: */
54 prepareMenu();
55#endif /* Q_WS_MAC */
56
57 /* Retranslate normal window finally: */
58 retranslateUi();
59
60 /* Prepare machine view container: */
61 prepareMachineViewContainer();
62
63 /* Prepare normal machine view: */
64 prepareMachineView();
65
66 /* Load normal window settings: */
67 loadWindowSettings();
68
69 /* Update all the elements: */
70 updateAppearanceOf(UIVisualElement_AllStuff);
71
72 /* Show window: */
73// show();
74}
75
76UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
77{
78 /* Save normal window settings: */
79 saveWindowSettings();
80
81 /* Cleanup normal machine view: */
82 cleanupMachineView();
83}
84
85void UIMachineWindowFullscreen::sltMachineStateChanged()
86{
87 UIMachineWindow::sltMachineStateChanged();
88}
89
90void UIMachineWindowFullscreen::sltTryClose()
91{
92 UIMachineWindow::sltTryClose();
93}
94
95void UIMachineWindowFullscreen::retranslateUi()
96{
97 /* Translate parent class: */
98 UIMachineWindow::retranslateUi();
99
100#ifdef Q_WS_MAC
101 // TODO_NEW_CORE
102// m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
103// m_pDockDisablePreview->setText(tr("Show Application Icon"));
104// m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
105#endif /* Q_WS_MAC */
106}
107
108#ifdef Q_WS_X11
109bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent)
110{
111 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
112 * WindowActivate and WindowDeactivate Qt events are not properly sent
113 * on top level window (i.e. this) deactivation. The fix is to substiute
114 * the mode in FocusOut X11 event structure to NotifyNormal to cause
115 * Qt to process it as desired. */
116 if (pEvent->type == FocusOut)
117 {
118 if (pEvent->xfocus.mode == NotifyWhileGrabbed &&
119 (pEvent->xfocus.detail == NotifyAncestor ||
120 pEvent->xfocus.detail == NotifyInferior ||
121 pEvent->xfocus.detail == NotifyNonlinear))
122 {
123 pEvent->xfocus.mode = NotifyNormal;
124 }
125 }
126 return false;
127}
128#endif
129
130void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent)
131{
132 return UIMachineWindow::closeEvent(pEvent);
133}
134
135#ifdef Q_WS_MAC
136void UIMachineWindowFullscreen::prepareMenu()
137{
138 setMenuBar(uisession()->newMenuBar());
139}
140#endif /* Q_WS_MAC */
141
142void UIMachineWindowFullscreen::prepareMachineView()
143{
144#ifdef VBOX_WITH_VIDEOHWACCEL
145 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
146 bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
147#endif
148
149 /* Set central widget: */
150 setCentralWidget(new QWidget(this));
151
152 /* Set central widget layout: */
153 centralWidget()->setLayout(m_pMachineViewContainer);
154
155 m_pMachineView = UIMachineView::create( this
156 , vboxGlobal().vmRenderMode()
157#ifdef VBOX_WITH_VIDEOHWACCEL
158 , bAccelerate2DVideo
159#endif
160 , machineLogic()->visualStateType()
161 , m_uScreenId);
162
163 /* Add machine view into layout: */
164 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
165}
166
167void UIMachineWindowFullscreen::loadWindowSettings()
168{
169 /* Toggle console to manual resize mode. */
170 m_pMachineView->setFrameBufferResizeIgnored(true);
171
172 /* The background has to go black */
173 QPalette palette(centralWidget()->palette());
174 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
175 centralWidget()->setPalette(palette);
176 centralWidget()->setAutoFillBackground(true);
177 setAutoFillBackground(true);
178
179 /* Here we are going really fullscreen */
180 setWindowState(windowState() | Qt::WindowFullScreen);
181
182 /* Show the window */
183 show();
184 /* Make sure it is really on the right place (especially on the Mac) */
185 move(0, 0);
186}
187
188void UIMachineWindowFullscreen::saveWindowSettings()
189{
190}
191
192void UIMachineWindowFullscreen::cleanupMachineView()
193{
194 /* Do not cleanup machine view if it is not present: */
195 if (!machineView())
196 return;
197
198 UIMachineView::destroy(m_pMachineView);
199 m_pMachineView = 0;
200}
201
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