VirtualBox

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

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

FE/Qt4-OSX: Quartz2D backend back to life for Cocoa.

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