VirtualBox

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

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

FE/Qt4-OSX: Change the Host+<key> sequence for the ConsoleWindow on the mac.

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