VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h@ 7678

Last change on this file since 7678 was 7678, checked in by vboxsync, 17 years ago

FE/Qt4: Ported the Console Window to Qt4.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxGlobal class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
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
19#ifndef __VBoxGlobal_h__
20#define __VBoxGlobal_h__
21
22#include "COMDefs.h"
23
24#include "VBoxGlobalSettings.h"
25
26#include <qapplication.h>
27#include <qpixmap.h>
28#include <qicon.h>
29#include <qcolor.h>
30#include <quuid.h>
31#include <qthread.h>
32#include <q3popupmenu.h>
33#include <QMenu>
34#include <qtooltip.h>
35
36#include <q3ptrvector.h>
37#include <q3valuevector.h>
38#include <q3valuelist.h>
39#include <q3dict.h>
40#include <q3intdict.h>
41//Added by qt3to4:
42#include <QLabel>
43#include <QEvent>
44#include <QLayout>
45
46class QAction;
47class QLabel;
48class QToolButton;
49
50// Auxiliary types
51////////////////////////////////////////////////////////////////////////////////
52
53/** Simple media descriptor type. */
54struct VBoxMedia
55{
56 enum Status { Unknown, Ok, Error, Inaccessible };
57
58 VBoxMedia() : type (VBoxDefs::InvalidType), status (Ok) {}
59
60 VBoxMedia (const CUnknown &d, VBoxDefs::DiskType t, Status s)
61 : disk (d), type (t), status (s) {}
62
63 CUnknown disk;
64 VBoxDefs::DiskType type;
65 Status status;
66};
67
68typedef Q3ValueList <VBoxMedia> VBoxMediaList;
69
70// VirtualBox callback events
71////////////////////////////////////////////////////////////////////////////////
72
73class VBoxMachineStateChangeEvent : public QEvent
74{
75public:
76 VBoxMachineStateChangeEvent (const QUuid &aId, KMachineState aState)
77 : QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType)
78 , id (aId), state (aState)
79 {}
80
81 const QUuid id;
82 const KMachineState state;
83};
84
85class VBoxMachineDataChangeEvent : public QEvent
86{
87public:
88 VBoxMachineDataChangeEvent (const QUuid &aId)
89 : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
90 , id (aId)
91 {}
92
93 const QUuid id;
94};
95
96class VBoxMachineRegisteredEvent : public QEvent
97{
98public:
99 VBoxMachineRegisteredEvent (const QUuid &aId, bool aRegistered)
100 : QEvent ((QEvent::Type) VBoxDefs::MachineRegisteredEventType)
101 , id (aId), registered (aRegistered)
102 {}
103
104 const QUuid id;
105 const bool registered;
106};
107
108class VBoxSessionStateChangeEvent : public QEvent
109{
110public:
111 VBoxSessionStateChangeEvent (const QUuid &aId, KSessionState aState)
112 : QEvent ((QEvent::Type) VBoxDefs::SessionStateChangeEventType)
113 , id (aId), state (aState)
114 {}
115
116 const QUuid id;
117 const KSessionState state;
118};
119
120class VBoxSnapshotEvent : public QEvent
121{
122public:
123
124 enum What { Taken, Discarded, Changed };
125
126 VBoxSnapshotEvent (const QUuid &aMachineId, const QUuid &aSnapshotId,
127 What aWhat)
128 : QEvent ((QEvent::Type) VBoxDefs::SnapshotEventType)
129 , what (aWhat)
130 , machineId (aMachineId), snapshotId (aSnapshotId)
131 {}
132
133 const What what;
134
135 const QUuid machineId;
136 const QUuid snapshotId;
137};
138
139class VBoxCanShowRegDlgEvent : public QEvent
140{
141public:
142 VBoxCanShowRegDlgEvent (bool aCanShow)
143 : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
144 , mCanShow (aCanShow)
145 {}
146
147 const bool mCanShow;
148};
149
150// VBoxGlobal
151////////////////////////////////////////////////////////////////////////////////
152
153class VBoxSelectorWnd;
154class VBoxConsoleWnd;
155class VBoxRegistrationDlg;
156
157class VBoxGlobal : public QObject
158{
159 Q_OBJECT
160
161public:
162
163 static VBoxGlobal &instance();
164
165 bool isValid() { return mValid; }
166
167 QString versionString() { return verString; }
168
169 CVirtualBox virtualBox() const { return mVBox; }
170
171 const VBoxGlobalSettings &settings() const { return gset; }
172 bool setSettings (const VBoxGlobalSettings &gs);
173
174 VBoxSelectorWnd &selectorWnd();
175 VBoxConsoleWnd &consoleWnd();
176
177 bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
178 QUuid managedVMUuid() const { return vmUuid; }
179
180 VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
181 const char *vmRenderModeStr() const { return vm_render_mode_str; }
182
183#ifdef VBOX_WITH_DEBUGGER_GUI
184 bool isDebuggerEnabled() const { return dbg_enabled; }
185 bool isDebuggerVisibleAtStartup() const { return dbg_visible_at_startup; }
186#endif
187
188 /* VBox enum to/from string/icon/color convertors */
189
190 QStringList vmGuestOSTypeDescriptions() const;
191 CGuestOSType vmGuestOSType (int aIndex) const;
192 int vmGuestOSTypeIndex (const QString &aId) const;
193 QPixmap vmGuestOSTypeIcon (const QString &aId) const;
194 QString vmGuestOSTypeDescription (const QString &aId) const;
195
196 QPixmap toIcon (KMachineState s) const
197 {
198 QPixmap *pm = mStateIcons [s];
199 AssertMsg (pm, ("Icon for VM state %d must be defined", s));
200 return pm ? *pm : QPixmap();
201 }
202
203 const QColor &toColor (KMachineState s) const
204 {
205 static const QColor none;
206 AssertMsg (vm_state_color [s], ("No color for %d", s));
207 return vm_state_color [s] ? *vm_state_color [s] : none;
208 }
209
210 QString toString (KMachineState s) const
211 {
212 AssertMsg (!machineStates [s].isNull(), ("No text for %d", s));
213 return machineStates [s];
214 }
215
216 QString toString (KSessionState s) const
217 {
218 AssertMsg (!sessionStates [s].isNull(), ("No text for %d", s));
219 return sessionStates [s];
220 }
221
222 QString toString (KStorageBus t) const
223 {
224 AssertMsg (!storageBuses [t].isNull(), ("No text for %d", t));
225 return storageBuses [t];
226 }
227
228 QString toString (KStorageBus t, LONG c) const;
229 QString toString (KStorageBus t, LONG c, LONG d) const;
230
231 QString toString (KHardDiskType t) const
232 {
233 AssertMsg (!diskTypes [t].isNull(), ("No text for %d", t));
234 return diskTypes [t];
235 }
236
237 QString toString (KHardDiskStorageType t) const
238 {
239 AssertMsg (!diskStorageTypes [t].isNull(), ("No text for %d", t));
240 return diskStorageTypes [t];
241 }
242
243 QString toString (KVRDPAuthType t) const
244 {
245 AssertMsg (!vrdpAuthTypes [t].isNull(), ("No text for %d", t));
246 return vrdpAuthTypes [t];
247 }
248
249 QString toString (KPortMode t) const
250 {
251 AssertMsg (!portModeTypes [t].isNull(), ("No text for %d", t));
252 return portModeTypes [t];
253 }
254
255 QString toString (KUSBDeviceFilterAction t) const
256 {
257 AssertMsg (!usbFilterActionTypes [t].isNull(), ("No text for %d", t));
258 return usbFilterActionTypes [t];
259 }
260
261 QString toString (KClipboardMode t) const
262 {
263 AssertMsg (!clipboardTypes [t].isNull(), ("No text for %d", t));
264 return clipboardTypes [t];
265 }
266
267 KClipboardMode toClipboardModeType (const QString &s) const
268 {
269 QStringVector::const_iterator it =
270 qFind (clipboardTypes.begin(), clipboardTypes.end(), s);
271 AssertMsg (it != clipboardTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
272 return KClipboardMode (it - clipboardTypes.begin());
273 }
274
275 QString toString (KIDEControllerType t) const
276 {
277 AssertMsg (!ideControllerTypes [t].isNull(), ("No text for %d", t));
278 return ideControllerTypes [t];
279 }
280
281 KIDEControllerType toIDEControllerType (const QString &s) const
282 {
283 QStringVector::const_iterator it =
284 qFind (ideControllerTypes.begin(), ideControllerTypes.end(), s);
285 AssertMsg (it != ideControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
286 return KIDEControllerType (it - ideControllerTypes.begin());
287 }
288
289 KVRDPAuthType toVRDPAuthType (const QString &s) const
290 {
291 QStringVector::const_iterator it =
292 qFind (vrdpAuthTypes.begin(), vrdpAuthTypes.end(), s);
293 AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
294 return KVRDPAuthType (it - vrdpAuthTypes.begin());
295 }
296
297 KPortMode toPortMode (const QString &s) const
298 {
299 QStringVector::const_iterator it =
300 qFind (portModeTypes.begin(), portModeTypes.end(), s);
301 AssertMsg (it != portModeTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
302 return KPortMode (it - portModeTypes.begin());
303 }
304
305 KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
306 {
307 QStringVector::const_iterator it =
308 qFind (usbFilterActionTypes.begin(), usbFilterActionTypes.end(), s);
309 AssertMsg (it != usbFilterActionTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
310 return KUSBDeviceFilterAction (it - usbFilterActionTypes.begin());
311 }
312
313 /**
314 * Similar to toString (KHardDiskType), but returns 'Differencing'
315 * for normal hard disks that have a parent hard disk.
316 */
317 QString hardDiskTypeString (const CHardDisk &aHD) const
318 {
319 if (!aHD.GetParent().isNull())
320 {
321 Assert (aHD.GetType() == KHardDiskType_Normal);
322 return tr ("Differencing", "hard disk");
323 }
324 return toString (aHD.GetType());
325 }
326
327 QString toString (KDeviceType t) const
328 {
329 AssertMsg (!deviceTypes [t].isNull(), ("No text for %d", t));
330 return deviceTypes [t];
331 }
332
333 KDeviceType toDeviceType (const QString &s) const
334 {
335 QStringVector::const_iterator it =
336 qFind (deviceTypes.begin(), deviceTypes.end(), s);
337 AssertMsg (it != deviceTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
338 return KDeviceType (it - deviceTypes.begin());
339 }
340
341 QStringList deviceTypeStrings() const;
342
343 QString toString (KAudioDriverType t) const
344 {
345 AssertMsg (!audioDriverTypes [t].isNull(), ("No text for %d", t));
346 return audioDriverTypes [t];
347 }
348
349 KAudioDriverType toAudioDriverType (const QString &s) const
350 {
351 QStringVector::const_iterator it =
352 qFind (audioDriverTypes.begin(), audioDriverTypes.end(), s);
353 AssertMsg (it != audioDriverTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
354 return KAudioDriverType (it - audioDriverTypes.begin());
355 }
356
357 QString toString (KAudioControllerType t) const
358 {
359 AssertMsg (!audioControllerTypes [t].isNull(), ("No text for %d", t));
360 return audioControllerTypes [t];
361 }
362
363 KAudioControllerType toAudioControllerType (const QString &s) const
364 {
365 QStringVector::const_iterator it =
366 qFind (audioControllerTypes.begin(), audioControllerTypes.end(), s);
367 AssertMsg (it != audioControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
368 return KAudioControllerType (it - audioControllerTypes.begin());
369 }
370
371 QString toString (KNetworkAdapterType t) const
372 {
373 AssertMsg (!networkAdapterTypes [t].isNull(), ("No text for %d", t));
374 return networkAdapterTypes [t];
375 }
376
377 KNetworkAdapterType toNetworkAdapterType (const QString &s) const
378 {
379 QStringVector::const_iterator it =
380 qFind (networkAdapterTypes.begin(), networkAdapterTypes.end(), s);
381 AssertMsg (it != networkAdapterTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
382 return KNetworkAdapterType (it - networkAdapterTypes.begin());
383 }
384
385 QString toString (KNetworkAttachmentType t) const
386 {
387 AssertMsg (!networkAttachmentTypes [t].isNull(), ("No text for %d", t));
388 return networkAttachmentTypes [t];
389 }
390
391 KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
392 {
393 QStringVector::const_iterator it =
394 qFind (networkAttachmentTypes.begin(), networkAttachmentTypes.end(), s);
395 AssertMsg (it != networkAttachmentTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
396 return KNetworkAttachmentType (it - networkAttachmentTypes.begin());
397 }
398
399 QString toString (KUSBDeviceState aState) const
400 {
401 AssertMsg (!USBDeviceStates [aState].isNull(), ("No text for %d", aState));
402 return USBDeviceStates [aState];
403 }
404
405 QStringList COMPortNames() const;
406 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
407 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
408
409 QStringList LPTPortNames() const;
410 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
411 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
412
413 QPixmap snapshotIcon (bool online) const
414 {
415 return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
416 }
417
418 /* details generators */
419
420 QString details (const CHardDisk &aHD, bool aPredict = false,
421 bool aDoRefresh = true);
422
423 QString details (const CUSBDevice &aDevice) const;
424 QString toolTip (const CUSBDevice &aDevice) const;
425
426 QString prepareFileNameForHTML (const QString &fn) const;
427
428 QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks,
429 bool aDoRefresh = true);
430
431 /* VirtualBox helpers */
432
433#ifdef Q_WS_X11
434 bool showVirtualBoxLicense();
435#endif
436
437 void checkForAutoConvertedSettings();
438
439 CSession openSession (const QUuid &aId, bool aExisting = false);
440
441 /** Shortcut to openSession (aId, true). */
442 CSession openExistingSession (const QUuid &aId) { return openSession (aId, true); }
443
444 bool startMachine (const QUuid &id);
445
446 void startEnumeratingMedia();
447
448 /**
449 * Returns a list of all currently registered media. This list is used
450 * to globally track the accessiblity state of all media on a dedicated
451 * thread. This the list is initially empty (before the first enumeration
452 * process is started using #startEnumeratingMedia()).
453 */
454 const VBoxMediaList &currentMediaList() const { return media_list; }
455
456 /** Returns true if the media enumeration is in progress. */
457 bool isMediaEnumerationStarted() const { return media_enum_thread != NULL; }
458
459 void addMedia (const VBoxMedia &);
460 void updateMedia (const VBoxMedia &);
461 void removeMedia (VBoxDefs::DiskType, const QUuid &);
462
463 bool findMedia (const CUnknown &, VBoxMedia &) const;
464
465 /* various helpers */
466
467 QString languageName() const;
468 QString languageCountry() const;
469 QString languageNameEnglish() const;
470 QString languageCountryEnglish() const;
471 QString languageTranslators() const;
472
473 void languageChange();
474
475 /** @internal made public for internal purposes */
476 void cleanup();
477
478 /* public static stuff */
479
480 static bool isDOSType (const QString &aOSTypeId);
481
482 static void adoptLabelPixmap (QLabel *);
483
484 static QString languageId();
485 static void loadLanguage (const QString &aLangId = QString::null);
486
487 static QIcon iconSet (const char *aNormal,
488 const char *aDisabled = NULL,
489 const char *aActive = NULL);
490 static QIcon iconSetEx (const char *aNormal, const char *aSmallNormal,
491 const char *aDisabled = NULL,
492 const char *aSmallDisabled = NULL,
493 const char *aActive = NULL,
494 const char *aSmallActive = NULL);
495
496 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
497
498 static QRect normalizeGeometry (const QRect &aRect, const QRect &aBoundRect,
499 bool aCanResize = true);
500
501 static void centerWidget (QWidget *aWidget, QWidget *aRelative,
502 bool aCanResize = true);
503
504 static QChar decimalSep();
505 static QString sizeRegexp();
506
507 static Q_UINT64 parseSize (const QString &);
508 static QString formatSize (Q_UINT64, int aMode = 0);
509
510 static QString highlight (const QString &aStr, bool aToolTip = false);
511
512 static QString systemLanguageId();
513
514 static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
515 const char *aName = 0,
516 const QString &aCaption = QString::null,
517 bool aDirOnly = TRUE,
518 bool resolveSymlinks = TRUE);
519
520 static QString getOpenFileName (const QString &, const QString &, QWidget*,
521 const char*, const QString &,
522 QString *defaultFilter = 0,
523 bool resolveSymLinks = true);
524
525 static QString getFirstExistingDir (const QString &);
526
527 static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
528
529 static QString removeAccelMark (const QString &aText);
530
531 static QWidget *findWidget (QWidget *aParent, const char *aName,
532 const char *aClassName = NULL,
533 bool aRecursive = false);
534
535 /* Qt 4.2.0 support function */
536 static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
537 {
538#if QT_VERSION < 0x040300
539 /* Deprecated since > 4.2 */
540 aLayout->setMargin (aMargin);
541#else
542 /* New since > 4.2 */
543 aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
544#endif
545 }
546
547signals:
548
549 /**
550 * Emitted at the beginning of the enumeration process started
551 * by #startEnumeratingMedia().
552 */
553 void mediaEnumStarted();
554
555 /**
556 * Emitted when a new media item from the list has updated
557 * its accessibility state.
558 */
559 void mediaEnumerated (const VBoxMedia &aMedia, int aIndex);
560
561 /**
562 * Emitted at the end of the enumeration process started
563 * by #startEnumeratingMedia(). The @a aList argument is passed for
564 * convenience, it is exactly the same as returned by #currentMediaList().
565 */
566 void mediaEnumFinished (const VBoxMediaList &aList);
567
568 /** Emitted when a new media is added using #addMedia(). */
569 void mediaAdded (const VBoxMedia &);
570
571 /** Emitted when the media is updated using #updateMedia(). */
572 void mediaUpdated (const VBoxMedia &);
573
574 /** Emitted when the media is removed using #removeMedia(). */
575 void mediaRemoved (VBoxDefs::DiskType, const QUuid &);
576
577 /* signals emitted when the VirtualBox callback is called by the server
578 * (not that currently these signals are emitted only when the application
579 * is the in the VM selector mode) */
580
581 void machineStateChanged (const VBoxMachineStateChangeEvent &e);
582 void machineDataChanged (const VBoxMachineDataChangeEvent &e);
583 void machineRegistered (const VBoxMachineRegisteredEvent &e);
584 void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
585 void snapshotChanged (const VBoxSnapshotEvent &e);
586
587 void canShowRegDlg (bool aCanShow);
588
589public slots:
590
591 bool openURL (const QString &aURL);
592
593 void showRegistrationDialog (bool aForce = true);
594
595protected:
596
597 bool event (QEvent *e);
598 bool eventFilter (QObject *, QEvent *);
599
600private:
601
602 VBoxGlobal();
603 ~VBoxGlobal() {}
604
605 void init();
606
607 bool mValid;
608
609 CVirtualBox mVBox;
610
611 VBoxGlobalSettings gset;
612
613 VBoxSelectorWnd *mSelectorWnd;
614 VBoxConsoleWnd *mConsoleWnd;
615
616#ifdef VBOX_WITH_REGISTRATION
617 VBoxRegistrationDlg *mRegDlg;
618#endif
619
620 QUuid vmUuid;
621
622 QThread *media_enum_thread;
623 VBoxMediaList media_list;
624
625 VBoxDefs::RenderMode vm_render_mode;
626 const char * vm_render_mode_str;
627
628#ifdef VBOX_WITH_DEBUGGER_GUI
629 bool dbg_enabled;
630 bool dbg_visible_at_startup;
631#endif
632
633#if defined (Q_WS_WIN32)
634 DWORD dwHTMLHelpCookie;
635#endif
636
637 CVirtualBoxCallback callback;
638
639 typedef Q3ValueVector <QString> QStringVector;
640
641 QString verString;
642
643 Q3ValueVector <CGuestOSType> vm_os_types;
644 Q3Dict <QPixmap> vm_os_type_icons;
645 Q3PtrVector <QColor> vm_state_color;
646
647 Q3IntDict <QPixmap> mStateIcons;
648 QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
649
650 QStringVector machineStates;
651 QStringVector sessionStates;
652 QStringVector deviceTypes;
653 QStringVector storageBuses;
654 QStringVector storageBusDevices;
655 QStringVector storageBusChannels;
656 QStringVector diskTypes;
657 QStringVector diskStorageTypes;
658 QStringVector vrdpAuthTypes;
659 QStringVector portModeTypes;
660 QStringVector usbFilterActionTypes;
661 QStringVector audioDriverTypes;
662 QStringVector audioControllerTypes;
663 QStringVector networkAdapterTypes;
664 QStringVector networkAttachmentTypes;
665 QStringVector clipboardTypes;
666 QStringVector ideControllerTypes;
667 QStringVector USBDeviceStates;
668
669 QString mUserDefinedPortName;
670
671 mutable bool detailReportTemplatesReady;
672
673 friend VBoxGlobal &vboxGlobal();
674 friend class VBoxCallback;
675};
676
677inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
678
679// Helper classes
680////////////////////////////////////////////////////////////////////////////////
681
682/**
683 * Generic asyncronous event.
684 *
685 * This abstract class is intended to provide a conveinent way to execute
686 * code on the main GUI thread asynchronously to the calling party. This is
687 * done by putting necessary actions to the #handle() function in a subclass
688 * and then posting an instance of the subclass using #post(). The instance
689 * must be allocated on the heap using the <tt>new</tt> operation and will be
690 * automatically deleted after processing. Note that if you don't call #post()
691 * on the created instance, you have to delete it yourself.
692 */
693class VBoxAsyncEvent : public QEvent
694{
695public:
696
697 VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {}
698
699 /**
700 * Worker function. Gets executed on the GUI thread when the posted event
701 * is processed by the main event loop.
702 */
703 virtual void handle() = 0;
704
705 /**
706 * Posts this event to the main event loop.
707 * The caller loses ownership of this object after this method returns
708 * and must not delete the object.
709 */
710 void post()
711 {
712 QApplication::postEvent (&vboxGlobal(), this);
713 }
714};
715
716/**
717 * USB Popup Menu class.
718 * This class provides the list of USB devices attached to the host.
719 */
720class VBoxUSBMenu : public QMenu
721{
722 Q_OBJECT
723
724public:
725
726 VBoxUSBMenu (QWidget *);
727
728 const CUSBDevice& getUSB (QAction *aAction);
729
730 void setConsole (const CConsole &);
731
732private slots:
733
734 void processAboutToShow();
735
736private:
737 bool event(QEvent *aEvent);
738
739 QMap <QAction *, CUSBDevice> mUSBDevicesMap;
740 CConsole mConsole;
741};
742
743/**
744 * Enable/Disable Menu class.
745 * This class provides enable/disable menu items.
746 */
747class VBoxSwitchMenu : public QMenu
748{
749 Q_OBJECT
750
751public:
752
753 VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
754
755 void setToolTip (const QString &);
756
757private slots:
758
759 void processAboutToShow();
760
761private:
762
763 QAction *mAction;
764 bool mInverted;
765};
766
767#endif /* __VBoxGlobal_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