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