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