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 |
|
---|
38 | class QAction;
|
---|
39 | class QLabel;
|
---|
40 | class QToolButton;
|
---|
41 |
|
---|
42 | // Auxiliary types
|
---|
43 | ////////////////////////////////////////////////////////////////////////////////
|
---|
44 |
|
---|
45 | /** Simple media descriptor type. */
|
---|
46 | struct 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 |
|
---|
60 | typedef QList <VBoxMedia> VBoxMediaList;
|
---|
61 |
|
---|
62 | // VirtualBox callback events
|
---|
63 | ////////////////////////////////////////////////////////////////////////////////
|
---|
64 |
|
---|
65 | class VBoxMachineStateChangeEvent : public QEvent
|
---|
66 | {
|
---|
67 | public:
|
---|
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 |
|
---|
77 | class VBoxMachineDataChangeEvent : public QEvent
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | VBoxMachineDataChangeEvent (const QUuid &aId)
|
---|
81 | : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
|
---|
82 | , id (aId)
|
---|
83 | {}
|
---|
84 |
|
---|
85 | const QUuid id;
|
---|
86 | };
|
---|
87 |
|
---|
88 | class VBoxMachineRegisteredEvent : public QEvent
|
---|
89 | {
|
---|
90 | public:
|
---|
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 |
|
---|
100 | class VBoxSessionStateChangeEvent : public QEvent
|
---|
101 | {
|
---|
102 | public:
|
---|
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 |
|
---|
112 | class VBoxSnapshotEvent : public QEvent
|
---|
113 | {
|
---|
114 | public:
|
---|
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 |
|
---|
131 | class VBoxCanShowRegDlgEvent : public QEvent
|
---|
132 | {
|
---|
133 | public:
|
---|
134 | VBoxCanShowRegDlgEvent (bool aCanShow)
|
---|
135 | : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
|
---|
136 | , mCanShow (aCanShow)
|
---|
137 | {}
|
---|
138 |
|
---|
139 | const bool mCanShow;
|
---|
140 | };
|
---|
141 |
|
---|
142 | class VBoxCanShowUpdDlgEvent : public QEvent
|
---|
143 | {
|
---|
144 | public:
|
---|
145 | VBoxCanShowUpdDlgEvent (bool aCanShow)
|
---|
146 | : QEvent ((QEvent::Type) VBoxDefs::CanShowUpdDlgEventType)
|
---|
147 | , mCanShow (aCanShow)
|
---|
148 | {}
|
---|
149 |
|
---|
150 | const bool mCanShow;
|
---|
151 | };
|
---|
152 |
|
---|
153 | class VBoxChangeGUILanguageEvent : public QEvent
|
---|
154 | {
|
---|
155 | public:
|
---|
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 |
|
---|
167 | class VBoxSelectorWnd;
|
---|
168 | class VBoxConsoleWnd;
|
---|
169 | class VBoxRegistrationDlg;
|
---|
170 | class VBoxUpdateDlg;
|
---|
171 |
|
---|
172 | class VBoxGlobal : public QObject
|
---|
173 | {
|
---|
174 | Q_OBJECT
|
---|
175 |
|
---|
176 | public:
|
---|
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 |
|
---|
468 | QString prepareFileNameForHTML (const QString &fn) const;
|
---|
469 |
|
---|
470 | QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks,
|
---|
471 | bool aDoRefresh = true);
|
---|
472 |
|
---|
473 | /* VirtualBox helpers */
|
---|
474 |
|
---|
475 | #if defined(Q_WS_X11) && !defined(VBOX_OSE)
|
---|
476 | bool showVirtualBoxLicense();
|
---|
477 | #endif
|
---|
478 |
|
---|
479 | void checkForAutoConvertedSettings();
|
---|
480 |
|
---|
481 | CSession openSession (const QUuid &aId, bool aExisting = false);
|
---|
482 |
|
---|
483 | /** Shortcut to openSession (aId, true). */
|
---|
484 | CSession openExistingSession (const QUuid &aId) { return openSession (aId, true); }
|
---|
485 |
|
---|
486 | bool startMachine (const QUuid &id);
|
---|
487 |
|
---|
488 | void startEnumeratingMedia();
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Returns a list of all currently registered media. This list is used
|
---|
492 | * to globally track the accessiblity state of all media on a dedicated
|
---|
493 | * thread. This the list is initially empty (before the first enumeration
|
---|
494 | * process is started using #startEnumeratingMedia()).
|
---|
495 | */
|
---|
496 | const VBoxMediaList ¤tMediaList() const { return media_list; }
|
---|
497 |
|
---|
498 | /** Returns true if the media enumeration is in progress. */
|
---|
499 | bool isMediaEnumerationStarted() const { return media_enum_thread != NULL; }
|
---|
500 |
|
---|
501 | void addMedia (const VBoxMedia &);
|
---|
502 | void updateMedia (const VBoxMedia &);
|
---|
503 | void removeMedia (VBoxDefs::DiskType, const QUuid &);
|
---|
504 |
|
---|
505 | bool findMedia (const CUnknown &, VBoxMedia &) const;
|
---|
506 |
|
---|
507 | /* various helpers */
|
---|
508 |
|
---|
509 | QString languageName() const;
|
---|
510 | QString languageCountry() const;
|
---|
511 | QString languageNameEnglish() const;
|
---|
512 | QString languageCountryEnglish() const;
|
---|
513 | QString languageTranslators() const;
|
---|
514 |
|
---|
515 | void retranslateUi();
|
---|
516 |
|
---|
517 | /** @internal made public for internal purposes */
|
---|
518 | void cleanup();
|
---|
519 |
|
---|
520 | /* public static stuff */
|
---|
521 |
|
---|
522 | static bool isDOSType (const QString &aOSTypeId);
|
---|
523 |
|
---|
524 | static void adoptLabelPixmap (QLabel *);
|
---|
525 |
|
---|
526 | static QString languageId();
|
---|
527 | static void loadLanguage (const QString &aLangId = QString::null);
|
---|
528 |
|
---|
529 | static QIcon iconSet (const char *aNormal,
|
---|
530 | const char *aDisabled = NULL,
|
---|
531 | const char *aActive = NULL);
|
---|
532 | static QIcon iconSetEx (const char *aNormal, const char *aSmallNormal,
|
---|
533 | const char *aDisabled = NULL,
|
---|
534 | const char *aSmallDisabled = NULL,
|
---|
535 | const char *aActive = NULL,
|
---|
536 | const char *aSmallActive = NULL);
|
---|
537 |
|
---|
538 | static QIcon standardIcon (QStyle::StandardPixmap aStandard, QWidget *aWidget = NULL);
|
---|
539 |
|
---|
540 | static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
|
---|
541 |
|
---|
542 | static QRect normalizeGeometry (const QRect &aRect, const QRect &aBoundRect,
|
---|
543 | bool aCanResize = true);
|
---|
544 |
|
---|
545 | static void centerWidget (QWidget *aWidget, QWidget *aRelative,
|
---|
546 | bool aCanResize = true);
|
---|
547 |
|
---|
548 | static QChar decimalSep();
|
---|
549 | static QString sizeRegexp();
|
---|
550 |
|
---|
551 | static quint64 parseSize (const QString &);
|
---|
552 | static QString formatSize (quint64, int aMode = 0);
|
---|
553 |
|
---|
554 | static QString highlight (const QString &aStr, bool aToolTip = false);
|
---|
555 |
|
---|
556 | static QString systemLanguageId();
|
---|
557 |
|
---|
558 | static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
|
---|
559 | const QString &aCaption = QString::null,
|
---|
560 | bool aDirOnly = TRUE,
|
---|
561 | bool resolveSymlinks = TRUE);
|
---|
562 |
|
---|
563 | static QString getOpenFileName (const QString &, const QString &, QWidget*,
|
---|
564 | const QString &, QString *defaultFilter = 0,
|
---|
565 | bool resolveSymLinks = true);
|
---|
566 |
|
---|
567 | static QString getFirstExistingDir (const QString &);
|
---|
568 |
|
---|
569 | static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
|
---|
570 |
|
---|
571 | static QString removeAccelMark (const QString &aText);
|
---|
572 |
|
---|
573 | static QString insertKeyToActionText (const QString &aText, const QString &aKey);
|
---|
574 | static QString extractKeyFromActionText (const QString &aText);
|
---|
575 |
|
---|
576 | static QWidget *findWidget (QWidget *aParent, const char *aName,
|
---|
577 | const char *aClassName = NULL,
|
---|
578 | bool aRecursive = false);
|
---|
579 |
|
---|
580 | /* Qt 4.2.0 support function */
|
---|
581 | static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
|
---|
582 | {
|
---|
583 | #if QT_VERSION < 0x040300
|
---|
584 | /* Deprecated since > 4.2 */
|
---|
585 | aLayout->setMargin (aMargin);
|
---|
586 | #else
|
---|
587 | /* New since > 4.2 */
|
---|
588 | aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
|
---|
589 | #endif
|
---|
590 | }
|
---|
591 |
|
---|
592 | signals:
|
---|
593 |
|
---|
594 | /**
|
---|
595 | * Emitted at the beginning of the enumeration process started
|
---|
596 | * by #startEnumeratingMedia().
|
---|
597 | */
|
---|
598 | void mediaEnumStarted();
|
---|
599 |
|
---|
600 | /**
|
---|
601 | * Emitted when a new media item from the list has updated
|
---|
602 | * its accessibility state.
|
---|
603 | */
|
---|
604 | void mediaEnumerated (const VBoxMedia &aMedia, int aIndex);
|
---|
605 |
|
---|
606 | /**
|
---|
607 | * Emitted at the end of the enumeration process started
|
---|
608 | * by #startEnumeratingMedia(). The @a aList argument is passed for
|
---|
609 | * convenience, it is exactly the same as returned by #currentMediaList().
|
---|
610 | */
|
---|
611 | void mediaEnumFinished (const VBoxMediaList &aList);
|
---|
612 |
|
---|
613 | /** Emitted when a new media is added using #addMedia(). */
|
---|
614 | void mediaAdded (const VBoxMedia &);
|
---|
615 |
|
---|
616 | /** Emitted when the media is updated using #updateMedia(). */
|
---|
617 | void mediaUpdated (const VBoxMedia &);
|
---|
618 |
|
---|
619 | /** Emitted when the media is removed using #removeMedia(). */
|
---|
620 | void mediaRemoved (VBoxDefs::DiskType, const QUuid &);
|
---|
621 |
|
---|
622 | /* signals emitted when the VirtualBox callback is called by the server
|
---|
623 | * (not that currently these signals are emitted only when the application
|
---|
624 | * is the in the VM selector mode) */
|
---|
625 |
|
---|
626 | void machineStateChanged (const VBoxMachineStateChangeEvent &e);
|
---|
627 | void machineDataChanged (const VBoxMachineDataChangeEvent &e);
|
---|
628 | void machineRegistered (const VBoxMachineRegisteredEvent &e);
|
---|
629 | void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
|
---|
630 | void snapshotChanged (const VBoxSnapshotEvent &e);
|
---|
631 |
|
---|
632 | void canShowRegDlg (bool aCanShow);
|
---|
633 | void canShowUpdDlg (bool aCanShow);
|
---|
634 |
|
---|
635 | public slots:
|
---|
636 |
|
---|
637 | bool openURL (const QString &aURL);
|
---|
638 |
|
---|
639 | void showRegistrationDialog (bool aForce = true);
|
---|
640 | void showUpdateDialog (bool aForce = true);
|
---|
641 |
|
---|
642 | protected:
|
---|
643 |
|
---|
644 | bool event (QEvent *e);
|
---|
645 | bool eventFilter (QObject *, QEvent *);
|
---|
646 |
|
---|
647 | private:
|
---|
648 |
|
---|
649 | VBoxGlobal();
|
---|
650 | ~VBoxGlobal();
|
---|
651 |
|
---|
652 | void init();
|
---|
653 |
|
---|
654 | bool mValid;
|
---|
655 |
|
---|
656 | CVirtualBox mVBox;
|
---|
657 |
|
---|
658 | VBoxGlobalSettings gset;
|
---|
659 |
|
---|
660 | VBoxSelectorWnd *mSelectorWnd;
|
---|
661 | VBoxConsoleWnd *mConsoleWnd;
|
---|
662 | QWidget* mMainWindow;
|
---|
663 |
|
---|
664 | #ifdef VBOX_WITH_REGISTRATION
|
---|
665 | VBoxRegistrationDlg *mRegDlg;
|
---|
666 | #endif
|
---|
667 | VBoxUpdateDlg *mUpdDlg;
|
---|
668 |
|
---|
669 | QUuid vmUuid;
|
---|
670 |
|
---|
671 | QThread *media_enum_thread;
|
---|
672 | VBoxMediaList media_list;
|
---|
673 |
|
---|
674 | VBoxDefs::RenderMode vm_render_mode;
|
---|
675 | const char * vm_render_mode_str;
|
---|
676 |
|
---|
677 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
678 | bool dbg_enabled;
|
---|
679 | bool dbg_visible_at_startup;
|
---|
680 | #endif
|
---|
681 |
|
---|
682 | #if defined (Q_WS_WIN32)
|
---|
683 | DWORD dwHTMLHelpCookie;
|
---|
684 | #endif
|
---|
685 |
|
---|
686 | CVirtualBoxCallback callback;
|
---|
687 |
|
---|
688 | typedef QVector <QString> QStringVector;
|
---|
689 |
|
---|
690 | QString verString;
|
---|
691 |
|
---|
692 | QVector <CGuestOSType> vm_os_types;
|
---|
693 | QHash <QString, QPixmap *> vm_os_type_icons;
|
---|
694 | QVector <QColor *> vm_state_color;
|
---|
695 |
|
---|
696 | QHash <long int, QPixmap *> mStateIcons;
|
---|
697 | QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
|
---|
698 |
|
---|
699 | QStringVector machineStates;
|
---|
700 | QStringVector sessionStates;
|
---|
701 | QStringVector deviceTypes;
|
---|
702 | QStringVector storageBuses;
|
---|
703 | QStringVector storageBusDevices;
|
---|
704 | QStringVector storageBusChannels;
|
---|
705 | QStringVector diskTypes;
|
---|
706 | QStringVector diskStorageTypes;
|
---|
707 | QStringVector vrdpAuthTypes;
|
---|
708 | QStringVector portModeTypes;
|
---|
709 | QStringVector usbFilterActionTypes;
|
---|
710 | QStringVector audioDriverTypes;
|
---|
711 | QStringVector audioControllerTypes;
|
---|
712 | QStringVector networkAdapterTypes;
|
---|
713 | QStringVector networkAttachmentTypes;
|
---|
714 | QStringVector clipboardTypes;
|
---|
715 | QStringVector ideControllerTypes;
|
---|
716 | QStringVector USBDeviceStates;
|
---|
717 |
|
---|
718 | QString mUserDefinedPortName;
|
---|
719 |
|
---|
720 | mutable bool detailReportTemplatesReady;
|
---|
721 |
|
---|
722 | friend VBoxGlobal &vboxGlobal();
|
---|
723 | friend class VBoxCallback;
|
---|
724 | };
|
---|
725 |
|
---|
726 | inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
|
---|
727 |
|
---|
728 | // Helper classes
|
---|
729 | ////////////////////////////////////////////////////////////////////////////////
|
---|
730 |
|
---|
731 | /**
|
---|
732 | * Generic asyncronous event.
|
---|
733 | *
|
---|
734 | * This abstract class is intended to provide a conveinent way to execute
|
---|
735 | * code on the main GUI thread asynchronously to the calling party. This is
|
---|
736 | * done by putting necessary actions to the #handle() function in a subclass
|
---|
737 | * and then posting an instance of the subclass using #post(). The instance
|
---|
738 | * must be allocated on the heap using the <tt>new</tt> operation and will be
|
---|
739 | * automatically deleted after processing. Note that if you don't call #post()
|
---|
740 | * on the created instance, you have to delete it yourself.
|
---|
741 | */
|
---|
742 | class VBoxAsyncEvent : public QEvent
|
---|
743 | {
|
---|
744 | public:
|
---|
745 |
|
---|
746 | VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {}
|
---|
747 |
|
---|
748 | /**
|
---|
749 | * Worker function. Gets executed on the GUI thread when the posted event
|
---|
750 | * is processed by the main event loop.
|
---|
751 | */
|
---|
752 | virtual void handle() = 0;
|
---|
753 |
|
---|
754 | /**
|
---|
755 | * Posts this event to the main event loop.
|
---|
756 | * The caller loses ownership of this object after this method returns
|
---|
757 | * and must not delete the object.
|
---|
758 | */
|
---|
759 | void post()
|
---|
760 | {
|
---|
761 | QApplication::postEvent (&vboxGlobal(), this);
|
---|
762 | }
|
---|
763 | };
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * USB Popup Menu class.
|
---|
767 | * This class provides the list of USB devices attached to the host.
|
---|
768 | */
|
---|
769 | class VBoxUSBMenu : public QMenu
|
---|
770 | {
|
---|
771 | Q_OBJECT
|
---|
772 |
|
---|
773 | public:
|
---|
774 |
|
---|
775 | VBoxUSBMenu (QWidget *);
|
---|
776 |
|
---|
777 | const CUSBDevice& getUSB (QAction *aAction);
|
---|
778 |
|
---|
779 | void setConsole (const CConsole &);
|
---|
780 |
|
---|
781 | private slots:
|
---|
782 |
|
---|
783 | void processAboutToShow();
|
---|
784 |
|
---|
785 | private:
|
---|
786 | bool event(QEvent *aEvent);
|
---|
787 |
|
---|
788 | QMap <QAction *, CUSBDevice> mUSBDevicesMap;
|
---|
789 | CConsole mConsole;
|
---|
790 | };
|
---|
791 |
|
---|
792 | /**
|
---|
793 | * Enable/Disable Menu class.
|
---|
794 | * This class provides enable/disable menu items.
|
---|
795 | */
|
---|
796 | class VBoxSwitchMenu : public QMenu
|
---|
797 | {
|
---|
798 | Q_OBJECT
|
---|
799 |
|
---|
800 | public:
|
---|
801 |
|
---|
802 | VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
|
---|
803 |
|
---|
804 | void setToolTip (const QString &);
|
---|
805 |
|
---|
806 | private slots:
|
---|
807 |
|
---|
808 | void processAboutToShow();
|
---|
809 |
|
---|
810 | private:
|
---|
811 |
|
---|
812 | QAction *mAction;
|
---|
813 | bool mInverted;
|
---|
814 | };
|
---|
815 |
|
---|
816 | #endif /* __VBoxGlobal_h__ */
|
---|