VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

Last change on this file was 106061, checked in by vboxsync, 4 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* $Id: UIMachineWindow.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineWindow class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h
29#define FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMainWindow>
36
37/* GUI includes: */
38#include "UIExtraDataDefs.h"
39#ifdef VBOX_WS_MAC
40# include "VBoxUtils-darwin.h"
41#endif /* VBOX_WS_MAC */
42
43/* Forward declarations: */
44class QCloseEvent;
45class QEvent;
46class QHideEvent;
47class QGridLayout;
48class QShowEvent;
49class QSpacerItem;
50class UIActionPool;
51class UIMachine;
52class UIMachineLogic;
53class UIMachineView;
54class CSession;
55
56
57/* Machine-window interface: */
58class UIMachineWindow : public QMainWindow
59{
60 Q_OBJECT;
61
62public:
63
64 /* Factory functions to create/destroy machine-window: */
65 static UIMachineWindow* create(UIMachineLogic *pMachineLogic, ulong uScreenId = 0);
66 static void destroy(UIMachineWindow *pWhichWindow);
67
68 /* Prepare/cleanup machine-window: */
69 void prepare();
70 void cleanup();
71
72 /* Public getters: */
73 ulong screenId() const { return m_uScreenId; }
74 UIMachineView* machineView() const { return m_pMachineView; }
75 UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
76
77 /** Returns machine UI reference. */
78 UIMachine *uimachine() const;
79
80 /** Returns action-pool reference. */
81 UIActionPool *actionPool() const;
82
83 /** Returns the machine name. */
84 QString machineName() const;
85
86 /** Returns whether the machine-window should resize to fit to the guest display.
87 * @note Relevant only to normal (windowed) case. */
88 bool shouldResizeToGuestDisplay() const;
89
90 /** Restores cached window geometry.
91 * @note Reimplemented in sub-classes. Base implementation does nothing. */
92 virtual void restoreCachedGeometry() {}
93
94 /** Adjusts machine-window size to correspond current machine-view size.
95 * @param fAdjustPosition determines whether is it necessary to adjust position too.
96 * @param fResizeToGuestDisplay determines if is it necessary to resize the window to fit to guest display size.
97 * @note Reimplemented in sub-classes. Base implementation does nothing. */
98 virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) { Q_UNUSED(fAdjustPosition); Q_UNUSED(fResizeToGuestDisplay); }
99
100 /** Adjusts machine-view size to correspond current machine-window size. */
101 virtual void adjustMachineViewSize();
102
103 /** Sends machine-view size-hint to the guest. */
104 virtual void sendMachineViewSizeHint();
105
106#ifdef VBOX_WITH_MASKED_SEAMLESS
107 /* Virtual caller for base class setMask: */
108 virtual void setMask(const QRegion &region);
109#endif /* VBOX_WITH_MASKED_SEAMLESS */
110
111 /** Makes sure window is exposed in required mode/state. */
112 virtual void showInNecessaryMode() = 0;
113
114 /** Updates appearance for specified @a iElement. */
115 virtual void updateAppearanceOf(int iElement);
116
117protected slots:
118
119#ifdef VBOX_WS_NIX
120 /** X11: Performs machine-window geometry normalization. */
121 void sltNormalizeGeometry() { normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay()); }
122#endif /* VBOX_WS_NIX */
123
124 /** Performs machine-window activation. */
125 void sltActivateWindow() { activateWindow(); }
126
127 /* Session event-handlers: */
128 virtual void sltMachineStateChanged();
129
130protected:
131
132 /* Constructor: */
133 UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
134
135 /** Handles any Qt @a pEvent. */
136 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
137
138 /** Handles show @a pEvent. */
139 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
140 /** Handles hide @a pEvent. */
141 virtual void hideEvent(QHideEvent *pEvent) RT_OVERRIDE;
142
143 /** Close event handler. */
144 void closeEvent(QCloseEvent *pCloseEvent) RT_OVERRIDE;
145
146#ifdef VBOX_WS_MAC
147 /** Mac OS X: Handles native notifications.
148 * @param strNativeNotificationName Native notification name. */
149 virtual void handleNativeNotification(const QString & /* strNativeNotificationName */) {}
150
151 /** Mac OS X: Handles standard window button callbacks.
152 * @param enmButtonType Brings standard window button type.
153 * @param fWithOptionKey Brings whether the Option key was held. */
154 virtual void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey);
155#endif /* VBOX_WS_MAC */
156
157 /* Prepare helpers: */
158 virtual void prepareSelf();
159 virtual void prepareSessionConnections();
160 virtual void prepareMainLayout();
161 virtual void prepareMenu() {}
162 virtual void prepareStatusBar() {}
163 virtual void prepareMachineView();
164 virtual void prepareNotificationCenter();
165 virtual void prepareVisualState() {}
166 virtual void prepareHandlers();
167 virtual void loadSettings() {}
168
169 /* Cleanup helpers: */
170 virtual void saveSettings() {}
171 virtual void cleanupHandlers();
172 virtual void cleanupVisualState() {}
173 virtual void cleanupNotificationCenter();
174 virtual void cleanupMachineView();
175 virtual void cleanupStatusBar() {}
176 virtual void cleanupMenu() {}
177 virtual void cleanupMainLayout() {}
178 virtual void cleanupSessionConnections();
179 virtual void cleanupSelf() {}
180
181 /* Update stuff: */
182#ifdef VBOX_WITH_DEBUGGER_GUI
183 void updateDbgWindows();
184#endif /* VBOX_WITH_DEBUGGER_GUI */
185
186 /* Helpers: */
187 QString defaultWindowTitle() const { return m_strWindowTitlePrefix; }
188 static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
189
190#ifdef VBOX_WS_MAC
191 /** Mac OS X: Handles native notifications.
192 * @param strNativeNotificationName Native notification name.
193 * @param pWidget Widget, notification related to. */
194 static void handleNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
195
196 /** Mac OS X: Handles standard window button callbacks.
197 * @param enmButtonType Brings standard window button type.
198 * @param fWithOptionKey Brings whether the Option key was held.
199 * @param pWidget Brings widget, callback related to. */
200 static void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey, QWidget *pWidget);
201#endif /* VBOX_WS_MAC */
202
203 /* Variables: */
204 UIMachineLogic *m_pMachineLogic;
205 UIMachineView *m_pMachineView;
206 QString m_strWindowTitlePrefix;
207 ulong m_uScreenId;
208 QGridLayout *m_pMainLayout;
209 QSpacerItem *m_pTopSpacer;
210 QSpacerItem *m_pBottomSpacer;
211 QSpacerItem *m_pLeftSpacer;
212 QSpacerItem *m_pRightSpacer;
213
214private slots:
215
216 /* Translate stuff: */
217 void sltRetranslateUI();
218
219};
220
221#endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h */
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