VirtualBox

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

Last change on this file since 56870 was 56870, checked in by vboxsync, 9 years ago

FE/Qt: 5978: Runtime UI: Mini-toolbar: Unify minimize window functionality with corresponding action; Also on x11 adjust it to minimize mini-toolbar as well.

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