1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxGlobal class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 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 | #include "VBox/com/Guid.h"
|
---|
28 |
|
---|
29 | #include "VBoxGlobalSettings.h"
|
---|
30 | #include "VBoxMedium.h"
|
---|
31 |
|
---|
32 | /* Qt includes */
|
---|
33 | #include <QApplication>
|
---|
34 | #include <QLayout>
|
---|
35 | #include <QMenu>
|
---|
36 | #include <QStyle>
|
---|
37 | #include <QProcess>
|
---|
38 | #include <QHash>
|
---|
39 |
|
---|
40 | #ifdef Q_WS_X11
|
---|
41 | # include <sys/wait.h>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | class QAction;
|
---|
45 | class QLabel;
|
---|
46 | class QToolButton;
|
---|
47 | #ifdef VBOX_WITH_NEW_RUNTIME_CORE
|
---|
48 | class UIMachine;
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | // VirtualBox callback events
|
---|
52 | ////////////////////////////////////////////////////////////////////////////////
|
---|
53 |
|
---|
54 | class VBoxMachineStateChangeEvent : public QEvent
|
---|
55 | {
|
---|
56 | public:
|
---|
57 | VBoxMachineStateChangeEvent (const QString &aId, KMachineState aState)
|
---|
58 | : QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType)
|
---|
59 | , id (aId), state (aState)
|
---|
60 | {}
|
---|
61 |
|
---|
62 | const QString id;
|
---|
63 | const KMachineState state;
|
---|
64 | };
|
---|
65 |
|
---|
66 | class VBoxMachineDataChangeEvent : public QEvent
|
---|
67 | {
|
---|
68 | public:
|
---|
69 | VBoxMachineDataChangeEvent (const QString &aId)
|
---|
70 | : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
|
---|
71 | , id (aId)
|
---|
72 | {}
|
---|
73 |
|
---|
74 | const QString id;
|
---|
75 | };
|
---|
76 |
|
---|
77 | class VBoxMachineRegisteredEvent : public QEvent
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | VBoxMachineRegisteredEvent (const QString &aId, bool aRegistered)
|
---|
81 | : QEvent ((QEvent::Type) VBoxDefs::MachineRegisteredEventType)
|
---|
82 | , id (aId), registered (aRegistered)
|
---|
83 | {}
|
---|
84 |
|
---|
85 | const QString id;
|
---|
86 | const bool registered;
|
---|
87 | };
|
---|
88 |
|
---|
89 | class VBoxSessionStateChangeEvent : public QEvent
|
---|
90 | {
|
---|
91 | public:
|
---|
92 | VBoxSessionStateChangeEvent (const QString &aId, KSessionState aState)
|
---|
93 | : QEvent ((QEvent::Type) VBoxDefs::SessionStateChangeEventType)
|
---|
94 | , id (aId), state (aState)
|
---|
95 | {}
|
---|
96 |
|
---|
97 | const QString id;
|
---|
98 | const KSessionState state;
|
---|
99 | };
|
---|
100 |
|
---|
101 | class VBoxSnapshotEvent : public QEvent
|
---|
102 | {
|
---|
103 | public:
|
---|
104 |
|
---|
105 | enum What { Taken, Discarded, Changed };
|
---|
106 |
|
---|
107 | VBoxSnapshotEvent (const QString &aMachineId, const QString &aSnapshotId,
|
---|
108 | What aWhat)
|
---|
109 | : QEvent ((QEvent::Type) VBoxDefs::SnapshotEventType)
|
---|
110 | , what (aWhat)
|
---|
111 | , machineId (aMachineId), snapshotId (aSnapshotId)
|
---|
112 | {}
|
---|
113 |
|
---|
114 | const What what;
|
---|
115 |
|
---|
116 | const QString machineId;
|
---|
117 | const QString snapshotId;
|
---|
118 | };
|
---|
119 |
|
---|
120 | class VBoxCanShowRegDlgEvent : public QEvent
|
---|
121 | {
|
---|
122 | public:
|
---|
123 | VBoxCanShowRegDlgEvent (bool aCanShow)
|
---|
124 | : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
|
---|
125 | , mCanShow (aCanShow)
|
---|
126 | {}
|
---|
127 |
|
---|
128 | const bool mCanShow;
|
---|
129 | };
|
---|
130 |
|
---|
131 | class VBoxCanShowUpdDlgEvent : public QEvent
|
---|
132 | {
|
---|
133 | public:
|
---|
134 | VBoxCanShowUpdDlgEvent (bool aCanShow)
|
---|
135 | : QEvent ((QEvent::Type) VBoxDefs::CanShowUpdDlgEventType)
|
---|
136 | , mCanShow (aCanShow)
|
---|
137 | {}
|
---|
138 |
|
---|
139 | const bool mCanShow;
|
---|
140 | };
|
---|
141 |
|
---|
142 | class VBoxChangeGUILanguageEvent : public QEvent
|
---|
143 | {
|
---|
144 | public:
|
---|
145 | VBoxChangeGUILanguageEvent (QString aLangId)
|
---|
146 | : QEvent ((QEvent::Type) VBoxDefs::ChangeGUILanguageEventType)
|
---|
147 | , mLangId (aLangId)
|
---|
148 | {}
|
---|
149 |
|
---|
150 | const QString mLangId;
|
---|
151 | };
|
---|
152 |
|
---|
153 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
154 | class VBoxMainWindowCountChangeEvent : public QEvent
|
---|
155 | {
|
---|
156 | public:
|
---|
157 | VBoxMainWindowCountChangeEvent (int aCount)
|
---|
158 | : QEvent ((QEvent::Type) VBoxDefs::MainWindowCountChangeEventType)
|
---|
159 | , mCount (aCount)
|
---|
160 | {}
|
---|
161 |
|
---|
162 | const int mCount;
|
---|
163 | };
|
---|
164 |
|
---|
165 | class VBoxCanShowTrayIconEvent : public QEvent
|
---|
166 | {
|
---|
167 | public:
|
---|
168 | VBoxCanShowTrayIconEvent (bool aCanShow)
|
---|
169 | : QEvent ((QEvent::Type) VBoxDefs::CanShowTrayIconEventType)
|
---|
170 | , mCanShow (aCanShow)
|
---|
171 | {}
|
---|
172 |
|
---|
173 | const bool mCanShow;
|
---|
174 | };
|
---|
175 |
|
---|
176 | class VBoxShowTrayIconEvent : public QEvent
|
---|
177 | {
|
---|
178 | public:
|
---|
179 | VBoxShowTrayIconEvent (bool aShow)
|
---|
180 | : QEvent ((QEvent::Type) VBoxDefs::ShowTrayIconEventType)
|
---|
181 | , mShow (aShow)
|
---|
182 | {}
|
---|
183 |
|
---|
184 | const bool mShow;
|
---|
185 | };
|
---|
186 |
|
---|
187 | class VBoxChangeTrayIconEvent : public QEvent
|
---|
188 | {
|
---|
189 | public:
|
---|
190 | VBoxChangeTrayIconEvent (bool aChanged)
|
---|
191 | : QEvent ((QEvent::Type) VBoxDefs::TrayIconChangeEventType)
|
---|
192 | , mChanged (aChanged)
|
---|
193 | {}
|
---|
194 |
|
---|
195 | const bool mChanged;
|
---|
196 | };
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | class VBoxChangeDockIconUpdateEvent : public QEvent
|
---|
200 | {
|
---|
201 | public:
|
---|
202 | VBoxChangeDockIconUpdateEvent (bool aChanged)
|
---|
203 | : QEvent ((QEvent::Type) VBoxDefs::ChangeDockIconUpdateEventType)
|
---|
204 | , mChanged (aChanged)
|
---|
205 | {}
|
---|
206 |
|
---|
207 | const bool mChanged;
|
---|
208 | };
|
---|
209 |
|
---|
210 | class VBoxChangePresentationModeEvent : public QEvent
|
---|
211 | {
|
---|
212 | public:
|
---|
213 | VBoxChangePresentationModeEvent (bool aChanged)
|
---|
214 | : QEvent ((QEvent::Type) VBoxDefs::ChangePresentationmodeEventType)
|
---|
215 | , mChanged (aChanged)
|
---|
216 | {}
|
---|
217 |
|
---|
218 | const bool mChanged;
|
---|
219 | };
|
---|
220 |
|
---|
221 | class Process : public QProcess
|
---|
222 | {
|
---|
223 | Q_OBJECT;
|
---|
224 |
|
---|
225 | public:
|
---|
226 |
|
---|
227 | static QByteArray singleShot (const QString &aProcessName,
|
---|
228 | int aTimeout = 5000
|
---|
229 | /* wait for data maximum 5 seconds */)
|
---|
230 | {
|
---|
231 | /* Why is it really needed is because of Qt4.3 bug with QProcess.
|
---|
232 | * This bug is about QProcess sometimes (~70%) do not receive
|
---|
233 | * notification about process was finished, so this makes
|
---|
234 | * 'bool QProcess::waitForFinished (int)' block the GUI thread and
|
---|
235 | * never dismissed with 'true' result even if process was really
|
---|
236 | * started&finished. So we just waiting for some information
|
---|
237 | * on process output and destroy the process with force. Due to
|
---|
238 | * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
|
---|
239 | * we have to change process state to QProcess::NotRunning. */
|
---|
240 |
|
---|
241 | QByteArray result;
|
---|
242 | Process process;
|
---|
243 | process.start (aProcessName);
|
---|
244 | bool firstShotReady = process.waitForReadyRead (aTimeout);
|
---|
245 | if (firstShotReady)
|
---|
246 | result = process.readAllStandardOutput();
|
---|
247 | process.setProcessState (QProcess::NotRunning);
|
---|
248 | #ifdef Q_WS_X11
|
---|
249 | int status;
|
---|
250 | if (process.pid() > 0)
|
---|
251 | waitpid(process.pid(), &status, 0);
|
---|
252 | #endif
|
---|
253 | return result;
|
---|
254 | }
|
---|
255 |
|
---|
256 | protected:
|
---|
257 |
|
---|
258 | Process (QWidget *aParent = 0) : QProcess (aParent) {}
|
---|
259 | };
|
---|
260 |
|
---|
261 | struct StorageSlot
|
---|
262 | {
|
---|
263 | StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {}
|
---|
264 | StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {}
|
---|
265 | StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {}
|
---|
266 | StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; }
|
---|
267 | bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; }
|
---|
268 | bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; }
|
---|
269 | bool isNull() { return bus == KStorageBus_Null; }
|
---|
270 | KStorageBus bus; LONG port; LONG device;
|
---|
271 | };
|
---|
272 | Q_DECLARE_METATYPE (StorageSlot);
|
---|
273 |
|
---|
274 | // VBoxGlobal class
|
---|
275 | ////////////////////////////////////////////////////////////////////////////////
|
---|
276 |
|
---|
277 | class VBoxSelectorWnd;
|
---|
278 | class VBoxConsoleWnd;
|
---|
279 | class UIRegistrationWzd;
|
---|
280 | class VBoxUpdateDlg;
|
---|
281 |
|
---|
282 | class VBoxGlobal : public QObject
|
---|
283 | {
|
---|
284 | Q_OBJECT
|
---|
285 |
|
---|
286 | public:
|
---|
287 |
|
---|
288 | typedef QHash <ulong, QString> QULongStringHash;
|
---|
289 | typedef QHash <long, QString> QLongStringHash;
|
---|
290 |
|
---|
291 | static VBoxGlobal &instance();
|
---|
292 |
|
---|
293 | bool isValid() { return mValid; }
|
---|
294 |
|
---|
295 | static QString qtRTVersionString();
|
---|
296 | static uint qtRTVersion();
|
---|
297 | static QString qtCTVersionString();
|
---|
298 | static uint qtCTVersion();
|
---|
299 |
|
---|
300 | QString versionString() { return mVerString; }
|
---|
301 |
|
---|
302 | CVirtualBox virtualBox() const { return mVBox; }
|
---|
303 |
|
---|
304 | const VBoxGlobalSettings &settings() const { return gset; }
|
---|
305 | bool setSettings (const VBoxGlobalSettings &gs);
|
---|
306 |
|
---|
307 | VBoxSelectorWnd &selectorWnd();
|
---|
308 |
|
---|
309 | QWidget *vmWindow();
|
---|
310 |
|
---|
311 | VBoxConsoleWnd &consoleWnd();
|
---|
312 | #ifdef VBOX_WITH_NEW_RUNTIME_CORE
|
---|
313 | bool createVirtualMachine(const CSession &session);
|
---|
314 | UIMachine* virtualMachine();
|
---|
315 | #endif
|
---|
316 |
|
---|
317 | /* main window handle storage */
|
---|
318 | void setMainWindow (QWidget *aMainWindow) { mMainWindow = aMainWindow; }
|
---|
319 | QWidget *mainWindow() const { return mMainWindow; }
|
---|
320 |
|
---|
321 | /* branding */
|
---|
322 | bool brandingIsActive (bool aForce = false);
|
---|
323 | QString brandingGetKey (QString aKey);
|
---|
324 |
|
---|
325 | bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
|
---|
326 | bool showStartVMErrors() const { return mShowStartVMErrors; }
|
---|
327 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
328 | bool isTrayMenu() const;
|
---|
329 | void setTrayMenu(bool aIsTrayMenu);
|
---|
330 | void trayIconShowSelector();
|
---|
331 | bool trayIconInstall();
|
---|
332 | #endif
|
---|
333 | QString managedVMUuid() const { return vmUuid; }
|
---|
334 |
|
---|
335 | VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
|
---|
336 | const char *vmRenderModeStr() const { return vm_render_mode_str; }
|
---|
337 | bool isKWinManaged() const { return mIsKWinManaged; }
|
---|
338 |
|
---|
339 | const QRect availableGeometry(int iScreen = 0) const;
|
---|
340 |
|
---|
341 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
342 | bool isDebuggerEnabled() const { return mDbgEnabled; }
|
---|
343 | bool isDebuggerAutoShowEnabled() const { return mDbgAutoShow; }
|
---|
344 | bool isDebuggerAutoShowCommandLineEnabled() const { return mDbgAutoShowCommandLine; }
|
---|
345 | bool isDebuggerAutoShowStatisticsEnabled() const { return mDbgAutoShowStatistics; }
|
---|
346 | RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }
|
---|
347 |
|
---|
348 | bool isStartPausedEnabled() const { return mStartPaused; }
|
---|
349 | #else
|
---|
350 | bool isDebuggerAutoShowEnabled() const { return false; }
|
---|
351 | bool isDebuggerAutoShowCommandLineEnabled() const { return false; }
|
---|
352 | bool isDebuggerAutoShowStatisticsEnabled() const { return false; }
|
---|
353 |
|
---|
354 | bool isStartPausedEnabled() const { return false; }
|
---|
355 | #endif
|
---|
356 |
|
---|
357 | /* VBox enum to/from string/icon/color convertors */
|
---|
358 |
|
---|
359 | QList <CGuestOSType> vmGuestOSFamilyList() const;
|
---|
360 | QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
|
---|
361 | QPixmap vmGuestOSTypeIcon (const QString &aTypeId) const;
|
---|
362 | CGuestOSType vmGuestOSType (const QString &aTypeId,
|
---|
363 | const QString &aFamilyId = QString::null) const;
|
---|
364 | QString vmGuestOSTypeDescription (const QString &aTypeId) const;
|
---|
365 |
|
---|
366 | QPixmap toIcon (KMachineState s) const
|
---|
367 | {
|
---|
368 | QPixmap *pm = mVMStateIcons.value (s);
|
---|
369 | AssertMsg (pm, ("Icon for VM state %d must be defined", s));
|
---|
370 | return pm ? *pm : QPixmap();
|
---|
371 | }
|
---|
372 |
|
---|
373 | static inline QString yearsToString (uint32_t cVal)
|
---|
374 | {
|
---|
375 | return tr("%n year(s)", "", cVal);
|
---|
376 | }
|
---|
377 |
|
---|
378 | static inline QString monthsToString (uint32_t cVal)
|
---|
379 | {
|
---|
380 | return tr("%n month(s)", "", cVal);
|
---|
381 | }
|
---|
382 |
|
---|
383 | static inline QString daysToString (uint32_t cVal)
|
---|
384 | {
|
---|
385 | return tr("%n day(s)", "", cVal);
|
---|
386 | }
|
---|
387 |
|
---|
388 | static inline QString hoursToString (uint32_t cVal)
|
---|
389 | {
|
---|
390 | return tr("%n hour(s)", "", cVal);
|
---|
391 | }
|
---|
392 |
|
---|
393 | static inline QString minutesToString (uint32_t cVal)
|
---|
394 | {
|
---|
395 | return tr("%n minute(s)", "", cVal);
|
---|
396 | }
|
---|
397 |
|
---|
398 | static inline QString secondsToString (uint32_t cVal)
|
---|
399 | {
|
---|
400 | return tr("%n second(s)", "", cVal);
|
---|
401 | }
|
---|
402 |
|
---|
403 | const QColor &toColor (KMachineState s) const
|
---|
404 | {
|
---|
405 | static const QColor none;
|
---|
406 | AssertMsg (mVMStateColors.value (s), ("No color for %d", s));
|
---|
407 | return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;
|
---|
408 | }
|
---|
409 |
|
---|
410 | QString toString (KMachineState s) const
|
---|
411 | {
|
---|
412 | AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));
|
---|
413 | return mMachineStates.value (s);
|
---|
414 | }
|
---|
415 |
|
---|
416 | QString toString (KSessionState s) const
|
---|
417 | {
|
---|
418 | AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));
|
---|
419 | return mSessionStates.value (s);
|
---|
420 | }
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Returns a string representation of the given KStorageBus enum value.
|
---|
424 | * Complementary to #toStorageBusType (const QString &) const.
|
---|
425 | */
|
---|
426 | QString toString (KStorageBus aBus) const
|
---|
427 | {
|
---|
428 | AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));
|
---|
429 | return mStorageBuses [aBus];
|
---|
430 | }
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * Returns a KStorageBus enum value corresponding to the given string
|
---|
434 | * representation. Complementary to #toString (KStorageBus) const.
|
---|
435 | */
|
---|
436 | KStorageBus toStorageBusType (const QString &aBus) const
|
---|
437 | {
|
---|
438 | QULongStringHash::const_iterator it =
|
---|
439 | qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);
|
---|
440 | AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",
|
---|
441 | aBus.toLatin1().constData()));
|
---|
442 | return KStorageBus (it.key());
|
---|
443 | }
|
---|
444 |
|
---|
445 | KStorageBus toStorageBusType (KStorageControllerType aControllerType) const
|
---|
446 | {
|
---|
447 | KStorageBus sb = KStorageBus_Null;
|
---|
448 | switch (aControllerType)
|
---|
449 | {
|
---|
450 | case KStorageControllerType_Null: sb = KStorageBus_Null; break;
|
---|
451 | case KStorageControllerType_PIIX3:
|
---|
452 | case KStorageControllerType_PIIX4:
|
---|
453 | case KStorageControllerType_ICH6: sb = KStorageBus_IDE; break;
|
---|
454 | case KStorageControllerType_IntelAhci: sb = KStorageBus_SATA; break;
|
---|
455 | case KStorageControllerType_LsiLogic:
|
---|
456 | case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break;
|
---|
457 | case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break;
|
---|
458 | default:
|
---|
459 | AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break;
|
---|
460 | }
|
---|
461 | return sb;
|
---|
462 | }
|
---|
463 |
|
---|
464 | QString toString (KStorageBus aBus, LONG aChannel) const;
|
---|
465 | LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;
|
---|
466 |
|
---|
467 | QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
|
---|
468 | LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
|
---|
469 |
|
---|
470 | QString toString (StorageSlot aSlot) const;
|
---|
471 | StorageSlot toStorageSlot (const QString &aSlot) const;
|
---|
472 |
|
---|
473 | QString toString (KMediumType t) const
|
---|
474 | {
|
---|
475 | AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));
|
---|
476 | return mDiskTypes.value (t);
|
---|
477 | }
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Similar to toString (KMediumType), but returns 'Differencing' for
|
---|
481 | * normal hard disks that have a parent.
|
---|
482 | */
|
---|
483 | QString mediumTypeString (const CMedium &aHD) const
|
---|
484 | {
|
---|
485 | if (!aHD.GetParent().isNull())
|
---|
486 | {
|
---|
487 | Assert (aHD.GetType() == KMediumType_Normal);
|
---|
488 | return mDiskTypes_Differencing;
|
---|
489 | }
|
---|
490 | return toString (aHD.GetType());
|
---|
491 | }
|
---|
492 |
|
---|
493 | QString toString (KVRDPAuthType t) const
|
---|
494 | {
|
---|
495 | AssertMsg (!mVRDPAuthTypes.value (t).isNull(), ("No text for %d", t));
|
---|
496 | return mVRDPAuthTypes.value (t);
|
---|
497 | }
|
---|
498 |
|
---|
499 | QString toString (KPortMode t) const
|
---|
500 | {
|
---|
501 | AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));
|
---|
502 | return mPortModeTypes.value (t);
|
---|
503 | }
|
---|
504 |
|
---|
505 | QString toString (KUSBDeviceFilterAction t) const
|
---|
506 | {
|
---|
507 | AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));
|
---|
508 | return mUSBFilterActionTypes.value (t);
|
---|
509 | }
|
---|
510 |
|
---|
511 | QString toString (KClipboardMode t) const
|
---|
512 | {
|
---|
513 | AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));
|
---|
514 | return mClipboardTypes.value (t);
|
---|
515 | }
|
---|
516 |
|
---|
517 | KClipboardMode toClipboardModeType (const QString &s) const
|
---|
518 | {
|
---|
519 | QULongStringHash::const_iterator it =
|
---|
520 | qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);
|
---|
521 | AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",
|
---|
522 | s.toLatin1().constData()));
|
---|
523 | return KClipboardMode (it.key());
|
---|
524 | }
|
---|
525 |
|
---|
526 | QString toString (KStorageControllerType t) const
|
---|
527 | {
|
---|
528 | AssertMsg (!mStorageControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
529 | return mStorageControllerTypes.value (t);
|
---|
530 | }
|
---|
531 |
|
---|
532 | KStorageControllerType toControllerType (const QString &s) const
|
---|
533 | {
|
---|
534 | QULongStringHash::const_iterator it =
|
---|
535 | qFind (mStorageControllerTypes.begin(), mStorageControllerTypes.end(), s);
|
---|
536 | AssertMsg (it != mStorageControllerTypes.end(), ("No value for {%s}",
|
---|
537 | s.toLatin1().constData()));
|
---|
538 | return KStorageControllerType (it.key());
|
---|
539 | }
|
---|
540 |
|
---|
541 | KVRDPAuthType toVRDPAuthType (const QString &s) const
|
---|
542 | {
|
---|
543 | QULongStringHash::const_iterator it =
|
---|
544 | qFind (mVRDPAuthTypes.begin(), mVRDPAuthTypes.end(), s);
|
---|
545 | AssertMsg (it != mVRDPAuthTypes.end(), ("No value for {%s}",
|
---|
546 | s.toLatin1().constData()));
|
---|
547 | return KVRDPAuthType (it.key());
|
---|
548 | }
|
---|
549 |
|
---|
550 | KPortMode toPortMode (const QString &s) const
|
---|
551 | {
|
---|
552 | QULongStringHash::const_iterator it =
|
---|
553 | qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);
|
---|
554 | AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",
|
---|
555 | s.toLatin1().constData()));
|
---|
556 | return KPortMode (it.key());
|
---|
557 | }
|
---|
558 |
|
---|
559 | KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
|
---|
560 | {
|
---|
561 | QULongStringHash::const_iterator it =
|
---|
562 | qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);
|
---|
563 | AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",
|
---|
564 | s.toLatin1().constData()));
|
---|
565 | return KUSBDeviceFilterAction (it.key());
|
---|
566 | }
|
---|
567 |
|
---|
568 | QString toString (KDeviceType t) const
|
---|
569 | {
|
---|
570 | AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));
|
---|
571 | return mDeviceTypes.value (t);
|
---|
572 | }
|
---|
573 |
|
---|
574 | KDeviceType toDeviceType (const QString &s) const
|
---|
575 | {
|
---|
576 | QULongStringHash::const_iterator it =
|
---|
577 | qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);
|
---|
578 | AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",
|
---|
579 | s.toLatin1().constData()));
|
---|
580 | return KDeviceType (it.key());
|
---|
581 | }
|
---|
582 |
|
---|
583 | QStringList deviceTypeStrings() const;
|
---|
584 |
|
---|
585 | QString toString (KAudioDriverType t) const
|
---|
586 | {
|
---|
587 | AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));
|
---|
588 | return mAudioDriverTypes.value (t);
|
---|
589 | }
|
---|
590 |
|
---|
591 | KAudioDriverType toAudioDriverType (const QString &s) const
|
---|
592 | {
|
---|
593 | QULongStringHash::const_iterator it =
|
---|
594 | qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);
|
---|
595 | AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",
|
---|
596 | s.toLatin1().constData()));
|
---|
597 | return KAudioDriverType (it.key());
|
---|
598 | }
|
---|
599 |
|
---|
600 | QString toString (KAudioControllerType t) const
|
---|
601 | {
|
---|
602 | AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
603 | return mAudioControllerTypes.value (t);
|
---|
604 | }
|
---|
605 |
|
---|
606 | KAudioControllerType toAudioControllerType (const QString &s) const
|
---|
607 | {
|
---|
608 | QULongStringHash::const_iterator it =
|
---|
609 | qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);
|
---|
610 | AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",
|
---|
611 | s.toLatin1().constData()));
|
---|
612 | return KAudioControllerType (it.key());
|
---|
613 | }
|
---|
614 |
|
---|
615 | QString toString (KNetworkAdapterType t) const
|
---|
616 | {
|
---|
617 | AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));
|
---|
618 | return mNetworkAdapterTypes.value (t);
|
---|
619 | }
|
---|
620 |
|
---|
621 | KNetworkAdapterType toNetworkAdapterType (const QString &s) const
|
---|
622 | {
|
---|
623 | QULongStringHash::const_iterator it =
|
---|
624 | qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);
|
---|
625 | AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",
|
---|
626 | s.toLatin1().constData()));
|
---|
627 | return KNetworkAdapterType (it.key());
|
---|
628 | }
|
---|
629 |
|
---|
630 | QString toString (KNetworkAttachmentType t) const
|
---|
631 | {
|
---|
632 | AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
|
---|
633 | return mNetworkAttachmentTypes.value (t);
|
---|
634 | }
|
---|
635 |
|
---|
636 | KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
|
---|
637 | {
|
---|
638 | QULongStringHash::const_iterator it =
|
---|
639 | qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);
|
---|
640 | AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",
|
---|
641 | s.toLatin1().constData()));
|
---|
642 | return KNetworkAttachmentType (it.key());
|
---|
643 | }
|
---|
644 |
|
---|
645 | QString toString (KUSBDeviceState aState) const
|
---|
646 | {
|
---|
647 | AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
|
---|
648 | return mUSBDeviceStates.value (aState);
|
---|
649 | }
|
---|
650 |
|
---|
651 | QStringList COMPortNames() const;
|
---|
652 | QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
653 | bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
654 |
|
---|
655 | QStringList LPTPortNames() const;
|
---|
656 | QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
657 | bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
658 |
|
---|
659 | QPixmap snapshotIcon (bool online) const
|
---|
660 | {
|
---|
661 | return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
|
---|
662 | }
|
---|
663 |
|
---|
664 | QPixmap warningIcon() const { return mWarningIcon; }
|
---|
665 | QPixmap errorIcon() const { return mErrorIcon; }
|
---|
666 |
|
---|
667 | /* details generators */
|
---|
668 |
|
---|
669 | QString details (const CMedium &aHD, bool aPredictDiff);
|
---|
670 |
|
---|
671 | QString details (const CUSBDevice &aDevice) const;
|
---|
672 | QString toolTip (const CUSBDevice &aDevice) const;
|
---|
673 | QString toolTip (const CUSBDeviceFilter &aFilter) const;
|
---|
674 |
|
---|
675 | QString detailsReport (const CMachine &aMachine, bool aWithLinks);
|
---|
676 |
|
---|
677 | QString platformInfo();
|
---|
678 |
|
---|
679 | /* VirtualBox helpers */
|
---|
680 |
|
---|
681 | #if defined(Q_WS_X11) && !defined(VBOX_OSE)
|
---|
682 | double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
|
---|
683 | bool showVirtualBoxLicense();
|
---|
684 | #endif
|
---|
685 |
|
---|
686 | CSession openSession (const QString &aId, bool aExisting = false);
|
---|
687 |
|
---|
688 | /** Shortcut to openSession (aId, true). */
|
---|
689 | CSession openExistingSession (const QString &aId) { return openSession (aId, true); }
|
---|
690 |
|
---|
691 | bool startMachine(const QString &strId);
|
---|
692 |
|
---|
693 | void startEnumeratingMedia();
|
---|
694 |
|
---|
695 | /**
|
---|
696 | * Returns a list of all currently registered media. This list is used to
|
---|
697 | * globally track the accessiblity state of all media on a dedicated thread.
|
---|
698 | *
|
---|
699 | * Note that the media list is initially empty (i.e. before the enumeration
|
---|
700 | * process is started for the first time using #startEnumeratingMedia()).
|
---|
701 | * See #startEnumeratingMedia() for more information about how meida are
|
---|
702 | * sorted in the returned list.
|
---|
703 | */
|
---|
704 | const VBoxMediaList ¤tMediaList() const { return mMediaList; }
|
---|
705 |
|
---|
706 | /** Returns true if the media enumeration is in progress. */
|
---|
707 | bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }
|
---|
708 |
|
---|
709 | void addMedium (const VBoxMedium &);
|
---|
710 | void updateMedium (const VBoxMedium &);
|
---|
711 | void removeMedium (VBoxDefs::MediumType, const QString &);
|
---|
712 |
|
---|
713 | bool findMedium (const CMedium &, VBoxMedium &) const;
|
---|
714 | VBoxMedium findMedium (const QString &aMediumId) const;
|
---|
715 |
|
---|
716 | /** Compact version of #findMediumTo(). Asserts if not found. */
|
---|
717 | VBoxMedium getMedium (const CMedium &aObj) const
|
---|
718 | {
|
---|
719 | VBoxMedium medium;
|
---|
720 | if (!findMedium (aObj, medium))
|
---|
721 | AssertFailed();
|
---|
722 | return medium;
|
---|
723 | }
|
---|
724 |
|
---|
725 | /* Returns the number of current running Fe/Qt4 main windows. */
|
---|
726 | int mainWindowCount();
|
---|
727 |
|
---|
728 | /* various helpers */
|
---|
729 |
|
---|
730 | QString languageName() const;
|
---|
731 | QString languageCountry() const;
|
---|
732 | QString languageNameEnglish() const;
|
---|
733 | QString languageCountryEnglish() const;
|
---|
734 | QString languageTranslators() const;
|
---|
735 |
|
---|
736 | void retranslateUi();
|
---|
737 |
|
---|
738 | /** @internal made public for internal purposes */
|
---|
739 | void cleanup();
|
---|
740 |
|
---|
741 | /* public static stuff */
|
---|
742 |
|
---|
743 | static bool isDOSType (const QString &aOSTypeId);
|
---|
744 |
|
---|
745 | static QString languageId();
|
---|
746 | static void loadLanguage (const QString &aLangId = QString::null);
|
---|
747 | QString helpFile() const;
|
---|
748 |
|
---|
749 | static QIcon iconSet (const QPixmap &aNormal,
|
---|
750 | const QPixmap &aDisabled = QPixmap(),
|
---|
751 | const QPixmap &aActive = QPixmap());
|
---|
752 | static QIcon iconSet (const char *aNormal,
|
---|
753 | const char *aDisabled = NULL,
|
---|
754 | const char *aActive = NULL);
|
---|
755 | static QIcon iconSetOnOff (const char *aNormal, const char *aNormalOff,
|
---|
756 | const char *aDisabled = NULL,
|
---|
757 | const char *aDisabledOff = NULL,
|
---|
758 | const char *aActive = NULL,
|
---|
759 | const char *aActiveOff = NULL);
|
---|
760 | static QIcon iconSetFull (const QSize &aNormalSize, const QSize &aSmallSize,
|
---|
761 | const char *aNormal, const char *aSmallNormal,
|
---|
762 | const char *aDisabled = NULL,
|
---|
763 | const char *aSmallDisabled = NULL,
|
---|
764 | const char *aActive = NULL,
|
---|
765 | const char *aSmallActive = NULL);
|
---|
766 |
|
---|
767 | static QIcon standardIcon (QStyle::StandardPixmap aStandard, QWidget *aWidget = NULL);
|
---|
768 |
|
---|
769 | static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
|
---|
770 |
|
---|
771 | static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
772 | bool aCanResize = true);
|
---|
773 | static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
774 | bool aCanResize = true);
|
---|
775 | static QRegion flip (const QRegion &aRegion);
|
---|
776 |
|
---|
777 | static void centerWidget (QWidget *aWidget, QWidget *aRelative,
|
---|
778 | bool aCanResize = true);
|
---|
779 |
|
---|
780 | static QChar decimalSep();
|
---|
781 | static QString sizeRegexp();
|
---|
782 |
|
---|
783 | static quint64 parseSize (const QString &);
|
---|
784 | static QString formatSize (quint64 aSize, uint aDecimal = 2,
|
---|
785 | VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);
|
---|
786 |
|
---|
787 | static quint64 requiredVideoMemory (CMachine *aMachine = 0, int cMonitors = 1);
|
---|
788 |
|
---|
789 | static QString locationForHTML (const QString &aFileName);
|
---|
790 |
|
---|
791 | static QString highlight (const QString &aStr, bool aToolTip = false);
|
---|
792 |
|
---|
793 | static QString replaceHtmlEntities(QString strText);
|
---|
794 | static QString emphasize (const QString &aStr);
|
---|
795 |
|
---|
796 | static QString systemLanguageId();
|
---|
797 |
|
---|
798 | static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
|
---|
799 |
|
---|
800 | static QString removeAccelMark (const QString &aText);
|
---|
801 |
|
---|
802 | static QString insertKeyToActionText (const QString &aText, const QString &aKey);
|
---|
803 | static QString extractKeyFromActionText (const QString &aText);
|
---|
804 |
|
---|
805 | static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
|
---|
806 |
|
---|
807 | static QWidget *findWidget (QWidget *aParent, const char *aName,
|
---|
808 | const char *aClassName = NULL,
|
---|
809 | bool aRecursive = false);
|
---|
810 |
|
---|
811 | static QList <QPair <QString, QString> > HDDBackends();
|
---|
812 |
|
---|
813 | /* Qt 4.2.0 support function */
|
---|
814 | static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
|
---|
815 | {
|
---|
816 | #if QT_VERSION < 0x040300
|
---|
817 | /* Deprecated since > 4.2 */
|
---|
818 | aLayout->setMargin (aMargin);
|
---|
819 | #else
|
---|
820 | /* New since > 4.2 */
|
---|
821 | aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
|
---|
822 | #endif
|
---|
823 | }
|
---|
824 |
|
---|
825 | static QString documentsPath();
|
---|
826 |
|
---|
827 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
828 | static bool isAcceleration2DVideoAvailable();
|
---|
829 |
|
---|
830 | /** additional video memory required for the best 2D support performance
|
---|
831 | * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
|
---|
832 | static quint64 required2DOffscreenVideoMemory();
|
---|
833 | #endif
|
---|
834 |
|
---|
835 | signals:
|
---|
836 |
|
---|
837 | /**
|
---|
838 | * Emitted at the beginning of the enumeration process started by
|
---|
839 | * #startEnumeratingMedia().
|
---|
840 | */
|
---|
841 | void mediumEnumStarted();
|
---|
842 |
|
---|
843 | /**
|
---|
844 | * Emitted when a new medium item from the list has updated its
|
---|
845 | * accessibility state.
|
---|
846 | */
|
---|
847 | void mediumEnumerated (const VBoxMedium &aMedum);
|
---|
848 |
|
---|
849 | /**
|
---|
850 | * Emitted at the end of the enumeration process started by
|
---|
851 | * #startEnumeratingMedia(). The @a aList argument is passed for
|
---|
852 | * convenience, it is exactly the same as returned by #currentMediaList().
|
---|
853 | */
|
---|
854 | void mediumEnumFinished (const VBoxMediaList &aList);
|
---|
855 |
|
---|
856 | /** Emitted when a new media is added using #addMedia(). */
|
---|
857 | void mediumAdded (const VBoxMedium &);
|
---|
858 |
|
---|
859 | /** Emitted when the media is updated using #updateMedia(). */
|
---|
860 | void mediumUpdated (const VBoxMedium &);
|
---|
861 |
|
---|
862 | /** Emitted when the media is removed using #removeMedia(). */
|
---|
863 | void mediumRemoved (VBoxDefs::MediumType, const QString &);
|
---|
864 |
|
---|
865 | /* signals emitted when the VirtualBox callback is called by the server
|
---|
866 | * (note that currently these signals are emitted only when the application
|
---|
867 | * is the in the VM selector mode) */
|
---|
868 |
|
---|
869 | void machineStateChanged (const VBoxMachineStateChangeEvent &e);
|
---|
870 | void machineDataChanged (const VBoxMachineDataChangeEvent &e);
|
---|
871 | void machineRegistered (const VBoxMachineRegisteredEvent &e);
|
---|
872 | void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
|
---|
873 | void snapshotChanged (const VBoxSnapshotEvent &e);
|
---|
874 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
875 | void mainWindowCountChanged (const VBoxMainWindowCountChangeEvent &e);
|
---|
876 | void trayIconCanShow (const VBoxCanShowTrayIconEvent &e);
|
---|
877 | void trayIconShow (const VBoxShowTrayIconEvent &e);
|
---|
878 | void trayIconChanged (const VBoxChangeTrayIconEvent &e);
|
---|
879 | #endif
|
---|
880 | void dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &e);
|
---|
881 | void presentationModeChanged (const VBoxChangePresentationModeEvent &e);
|
---|
882 |
|
---|
883 | void canShowRegDlg (bool aCanShow);
|
---|
884 | void canShowUpdDlg (bool aCanShow);
|
---|
885 |
|
---|
886 | public slots:
|
---|
887 |
|
---|
888 | bool openURL (const QString &aURL);
|
---|
889 |
|
---|
890 | void showRegistrationDialog (bool aForce = true);
|
---|
891 | void showUpdateDialog (bool aForce = true);
|
---|
892 | void perDayNewVersionNotifier();
|
---|
893 |
|
---|
894 | protected:
|
---|
895 |
|
---|
896 | bool event (QEvent *e);
|
---|
897 | bool eventFilter (QObject *, QEvent *);
|
---|
898 |
|
---|
899 | private:
|
---|
900 |
|
---|
901 | VBoxGlobal();
|
---|
902 | ~VBoxGlobal();
|
---|
903 |
|
---|
904 | void init();
|
---|
905 |
|
---|
906 | bool mValid;
|
---|
907 |
|
---|
908 | CVirtualBox mVBox;
|
---|
909 |
|
---|
910 | VBoxGlobalSettings gset;
|
---|
911 |
|
---|
912 | VBoxSelectorWnd *mSelectorWnd;
|
---|
913 | VBoxConsoleWnd *mConsoleWnd;
|
---|
914 | #ifdef VBOX_WITH_NEW_RUNTIME_CORE
|
---|
915 | UIMachine *m_pVirtualMachine;
|
---|
916 | #endif
|
---|
917 | QWidget* mMainWindow;
|
---|
918 |
|
---|
919 | #ifdef VBOX_WITH_REGISTRATION
|
---|
920 | UIRegistrationWzd *mRegDlg;
|
---|
921 | #endif
|
---|
922 | VBoxUpdateDlg *mUpdDlg;
|
---|
923 |
|
---|
924 | QString vmUuid;
|
---|
925 |
|
---|
926 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
927 | bool mIsTrayMenu : 1; /*< Tray icon active/desired? */
|
---|
928 | bool mIncreasedWindowCounter : 1;
|
---|
929 | #endif
|
---|
930 |
|
---|
931 | /** Whether to show error message boxes for VM start errors. */
|
---|
932 | bool mShowStartVMErrors;
|
---|
933 |
|
---|
934 | QThread *mMediaEnumThread;
|
---|
935 | VBoxMediaList mMediaList;
|
---|
936 |
|
---|
937 | VBoxDefs::RenderMode vm_render_mode;
|
---|
938 | const char * vm_render_mode_str;
|
---|
939 | bool mIsKWinManaged;
|
---|
940 |
|
---|
941 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
942 | /** Whether the debugger should be accessible or not.
|
---|
943 | * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.
|
---|
944 | * VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
945 | bool mDbgEnabled;
|
---|
946 | /** Whether to show the debugger automatically with the console.
|
---|
947 | * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
948 | bool mDbgAutoShow;
|
---|
949 | /** Whether to show the command line window when mDbgAutoShow is set. */
|
---|
950 | bool mDbgAutoShowCommandLine;
|
---|
951 | /** Whether to show the statistics window when mDbgAutoShow is set. */
|
---|
952 | bool mDbgAutoShowStatistics;
|
---|
953 | /** VBoxDbg module handle. */
|
---|
954 | RTLDRMOD mhVBoxDbg;
|
---|
955 |
|
---|
956 | /** Whether to start the VM in paused state or not. */
|
---|
957 | bool mStartPaused;
|
---|
958 | #endif
|
---|
959 |
|
---|
960 | #if defined (Q_WS_WIN32)
|
---|
961 | DWORD dwHTMLHelpCookie;
|
---|
962 | #endif
|
---|
963 |
|
---|
964 | CVirtualBoxCallback callback;
|
---|
965 |
|
---|
966 | QString mVerString;
|
---|
967 | QString mBrandingConfig;
|
---|
968 |
|
---|
969 | QList <QString> mFamilyIDs;
|
---|
970 | QList <QList <CGuestOSType> > mTypes;
|
---|
971 | QHash <QString, QPixmap *> mOsTypeIcons;
|
---|
972 |
|
---|
973 | QHash <ulong, QPixmap *> mVMStateIcons;
|
---|
974 | QHash <ulong, QColor *> mVMStateColors;
|
---|
975 |
|
---|
976 | QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
|
---|
977 |
|
---|
978 | QULongStringHash mMachineStates;
|
---|
979 | QULongStringHash mSessionStates;
|
---|
980 | QULongStringHash mDeviceTypes;
|
---|
981 |
|
---|
982 | QULongStringHash mStorageBuses;
|
---|
983 | QLongStringHash mStorageBusChannels;
|
---|
984 | QLongStringHash mStorageBusDevices;
|
---|
985 | QULongStringHash mSlotTemplates;
|
---|
986 |
|
---|
987 | QULongStringHash mDiskTypes;
|
---|
988 | QString mDiskTypes_Differencing;
|
---|
989 |
|
---|
990 | QULongStringHash mVRDPAuthTypes;
|
---|
991 | QULongStringHash mPortModeTypes;
|
---|
992 | QULongStringHash mUSBFilterActionTypes;
|
---|
993 | QULongStringHash mAudioDriverTypes;
|
---|
994 | QULongStringHash mAudioControllerTypes;
|
---|
995 | QULongStringHash mNetworkAdapterTypes;
|
---|
996 | QULongStringHash mNetworkAttachmentTypes;
|
---|
997 | QULongStringHash mClipboardTypes;
|
---|
998 | QULongStringHash mStorageControllerTypes;
|
---|
999 | QULongStringHash mUSBDeviceStates;
|
---|
1000 |
|
---|
1001 | QString mUserDefinedPortName;
|
---|
1002 |
|
---|
1003 | QPixmap mWarningIcon, mErrorIcon;
|
---|
1004 |
|
---|
1005 | friend VBoxGlobal &vboxGlobal();
|
---|
1006 | friend class VBoxCallback;
|
---|
1007 | };
|
---|
1008 |
|
---|
1009 | inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
|
---|
1010 |
|
---|
1011 | // Helper classes
|
---|
1012 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1013 |
|
---|
1014 | /**
|
---|
1015 | * Generic asyncronous event.
|
---|
1016 | *
|
---|
1017 | * This abstract class is intended to provide a conveinent way to execute
|
---|
1018 | * code on the main GUI thread asynchronously to the calling party. This is
|
---|
1019 | * done by putting necessary actions to the #handle() function in a subclass
|
---|
1020 | * and then posting an instance of the subclass using #post(). The instance
|
---|
1021 | * must be allocated on the heap using the <tt>new</tt> operation and will be
|
---|
1022 | * automatically deleted after processing. Note that if you don't call #post()
|
---|
1023 | * on the created instance, you have to delete it yourself.
|
---|
1024 | */
|
---|
1025 | class VBoxAsyncEvent : public QEvent
|
---|
1026 | {
|
---|
1027 | public:
|
---|
1028 |
|
---|
1029 | VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {}
|
---|
1030 |
|
---|
1031 | /**
|
---|
1032 | * Worker function. Gets executed on the GUI thread when the posted event
|
---|
1033 | * is processed by the main event loop.
|
---|
1034 | */
|
---|
1035 | virtual void handle() = 0;
|
---|
1036 |
|
---|
1037 | /**
|
---|
1038 | * Posts this event to the main event loop.
|
---|
1039 | * The caller loses ownership of this object after this method returns
|
---|
1040 | * and must not delete the object.
|
---|
1041 | */
|
---|
1042 | void post()
|
---|
1043 | {
|
---|
1044 | QApplication::postEvent (&vboxGlobal(), this);
|
---|
1045 | }
|
---|
1046 | };
|
---|
1047 |
|
---|
1048 | /**
|
---|
1049 | * USB Popup Menu class.
|
---|
1050 | * This class provides the list of USB devices attached to the host.
|
---|
1051 | */
|
---|
1052 | class VBoxUSBMenu : public QMenu
|
---|
1053 | {
|
---|
1054 | Q_OBJECT
|
---|
1055 |
|
---|
1056 | public:
|
---|
1057 |
|
---|
1058 | VBoxUSBMenu (QWidget *);
|
---|
1059 |
|
---|
1060 | const CUSBDevice& getUSB (QAction *aAction);
|
---|
1061 |
|
---|
1062 | void setConsole (const CConsole &);
|
---|
1063 |
|
---|
1064 | private slots:
|
---|
1065 |
|
---|
1066 | void processAboutToShow();
|
---|
1067 |
|
---|
1068 | private:
|
---|
1069 | bool event(QEvent *aEvent);
|
---|
1070 |
|
---|
1071 | QMap <QAction *, CUSBDevice> mUSBDevicesMap;
|
---|
1072 | CConsole mConsole;
|
---|
1073 | };
|
---|
1074 |
|
---|
1075 | /**
|
---|
1076 | * Enable/Disable Menu class.
|
---|
1077 | * This class provides enable/disable menu items.
|
---|
1078 | */
|
---|
1079 | class VBoxSwitchMenu : public QMenu
|
---|
1080 | {
|
---|
1081 | Q_OBJECT
|
---|
1082 |
|
---|
1083 | public:
|
---|
1084 |
|
---|
1085 | VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
|
---|
1086 |
|
---|
1087 | void setToolTip (const QString &);
|
---|
1088 |
|
---|
1089 | private slots:
|
---|
1090 |
|
---|
1091 | void processAboutToShow();
|
---|
1092 |
|
---|
1093 | private:
|
---|
1094 |
|
---|
1095 | QAction *mAction;
|
---|
1096 | bool mInverted;
|
---|
1097 | };
|
---|
1098 |
|
---|
1099 | #endif /* __VBoxGlobal_h__ */
|
---|
1100 |
|
---|