VirtualBox

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

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette