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