VirtualBox

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

Last change on this file since 20048 was 20047, checked in by vboxsync, 16 years ago

FE/Qt4: 3948: Mini-ToolBar for Full-screen & Seamless modes - Initial commit.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette