VirtualBox

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

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

FE/Qt4: VM USB settings face lift.

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