1 | /* $Id: UIMachineWindow.h 58142 2015-10-09 12:07:45Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMachineWindow class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2013 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 __UIMachineWindow_h__
|
---|
19 | #define __UIMachineWindow_h__
|
---|
20 |
|
---|
21 | /* Qt includes: */
|
---|
22 | #include <QMainWindow>
|
---|
23 |
|
---|
24 | /* GUI includes: */
|
---|
25 | #include "QIWithRetranslateUI.h"
|
---|
26 | #include "UIExtraDataDefs.h"
|
---|
27 | #ifdef Q_WS_MAC
|
---|
28 | # include "VBoxUtils-darwin.h"
|
---|
29 | #endif /* Q_WS_MAC */
|
---|
30 |
|
---|
31 | /* COM includes: */
|
---|
32 | #include "COMEnums.h"
|
---|
33 | #include "CMachine.h"
|
---|
34 |
|
---|
35 | /* Forward declarations: */
|
---|
36 | class QGridLayout;
|
---|
37 | class QSpacerItem;
|
---|
38 | class QCloseEvent;
|
---|
39 | class CSession;
|
---|
40 | class UISession;
|
---|
41 | class UIMachineLogic;
|
---|
42 | class UIMachineView;
|
---|
43 | class UIActionPool;
|
---|
44 |
|
---|
45 | /* Machine-window interface: */
|
---|
46 | class UIMachineWindow : public QIWithRetranslateUI2<QMainWindow>
|
---|
47 | {
|
---|
48 | Q_OBJECT;
|
---|
49 |
|
---|
50 | signals:
|
---|
51 |
|
---|
52 | /** Notifies about frame-buffer resize. */
|
---|
53 | void sigFrameBufferResize();
|
---|
54 |
|
---|
55 | public:
|
---|
56 |
|
---|
57 | /* Factory functions to create/destroy machine-window: */
|
---|
58 | static UIMachineWindow* create(UIMachineLogic *pMachineLogic, ulong uScreenId = 0);
|
---|
59 | static void destroy(UIMachineWindow *pWhichWindow);
|
---|
60 |
|
---|
61 | /* Prepare/cleanup machine-window: */
|
---|
62 | void prepare();
|
---|
63 | void cleanup();
|
---|
64 |
|
---|
65 | /* Public getters: */
|
---|
66 | ulong screenId() const { return m_uScreenId; }
|
---|
67 | UIMachineView* machineView() const { return m_pMachineView; }
|
---|
68 | UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
|
---|
69 | UIActionPool* actionPool() const;
|
---|
70 | UISession* uisession() const;
|
---|
71 |
|
---|
72 | /** Returns the session reference. */
|
---|
73 | CSession& session() const;
|
---|
74 | /** Returns the session's machine reference. */
|
---|
75 | CMachine& machine() const;
|
---|
76 | /** Returns the session's console reference. */
|
---|
77 | CConsole& console() const;
|
---|
78 |
|
---|
79 | /** Returns the machine name. */
|
---|
80 | const QString& machineName() const;
|
---|
81 |
|
---|
82 | /** Adjusts machine-window size to correspond current machine-view size.
|
---|
83 | * @param fAdjustPosition determines whether is it necessary to adjust position too.
|
---|
84 | * @note Reimplemented in sub-classes. Base implementation does nothing. */
|
---|
85 | virtual void normalizeGeometry(bool fAdjustPosition) { Q_UNUSED(fAdjustPosition); }
|
---|
86 |
|
---|
87 | /** Adjusts machine-view size to correspond current machine-window size. */
|
---|
88 | virtual void adjustMachineViewSize();
|
---|
89 |
|
---|
90 | /** Sends machine-view size-hint to the guest. */
|
---|
91 | virtual void sendMachineViewSizeHint();
|
---|
92 |
|
---|
93 | #ifdef VBOX_WITH_MASKED_SEAMLESS
|
---|
94 | /* Virtual caller for base class setMask: */
|
---|
95 | virtual void setMask(const QRegion ®ion);
|
---|
96 | #endif /* VBOX_WITH_MASKED_SEAMLESS */
|
---|
97 |
|
---|
98 | protected slots:
|
---|
99 |
|
---|
100 | /** Performs machine-window activation. */
|
---|
101 | void sltActivateWindow() { activateWindow(); }
|
---|
102 |
|
---|
103 | /* Session event-handlers: */
|
---|
104 | virtual void sltMachineStateChanged();
|
---|
105 |
|
---|
106 | protected:
|
---|
107 |
|
---|
108 | /* Constructor: */
|
---|
109 | UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
|
---|
110 |
|
---|
111 | /* Show stuff: */
|
---|
112 | virtual void showInNecessaryMode() = 0;
|
---|
113 |
|
---|
114 | /* Translate stuff: */
|
---|
115 | void retranslateUi();
|
---|
116 |
|
---|
117 | /* Event handlers: */
|
---|
118 | #ifdef Q_WS_X11
|
---|
119 | /** X11: Native event handler. */
|
---|
120 | bool x11Event(XEvent *pEvent);
|
---|
121 | #endif /* Q_WS_X11 */
|
---|
122 |
|
---|
123 | /** Show event handler. */
|
---|
124 | void showEvent(QShowEvent *pShowEvent);
|
---|
125 |
|
---|
126 | /** Close event handler. */
|
---|
127 | void closeEvent(QCloseEvent *pCloseEvent);
|
---|
128 |
|
---|
129 | #ifdef Q_WS_MAC
|
---|
130 | /** Mac OS X: Handles native notifications.
|
---|
131 | * @param strNativeNotificationName Native notification name. */
|
---|
132 | virtual void handleNativeNotification(const QString & /* strNativeNotificationName */) {}
|
---|
133 |
|
---|
134 | /** Mac OS X: Handles standard window button callbacks.
|
---|
135 | * @param enmButtonType Brings standard window button type.
|
---|
136 | * @param fWithOptionKey Brings whether the Option key was held. */
|
---|
137 | virtual void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey);
|
---|
138 | #endif /* Q_WS_MAC */
|
---|
139 |
|
---|
140 | /* Prepare helpers: */
|
---|
141 | virtual void prepareSessionConnections();
|
---|
142 | virtual void prepareMainLayout();
|
---|
143 | virtual void prepareMenu() {}
|
---|
144 | virtual void prepareStatusBar() {}
|
---|
145 | virtual void prepareMachineView();
|
---|
146 | virtual void prepareVisualState() {}
|
---|
147 | virtual void prepareHandlers();
|
---|
148 | virtual void loadSettings() {}
|
---|
149 |
|
---|
150 | /* Cleanup helpers: */
|
---|
151 | virtual void saveSettings() {}
|
---|
152 | virtual void cleanupHandlers();
|
---|
153 | virtual void cleanupVisualState() {}
|
---|
154 | virtual void cleanupMachineView();
|
---|
155 | virtual void cleanupStatusBar() {}
|
---|
156 | virtual void cleanupMenu() {}
|
---|
157 | virtual void cleanupMainLayout() {}
|
---|
158 | virtual void cleanupSessionConnections();
|
---|
159 |
|
---|
160 | /* Update stuff: */
|
---|
161 | virtual void updateAppearanceOf(int iElement);
|
---|
162 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
163 | void updateDbgWindows();
|
---|
164 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
165 |
|
---|
166 | /* Helpers: */
|
---|
167 | const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
|
---|
168 | static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
|
---|
169 |
|
---|
170 | #ifdef Q_WS_MAC
|
---|
171 | /** Mac OS X: Handles native notifications.
|
---|
172 | * @param strNativeNotificationName Native notification name.
|
---|
173 | * @param pWidget Widget, notification related to. */
|
---|
174 | static void handleNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
|
---|
175 |
|
---|
176 | /** Mac OS X: Handles standard window button callbacks.
|
---|
177 | * @param enmButtonType Brings standard window button type.
|
---|
178 | * @param fWithOptionKey Brings whether the Option key was held.
|
---|
179 | * @param pWidget Brings widget, callback related to. */
|
---|
180 | static void handleStandardWindowButtonCallback(StandardWindowButtonType enmButtonType, bool fWithOptionKey, QWidget *pWidget);
|
---|
181 | #endif /* Q_WS_MAC */
|
---|
182 |
|
---|
183 | /* Variables: */
|
---|
184 | UIMachineLogic *m_pMachineLogic;
|
---|
185 | UIMachineView *m_pMachineView;
|
---|
186 | QString m_strWindowTitlePrefix;
|
---|
187 | ulong m_uScreenId;
|
---|
188 | QGridLayout *m_pMainLayout;
|
---|
189 | QSpacerItem *m_pTopSpacer;
|
---|
190 | QSpacerItem *m_pBottomSpacer;
|
---|
191 | QSpacerItem *m_pLeftSpacer;
|
---|
192 | QSpacerItem *m_pRightSpacer;
|
---|
193 |
|
---|
194 | /* Friend classes: */
|
---|
195 | friend class UIMachineLogic;
|
---|
196 | friend class UIMachineLogicFullscreen;
|
---|
197 | friend class UIMachineLogicSeamless;
|
---|
198 | };
|
---|
199 |
|
---|
200 | #endif // __UIMachineWindow_h__
|
---|
201 |
|
---|