VirtualBox

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

Last change on this file since 104158 was 103977, checked in by vboxsync, 9 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

  • 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 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineWindow class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2023 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 "QIWithRetranslateUI.h"
39#include "UIExtraDataDefs.h"
40#ifdef VBOX_WS_MAC
41# include "VBoxUtils-darwin.h"
42#endif /* VBOX_WS_MAC */
43
44/* Forward declarations: */
45class QCloseEvent;
46class QEvent;
47class QHideEvent;
48class QGridLayout;
49class QShowEvent;
50class QSpacerItem;
51class UIActionPool;
52class UIMachine;
53class UIMachineLogic;
54class UIMachineView;
55class CSession;
56
57
58/* Machine-window interface: */
59class UIMachineWindow : public QIWithRetranslateUI2<QMainWindow>
60{
61 Q_OBJECT;
62
63public:
64
65 /* Factory functions to create/destroy machine-window: */
66 static UIMachineWindow* create(UIMachineLogic *pMachineLogic, ulong uScreenId = 0);
67 static void destroy(UIMachineWindow *pWhichWindow);
68
69 /* Prepare/cleanup machine-window: */
70 void prepare();
71 void cleanup();
72
73 /* Public getters: */
74 ulong screenId() const { return m_uScreenId; }
75 UIMachineView* machineView() const { return m_pMachineView; }
76 UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
77
78 /** Returns machine UI reference. */
79 UIMachine *uimachine() const;
80
81 /** Returns action-pool reference. */
82 UIActionPool *actionPool() const;
83
84 /** Returns the machine name. */
85 QString machineName() const;
86
87 /** Returns whether the machine-window should resize to fit to the guest display.
88 * @note Relevant only to normal (windowed) case. */
89 bool shouldResizeToGuestDisplay() const;
90
91 /** Restores cached window geometry.
92 * @note Reimplemented in sub-classes. Base implementation does nothing. */
93 virtual void restoreCachedGeometry() {}
94
95 /** Adjusts machine-window size to correspond current machine-view size.
96 * @param fAdjustPosition determines whether is it necessary to adjust position too.
97 * @param fResizeToGuestDisplay determines if is it necessary to resize the window to fit to guest display size.
98 * @note Reimplemented in sub-classes. Base implementation does nothing. */
99 virtual void normalizeGeometry(bool fAdjustPosition, bool fResizeToGuestDisplay) { Q_UNUSED(fAdjustPosition); Q_UNUSED(fResizeToGuestDisplay); }
100
101 /** Adjusts machine-view size to correspond current machine-window size. */
102 virtual void adjustMachineViewSize();
103
104 /** Sends machine-view size-hint to the guest. */
105 virtual void sendMachineViewSizeHint();
106
107#ifdef VBOX_WITH_MASKED_SEAMLESS
108 /* Virtual caller for base class setMask: */
109 virtual void setMask(const QRegion &region);
110#endif /* VBOX_WITH_MASKED_SEAMLESS */
111
112 /** Makes sure window is exposed in required mode/state. */
113 virtual void showInNecessaryMode() = 0;
114
115 /** Updates appearance for specified @a iElement. */
116 virtual void updateAppearanceOf(int iElement);
117
118protected slots:
119
120#ifdef VBOX_WS_NIX
121 /** X11: Performs machine-window geometry normalization. */
122 void sltNormalizeGeometry() { normalizeGeometry(true /* adjust position */, shouldResizeToGuestDisplay()); }
123#endif /* VBOX_WS_NIX */
124
125 /** Performs machine-window activation. */
126 void sltActivateWindow() { activateWindow(); }
127
128 /* Session event-handlers: */
129 virtual void sltMachineStateChanged();
130
131protected:
132
133 /* Constructor: */
134 UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
135
136 /* Translate stuff: */
137 void retranslateUi() RT_OVERRIDE;
138
139 /** Handles any Qt @a pEvent. */
140 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
141
142 /** Handles show @a pEvent. */
143 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
144 /** Handles hide @a pEvent. */
145 virtual void hideEvent(QHideEvent *pEvent) RT_OVERRIDE;
146
147 /** Close event handler. */
148 void closeEvent(QCloseEvent *pCloseEvent) RT_OVERRIDE;
149
150#ifdef VBOX_WS_MAC
151 /** Mac OS X: Handles native notifications.
152 * @param strNativeNotificationName Native notification name. */
153 virtual void handleNativeNotification(const QString & /* strNativeNotificationName */) {}
154
155 /** Mac OS X: Handles standard window button callbacks.
156 * @param enmButtonType Brings standard window button type.
157 * @param fWithOptionKey Brings whether the Option key was held. */
158 virtual void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey);
159#endif /* VBOX_WS_MAC */
160
161 /* Prepare helpers: */
162 virtual void prepareSelf();
163 virtual void prepareSessionConnections();
164 virtual void prepareMainLayout();
165 virtual void prepareMenu() {}
166 virtual void prepareStatusBar() {}
167 virtual void prepareMachineView();
168 virtual void prepareNotificationCenter();
169 virtual void prepareVisualState() {}
170 virtual void prepareHandlers();
171 virtual void loadSettings() {}
172
173 /* Cleanup helpers: */
174 virtual void saveSettings() {}
175 virtual void cleanupHandlers();
176 virtual void cleanupVisualState() {}
177 virtual void cleanupNotificationCenter();
178 virtual void cleanupMachineView();
179 virtual void cleanupStatusBar() {}
180 virtual void cleanupMenu() {}
181 virtual void cleanupMainLayout() {}
182 virtual void cleanupSessionConnections();
183 virtual void cleanupSelf() {}
184
185 /* Update stuff: */
186#ifdef VBOX_WITH_DEBUGGER_GUI
187 void updateDbgWindows();
188#endif /* VBOX_WITH_DEBUGGER_GUI */
189
190 /* Helpers: */
191 QString defaultWindowTitle() const { return m_strWindowTitlePrefix; }
192 static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
193
194#ifdef VBOX_WS_MAC
195 /** Mac OS X: Handles native notifications.
196 * @param strNativeNotificationName Native notification name.
197 * @param pWidget Widget, notification related to. */
198 static void handleNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
199
200 /** Mac OS X: Handles standard window button callbacks.
201 * @param enmButtonType Brings standard window button type.
202 * @param fWithOptionKey Brings whether the Option key was held.
203 * @param pWidget Brings widget, callback related to. */
204 static void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey, QWidget *pWidget);
205#endif /* VBOX_WS_MAC */
206
207 /* Variables: */
208 UIMachineLogic *m_pMachineLogic;
209 UIMachineView *m_pMachineView;
210 QString m_strWindowTitlePrefix;
211 ulong m_uScreenId;
212 QGridLayout *m_pMainLayout;
213 QSpacerItem *m_pTopSpacer;
214 QSpacerItem *m_pBottomSpacer;
215 QSpacerItem *m_pLeftSpacer;
216 QSpacerItem *m_pRightSpacer;
217};
218
219#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