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