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 |
|
---|
28 | #include "QIWithRetranslateUI.h"
|
---|
29 |
|
---|
30 | #include "VBoxProblemReporter.h"
|
---|
31 |
|
---|
32 | /* Qt includes */
|
---|
33 | #include <QMainWindow>
|
---|
34 | #include <QMap>
|
---|
35 | #include <QColor>
|
---|
36 | #include <QDialog>
|
---|
37 |
|
---|
38 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
39 | # include <VBox/dbggui.h>
|
---|
40 | #endif
|
---|
41 | #ifdef Q_WS_MAC
|
---|
42 | # undef PAGE_SIZE
|
---|
43 | # undef PAGE_SHIFT
|
---|
44 | # include <Carbon/Carbon.h>
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | class QAction;
|
---|
48 | class QActionGroup;
|
---|
49 | class QLabel;
|
---|
50 | class QSpacerItem;
|
---|
51 | class QMenu;
|
---|
52 |
|
---|
53 | class VBoxConsoleView;
|
---|
54 | class QIStateIndicator;
|
---|
55 |
|
---|
56 | class VBoxUSBMenu;
|
---|
57 | class VBoxSwitchMenu;
|
---|
58 |
|
---|
59 | class VBoxConsoleWnd : public QIWithRetranslateUI2<QMainWindow>
|
---|
60 | {
|
---|
61 | Q_OBJECT;
|
---|
62 |
|
---|
63 | public:
|
---|
64 |
|
---|
65 | VBoxConsoleWnd (VBoxConsoleWnd **aSelf,
|
---|
66 | QWidget* aParent = 0,
|
---|
67 | Qt::WindowFlags aFlags = Qt::Window);
|
---|
68 | virtual ~VBoxConsoleWnd();
|
---|
69 |
|
---|
70 | bool openView (const CSession &session);
|
---|
71 |
|
---|
72 | void refreshView();
|
---|
73 |
|
---|
74 | bool isTrueFullscreen() const { return mIsFullscreen; }
|
---|
75 |
|
---|
76 | bool isTrueSeamless() const { return mIsSeamless; }
|
---|
77 |
|
---|
78 | void setMouseIntegrationLocked (bool aDisabled);
|
---|
79 |
|
---|
80 | void popupMainMenu (bool aCenter);
|
---|
81 |
|
---|
82 | void installGuestAdditionsFrom (const QString &aSource);
|
---|
83 |
|
---|
84 | void setMask (const QRegion &aRegion);
|
---|
85 |
|
---|
86 | void clearMask();
|
---|
87 |
|
---|
88 | #ifdef Q_WS_MAC
|
---|
89 | CGImageRef dockImageState () const;
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | public slots:
|
---|
93 |
|
---|
94 | protected:
|
---|
95 |
|
---|
96 | // events
|
---|
97 | bool event (QEvent *e);
|
---|
98 | void closeEvent (QCloseEvent *e);
|
---|
99 | #if defined(Q_WS_X11)
|
---|
100 | bool x11Event (XEvent *event);
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | void retranslateUi();
|
---|
104 |
|
---|
105 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
106 | bool dbgCreated();
|
---|
107 | void dbgDestroy();
|
---|
108 | void dbgAdjustRelativePos();
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | protected slots:
|
---|
112 |
|
---|
113 | void closeView();
|
---|
114 |
|
---|
115 | private:
|
---|
116 |
|
---|
117 | enum /* Stuff */
|
---|
118 | {
|
---|
119 | FloppyStuff = 0x01,
|
---|
120 | DVDStuff = 0x02,
|
---|
121 | HardDiskStuff = 0x04,
|
---|
122 | PauseAction = 0x08,
|
---|
123 | NetworkStuff = 0x10,
|
---|
124 | DisableMouseIntegrAction = 0x20,
|
---|
125 | Caption = 0x40,
|
---|
126 | USBStuff = 0x80,
|
---|
127 | VRDPStuff = 0x100,
|
---|
128 | SharedFolderStuff = 0x200,
|
---|
129 | AllStuff = 0xFFFF,
|
---|
130 | };
|
---|
131 |
|
---|
132 | void updateAppearanceOf (int element);
|
---|
133 |
|
---|
134 | bool toggleFullscreenMode (bool, bool);
|
---|
135 |
|
---|
136 | private slots:
|
---|
137 |
|
---|
138 | void finalizeOpenView();
|
---|
139 |
|
---|
140 | void activateUICustomizations();
|
---|
141 |
|
---|
142 | void vmFullscreen (bool on);
|
---|
143 | void vmSeamless (bool on);
|
---|
144 | void vmAutoresizeGuest (bool on);
|
---|
145 | void vmAdjustWindow();
|
---|
146 |
|
---|
147 | void vmTypeCAD();
|
---|
148 | void vmTypeCABS();
|
---|
149 | void vmReset();
|
---|
150 | void vmPause(bool);
|
---|
151 | void vmACPIShutdown();
|
---|
152 | void vmClose();
|
---|
153 | void vmTakeSnapshot();
|
---|
154 | void vmShowInfoDialog();
|
---|
155 | void vmDisableMouseIntegr (bool);
|
---|
156 |
|
---|
157 | void devicesMountFloppyImage();
|
---|
158 | void devicesUnmountFloppy();
|
---|
159 | void devicesMountDVDImage();
|
---|
160 | void devicesUnmountDVD();
|
---|
161 | void devicesSwitchVrdp (bool);
|
---|
162 | void devicesOpenSFDialog();
|
---|
163 | void devicesInstallGuestAdditions();
|
---|
164 |
|
---|
165 | void prepareFloppyMenu();
|
---|
166 | void prepareDVDMenu();
|
---|
167 | void prepareNetworkMenu();
|
---|
168 |
|
---|
169 | void setDynamicMenuItemStatusTip (QAction *aAction);
|
---|
170 |
|
---|
171 | void captureFloppy (QAction *aAction);
|
---|
172 | void captureDVD (QAction *aAction);
|
---|
173 | void activateNetworkMenu (QAction *aAction);
|
---|
174 | void switchUSB (QAction *aAction);
|
---|
175 |
|
---|
176 | void statusTipChanged (const QString &);
|
---|
177 | void clearStatusBar();
|
---|
178 |
|
---|
179 | void showIndicatorContextMenu (QIStateIndicator *ind, QContextMenuEvent *e);
|
---|
180 |
|
---|
181 | void updateDeviceLights();
|
---|
182 | void updateMachineState (KMachineState state);
|
---|
183 | void updateMouseState (int state);
|
---|
184 | void updateAdditionsState (const QString&, bool, bool, bool);
|
---|
185 | void updateNetworkAdarptersState();
|
---|
186 | void updateUsbState();
|
---|
187 | void updateMediaDriveState (VBoxDefs::MediaType aType);
|
---|
188 | void updateSharedFoldersState();
|
---|
189 |
|
---|
190 | void tryClose();
|
---|
191 |
|
---|
192 | void processGlobalSettingChange (const char *publicName, const char *name);
|
---|
193 |
|
---|
194 | void dbgPrepareDebugMenu();
|
---|
195 | void dbgShowStatistics();
|
---|
196 | void dbgShowCommandLine();
|
---|
197 | void dbgLoggingToggled(bool aBool);
|
---|
198 |
|
---|
199 | void onExitFullscreen();
|
---|
200 | void unlockActionsSwitch();
|
---|
201 |
|
---|
202 | void switchToFullscreen (bool aOn, bool aSeamless);
|
---|
203 | void setViewInSeamlessMode (const QRect &aTargetRect);
|
---|
204 |
|
---|
205 | private:
|
---|
206 |
|
---|
207 | /** Popup version of the main menu */
|
---|
208 | QMenu *mMainMenu;
|
---|
209 |
|
---|
210 | QActionGroup *mRunningActions;
|
---|
211 | QActionGroup *mRunningOrPausedActions;
|
---|
212 |
|
---|
213 | /* Machine actions */
|
---|
214 | QAction *mVmFullscreenAction;
|
---|
215 | QAction *mVmSeamlessAction;
|
---|
216 | QAction *mVmAutoresizeGuestAction;
|
---|
217 | QAction *mVmAdjustWindowAction;
|
---|
218 | QAction *mVmTypeCADAction;
|
---|
219 | #if defined(Q_WS_X11)
|
---|
220 | QAction *mVmTypeCABSAction;
|
---|
221 | #endif
|
---|
222 | QAction *mVmResetAction;
|
---|
223 | QAction *mVmPauseAction;
|
---|
224 | QAction *mVmACPIShutdownAction;
|
---|
225 | QAction *mVmCloseAction;
|
---|
226 | QAction *mVmTakeSnapshotAction;
|
---|
227 | QAction *mVmDisableMouseIntegrAction;
|
---|
228 | QAction *mVmShowInformationDlgAction;
|
---|
229 |
|
---|
230 | /* Devices actions */
|
---|
231 | QAction *mDevicesMountFloppyImageAction;
|
---|
232 | QAction *mDevicesUnmountFloppyAction;
|
---|
233 | QAction *mDevicesMountDVDImageAction;
|
---|
234 | QAction *mDevicesUnmountDVDAction;
|
---|
235 | QAction *mDevicesSwitchVrdpAction;
|
---|
236 | QAction *mDevicesSFDialogAction;
|
---|
237 | QAction *mDevicesInstallGuestToolsAction;
|
---|
238 |
|
---|
239 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
240 | /* Debugger actions */
|
---|
241 | QAction *mDbgStatisticsAction;
|
---|
242 | QAction *mDbgCommandLineAction;
|
---|
243 | QAction *mDbgLoggingAction;
|
---|
244 | #endif
|
---|
245 |
|
---|
246 | /* Help actions */
|
---|
247 | VBoxHelpActions mHelpActions;
|
---|
248 |
|
---|
249 | /* Machine popup menus */
|
---|
250 | VBoxSwitchMenu *mVmAutoresizeMenu;
|
---|
251 | VBoxSwitchMenu *mVmDisMouseIntegrMenu;
|
---|
252 |
|
---|
253 | /* Devices popup menus */
|
---|
254 | bool mWaitForStatusBarChange : 1;
|
---|
255 | bool mStatusBarChangedInside : 1;
|
---|
256 |
|
---|
257 | QAction *mDevicesUSBMenuSeparator;
|
---|
258 | QAction *mDevicesVRDPMenuSeparator;
|
---|
259 | QAction *mDevicesSFMenuSeparator;
|
---|
260 |
|
---|
261 | QMenu *mVMMenu;
|
---|
262 | QMenu *mDevicesMenu;
|
---|
263 | QMenu *mDevicesMountFloppyMenu;
|
---|
264 | QMenu *mDevicesMountDVDMenu;
|
---|
265 | /* see showIndicatorContextMenu for a description of mDevicesSFMenu */
|
---|
266 | /* QMenu *mDevicesSFMenu; */
|
---|
267 | QMenu *mDevicesNetworkMenu;
|
---|
268 | VBoxUSBMenu *mDevicesUSBMenu;
|
---|
269 | /* VBoxSwitchMenu *mDevicesVRDPMenu; */
|
---|
270 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
271 | // Debugger popup menu
|
---|
272 | QMenu *mDbgMenu;
|
---|
273 | #endif
|
---|
274 | QMenu *mHelpMenu;
|
---|
275 |
|
---|
276 | QSpacerItem *mShiftingSpacerLeft;
|
---|
277 | QSpacerItem *mShiftingSpacerTop;
|
---|
278 | QSpacerItem *mShiftingSpacerRight;
|
---|
279 | QSpacerItem *mShiftingSpacerBottom;
|
---|
280 | QSize mMaskShift;
|
---|
281 |
|
---|
282 | CSession csession;
|
---|
283 |
|
---|
284 | // widgets
|
---|
285 | VBoxConsoleView *console;
|
---|
286 | QIStateIndicator *hd_light, *cd_light, *fd_light, *net_light, *usb_light, *sf_light;
|
---|
287 | QIStateIndicator *mouse_state, *hostkey_state;
|
---|
288 | QIStateIndicator *autoresize_state;
|
---|
289 | QIStateIndicator *vrdp_state;
|
---|
290 | QWidget *hostkey_hbox;
|
---|
291 | QLabel *hostkey_name;
|
---|
292 |
|
---|
293 | QTimer *idle_timer;
|
---|
294 | KMachineState machine_state;
|
---|
295 | QString caption_prefix;
|
---|
296 |
|
---|
297 | bool no_auto_close : 1;
|
---|
298 |
|
---|
299 | QMap <QAction *, CHostDVDDrive> hostDVDMap;
|
---|
300 | QMap <QAction *, CHostFloppyDrive> hostFloppyMap;
|
---|
301 |
|
---|
302 | QRect mNormalGeo;
|
---|
303 | QSize prev_min_size;
|
---|
304 |
|
---|
305 | #ifdef Q_WS_WIN
|
---|
306 | QRegion mPrevRegion;
|
---|
307 | #endif
|
---|
308 |
|
---|
309 | #ifdef Q_WS_MAC
|
---|
310 | QRegion mCurrRegion;
|
---|
311 | EventHandlerRef mDarwinRegionEventHandlerRef;
|
---|
312 | #endif
|
---|
313 |
|
---|
314 | // variables for dealing with true fullscreen
|
---|
315 | QRegion mStrictedRegion;
|
---|
316 | bool mIsFullscreen : 1;
|
---|
317 | bool mIsSeamless : 1;
|
---|
318 | bool mIsSeamlessSupported : 1;
|
---|
319 | bool mIsGraphicsSupported : 1;
|
---|
320 | bool mIsWaitingModeResize : 1;
|
---|
321 | bool was_max : 1;
|
---|
322 | QObjectList hidden_children;
|
---|
323 | int console_style;
|
---|
324 | QPalette mErasePalette;
|
---|
325 |
|
---|
326 | bool mIsOpenViewFinished : 1;
|
---|
327 | bool mIsFirstTimeStarted : 1;
|
---|
328 | bool mIsAutoSaveMedia : 1;
|
---|
329 |
|
---|
330 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
331 | /** The handle to the debugger gui. */
|
---|
332 | PDBGGUI mDbgGui;
|
---|
333 | /** The virtual method table for the debugger GUI. */
|
---|
334 | PCDBGGUIVT mDbgGuiVT;
|
---|
335 | #endif
|
---|
336 |
|
---|
337 | #ifdef Q_WS_MAC
|
---|
338 | /* For seamless maximizing */
|
---|
339 | QRect mNormalGeometry;
|
---|
340 | Qt::WindowFlags mSavedFlags;
|
---|
341 | /* Dock images */
|
---|
342 | CGImageRef dockImgStatePaused;
|
---|
343 | CGImageRef dockImgStateSaving;
|
---|
344 | CGImageRef dockImgStateRestoring;
|
---|
345 | CGImageRef dockImgBack100x75;
|
---|
346 | CGImageRef dockImgOS;
|
---|
347 | /* For the fade effect if the the window goes fullscreen */
|
---|
348 | CGDisplayFadeReservationToken mFadeToken;
|
---|
349 | #endif
|
---|
350 | };
|
---|
351 |
|
---|
352 |
|
---|
353 | class VBoxVMSettingsSF;
|
---|
354 | class VBoxSFDialog : public QIWithRetranslateUI<QDialog>
|
---|
355 | {
|
---|
356 | Q_OBJECT;
|
---|
357 |
|
---|
358 | public:
|
---|
359 |
|
---|
360 | VBoxSFDialog (QWidget*, CSession&);
|
---|
361 |
|
---|
362 | protected:
|
---|
363 |
|
---|
364 | void retranslateUi();
|
---|
365 |
|
---|
366 | protected slots:
|
---|
367 |
|
---|
368 | virtual void accept();
|
---|
369 |
|
---|
370 | protected:
|
---|
371 |
|
---|
372 | void showEvent (QShowEvent*);
|
---|
373 |
|
---|
374 | private:
|
---|
375 |
|
---|
376 | VBoxVMSettingsSF *mSettings;
|
---|
377 | CSession &mSession;
|
---|
378 | };
|
---|
379 |
|
---|
380 |
|
---|
381 | #endif // __VBoxConsoleWnd_h__
|
---|