1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxConsoleWnd class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VBoxConsoleWnd_h__
|
---|
24 | #define __VBoxConsoleWnd_h__
|
---|
25 |
|
---|
26 | #include "COMDefs.h"
|
---|
27 | #include "QIWithRetranslateUI.h"
|
---|
28 |
|
---|
29 | /* Qt includes */
|
---|
30 | #include <QMainWindow>
|
---|
31 | #include <QMap>
|
---|
32 | #include <QColor>
|
---|
33 | #include <QDialog>
|
---|
34 |
|
---|
35 |
|
---|
36 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
37 | # include <VBox/dbggui.h>
|
---|
38 | #endif
|
---|
39 | #ifdef Q_WS_MAC
|
---|
40 | # undef PAGE_SIZE
|
---|
41 | # undef PAGE_SHIFT
|
---|
42 | # include <Carbon/Carbon.h>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | class QAction;
|
---|
46 | class QActionGroup;
|
---|
47 | class QLabel;
|
---|
48 | class QSpacerItem;
|
---|
49 | class QMenu;
|
---|
50 |
|
---|
51 | class VBoxConsoleView;
|
---|
52 | class QIStateIndicator;
|
---|
53 |
|
---|
54 | class VBoxUSBMenu;
|
---|
55 | class VBoxSwitchMenu;
|
---|
56 |
|
---|
57 | class VBoxConsoleWnd : public QIWithRetranslateUI2<QMainWindow>
|
---|
58 | {
|
---|
59 | Q_OBJECT;
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | VBoxConsoleWnd (VBoxConsoleWnd **aSelf,
|
---|
64 | QWidget* aParent = 0,
|
---|
65 | Qt::WindowFlags aFlags = Qt::Window);
|
---|
66 | virtual ~VBoxConsoleWnd();
|
---|
67 |
|
---|
68 | bool openView (const CSession &session);
|
---|
69 | void closeView();
|
---|
70 |
|
---|
71 | void refreshView();
|
---|
72 |
|
---|
73 | bool isTrueFullscreen() const { return mIsFullscreen; }
|
---|
74 |
|
---|
75 | bool isTrueSeamless() const { return mIsSeamless; }
|
---|
76 |
|
---|
77 | void setMouseIntegrationLocked (bool aDisabled);
|
---|
78 |
|
---|
79 | void popupMainMenu (bool aCenter);
|
---|
80 |
|
---|
81 | void installGuestAdditionsFrom (const QString &aSource);
|
---|
82 |
|
---|
83 | void setMask (const QRegion &aRegion);
|
---|
84 |
|
---|
85 | #ifdef Q_WS_MAC
|
---|
86 | CGImageRef dockImageState () const;
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | public slots:
|
---|
90 |
|
---|
91 | protected:
|
---|
92 |
|
---|
93 | // events
|
---|
94 | bool event (QEvent *e);
|
---|
95 | void closeEvent (QCloseEvent *e);
|
---|
96 | #if defined(Q_WS_X11)
|
---|
97 | bool x11Event (XEvent *event);
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | void retranslateUi();
|
---|
101 |
|
---|
102 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
103 | bool dbgCreated();
|
---|
104 | void dbgDestroy();
|
---|
105 | void dbgAdjustRelativePos();
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | protected slots:
|
---|
109 |
|
---|
110 | private:
|
---|
111 |
|
---|
112 | enum /* Stuff */
|
---|
113 | {
|
---|
114 | FloppyStuff = 0x01,
|
---|
115 | DVDStuff = 0x02,
|
---|
116 | HardDiskStuff = 0x04,
|
---|
117 | PauseAction = 0x08,
|
---|
118 | NetworkStuff = 0x10,
|
---|
119 | DisableMouseIntegrAction = 0x20,
|
---|
120 | Caption = 0x40,
|
---|
121 | USBStuff = 0x80,
|
---|
122 | VRDPStuff = 0x100,
|
---|
123 | SharedFolderStuff = 0x200,
|
---|
124 | AllStuff = 0xFFFF,
|
---|
125 | };
|
---|
126 |
|
---|
127 | void updateAppearanceOf (int element);
|
---|
128 |
|
---|
129 | bool toggleFullscreenMode (bool, bool);
|
---|
130 |
|
---|
131 | private slots:
|
---|
132 |
|
---|
133 | void finalizeOpenView();
|
---|
134 |
|
---|
135 | void activateUICustomizations();
|
---|
136 |
|
---|
137 | void vmFullscreen (bool on);
|
---|
138 | void vmSeamless (bool on);
|
---|
139 | void vmAutoresizeGuest (bool on);
|
---|
140 | void vmAdjustWindow();
|
---|
141 |
|
---|
142 | void vmTypeCAD();
|
---|
143 | void vmTypeCABS();
|
---|
144 | void vmReset();
|
---|
145 | void vmPause(bool);
|
---|
146 | void vmACPIShutdown();
|
---|
147 | void vmClose();
|
---|
148 | void vmTakeSnapshot();
|
---|
149 | void vmShowInfoDialog();
|
---|
150 | void vmDisableMouseIntegr (bool);
|
---|
151 |
|
---|
152 | void devicesMountFloppyImage();
|
---|
153 | void devicesUnmountFloppy();
|
---|
154 | void devicesMountDVDImage();
|
---|
155 | void devicesUnmountDVD();
|
---|
156 | void devicesSwitchVrdp (bool);
|
---|
157 | void devicesOpenSFDialog();
|
---|
158 | void devicesInstallGuestAdditions();
|
---|
159 |
|
---|
160 | void prepareFloppyMenu();
|
---|
161 | void prepareDVDMenu();
|
---|
162 | void prepareNetworkMenu();
|
---|
163 |
|
---|
164 | void setDynamicMenuItemStatusTip (QAction *aAction);
|
---|
165 |
|
---|
166 | void captureFloppy (QAction *aAction);
|
---|
167 | void captureDVD (QAction *aAction);
|
---|
168 | void activateNetworkMenu (QAction *aAction);
|
---|
169 | void switchUSB (QAction *aAction);
|
---|
170 |
|
---|
171 | void statusTipChanged (const QString &);
|
---|
172 | void clearStatusBar();
|
---|
173 |
|
---|
174 | void showIndicatorContextMenu (QIStateIndicator *ind, QContextMenuEvent *e);
|
---|
175 |
|
---|
176 | void updateDeviceLights();
|
---|
177 | void updateMachineState (KMachineState state);
|
---|
178 | void updateMouseState (int state);
|
---|
179 | void updateAdditionsState (const QString&, bool, bool, bool);
|
---|
180 | void updateNetworkAdarptersState();
|
---|
181 | void updateUsbState();
|
---|
182 | void updateMediaState (VBoxDefs::DiskType aType);
|
---|
183 | void updateSharedFoldersState();
|
---|
184 |
|
---|
185 | void tryClose();
|
---|
186 |
|
---|
187 | void processGlobalSettingChange (const char *publicName, const char *name);
|
---|
188 |
|
---|
189 | void dbgShowStatistics();
|
---|
190 | void dbgShowCommandLine();
|
---|
191 |
|
---|
192 | void onExitFullscreen();
|
---|
193 | void unlockActionsSwitch();
|
---|
194 |
|
---|
195 | void switchToFullscreen (bool aOn, bool aSeamless);
|
---|
196 | void setViewInSeamlessMode (const QRect &aTargetRect);
|
---|
197 |
|
---|
198 | private:
|
---|
199 |
|
---|
200 | /** Popup version of the main menu */
|
---|
201 | QMenu *mMainMenu;
|
---|
202 |
|
---|
203 | QActionGroup *mRunningActions;
|
---|
204 | QActionGroup *mRunningOrPausedActions;
|
---|
205 |
|
---|
206 | // Machine actions
|
---|
207 | QAction *vmFullscreenAction;
|
---|
208 | QAction *vmSeamlessAction;
|
---|
209 | QAction *vmAutoresizeGuestAction;
|
---|
210 | QAction *vmAdjustWindowAction;
|
---|
211 | QAction *vmTypeCADAction;
|
---|
212 | #if defined(Q_WS_X11)
|
---|
213 | QAction *vmTypeCABSAction;
|
---|
214 | #endif
|
---|
215 | QAction *vmResetAction;
|
---|
216 | QAction *vmPauseAction;
|
---|
217 | QAction *vmACPIShutdownAction;
|
---|
218 | QAction *vmCloseAction;
|
---|
219 | QAction *vmTakeSnapshotAction;
|
---|
220 | QAction *vmDisableMouseIntegrAction;
|
---|
221 | QAction *vmShowInformationDlgAction;
|
---|
222 |
|
---|
223 | // Devices actions
|
---|
224 | QAction *devicesMountFloppyImageAction;
|
---|
225 | QAction *devicesUnmountFloppyAction;
|
---|
226 | QAction *devicesMountDVDImageAction;
|
---|
227 | QAction *devicesUnmountDVDAction;
|
---|
228 | QAction *devicesSwitchVrdpAction;
|
---|
229 | QAction *devicesSFDialogAction;
|
---|
230 | QAction *devicesInstallGuestToolsAction;
|
---|
231 |
|
---|
232 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
233 | // Debugger actions
|
---|
234 | QAction *dbgStatisticsAction;
|
---|
235 | QAction *dbgCommandLineAction;
|
---|
236 | #endif
|
---|
237 |
|
---|
238 | // Help actions
|
---|
239 | QAction *helpContentsAction;
|
---|
240 | QAction *helpWebAction;
|
---|
241 | QAction *helpRegisterAction;
|
---|
242 | QAction *helpUpdateAction;
|
---|
243 | QAction *helpAboutAction;
|
---|
244 | QAction *helpResetMessagesAction;
|
---|
245 |
|
---|
246 | // Machine popup menus
|
---|
247 | VBoxSwitchMenu *vmAutoresizeMenu;
|
---|
248 | VBoxSwitchMenu *vmDisMouseIntegrMenu;
|
---|
249 |
|
---|
250 | // Devices popup menus
|
---|
251 | bool waitForStatusBarChange;
|
---|
252 | bool statusBarChangedInside;
|
---|
253 |
|
---|
254 | QAction *mDevicesUSBMenuSeparator;
|
---|
255 | QAction *mDevicesVRDPMenuSeparator;
|
---|
256 | QAction *mDevicesSFMenuSeparator;
|
---|
257 |
|
---|
258 | QMenu *mVMMenu;
|
---|
259 | QMenu *mDevicesMenu;
|
---|
260 | QMenu *mDevicesMountFloppyMenu;
|
---|
261 | QMenu *mDevicesMountDVDMenu;
|
---|
262 | /* see showIndicatorContextMenu for a description of mDevicesSFMenu */
|
---|
263 | /* QMenu *mDevicesSFMenu; */
|
---|
264 | QMenu *mDevicesNetworkMenu;
|
---|
265 | VBoxUSBMenu *mDevicesUSBMenu;
|
---|
266 | /* VBoxSwitchMenu *mDevicesVRDPMenu; */
|
---|
267 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
268 | // Debugger popup menu
|
---|
269 | QMenu *mDbgMenu;
|
---|
270 | #endif
|
---|
271 | QMenu *mHelpMenu;
|
---|
272 |
|
---|
273 | QSpacerItem *mShiftingSpacerLeft;
|
---|
274 | QSpacerItem *mShiftingSpacerTop;
|
---|
275 | QSpacerItem *mShiftingSpacerRight;
|
---|
276 | QSpacerItem *mShiftingSpacerBottom;
|
---|
277 | QSize mMaskShift;
|
---|
278 |
|
---|
279 | CSession csession;
|
---|
280 |
|
---|
281 | // widgets
|
---|
282 | VBoxConsoleView *console;
|
---|
283 | QIStateIndicator *hd_light, *cd_light, *fd_light, *net_light, *usb_light, *sf_light;
|
---|
284 | QIStateIndicator *mouse_state, *hostkey_state;
|
---|
285 | QIStateIndicator *autoresize_state;
|
---|
286 | QIStateIndicator *vrdp_state;
|
---|
287 | QWidget *hostkey_hbox;
|
---|
288 | QLabel *hostkey_name;
|
---|
289 |
|
---|
290 | QTimer *idle_timer;
|
---|
291 | KMachineState machine_state;
|
---|
292 | QString caption_prefix;
|
---|
293 |
|
---|
294 | bool no_auto_close : 1;
|
---|
295 |
|
---|
296 | QMap <QAction *, CHostDVDDrive> hostDVDMap;
|
---|
297 | QMap <QAction *, CHostFloppyDrive> hostFloppyMap;
|
---|
298 |
|
---|
299 | QRect mNormalGeo;
|
---|
300 | QSize prev_min_size;
|
---|
301 |
|
---|
302 | #ifdef Q_WS_WIN32
|
---|
303 | QRegion mPrevRegion;
|
---|
304 | #endif
|
---|
305 |
|
---|
306 | #ifdef Q_WS_MAC
|
---|
307 | QRegion mCurrRegion;
|
---|
308 | EventHandlerRef mDarwinRegionEventHandlerRef;
|
---|
309 | #endif
|
---|
310 |
|
---|
311 | // variables for dealing with true fullscreen
|
---|
312 | QRegion mStrictedRegion;
|
---|
313 | bool mIsFullscreen : 1;
|
---|
314 | bool mIsSeamless : 1;
|
---|
315 | bool mIsSeamlessSupported : 1;
|
---|
316 | bool mIsGraphicsSupported : 1;
|
---|
317 | bool mIsWaitingModeResize : 1;
|
---|
318 | bool was_max : 1;
|
---|
319 | QObjectList hidden_children;
|
---|
320 | int console_style;
|
---|
321 | QPalette mErasePalette;
|
---|
322 |
|
---|
323 | bool mIsOpenViewFinished : 1;
|
---|
324 | bool mIsFirstTimeStarted : 1;
|
---|
325 | bool mIsAutoSaveMedia : 1;
|
---|
326 |
|
---|
327 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
328 | // Debugger GUI
|
---|
329 | PDBGGUI dbg_gui;
|
---|
330 | #endif
|
---|
331 |
|
---|
332 | #ifdef Q_WS_MAC
|
---|
333 | /* For seamless maximizing */
|
---|
334 | QRect mNormalGeometry;
|
---|
335 | Qt::WindowFlags mSavedFlags;
|
---|
336 | /* Dock images */
|
---|
337 | CGImageRef dockImgStatePaused;
|
---|
338 | CGImageRef dockImgStateSaving;
|
---|
339 | CGImageRef dockImgStateRestoring;
|
---|
340 | CGImageRef dockImgBack100x75;
|
---|
341 | CGImageRef dockImgOS;
|
---|
342 | /* For the fade effect if the the window goes fullscreen */
|
---|
343 | CGDisplayFadeReservationToken mFadeToken;
|
---|
344 | #endif
|
---|
345 | };
|
---|
346 |
|
---|
347 |
|
---|
348 | class VBoxVMSettingsSF;
|
---|
349 | class VBoxSFDialog : public QIWithRetranslateUI<QDialog>
|
---|
350 | {
|
---|
351 | Q_OBJECT;
|
---|
352 |
|
---|
353 | public:
|
---|
354 |
|
---|
355 | VBoxSFDialog (QWidget*, CSession&);
|
---|
356 |
|
---|
357 | protected:
|
---|
358 |
|
---|
359 | void retranslateUi();
|
---|
360 |
|
---|
361 | protected slots:
|
---|
362 |
|
---|
363 | virtual void accept();
|
---|
364 |
|
---|
365 | protected:
|
---|
366 |
|
---|
367 | void showEvent (QShowEvent*);
|
---|
368 |
|
---|
369 | private:
|
---|
370 |
|
---|
371 | VBoxVMSettingsSF *mSettings;
|
---|
372 | CSession &mSession;
|
---|
373 | };
|
---|
374 |
|
---|
375 |
|
---|
376 | #endif // __VBoxConsoleWnd_h__
|
---|