VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h@ 21950

Last change on this file since 21950 was 21842, checked in by vboxsync, 15 years ago

FE/Qt4: Fixing quite old crash happening if going f/s mode just when starting VM and exiting f/s mode later.

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