VirtualBox

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

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

FE/Qt4: New running VM core: fullscreen/seamless modes menu restored (non-mac host for now).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 27141 2010-03-07 16:30:12Z 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#ifdef Q_WS_MAC
27# include <QMenuBar>
28#endif /* Q_WS_MAC */
29
30/* Local includes */
31#include "VBoxGlobal.h"
32
33#include "UISession.h"
34#include "UIMachineLogic.h"
35#include "UIMachineView.h"
36#include "UIMachineWindowFullscreen.h"
37
38UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
39 : QIWithRetranslateUI2<QIMainDialog>(0, Qt::FramelessWindowHint)
40 , UIMachineWindow(pMachineLogic, uScreenId)
41 , m_pMainMenu(0)
42{
43 /* "This" is machine window: */
44 m_pMachineWindow = this;
45
46 /* Set the main window in VBoxGlobal: */
47 if (uScreenId == 0)
48 vboxGlobal().setMainWindow(this);
49
50 /* Prepare fullscreen window icon: */
51 prepareWindowIcon();
52
53 /* Prepare console connections: */
54 prepareConsoleConnections();
55
56 /* Prepare fullscreen menu: */
57 prepareMenu();
58
59 /* Retranslate fullscreen window finally: */
60 retranslateUi();
61
62 /* Prepare machine view container: */
63 prepareMachineViewContainer();
64
65 /* Prepare fullscreen machine view: */
66 prepareMachineView();
67
68 /* Update all the elements: */
69 updateAppearanceOf(UIVisualElement_AllStuff);
70
71 /* Show window: */
72 showFullScreen();
73
74#ifdef Q_WS_MAC
75 /* Make sure it is really on the right place (especially on the Mac) */
76 move(0, 0);
77#endif /* Q_WS_MAC */
78}
79
80UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
81{
82 /* Cleanup normal machine view: */
83 cleanupMachineView();
84
85 /* Cleanup menu: */
86 cleanupMenu();
87}
88
89void UIMachineWindowFullscreen::sltMachineStateChanged()
90{
91 UIMachineWindow::sltMachineStateChanged();
92}
93
94void UIMachineWindowFullscreen::sltPopupMainMenu()
95{
96 /* Popup main menu if present: */
97 if (m_pMainMenu && !m_pMainMenu->isEmpty())
98 m_pMainMenu->popup(machineWindow()->geometry().center());
99}
100
101void UIMachineWindowFullscreen::sltTryClose()
102{
103 UIMachineWindow::sltTryClose();
104}
105
106void UIMachineWindowFullscreen::retranslateUi()
107{
108 /* Translate parent class: */
109 UIMachineWindow::retranslateUi();
110
111#ifdef Q_WS_MAC
112 // TODO_NEW_CORE
113// m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
114// m_pDockDisablePreview->setText(tr("Show Application Icon"));
115// m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
116#endif /* Q_WS_MAC */
117}
118
119#ifdef Q_WS_X11
120bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent)
121{
122 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
123 * WindowActivate and WindowDeactivate Qt events are not properly sent
124 * on top level window (i.e. this) deactivation. The fix is to substiute
125 * the mode in FocusOut X11 event structure to NotifyNormal to cause
126 * Qt to process it as desired. */
127 if (pEvent->type == FocusOut)
128 {
129 if (pEvent->xfocus.mode == NotifyWhileGrabbed &&
130 (pEvent->xfocus.detail == NotifyAncestor ||
131 pEvent->xfocus.detail == NotifyInferior ||
132 pEvent->xfocus.detail == NotifyNonlinear))
133 {
134 pEvent->xfocus.mode = NotifyNormal;
135 }
136 }
137 return false;
138}
139#endif
140
141void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent)
142{
143 return UIMachineWindow::closeEvent(pEvent);
144}
145
146void UIMachineWindowFullscreen::prepareMenu()
147{
148#ifdef Q_WS_MAC
149 setMenuBar(uisession()->newMenuBar());
150#else /* To NaN: Please uncomment below for mac too and test! */
151 m_pMainMenu = uisession()->newMenu();
152#endif /* Q_WS_MAC */
153}
154
155void UIMachineWindowFullscreen::prepareMachineView()
156{
157#ifdef VBOX_WITH_VIDEOHWACCEL
158 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
159 bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
160#endif
161
162 /* Set central widget: */
163 setCentralWidget(new QWidget);
164
165 /* Set central widget layout: */
166 centralWidget()->setLayout(m_pMachineViewContainer);
167
168 m_pMachineView = UIMachineView::create( this
169 , vboxGlobal().vmRenderMode()
170#ifdef VBOX_WITH_VIDEOHWACCEL
171 , bAccelerate2DVideo
172#endif
173 , machineLogic()->visualStateType()
174 , m_uScreenId);
175
176 /* Add machine view into layout: */
177 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
178
179 /* The background has to go black: */
180 QPalette palette(centralWidget()->palette());
181 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
182 centralWidget()->setPalette(palette);
183 centralWidget()->setAutoFillBackground(true);
184 setAutoFillBackground(true);
185}
186
187void UIMachineWindowFullscreen::cleanupMachineView()
188{
189 /* Do not cleanup machine view if it is not present: */
190 if (!machineView())
191 return;
192
193 UIMachineView::destroy(m_pMachineView);
194 m_pMachineView = 0;
195}
196
197void UIMachineWindowFullscreen::cleanupMenu()
198{
199#ifdef Q_WS_MAC
200 // Sync with UIMachineWindowFullscreen::prepareMenu()!
201#else /* To NaN: Please uncomment below for mac too and test! */
202 delete m_pMainMenu;
203 m_pMainMenu = 0;
204#endif /* Q_WS_MAC */
205}
206
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