VirtualBox

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

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

Qt4Gui: Carbon -> Coca; make it build. (darwin/amd64)

  • 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
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# ifdef QT_MAC_USE_COCOA
44 /** @todo Carbon -> Cocoa */
45# else
46# undef PAGE_SIZE
47# undef PAGE_SHIFT
48# include <Carbon/Carbon.h>
49# endif
50#endif
51
52class QAction;
53class QActionGroup;
54class QLabel;
55class QSpacerItem;
56
57class VBoxConsoleView;
58class QIStateIndicator;
59
60class VBoxUSBMenu;
61class VBoxSwitchMenu;
62
63class VBoxChangeDockIconUpdateEvent;
64
65/* We want to make the first action highlighted but not
66 * selected, but Qt makes the both or neither one of this,
67 * so, just move the focus to the next eligible object,
68 * which will be the first menu action. This little
69 * subclass made only for that purpose. */
70class QIMenu : public QMenu
71{
72 Q_OBJECT;
73
74public:
75
76 QIMenu (QWidget *aParent) : QMenu (aParent) {}
77
78 void selectFirstAction() { QMenu::focusNextChild(); }
79};
80
81class VBoxConsoleWnd : public QIWithRetranslateUI2<QMainWindow>
82{
83 Q_OBJECT;
84
85public:
86
87 VBoxConsoleWnd (VBoxConsoleWnd **aSelf,
88 QWidget* aParent = 0,
89 Qt::WindowFlags aFlags = Qt::Window);
90 virtual ~VBoxConsoleWnd();
91
92 bool openView (const CSession &session);
93
94 void refreshView();
95
96 bool isWindowMaximized() const
97 {
98#ifdef Q_WS_MAC
99 /* On Mac OS X we didn't really jump to the fullscreen mode but
100 * maximize the window. This situation has to be considered when
101 * checking for maximized or fullscreen mode. */
102 return !(isTrueSeamless()) && QMainWindow::isMaximized();
103#else /* Q_WS_MAC */
104 return QMainWindow::isMaximized();
105#endif /* Q_WS_MAC */
106 }
107 bool isWindowFullScreen() const
108 {
109#ifdef Q_WS_MAC
110 /* On Mac OS X we didn't really jump to the fullscreen mode but
111 * maximize the window. This situation has to be considered when
112 * checking for maximized or fullscreen mode. */
113 return isTrueFullscreen() || isTrueSeamless();
114#else /* Q_WS_MAC */
115 return QMainWindow::isFullScreen();
116#endif /* Q_WS_MAC */
117 }
118
119 bool isTrueFullscreen() const { return mIsFullscreen; }
120
121 bool isTrueSeamless() const { return mIsSeamless; }
122
123 void setMouseIntegrationLocked (bool aDisabled);
124
125 void popupMainMenu (bool aCenter);
126
127 void installGuestAdditionsFrom (const QString &aSource);
128
129 void setMask (const QRegion &aRegion);
130
131 void clearMask();
132
133 KMachineState machineState() const { return machine_state; }
134
135public slots:
136
137 void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &e);
138
139signals:
140
141 void closing();
142
143protected:
144
145 // events
146 bool event (QEvent *e);
147 void closeEvent (QCloseEvent *e);
148#if defined(Q_WS_X11)
149 bool x11Event (XEvent *event);
150#endif
151
152 void retranslateUi();
153
154#ifdef VBOX_WITH_DEBUGGER_GUI
155 bool dbgCreated();
156 void dbgDestroy();
157 void dbgAdjustRelativePos();
158#endif
159
160protected slots:
161
162 void closeView();
163
164private:
165
166 enum /* Stuff */
167 {
168 FloppyStuff = 0x01,
169 DVDStuff = 0x02,
170 HardDiskStuff = 0x04,
171 PauseAction = 0x08,
172 NetworkStuff = 0x10,
173 DisableMouseIntegrAction = 0x20,
174 Caption = 0x40,
175 USBStuff = 0x80,
176 VRDPStuff = 0x100,
177 SharedFolderStuff = 0x200,
178 VirtualizationStuff = 0x400,
179 AllStuff = 0xFFFF,
180 };
181
182 void updateAppearanceOf (int element);
183
184 bool toggleFullscreenMode (bool, bool);
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
255private:
256
257 /** Popup version of the main menu */
258 QIMenu *mMainMenu;
259
260 QActionGroup *mRunningActions;
261 QActionGroup *mRunningOrPausedActions;
262
263 /* Machine actions */
264 QAction *mVmFullscreenAction;
265 QAction *mVmSeamlessAction;
266 QAction *mVmAutoresizeGuestAction;
267 QAction *mVmAdjustWindowAction;
268 QAction *mVmTypeCADAction;
269#if defined(Q_WS_X11)
270 QAction *mVmTypeCABSAction;
271#endif
272 QAction *mVmResetAction;
273 QAction *mVmPauseAction;
274 QAction *mVmACPIShutdownAction;
275 QAction *mVmCloseAction;
276 QAction *mVmTakeSnapshotAction;
277 QAction *mVmDisableMouseIntegrAction;
278 QAction *mVmShowInformationDlgAction;
279
280 /* Devices actions */
281 QAction *mDevicesMountFloppyImageAction;
282 QAction *mDevicesUnmountFloppyAction;
283 QAction *mDevicesMountDVDImageAction;
284 QAction *mDevicesUnmountDVDAction;
285 QAction *mDevicesSwitchVrdpAction;
286 QAction *mDevicesSFDialogAction;
287 QAction *mDevicesInstallGuestToolsAction;
288
289#ifdef VBOX_WITH_DEBUGGER_GUI
290 /* Debugger actions */
291 QAction *mDbgStatisticsAction;
292 QAction *mDbgCommandLineAction;
293 QAction *mDbgLoggingAction;
294#endif
295
296 /* Help actions */
297 VBoxHelpActions mHelpActions;
298
299 /* Machine popup menus */
300 VBoxSwitchMenu *mVmAutoresizeMenu;
301 VBoxSwitchMenu *mVmDisMouseIntegrMenu;
302
303 /* Devices popup menus */
304 bool mWaitForStatusBarChange : 1;
305 bool mStatusBarChangedInside : 1;
306
307 QAction *mDevicesUSBMenuSeparator;
308 QAction *mDevicesVRDPMenuSeparator;
309 QAction *mDevicesSFMenuSeparator;
310
311 QMenu *mVMMenu;
312 QMenu *mDevicesMenu;
313 QMenu *mDevicesMountFloppyMenu;
314 QMenu *mDevicesMountDVDMenu;
315 /* see showIndicatorContextMenu for a description of mDevicesSFMenu */
316 /* QMenu *mDevicesSFMenu; */
317 QMenu *mDevicesNetworkMenu;
318 VBoxUSBMenu *mDevicesUSBMenu;
319 /* VBoxSwitchMenu *mDevicesVRDPMenu; */
320#ifdef VBOX_WITH_DEBUGGER_GUI
321 // Debugger popup menu
322 QMenu *mDbgMenu;
323#endif
324 QMenu *mHelpMenu;
325
326 QSpacerItem *mShiftingSpacerLeft;
327 QSpacerItem *mShiftingSpacerTop;
328 QSpacerItem *mShiftingSpacerRight;
329 QSpacerItem *mShiftingSpacerBottom;
330 QSize mMaskShift;
331
332 CSession csession;
333
334 // widgets
335 VBoxConsoleView *console;
336 QIStateIndicator *hd_light, *cd_light, *fd_light, *net_light, *usb_light, *sf_light;
337 QIStateIndicator *mVirtLed;
338 QIStateIndicator *mouse_state, *hostkey_state;
339 QIStateIndicator *autoresize_state;
340 QIStateIndicator *vrdp_state;
341 QWidget *hostkey_hbox;
342 QLabel *hostkey_name;
343
344 QTimer *idle_timer;
345 KMachineState machine_state;
346 QString caption_prefix;
347
348 bool no_auto_close : 1;
349
350 QMap <QAction *, CHostDVDDrive> hostDVDMap;
351 QMap <QAction *, CHostFloppyDrive> hostFloppyMap;
352
353 QRect mNormalGeo;
354 QSize prev_min_size;
355
356#ifdef Q_WS_WIN
357 QRegion mPrevRegion;
358#endif
359
360#ifdef Q_WS_MAC
361 QRegion mCurrRegion;
362# ifdef QT_MAC_USE_COCOA
363 /** @todo Carbon -> Cocoa */
364# else
365 EventHandlerRef mDarwinRegionEventHandlerRef;
366# endif
367#endif
368
369 // variables for dealing with true fullscreen
370 QRegion mStrictedRegion;
371 bool mIsFullscreen : 1;
372 bool mIsSeamless : 1;
373 bool mIsSeamlessSupported : 1;
374 bool mIsGraphicsSupported : 1;
375 bool mIsWaitingModeResize : 1;
376 bool was_max : 1;
377 QObjectList hidden_children;
378 int console_style;
379 QPalette mErasePalette;
380
381 bool mIsOpenViewFinished : 1;
382 bool mIsFirstTimeStarted : 1;
383 bool mIsAutoSaveMedia : 1;
384
385#ifdef VBOX_WITH_DEBUGGER_GUI
386 /** The handle to the debugger gui. */
387 PDBGGUI mDbgGui;
388 /** The virtual method table for the debugger GUI. */
389 PCDBGGUIVT mDbgGuiVT;
390#endif
391
392#ifdef Q_WS_MAC
393 /* For seamless maximizing */
394 QRect mNormalGeometry;
395 Qt::WindowFlags mSavedFlags;
396# ifdef QT_MAC_USE_COCOA
397 /** @todo Carbon -> Cocoa */
398# else
399 /* For the fade effect if the the window goes fullscreen */
400 CGDisplayFadeReservationToken mFadeToken;
401# endif
402#endif
403};
404
405
406class VBoxVMSettingsSF;
407class VBoxSFDialog : public QIWithRetranslateUI<QDialog>
408{
409 Q_OBJECT;
410
411public:
412
413 VBoxSFDialog (QWidget*, CSession&);
414
415protected:
416
417 void retranslateUi();
418
419protected slots:
420
421 virtual void accept();
422
423protected:
424
425 void showEvent (QShowEvent*);
426
427private:
428
429 VBoxVMSettingsSF *mSettings;
430 CSession &mSession;
431};
432
433
434#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