1 | /** @file
|
---|
2 | * VBox Qt GUI - UIMachineWindow class declaration.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2010-2013 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef __UIMachineWindow_h__
|
---|
18 | #define __UIMachineWindow_h__
|
---|
19 |
|
---|
20 | /* Qt includes: */
|
---|
21 | #include <QMainWindow>
|
---|
22 |
|
---|
23 | /* GUI includes: */
|
---|
24 | #include "QIWithRetranslateUI.h"
|
---|
25 | #include "UIExtraDataDefs.h"
|
---|
26 |
|
---|
27 | /* COM includes: */
|
---|
28 | #include "COMEnums.h"
|
---|
29 | #include "CMachine.h"
|
---|
30 |
|
---|
31 | /* Forward declarations: */
|
---|
32 | class QGridLayout;
|
---|
33 | class QSpacerItem;
|
---|
34 | class QCloseEvent;
|
---|
35 | class CSession;
|
---|
36 | class UISession;
|
---|
37 | class UIMachineLogic;
|
---|
38 | class UIMachineView;
|
---|
39 | class UIActionPool;
|
---|
40 |
|
---|
41 | /* Machine-window interface: */
|
---|
42 | class UIMachineWindow : public QIWithRetranslateUI2<QMainWindow>
|
---|
43 | {
|
---|
44 | Q_OBJECT;
|
---|
45 |
|
---|
46 | signals:
|
---|
47 |
|
---|
48 | /** Notifies about frame-buffer resize. */
|
---|
49 | void sigFrameBufferResize();
|
---|
50 |
|
---|
51 | public:
|
---|
52 |
|
---|
53 | /* Factory functions to create/destroy machine-window: */
|
---|
54 | static UIMachineWindow* create(UIMachineLogic *pMachineLogic, ulong uScreenId = 0);
|
---|
55 | static void destroy(UIMachineWindow *pWhichWindow);
|
---|
56 |
|
---|
57 | /* Prepare/cleanup machine-window: */
|
---|
58 | void prepare();
|
---|
59 | void cleanup();
|
---|
60 |
|
---|
61 | /* Public getters: */
|
---|
62 | ulong screenId() const { return m_uScreenId; }
|
---|
63 | UIMachineView* machineView() const { return m_pMachineView; }
|
---|
64 | UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
|
---|
65 | UIActionPool* actionPool() const;
|
---|
66 | UISession* uisession() const;
|
---|
67 |
|
---|
68 | /** Returns the session reference. */
|
---|
69 | CSession& session() const;
|
---|
70 | /** Returns the session's machine reference. */
|
---|
71 | CMachine& machine() const;
|
---|
72 | /** Returns the session's console reference. */
|
---|
73 | CConsole& console() const;
|
---|
74 |
|
---|
75 | /** Returns the machine name. */
|
---|
76 | const QString& machineName() const;
|
---|
77 |
|
---|
78 | /** Adjusts machine-window size to correspond current machine-view size.
|
---|
79 | * @param fAdjustPosition determines whether is it necessary to adjust position too.
|
---|
80 | * @note Reimplemented in sub-classes. Base implementation does nothing. */
|
---|
81 | virtual void normalizeGeometry(bool fAdjustPosition) { Q_UNUSED(fAdjustPosition); }
|
---|
82 |
|
---|
83 | /** Adjusts machine-view size to correspond current machine-window size. */
|
---|
84 | virtual void adjustMachineViewSize();
|
---|
85 |
|
---|
86 | #ifdef VBOX_WITH_MASKED_SEAMLESS
|
---|
87 | /* Virtual caller for base class setMask: */
|
---|
88 | virtual void setMask(const QRegion ®ion);
|
---|
89 | #endif /* VBOX_WITH_MASKED_SEAMLESS */
|
---|
90 |
|
---|
91 | protected slots:
|
---|
92 |
|
---|
93 | /* Session event-handlers: */
|
---|
94 | virtual void sltMachineStateChanged();
|
---|
95 |
|
---|
96 | protected:
|
---|
97 |
|
---|
98 | /* Constructor: */
|
---|
99 | UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
|
---|
100 |
|
---|
101 | /* Show stuff: */
|
---|
102 | virtual void showInNecessaryMode() = 0;
|
---|
103 |
|
---|
104 | /* Translate stuff: */
|
---|
105 | void retranslateUi();
|
---|
106 |
|
---|
107 | /* Event handlers: */
|
---|
108 | #ifdef Q_WS_X11
|
---|
109 | /** X11: Native event handler. */
|
---|
110 | bool x11Event(XEvent *pEvent);
|
---|
111 | #endif /* Q_WS_X11 */
|
---|
112 |
|
---|
113 | /** Show event handler. */
|
---|
114 | void showEvent(QShowEvent *pShowEvent);
|
---|
115 |
|
---|
116 | /** Close event handler. */
|
---|
117 | void closeEvent(QCloseEvent *pCloseEvent);
|
---|
118 |
|
---|
119 | #ifdef Q_WS_MAC
|
---|
120 | /** Mac OS X: Handles native notifications.
|
---|
121 | * @param strNativeNotificationName Native notification name. */
|
---|
122 | virtual void handleNativeNotification(const QString & /* strNativeNotificationName */) {}
|
---|
123 | #endif /* Q_WS_MAC */
|
---|
124 |
|
---|
125 | /* Prepare helpers: */
|
---|
126 | virtual void prepareSessionConnections();
|
---|
127 | virtual void prepareMainLayout();
|
---|
128 | virtual void prepareMenu() {}
|
---|
129 | virtual void prepareStatusBar() {}
|
---|
130 | virtual void prepareMachineView();
|
---|
131 | virtual void prepareVisualState() {}
|
---|
132 | virtual void prepareHandlers();
|
---|
133 | virtual void loadSettings() {}
|
---|
134 |
|
---|
135 | /* Cleanup helpers: */
|
---|
136 | virtual void saveSettings() {}
|
---|
137 | virtual void cleanupHandlers();
|
---|
138 | virtual void cleanupVisualState() {}
|
---|
139 | virtual void cleanupMachineView();
|
---|
140 | virtual void cleanupStatusBar() {}
|
---|
141 | virtual void cleanupMenu() {}
|
---|
142 | virtual void cleanupMainLayout() {}
|
---|
143 | virtual void cleanupSessionConnections() {}
|
---|
144 |
|
---|
145 | /* Update stuff: */
|
---|
146 | virtual void updateAppearanceOf(int iElement);
|
---|
147 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
148 | void updateDbgWindows();
|
---|
149 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
150 |
|
---|
151 | /* Helpers: */
|
---|
152 | const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
|
---|
153 | static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
|
---|
154 |
|
---|
155 | #ifdef Q_WS_MAC
|
---|
156 | /** Mac OS X: Handles native notifications.
|
---|
157 | * @param strNativeNotificationName Native notification name.
|
---|
158 | * @param pWidget Widget, notification related to. */
|
---|
159 | static void handleNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
|
---|
160 | #endif /* Q_WS_MAC */
|
---|
161 |
|
---|
162 | /* Variables: */
|
---|
163 | UIMachineLogic *m_pMachineLogic;
|
---|
164 | UIMachineView *m_pMachineView;
|
---|
165 | QString m_strWindowTitlePrefix;
|
---|
166 | ulong m_uScreenId;
|
---|
167 | QGridLayout *m_pMainLayout;
|
---|
168 | QSpacerItem *m_pTopSpacer;
|
---|
169 | QSpacerItem *m_pBottomSpacer;
|
---|
170 | QSpacerItem *m_pLeftSpacer;
|
---|
171 | QSpacerItem *m_pRightSpacer;
|
---|
172 |
|
---|
173 | /* Friend classes: */
|
---|
174 | friend class UIMachineLogic;
|
---|
175 | friend class UIMachineLogicFullscreen;
|
---|
176 | friend class UIMachineLogicSeamless;
|
---|
177 | };
|
---|
178 |
|
---|
179 | #endif // __UIMachineWindow_h__
|
---|
180 |
|
---|