1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxConsoleWnd class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2009 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 | /* Global includes */
|
---|
27 | #include <QColor>
|
---|
28 | #include <QDialog>
|
---|
29 | #include <QMainWindow>
|
---|
30 | #include <QMap>
|
---|
31 | #include <QMenu>
|
---|
32 | #include <QPointer>
|
---|
33 |
|
---|
34 | /* Local includes */
|
---|
35 | #include "COMDefs.h"
|
---|
36 | #include "QIWithRetranslateUI.h"
|
---|
37 | #include "VBoxProblemReporter.h"
|
---|
38 | #include "VBoxHelpActions.h"
|
---|
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 | # ifndef QT_MAC_USE_COCOA
|
---|
46 | # include <Carbon/Carbon.h>
|
---|
47 | # endif /* !QT_MAC_USE_COCOA */
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | /* Global forwards */
|
---|
51 | class QAction;
|
---|
52 | class QActionGroup;
|
---|
53 | class QLabel;
|
---|
54 | class QSpacerItem;
|
---|
55 | class QIWidgetValidator;
|
---|
56 |
|
---|
57 | /* Local forwards */
|
---|
58 | class QIMenu;
|
---|
59 | class QIStateIndicator;
|
---|
60 | class VBoxChangeDockIconUpdateEvent;
|
---|
61 | class VBoxConsoleView;
|
---|
62 | class VBoxMiniToolBar;
|
---|
63 | class VBoxSwitchMenu;
|
---|
64 | class VBoxUSBMenu;
|
---|
65 |
|
---|
66 | class VBoxConsoleWnd : public QIWithRetranslateUI2 <QMainWindow>
|
---|
67 | {
|
---|
68 | Q_OBJECT;
|
---|
69 |
|
---|
70 | public:
|
---|
71 |
|
---|
72 | VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent = 0, Qt::WindowFlags aFlags = Qt::Window);
|
---|
73 | virtual ~VBoxConsoleWnd();
|
---|
74 |
|
---|
75 | bool isWindowMaximized() const
|
---|
76 | {
|
---|
77 | #ifdef Q_WS_MAC
|
---|
78 | /* On Mac OS X we didn't really jump to the fullscreen mode but
|
---|
79 | * maximize the window. This situation has to be considered when
|
---|
80 | * checking for maximized or fullscreen mode. */
|
---|
81 | return !isTrueSeamless() && QMainWindow::isMaximized();
|
---|
82 | #else /* Q_WS_MAC */
|
---|
83 | return QMainWindow::isMaximized();
|
---|
84 | #endif /* Q_WS_MAC */
|
---|
85 | }
|
---|
86 | bool isWindowFullScreen() const
|
---|
87 | {
|
---|
88 | #ifdef Q_WS_MAC
|
---|
89 | /* On Mac OS X we didn't really jump to the fullscreen mode but
|
---|
90 | * maximize the window. This situation has to be considered when
|
---|
91 | * checking for maximized or fullscreen mode. */
|
---|
92 | return isTrueFullscreen() || isTrueSeamless();
|
---|
93 | #else /* Q_WS_MAC */
|
---|
94 | return QMainWindow::isFullScreen();
|
---|
95 | #endif /* Q_WS_MAC */
|
---|
96 | }
|
---|
97 | bool isTrueFullscreen() const { return mIsFullscreen; }
|
---|
98 | bool isTrueSeamless() const { return mIsSeamless; }
|
---|
99 |
|
---|
100 | KMachineState machineState() const { return mMachineState; }
|
---|
101 |
|
---|
102 | bool openView (const CSession &aSession);
|
---|
103 |
|
---|
104 | void setMouseIntegrationLocked (bool aDisabled);
|
---|
105 |
|
---|
106 | void popupMainMenu (bool aCenter);
|
---|
107 |
|
---|
108 | void installGuestAdditionsFrom (const QString &aSource);
|
---|
109 |
|
---|
110 | void setMask (const QRegion &aRegion);
|
---|
111 | void clearMask();
|
---|
112 |
|
---|
113 | signals:
|
---|
114 |
|
---|
115 | void closing();
|
---|
116 |
|
---|
117 | protected:
|
---|
118 |
|
---|
119 | bool event (QEvent *aEvent);
|
---|
120 | void closeEvent (QCloseEvent *aEvent);
|
---|
121 | #ifdef Q_WS_X11
|
---|
122 | bool x11Event (XEvent *aEvent);
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | void retranslateUi();
|
---|
126 |
|
---|
127 | private slots:
|
---|
128 |
|
---|
129 | void finalizeOpenView();
|
---|
130 | void tryClose();
|
---|
131 |
|
---|
132 | void vmFullscreen (bool aOn);
|
---|
133 | void vmSeamless (bool aOn);
|
---|
134 | void vmAutoresizeGuest (bool aOn);
|
---|
135 | void vmAdjustWindow();
|
---|
136 | void vmDisableMouseIntegration (bool aOff);
|
---|
137 | void vmTypeCAD();
|
---|
138 | #ifdef Q_WS_X11
|
---|
139 | void vmTypeCABS();
|
---|
140 | #endif
|
---|
141 | void vmTakeSnapshot();
|
---|
142 | void vmShowInfoDialog();
|
---|
143 | void vmReset();
|
---|
144 | void vmPause (bool aOn);
|
---|
145 | void vmACPIShutdown();
|
---|
146 | void vmClose();
|
---|
147 |
|
---|
148 | void devicesSwitchVrdp (bool aOn);
|
---|
149 | void devicesOpenStorageDialog();
|
---|
150 | void devicesOpenNetworkDialog();
|
---|
151 | void devicesOpenSFDialog();
|
---|
152 | void devicesInstallGuestAdditions();
|
---|
153 |
|
---|
154 | void prepareStorageMenu();
|
---|
155 | void prepareNetworkMenu();
|
---|
156 | void prepareSFMenu();
|
---|
157 |
|
---|
158 | void switchUSB (QAction *aAction);
|
---|
159 |
|
---|
160 | void showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent);
|
---|
161 |
|
---|
162 | void updateDeviceLights();
|
---|
163 | void updateMachineState (KMachineState aState);
|
---|
164 | void updateMouseState (int aState);
|
---|
165 | void updateAdditionsState (const QString &aVersion, bool aActive,
|
---|
166 | bool aSeamlessSupported, bool aGraphicsSupported);
|
---|
167 | void updateNetworkAdaptersState();
|
---|
168 | void updateUsbState();
|
---|
169 | void updateMediaDriveState (VBoxDefs::MediumType aType);
|
---|
170 | void updateSharedFoldersState();
|
---|
171 |
|
---|
172 | void onExitFullscreen();
|
---|
173 | void unlockActionsSwitch();
|
---|
174 |
|
---|
175 | void mtExitMode();
|
---|
176 | void mtCloseVM();
|
---|
177 | void mtMaskUpdate();
|
---|
178 |
|
---|
179 | void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &aEvent);
|
---|
180 | void processGlobalSettingChange (const char *aPublicName, const char *aName);
|
---|
181 |
|
---|
182 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
183 | void dbgPrepareDebugMenu();
|
---|
184 | void dbgShowStatistics();
|
---|
185 | void dbgShowCommandLine();
|
---|
186 | void dbgLoggingToggled (bool aBool);
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | private:
|
---|
190 |
|
---|
191 | enum /* Stuff */
|
---|
192 | {
|
---|
193 | HardDiskStuff = 0x01,
|
---|
194 | DVDStuff = 0x02,
|
---|
195 | FloppyStuff = 0x04,
|
---|
196 | PauseAction = 0x08,
|
---|
197 | NetworkStuff = 0x10,
|
---|
198 | DisableMouseIntegrAction = 0x20,
|
---|
199 | Caption = 0x40,
|
---|
200 | USBStuff = 0x80,
|
---|
201 | VRDPStuff = 0x100,
|
---|
202 | SharedFolderStuff = 0x200,
|
---|
203 | VirtualizationStuff = 0x400,
|
---|
204 | AllStuff = 0xFFFF,
|
---|
205 | };
|
---|
206 |
|
---|
207 | void checkRequiredFeatures();
|
---|
208 | void activateUICustomizations();
|
---|
209 |
|
---|
210 | void updateAppearanceOf (int aElement);
|
---|
211 |
|
---|
212 | bool toggleFullscreenMode (bool aOn, bool aSeamless);
|
---|
213 | void switchToFullscreen (bool aOn, bool aSeamless);
|
---|
214 | void setViewInSeamlessMode (const QRect &aTargetRect);
|
---|
215 |
|
---|
216 | void closeView();
|
---|
217 |
|
---|
218 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
219 | bool dbgCreated();
|
---|
220 | void dbgDestroy();
|
---|
221 | void dbgAdjustRelativePos();
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | /* COM Variables */
|
---|
225 | CSession mSession;
|
---|
226 |
|
---|
227 | /* Machine State */
|
---|
228 | KMachineState mMachineState;
|
---|
229 |
|
---|
230 | /* Window Variables */
|
---|
231 | QString mCaptionPrefix;
|
---|
232 | int mConsoleStyle;
|
---|
233 |
|
---|
234 | /* Menu items */
|
---|
235 | QIMenu *mMainMenu;
|
---|
236 | QMenu *mVMMenu;
|
---|
237 | QMenu *mVMMenuMini;
|
---|
238 | QMenu *mDevicesMenu;
|
---|
239 | QMenu *mDevicesStorageMenu;
|
---|
240 | QMenu *mDevicesNetworkMenu;
|
---|
241 | QMenu *mDevicesSFMenu;
|
---|
242 | VBoxUSBMenu *mDevicesUSBMenu;
|
---|
243 | VBoxSwitchMenu *mVmDisMouseIntegrMenu;
|
---|
244 | #if 0 /* todo: allow to setup */
|
---|
245 | VBoxSwitchMenu *mDevicesVRDPMenu;
|
---|
246 | VBoxSwitchMenu *mVmAutoresizeMenu;
|
---|
247 | #endif
|
---|
248 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
249 | QMenu *mDbgMenu;
|
---|
250 | #endif
|
---|
251 | QMenu *mHelpMenu;
|
---|
252 |
|
---|
253 | QActionGroup *mRunningActions;
|
---|
254 | QActionGroup *mRunningOrPausedActions;
|
---|
255 |
|
---|
256 | /* Machine actions */
|
---|
257 | QAction *mVmFullscreenAction;
|
---|
258 | QAction *mVmSeamlessAction;
|
---|
259 | QAction *mVmAutoresizeGuestAction;
|
---|
260 | QAction *mVmAdjustWindowAction;
|
---|
261 | QAction *mVmDisableMouseIntegrAction;
|
---|
262 | QAction *mVmTypeCADAction;
|
---|
263 | #ifdef Q_WS_X11
|
---|
264 | QAction *mVmTypeCABSAction;
|
---|
265 | #endif
|
---|
266 | QAction *mVmTakeSnapshotAction;
|
---|
267 | QAction *mVmShowInformationDlgAction;
|
---|
268 | QAction *mVmResetAction;
|
---|
269 | QAction *mVmPauseAction;
|
---|
270 | QAction *mVmACPIShutdownAction;
|
---|
271 | QAction *mVmCloseAction;
|
---|
272 |
|
---|
273 | /* Devices actions */
|
---|
274 | QAction *mDevicesStorageDialogAction;
|
---|
275 | QAction *mDevicesNetworkDialogAction;
|
---|
276 | QAction *mDevicesSFDialogAction;
|
---|
277 | QAction *mDevicesSwitchVrdpSeparator;
|
---|
278 | QAction *mDevicesSwitchVrdpAction;
|
---|
279 | QAction *mDevicesInstallGuestToolsAction;
|
---|
280 |
|
---|
281 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
282 | /* Debugger actions */
|
---|
283 | QAction *mDbgStatisticsAction;
|
---|
284 | QAction *mDbgCommandLineAction;
|
---|
285 | QAction *mDbgLoggingAction;
|
---|
286 | #endif
|
---|
287 |
|
---|
288 | /* Help actions */
|
---|
289 | VBoxHelpActions mHelpActions;
|
---|
290 |
|
---|
291 | /* Widgets */
|
---|
292 | VBoxConsoleView *mConsole;
|
---|
293 | VBoxMiniToolBar *mMiniToolBar;
|
---|
294 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
295 | /** The handle to the debugger gui. */
|
---|
296 | PDBGGUI mDbgGui;
|
---|
297 | /** The virtual method table for the debugger GUI. */
|
---|
298 | PCDBGGUIVT mDbgGuiVT;
|
---|
299 | #endif
|
---|
300 |
|
---|
301 | /* Timer to update LEDs */
|
---|
302 | QTimer *mIdleTimer;
|
---|
303 |
|
---|
304 | /* LEDs */
|
---|
305 | QIStateIndicator *mHDLed;
|
---|
306 | QIStateIndicator *mCDLed;
|
---|
307 | #if 0 /* todo: allow to setup */
|
---|
308 | QIStateIndicator *mFDLed;
|
---|
309 | #endif
|
---|
310 | QIStateIndicator *mNetLed;
|
---|
311 | QIStateIndicator *mUSBLed;
|
---|
312 | QIStateIndicator *mSFLed;
|
---|
313 | QIStateIndicator *mVirtLed;
|
---|
314 | QIStateIndicator *mMouseLed;
|
---|
315 | QIStateIndicator *mHostkeyLed;
|
---|
316 | QWidget *mHostkeyLedContainer;
|
---|
317 | QLabel *mHostkeyName;
|
---|
318 | #if 0 /* todo: allow to setup */
|
---|
319 | QIStateIndicator *mVrdpLed;
|
---|
320 | QIStateIndicator *mAutoresizeLed;
|
---|
321 | #endif
|
---|
322 |
|
---|
323 | /* Normal Mode */
|
---|
324 | QRect mNormalGeo;
|
---|
325 |
|
---|
326 | /* Fullscreen/Seamless Mode */
|
---|
327 | QList < QPointer <QWidget> > mHiddenChildren;
|
---|
328 | QSpacerItem *mShiftingSpacerLeft;
|
---|
329 | QSpacerItem *mShiftingSpacerTop;
|
---|
330 | QSpacerItem *mShiftingSpacerRight;
|
---|
331 | QSpacerItem *mShiftingSpacerBottom;
|
---|
332 | QPalette mErasePalette;
|
---|
333 | QSize mPrevMinSize;
|
---|
334 | QSize mMaskShift;
|
---|
335 | QRegion mStrictedRegion;
|
---|
336 | #ifdef Q_WS_WIN
|
---|
337 | QRegion mPrevRegion;
|
---|
338 | #endif
|
---|
339 | #ifdef Q_WS_MAC
|
---|
340 | //QRegion mCurrRegion;
|
---|
341 | # ifndef QT_MAC_USE_COCOA
|
---|
342 | //EventHandlerRef mDarwinRegionEventHandlerRef;
|
---|
343 | # endif
|
---|
344 | /* For seamless maximizing */
|
---|
345 | QRect mNormalGeometry;
|
---|
346 | Qt::WindowFlags mSavedFlags;
|
---|
347 | /* For the fade effect if the the window goes fullscreen */
|
---|
348 | CGDisplayFadeReservationToken mFadeToken;
|
---|
349 | #endif
|
---|
350 |
|
---|
351 | /* Different bool flags */
|
---|
352 | bool mIsOpenViewFinished : 1;
|
---|
353 | bool mIsFirstTimeStarted : 1;
|
---|
354 | bool mIsAutoSaveMedia : 1;
|
---|
355 | bool mNoAutoClose : 1;
|
---|
356 | bool mIsFullscreen : 1;
|
---|
357 | bool mIsSeamless : 1;
|
---|
358 | bool mIsSeamlessSupported : 1;
|
---|
359 | bool mIsGraphicsSupported : 1;
|
---|
360 | bool mIsWaitingModeResize : 1;
|
---|
361 | bool mWasMax : 1;
|
---|
362 | };
|
---|
363 |
|
---|
364 | /* We want to make the first action highlighted but not
|
---|
365 | * selected, but Qt makes the both or neither one of this,
|
---|
366 | * so, just move the focus to the next eligible object,
|
---|
367 | * which will be the first menu action. This little
|
---|
368 | * subclass made only for that purpose. */
|
---|
369 | class QIMenu : public QMenu
|
---|
370 | {
|
---|
371 | Q_OBJECT;
|
---|
372 |
|
---|
373 | public:
|
---|
374 |
|
---|
375 | QIMenu (QWidget *aParent) : QMenu (aParent) {}
|
---|
376 |
|
---|
377 | void selectFirstAction() { QMenu::focusNextChild(); }
|
---|
378 | };
|
---|
379 |
|
---|
380 | class VBoxSettingsPage;
|
---|
381 | class VBoxStorageDialog : public QIWithRetranslateUI <QDialog>
|
---|
382 | {
|
---|
383 | Q_OBJECT;
|
---|
384 |
|
---|
385 | public:
|
---|
386 |
|
---|
387 | VBoxStorageDialog (QWidget *aParent, CSession &aSession);
|
---|
388 |
|
---|
389 | protected:
|
---|
390 |
|
---|
391 | void retranslateUi();
|
---|
392 |
|
---|
393 | protected slots:
|
---|
394 |
|
---|
395 | virtual void accept();
|
---|
396 |
|
---|
397 | void revalidate (QIWidgetValidator *aValidator);
|
---|
398 | void enableOk (const QIWidgetValidator *aValidator);
|
---|
399 |
|
---|
400 | protected:
|
---|
401 |
|
---|
402 | void showEvent (QShowEvent *aEvent);
|
---|
403 |
|
---|
404 | private:
|
---|
405 |
|
---|
406 | VBoxSettingsPage *mSettings;
|
---|
407 | QIDialogButtonBox *mButtonBox;
|
---|
408 | CSession &mSession;
|
---|
409 | };
|
---|
410 |
|
---|
411 | class VBoxNetworkDialog : public QIWithRetranslateUI <QDialog>
|
---|
412 | {
|
---|
413 | Q_OBJECT;
|
---|
414 |
|
---|
415 | public:
|
---|
416 |
|
---|
417 | VBoxNetworkDialog (QWidget *aParent, CSession &aSession);
|
---|
418 |
|
---|
419 | protected:
|
---|
420 |
|
---|
421 | void retranslateUi();
|
---|
422 |
|
---|
423 | protected slots:
|
---|
424 |
|
---|
425 | virtual void accept();
|
---|
426 |
|
---|
427 | protected:
|
---|
428 |
|
---|
429 | void showEvent (QShowEvent *aEvent);
|
---|
430 |
|
---|
431 | private:
|
---|
432 |
|
---|
433 | VBoxSettingsPage *mSettings;
|
---|
434 | CSession &mSession;
|
---|
435 | };
|
---|
436 |
|
---|
437 | class VBoxVMSettingsSF;
|
---|
438 | class VBoxSFDialog : public QIWithRetranslateUI <QDialog>
|
---|
439 | {
|
---|
440 | Q_OBJECT;
|
---|
441 |
|
---|
442 | public:
|
---|
443 |
|
---|
444 | VBoxSFDialog (QWidget *aParent, CSession &aSession);
|
---|
445 |
|
---|
446 | protected:
|
---|
447 |
|
---|
448 | void retranslateUi();
|
---|
449 |
|
---|
450 | protected slots:
|
---|
451 |
|
---|
452 | virtual void accept();
|
---|
453 |
|
---|
454 | protected:
|
---|
455 |
|
---|
456 | void showEvent (QShowEvent *aEvent);
|
---|
457 |
|
---|
458 | private:
|
---|
459 |
|
---|
460 | VBoxVMSettingsSF *mSettings;
|
---|
461 | CSession &mSession;
|
---|
462 | };
|
---|
463 |
|
---|
464 | #endif // __VBoxConsoleWnd_h__
|
---|