VirtualBox

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

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

FE/Qt4: No VBoxLicenseViewer class on OSE.

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