VirtualBox

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

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/* $Id: UIMachineWindow.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineWindow class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h
19#define FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QMainWindow>
26
27/* GUI includes: */
28#include "QIWithRetranslateUI.h"
29#include "UIExtraDataDefs.h"
30#ifdef VBOX_WS_MAC
31# include "VBoxUtils-darwin.h"
32#endif /* VBOX_WS_MAC */
33
34/* COM includes: */
35#include "COMEnums.h"
36#include "CMachine.h"
37
38/* Forward declarations: */
39class QCloseEvent;
40class QEvent;
41class QHideEvent;
42class QGridLayout;
43class QShowEvent;
44class QSpacerItem;
45class UIActionPool;
46class UISession;
47class UIMachineLogic;
48class UIMachineView;
49class CSession;
50
51
52/* Machine-window interface: */
53class UIMachineWindow : public QIWithRetranslateUI2<QMainWindow>
54{
55 Q_OBJECT;
56
57signals:
58
59 /** Notifies about frame-buffer resize. */
60 void sigFrameBufferResize();
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 UIActionPool* actionPool() const;
77 UISession* uisession() const;
78
79 /** Returns the session reference. */
80 CSession& session() const;
81 /** Returns the session's machine reference. */
82 CMachine& machine() const;
83 /** Returns the session's console reference. */
84 CConsole& console() const;
85
86 /** Returns the machine name. */
87 const QString& machineName() const;
88
89 /** Restores cached window geometry.
90 * @note Reimplemented in sub-classes. Base implementation does nothing. */
91 virtual void restoreCachedGeometry() {}
92
93 /** Adjusts machine-window size to correspond current machine-view size.
94 * @param fAdjustPosition determines whether is it necessary to adjust position too.
95 * @note Reimplemented in sub-classes. Base implementation does nothing. */
96 virtual void normalizeGeometry(bool fAdjustPosition) { Q_UNUSED(fAdjustPosition); }
97
98 /** Adjusts machine-view size to correspond current machine-window size. */
99 virtual void adjustMachineViewSize();
100
101 /** Sends machine-view size-hint to the guest. */
102 virtual void sendMachineViewSizeHint();
103
104#ifdef VBOX_WITH_MASKED_SEAMLESS
105 /* Virtual caller for base class setMask: */
106 virtual void setMask(const QRegion &region);
107#endif /* VBOX_WITH_MASKED_SEAMLESS */
108
109protected slots:
110
111#ifdef VBOX_WS_X11
112 /** X11: Performs machine-window geometry normalization. */
113 void sltNormalizeGeometry() { normalizeGeometry(true /* adjust position */); }
114#endif /* VBOX_WS_X11 */
115
116 /** Performs machine-window activation. */
117 void sltActivateWindow() { activateWindow(); }
118
119 /* Session event-handlers: */
120 virtual void sltMachineStateChanged();
121
122protected:
123
124 /* Constructor: */
125 UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
126
127 /* Show stuff: */
128 virtual void showInNecessaryMode() = 0;
129
130 /* Translate stuff: */
131 void retranslateUi();
132
133 /** Handles any Qt @a pEvent. */
134 virtual bool event(QEvent *pEvent) /* override */;
135
136 /** Handles show @a pEvent. */
137 virtual void showEvent(QShowEvent *pEvent) /* override */;
138 /** Handles hide @a pEvent. */
139 virtual void hideEvent(QHideEvent *pEvent) /* override */;
140
141 /** Close event handler. */
142 void closeEvent(QCloseEvent *pCloseEvent);
143
144#ifdef VBOX_WS_MAC
145 /** Mac OS X: Handles native notifications.
146 * @param strNativeNotificationName Native notification name. */
147 virtual void handleNativeNotification(const QString & /* strNativeNotificationName */) {}
148
149 /** Mac OS X: Handles standard window button callbacks.
150 * @param enmButtonType Brings standard window button type.
151 * @param fWithOptionKey Brings whether the Option key was held. */
152 virtual void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey);
153#endif /* VBOX_WS_MAC */
154
155 /* Prepare helpers: */
156 virtual void prepareSessionConnections();
157 virtual void prepareMainLayout();
158 virtual void prepareMenu() {}
159 virtual void prepareStatusBar() {}
160 virtual void prepareMachineView();
161 virtual void prepareVisualState() {}
162 virtual void prepareHandlers();
163 virtual void loadSettings() {}
164
165 /* Cleanup helpers: */
166 virtual void saveSettings() {}
167 virtual void cleanupHandlers();
168 virtual void cleanupVisualState() {}
169 virtual void cleanupMachineView();
170 virtual void cleanupStatusBar() {}
171 virtual void cleanupMenu() {}
172 virtual void cleanupMainLayout() {}
173 virtual void cleanupSessionConnections();
174
175 /* Update stuff: */
176 virtual void updateAppearanceOf(int iElement);
177#ifdef VBOX_WITH_DEBUGGER_GUI
178 void updateDbgWindows();
179#endif /* VBOX_WITH_DEBUGGER_GUI */
180
181 /* Helpers: */
182 const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
183 static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
184
185#ifdef VBOX_WS_MAC
186 /** Mac OS X: Handles native notifications.
187 * @param strNativeNotificationName Native notification name.
188 * @param pWidget Widget, notification related to. */
189 static void handleNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
190
191 /** Mac OS X: Handles standard window button callbacks.
192 * @param enmButtonType Brings standard window button type.
193 * @param fWithOptionKey Brings whether the Option key was held.
194 * @param pWidget Brings widget, callback related to. */
195 static void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey, QWidget *pWidget);
196#endif /* VBOX_WS_MAC */
197
198 /* Variables: */
199 UIMachineLogic *m_pMachineLogic;
200 UIMachineView *m_pMachineView;
201 QString m_strWindowTitlePrefix;
202 ulong m_uScreenId;
203 QGridLayout *m_pMainLayout;
204 QSpacerItem *m_pTopSpacer;
205 QSpacerItem *m_pBottomSpacer;
206 QSpacerItem *m_pLeftSpacer;
207 QSpacerItem *m_pRightSpacer;
208
209 /* Friend classes: */
210 friend class UIMachineLogic;
211 friend class UIMachineLogicFullscreen;
212 friend class UIMachineLogicSeamless;
213};
214
215#endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineWindow_h */
216
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use