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 | #include <QProcess>
|
---|
38 | #include <QLinkedList>
|
---|
39 |
|
---|
40 | class QAction;
|
---|
41 | class QLabel;
|
---|
42 | class QToolButton;
|
---|
43 |
|
---|
44 | // Auxiliary types
|
---|
45 | ////////////////////////////////////////////////////////////////////////////////
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Media descriptor for the GUI.
|
---|
49 | *
|
---|
50 | * Maintains the results of the last state (accessibility) check and precomposes
|
---|
51 | * string parameters such as location, size which can be used in various GUI
|
---|
52 | * controls.
|
---|
53 | *
|
---|
54 | * Many getter methods take the boolean @a aNoDiffs argument. Unless explicitly
|
---|
55 | * stated otherwise, this argument, when set to @c true, will cause the
|
---|
56 | * corresponding property of this object's root medium to be returned instead of
|
---|
57 | * its own one. This is useful when hard disk media is represented in the
|
---|
58 | * user-friendly "don't show diffs" mode. For non-hard disk media, the value of
|
---|
59 | * this argument is irrelevant because the root object for such medium is
|
---|
60 | * the medium itself.
|
---|
61 | *
|
---|
62 | * Note that this class "abuses" the KMediaState_NotCreated state value to
|
---|
63 | * indicate that the accessibility check of the given medium (see
|
---|
64 | * #blockAndQueryState()) has not been done yet and therefore some parameters
|
---|
65 | * such as #size() are meaningless because they can be read only from the
|
---|
66 | * accessible medium. The real KMediaState_NotCreated state is not necessary
|
---|
67 | * because this class is only used with created (existing) media.
|
---|
68 | */
|
---|
69 | class VBoxMedium
|
---|
70 | {
|
---|
71 | public:
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Creates a null medium descriptor which is not associated with any medium.
|
---|
75 | * The state field is set to KMediaState_NotCreated.
|
---|
76 | */
|
---|
77 | VBoxMedium()
|
---|
78 | : mType (VBoxDefs::MediaType_Invalid)
|
---|
79 | , mState (KMediaState_NotCreated)
|
---|
80 | , mIsReadOnly (false), mIsUsedInSnapshots (false)
|
---|
81 | , mParent (NULL) {}
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Creates a media descriptor associated with the given medium.
|
---|
85 | *
|
---|
86 | * The state field remain KMediaState_NotCreated until #blockAndQueryState()
|
---|
87 | * is called. All precomposed strings are filled up by implicitly calling
|
---|
88 | * #refresh(), see the #refresh() details for more info.
|
---|
89 | *
|
---|
90 | * One of the hardDisk, dvdImage, or floppyImage members is assigned from
|
---|
91 | * aMedium according to aType. @a aParent must be always NULL for non-hard
|
---|
92 | * disk media.
|
---|
93 | */
|
---|
94 | VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
|
---|
95 | VBoxMedium *aParent = NULL)
|
---|
96 | : mMedium (aMedium), mType (aType)
|
---|
97 | , mState (KMediaState_NotCreated)
|
---|
98 | , mIsReadOnly (false), mIsUsedInSnapshots (false)
|
---|
99 | , mParent (aParent) { init(); }
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Similar to the other non-null constructor but sets the media state to
|
---|
103 | * @a aState. Suitable when the media state is known such as right after
|
---|
104 | * creation.
|
---|
105 | */
|
---|
106 | VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
|
---|
107 | KMediaState aState)
|
---|
108 | : mMedium (aMedium), mType (aType)
|
---|
109 | , mState (aState)
|
---|
110 | , mIsReadOnly (false), mIsUsedInSnapshots (false)
|
---|
111 | , mParent (NULL) { init(); }
|
---|
112 |
|
---|
113 | void blockAndQueryState();
|
---|
114 | void refresh();
|
---|
115 |
|
---|
116 | const CMedium &medium() const { return mMedium; };
|
---|
117 |
|
---|
118 | VBoxDefs::MediaType type() const { return mType; }
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Media state. In "don't show diffs" mode, this is the worst state (in
|
---|
122 | * terms of inaccessibility) detected on the given hard disk chain.
|
---|
123 | *
|
---|
124 | * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode.
|
---|
125 | */
|
---|
126 | KMediaState state (bool aNoDiffs = false) const
|
---|
127 | {
|
---|
128 | unconst (this)->checkNoDiffs (aNoDiffs);
|
---|
129 | return aNoDiffs ? mNoDiffs.state : mState;
|
---|
130 | }
|
---|
131 |
|
---|
132 | QString lastAccessError() const { return mLastAccessError; }
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Result of the last blockAndQueryState() call. Will indicate an error and
|
---|
136 | * contain a proper error info if the last state check fails. In "don't show
|
---|
137 | * diffs" mode, this is the worst result (in terms of inaccessibility)
|
---|
138 | * detected on the given hard disk chain.
|
---|
139 | *
|
---|
140 | * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode.
|
---|
141 | */
|
---|
142 | const COMResult &result (bool aNoDiffs = false) const
|
---|
143 | {
|
---|
144 | unconst (this)->checkNoDiffs (aNoDiffs);
|
---|
145 | return aNoDiffs ? mNoDiffs.result : mResult;
|
---|
146 | }
|
---|
147 |
|
---|
148 | const CHardDisk2 &hardDisk() const { return mHardDisk; }
|
---|
149 | const CDVDImage2 &dvdImage() const { return mDVDImage; }
|
---|
150 | const CFloppyImage2 &floppyImage() const { return mFloppyImage; }
|
---|
151 |
|
---|
152 | QUuid id() const { return mId; }
|
---|
153 |
|
---|
154 | QString location (bool aNoDiffs = false) const
|
---|
155 | { return aNoDiffs ? root().mLocation : mLocation; }
|
---|
156 | QString name (bool aNoDiffs = false) const
|
---|
157 | { return aNoDiffs ? root().mName : mName; }
|
---|
158 |
|
---|
159 | QString size (bool aNoDiffs = false) const
|
---|
160 | { return aNoDiffs ? root().mSize : mSize; }
|
---|
161 |
|
---|
162 | QString hardDiskFormat (bool aNoDiffs = false) const
|
---|
163 | { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; }
|
---|
164 | QString hardDiskType (bool aNoDiffs = false) const
|
---|
165 | { return aNoDiffs ? root().mHardDiskType : mHardDiskType; }
|
---|
166 | QString logicalSize (bool aNoDiffs = false) const
|
---|
167 | { return aNoDiffs ? root().mLogicalSize : mLogicalSize; }
|
---|
168 |
|
---|
169 | QString usage (bool aNoDiffs = false) const
|
---|
170 | { return aNoDiffs ? root().mUsage : mUsage; }
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Returns @c true if this medium is read-only (either because it is
|
---|
174 | * Immutable or because it has child hard disks). Read-only media can only
|
---|
175 | * be attached indirectly.
|
---|
176 | */
|
---|
177 | bool isReadOnly() const { return mIsReadOnly; }
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Returns @c true if this medium is attached to any VM (in the current
|
---|
181 | * state or in a snapshot) in which case #usage() will contain a string with
|
---|
182 | * comma-sparated VM names (with snapshot names, if any, in parenthesis).
|
---|
183 | */
|
---|
184 | bool isUsed() const { return !mUsage.isNull(); }
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Returns @c true if this medium is attached to any VM in any snapshot.
|
---|
188 | * which case #usage() will contain a string with comma-sparated VM names.
|
---|
189 | */
|
---|
190 | bool isUsedInSnapshots() const { return mIsUsedInSnapshots; }
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Returns @c true if this medium is attached to the given machine in the
|
---|
194 | * current state.
|
---|
195 | */
|
---|
196 | bool isAttachedInCurStateTo (const QUuid &aMachineId) const
|
---|
197 | { return mCurStateMachineIds.indexOf (aMachineId) >= 0; }
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Returns a vector of IDs of all machines this medium is attached
|
---|
201 | * to in their current state (i.e. excluding snapshots).
|
---|
202 | */
|
---|
203 | const QList <QUuid> &curStateMachineIds() const
|
---|
204 | { return mCurStateMachineIds; }
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Returns a parent medium. For non-hard disk media, this is always NULL.
|
---|
208 | */
|
---|
209 | VBoxMedium *parent() const { return mParent; }
|
---|
210 |
|
---|
211 | VBoxMedium &root() const;
|
---|
212 |
|
---|
213 | QString toolTip(bool aNoDiffs = false, bool aCheckRO = false) const;
|
---|
214 | QPixmap icon (bool aNoDiffs = false, bool aCheckRO = false) const;
|
---|
215 |
|
---|
216 | /** Shortcut to <tt>#toolTip (aNoDiffs, true)</tt>. */
|
---|
217 | QString toolTipCheckRO (bool aNoDiffs = false) const
|
---|
218 | { return toolTip (aNoDiffs, true); }
|
---|
219 |
|
---|
220 | /** Shortcut to <tt>#icon (aNoDiffs, true)</tt>. */
|
---|
221 | QPixmap iconCheckRO (bool aNoDiffs = false) const
|
---|
222 | { return icon (aNoDiffs, true); }
|
---|
223 |
|
---|
224 | QString details (bool aNoDiffs = false, bool aPredictDiff = false,
|
---|
225 | bool aUseHTML = false) const;
|
---|
226 |
|
---|
227 | /** Shortcut to <tt>#details (aNoDiffs, aPredictDiff, true)</tt>. */
|
---|
228 | QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const
|
---|
229 | { return details (aNoDiffs, aPredictDiff, true); }
|
---|
230 |
|
---|
231 | /** Returns @c true if this media descriptor is a null object. */
|
---|
232 | bool isNull() const { return mMedium.isNull(); }
|
---|
233 |
|
---|
234 | private:
|
---|
235 |
|
---|
236 | void init();
|
---|
237 |
|
---|
238 | void checkNoDiffs (bool aNoDiffs);
|
---|
239 |
|
---|
240 | CMedium mMedium;
|
---|
241 |
|
---|
242 | VBoxDefs::MediaType mType;
|
---|
243 |
|
---|
244 | KMediaState mState;
|
---|
245 | QString mLastAccessError;
|
---|
246 | COMResult mResult;
|
---|
247 |
|
---|
248 | CHardDisk2 mHardDisk;
|
---|
249 | CDVDImage2 mDVDImage;
|
---|
250 | CFloppyImage2 mFloppyImage;
|
---|
251 |
|
---|
252 | QUuid mId;
|
---|
253 | QString mLocation;
|
---|
254 | QString mName;
|
---|
255 | QString mSize;
|
---|
256 |
|
---|
257 | QString mHardDiskFormat;
|
---|
258 | QString mHardDiskType;
|
---|
259 | QString mLogicalSize;
|
---|
260 |
|
---|
261 | QString mUsage;
|
---|
262 | QString mToolTip;
|
---|
263 |
|
---|
264 | bool mIsReadOnly : 1;
|
---|
265 | bool mIsUsedInSnapshots : 1;
|
---|
266 |
|
---|
267 | QList <QUuid> mCurStateMachineIds;
|
---|
268 |
|
---|
269 | VBoxMedium *mParent;
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Used to override some attributes in the user-friendly "don't show diffs"
|
---|
273 | * mode.
|
---|
274 | */
|
---|
275 | struct NoDiffs
|
---|
276 | {
|
---|
277 | NoDiffs() : isSet (false), state (KMediaState_NotCreated) {}
|
---|
278 |
|
---|
279 | bool isSet : 1;
|
---|
280 |
|
---|
281 | KMediaState state;
|
---|
282 | COMResult result;
|
---|
283 | QString toolTip;
|
---|
284 | }
|
---|
285 | mNoDiffs;
|
---|
286 | };
|
---|
287 |
|
---|
288 | typedef QLinkedList <VBoxMedium> VBoxMediaList;
|
---|
289 |
|
---|
290 | // VirtualBox callback events
|
---|
291 | ////////////////////////////////////////////////////////////////////////////////
|
---|
292 |
|
---|
293 | class VBoxMachineStateChangeEvent : public QEvent
|
---|
294 | {
|
---|
295 | public:
|
---|
296 | VBoxMachineStateChangeEvent (const QUuid &aId, KMachineState aState)
|
---|
297 | : QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType)
|
---|
298 | , id (aId), state (aState)
|
---|
299 | {}
|
---|
300 |
|
---|
301 | const QUuid id;
|
---|
302 | const KMachineState state;
|
---|
303 | };
|
---|
304 |
|
---|
305 | class VBoxMachineDataChangeEvent : public QEvent
|
---|
306 | {
|
---|
307 | public:
|
---|
308 | VBoxMachineDataChangeEvent (const QUuid &aId)
|
---|
309 | : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
|
---|
310 | , id (aId)
|
---|
311 | {}
|
---|
312 |
|
---|
313 | const QUuid id;
|
---|
314 | };
|
---|
315 |
|
---|
316 | class VBoxMachineRegisteredEvent : public QEvent
|
---|
317 | {
|
---|
318 | public:
|
---|
319 | VBoxMachineRegisteredEvent (const QUuid &aId, bool aRegistered)
|
---|
320 | : QEvent ((QEvent::Type) VBoxDefs::MachineRegisteredEventType)
|
---|
321 | , id (aId), registered (aRegistered)
|
---|
322 | {}
|
---|
323 |
|
---|
324 | const QUuid id;
|
---|
325 | const bool registered;
|
---|
326 | };
|
---|
327 |
|
---|
328 | class VBoxSessionStateChangeEvent : public QEvent
|
---|
329 | {
|
---|
330 | public:
|
---|
331 | VBoxSessionStateChangeEvent (const QUuid &aId, KSessionState aState)
|
---|
332 | : QEvent ((QEvent::Type) VBoxDefs::SessionStateChangeEventType)
|
---|
333 | , id (aId), state (aState)
|
---|
334 | {}
|
---|
335 |
|
---|
336 | const QUuid id;
|
---|
337 | const KSessionState state;
|
---|
338 | };
|
---|
339 |
|
---|
340 | class VBoxSnapshotEvent : public QEvent
|
---|
341 | {
|
---|
342 | public:
|
---|
343 |
|
---|
344 | enum What { Taken, Discarded, Changed };
|
---|
345 |
|
---|
346 | VBoxSnapshotEvent (const QUuid &aMachineId, const QUuid &aSnapshotId,
|
---|
347 | What aWhat)
|
---|
348 | : QEvent ((QEvent::Type) VBoxDefs::SnapshotEventType)
|
---|
349 | , what (aWhat)
|
---|
350 | , machineId (aMachineId), snapshotId (aSnapshotId)
|
---|
351 | {}
|
---|
352 |
|
---|
353 | const What what;
|
---|
354 |
|
---|
355 | const QUuid machineId;
|
---|
356 | const QUuid snapshotId;
|
---|
357 | };
|
---|
358 |
|
---|
359 | class VBoxCanShowRegDlgEvent : public QEvent
|
---|
360 | {
|
---|
361 | public:
|
---|
362 | VBoxCanShowRegDlgEvent (bool aCanShow)
|
---|
363 | : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
|
---|
364 | , mCanShow (aCanShow)
|
---|
365 | {}
|
---|
366 |
|
---|
367 | const bool mCanShow;
|
---|
368 | };
|
---|
369 |
|
---|
370 | class VBoxCanShowUpdDlgEvent : public QEvent
|
---|
371 | {
|
---|
372 | public:
|
---|
373 | VBoxCanShowUpdDlgEvent (bool aCanShow)
|
---|
374 | : QEvent ((QEvent::Type) VBoxDefs::CanShowUpdDlgEventType)
|
---|
375 | , mCanShow (aCanShow)
|
---|
376 | {}
|
---|
377 |
|
---|
378 | const bool mCanShow;
|
---|
379 | };
|
---|
380 |
|
---|
381 | class VBoxChangeGUILanguageEvent : public QEvent
|
---|
382 | {
|
---|
383 | public:
|
---|
384 | VBoxChangeGUILanguageEvent (QString aLangId)
|
---|
385 | : QEvent ((QEvent::Type) VBoxDefs::ChangeGUILanguageEventType)
|
---|
386 | , mLangId (aLangId)
|
---|
387 | {}
|
---|
388 |
|
---|
389 | const QString mLangId;
|
---|
390 | };
|
---|
391 |
|
---|
392 | class Process : public QProcess
|
---|
393 | {
|
---|
394 | Q_OBJECT;
|
---|
395 |
|
---|
396 | public:
|
---|
397 |
|
---|
398 | static QByteArray singleShot (const QString &aProcessName,
|
---|
399 | int aTimeout = 5000
|
---|
400 | /* wait for data maximum 5 seconds */)
|
---|
401 | {
|
---|
402 | /* Why is it really needed is because of Qt4.3 bug with QProcess.
|
---|
403 | * This bug is about QProcess sometimes (~70%) do not receive
|
---|
404 | * notification about process was finished, so this makes
|
---|
405 | * 'bool QProcess::waitForFinished (int)' block the GUI thread and
|
---|
406 | * never dismissed with 'true' result even if process was really
|
---|
407 | * started&finished. So we just waiting for some information
|
---|
408 | * on process output and destroy the process with force. Due to
|
---|
409 | * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
|
---|
410 | * we have to change process state to QProcess::NotRunning. */
|
---|
411 |
|
---|
412 | QByteArray result;
|
---|
413 | Process process;
|
---|
414 | process.start (aProcessName);
|
---|
415 | bool firstShotReady = process.waitForReadyRead (aTimeout);
|
---|
416 | if (firstShotReady)
|
---|
417 | result = process.readAllStandardOutput();
|
---|
418 | process.setProcessState (QProcess::NotRunning);
|
---|
419 | return result;
|
---|
420 | }
|
---|
421 |
|
---|
422 | protected:
|
---|
423 |
|
---|
424 | Process (QWidget *aParent = 0) : QProcess (aParent) {}
|
---|
425 | };
|
---|
426 |
|
---|
427 | // VBoxGlobal class
|
---|
428 | ////////////////////////////////////////////////////////////////////////////////
|
---|
429 |
|
---|
430 | class VBoxSelectorWnd;
|
---|
431 | class VBoxConsoleWnd;
|
---|
432 | class VBoxRegistrationDlg;
|
---|
433 | class VBoxUpdateDlg;
|
---|
434 |
|
---|
435 | class VBoxGlobal : public QObject
|
---|
436 | {
|
---|
437 | Q_OBJECT
|
---|
438 |
|
---|
439 | public:
|
---|
440 |
|
---|
441 | static VBoxGlobal &instance();
|
---|
442 |
|
---|
443 | bool isValid() { return mValid; }
|
---|
444 |
|
---|
445 | QString versionString() { return verString; }
|
---|
446 |
|
---|
447 | CVirtualBox virtualBox() const { return mVBox; }
|
---|
448 |
|
---|
449 | const VBoxGlobalSettings &settings() const { return gset; }
|
---|
450 | bool setSettings (const VBoxGlobalSettings &gs);
|
---|
451 |
|
---|
452 | VBoxSelectorWnd &selectorWnd();
|
---|
453 | VBoxConsoleWnd &consoleWnd();
|
---|
454 |
|
---|
455 | /* main window handle storage */
|
---|
456 | void setMainWindow (QWidget *aMainWindow) { mMainWindow = aMainWindow; }
|
---|
457 | QWidget *mainWindow() const { return mMainWindow; }
|
---|
458 |
|
---|
459 |
|
---|
460 | bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
|
---|
461 | QUuid managedVMUuid() const { return vmUuid; }
|
---|
462 |
|
---|
463 | VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
|
---|
464 | const char *vmRenderModeStr() const { return vm_render_mode_str; }
|
---|
465 |
|
---|
466 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
467 | bool isDebuggerEnabled() const { return mDbgEnabled; }
|
---|
468 | bool isDebuggerAutoShowEnabled() const { return mDbgAutoShow; }
|
---|
469 | RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }
|
---|
470 | #else
|
---|
471 | bool isDebuggerAutoShowEnabled() const { return false; }
|
---|
472 | #endif
|
---|
473 |
|
---|
474 | /* VBox enum to/from string/icon/color convertors */
|
---|
475 |
|
---|
476 | QStringList vmGuestOSTypeDescriptions() const;
|
---|
477 | QList<QPixmap> vmGuestOSTypeIcons (int aHorizonalMargin, int aVerticalMargin) const;
|
---|
478 | CGuestOSType vmGuestOSType (int aIndex) const;
|
---|
479 | int vmGuestOSTypeIndex (const QString &aId) const;
|
---|
480 | QPixmap vmGuestOSTypeIcon (const QString &aId) const;
|
---|
481 | QString vmGuestOSTypeDescription (const QString &aId) const;
|
---|
482 |
|
---|
483 | QPixmap toIcon (KMachineState s) const
|
---|
484 | {
|
---|
485 | QPixmap *pm = mStateIcons.value (s);
|
---|
486 | AssertMsg (pm, ("Icon for VM state %d must be defined", s));
|
---|
487 | return pm ? *pm : QPixmap();
|
---|
488 | }
|
---|
489 |
|
---|
490 | const QColor &toColor (KMachineState s) const
|
---|
491 | {
|
---|
492 | static const QColor none;
|
---|
493 | AssertMsg (vm_state_color.value (s), ("No color for %d", s));
|
---|
494 | return vm_state_color.value (s) ? *vm_state_color.value(s) : none;
|
---|
495 | }
|
---|
496 |
|
---|
497 | QString toString (KMachineState s) const
|
---|
498 | {
|
---|
499 | AssertMsg (!machineStates.value (s).isNull(), ("No text for %d", s));
|
---|
500 | return machineStates.value (s);
|
---|
501 | }
|
---|
502 |
|
---|
503 | QString toString (KSessionState s) const
|
---|
504 | {
|
---|
505 | AssertMsg (!sessionStates.value (s).isNull(), ("No text for %d", s));
|
---|
506 | return sessionStates.value (s);
|
---|
507 | }
|
---|
508 |
|
---|
509 | /**
|
---|
510 | * Returns a string representation of the given KStorageBus enum value.
|
---|
511 | * Complementary to #toStorageBusType (const QString &) const.
|
---|
512 | */
|
---|
513 | QString toString (KStorageBus aBus) const
|
---|
514 | {
|
---|
515 | AssertMsg (!storageBuses.value (aBus).isNull(), ("No text for %d", aBus));
|
---|
516 | return storageBuses [aBus];
|
---|
517 | }
|
---|
518 |
|
---|
519 | /**
|
---|
520 | * Returns a KStorageBus enum value corresponding to the given string
|
---|
521 | * representation. Complementary to #toString (KStorageBus) const.
|
---|
522 | */
|
---|
523 | KStorageBus toStorageBusType (const QString &aBus) const
|
---|
524 | {
|
---|
525 | QStringVector::const_iterator it =
|
---|
526 | qFind (storageBuses.begin(), storageBuses.end(), aBus);
|
---|
527 | AssertMsg (it != storageBuses.end(), ("No value for {%s}", aBus.toLatin1().constData()));
|
---|
528 | return KStorageBus (it - storageBuses.begin());
|
---|
529 | }
|
---|
530 |
|
---|
531 | QString toString (KStorageBus aBus, LONG aChannel) const;
|
---|
532 | LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;
|
---|
533 |
|
---|
534 | QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
|
---|
535 | LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
|
---|
536 |
|
---|
537 | QString toFullString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
|
---|
538 |
|
---|
539 | QString toString (KHardDiskType t) const
|
---|
540 | {
|
---|
541 | AssertMsg (!diskTypes.value (t).isNull(), ("No text for %d", t));
|
---|
542 | return diskTypes.value (t);
|
---|
543 | }
|
---|
544 |
|
---|
545 | /**
|
---|
546 | * Similar to toString (KHardDiskType), but returns 'Differencing' for
|
---|
547 | * normal hard disks that have a parent.
|
---|
548 | */
|
---|
549 | QString hardDiskTypeString (const CHardDisk2 &aHD) const
|
---|
550 | {
|
---|
551 | if (!aHD.GetParent().isNull())
|
---|
552 | {
|
---|
553 | Assert (aHD.GetType() == KHardDiskType_Normal);
|
---|
554 | return diskTypes_Differencing;
|
---|
555 | }
|
---|
556 | return toString (aHD.GetType());
|
---|
557 | }
|
---|
558 |
|
---|
559 | QString toString (KVRDPAuthType t) const
|
---|
560 | {
|
---|
561 | AssertMsg (!vrdpAuthTypes.value (t).isNull(), ("No text for %d", t));
|
---|
562 | return vrdpAuthTypes.value (t);
|
---|
563 | }
|
---|
564 |
|
---|
565 | QString toString (KPortMode t) const
|
---|
566 | {
|
---|
567 | AssertMsg (!portModeTypes.value (t).isNull(), ("No text for %d", t));
|
---|
568 | return portModeTypes.value (t);
|
---|
569 | }
|
---|
570 |
|
---|
571 | QString toString (KUSBDeviceFilterAction t) const
|
---|
572 | {
|
---|
573 | AssertMsg (!usbFilterActionTypes.value (t).isNull(), ("No text for %d", t));
|
---|
574 | return usbFilterActionTypes.value (t);
|
---|
575 | }
|
---|
576 |
|
---|
577 | QString toString (KClipboardMode t) const
|
---|
578 | {
|
---|
579 | AssertMsg (!clipboardTypes.value (t).isNull(), ("No text for %d", t));
|
---|
580 | return clipboardTypes.value (t);
|
---|
581 | }
|
---|
582 |
|
---|
583 | KClipboardMode toClipboardModeType (const QString &s) const
|
---|
584 | {
|
---|
585 | QStringVector::const_iterator it =
|
---|
586 | qFind (clipboardTypes.begin(), clipboardTypes.end(), s);
|
---|
587 | AssertMsg (it != clipboardTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
588 | return KClipboardMode (it - clipboardTypes.begin());
|
---|
589 | }
|
---|
590 |
|
---|
591 | QString toString (KIDEControllerType t) const
|
---|
592 | {
|
---|
593 | AssertMsg (!ideControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
594 | return ideControllerTypes.value (t);
|
---|
595 | }
|
---|
596 |
|
---|
597 | KIDEControllerType toIDEControllerType (const QString &s) const
|
---|
598 | {
|
---|
599 | QStringVector::const_iterator it =
|
---|
600 | qFind (ideControllerTypes.begin(), ideControllerTypes.end(), s);
|
---|
601 | AssertMsg (it != ideControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
602 | return KIDEControllerType (it - ideControllerTypes.begin());
|
---|
603 | }
|
---|
604 |
|
---|
605 | KVRDPAuthType toVRDPAuthType (const QString &s) const
|
---|
606 | {
|
---|
607 | QStringVector::const_iterator it =
|
---|
608 | qFind (vrdpAuthTypes.begin(), vrdpAuthTypes.end(), s);
|
---|
609 | AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
610 | return KVRDPAuthType (it - vrdpAuthTypes.begin());
|
---|
611 | }
|
---|
612 |
|
---|
613 | KPortMode toPortMode (const QString &s) const
|
---|
614 | {
|
---|
615 | QStringVector::const_iterator it =
|
---|
616 | qFind (portModeTypes.begin(), portModeTypes.end(), s);
|
---|
617 | AssertMsg (it != portModeTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
618 | return KPortMode (it - portModeTypes.begin());
|
---|
619 | }
|
---|
620 |
|
---|
621 | KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
|
---|
622 | {
|
---|
623 | QStringVector::const_iterator it =
|
---|
624 | qFind (usbFilterActionTypes.begin(), usbFilterActionTypes.end(), s);
|
---|
625 | AssertMsg (it != usbFilterActionTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
626 | return KUSBDeviceFilterAction (it - usbFilterActionTypes.begin());
|
---|
627 | }
|
---|
628 |
|
---|
629 | QString toString (KDeviceType t) const
|
---|
630 | {
|
---|
631 | AssertMsg (!deviceTypes.value (t).isNull(), ("No text for %d", t));
|
---|
632 | return deviceTypes.value (t);
|
---|
633 | }
|
---|
634 |
|
---|
635 | KDeviceType toDeviceType (const QString &s) const
|
---|
636 | {
|
---|
637 | QStringVector::const_iterator it =
|
---|
638 | qFind (deviceTypes.begin(), deviceTypes.end(), s);
|
---|
639 | AssertMsg (it != deviceTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
640 | return KDeviceType (it - deviceTypes.begin());
|
---|
641 | }
|
---|
642 |
|
---|
643 | QStringList deviceTypeStrings() const;
|
---|
644 |
|
---|
645 | QString toString (KAudioDriverType t) const
|
---|
646 | {
|
---|
647 | AssertMsg (!audioDriverTypes.value (t).isNull(), ("No text for %d", t));
|
---|
648 | return audioDriverTypes.value (t);
|
---|
649 | }
|
---|
650 |
|
---|
651 | KAudioDriverType toAudioDriverType (const QString &s) const
|
---|
652 | {
|
---|
653 | QStringVector::const_iterator it =
|
---|
654 | qFind (audioDriverTypes.begin(), audioDriverTypes.end(), s);
|
---|
655 | AssertMsg (it != audioDriverTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
656 | return KAudioDriverType (it - audioDriverTypes.begin());
|
---|
657 | }
|
---|
658 |
|
---|
659 | QString toString (KAudioControllerType t) const
|
---|
660 | {
|
---|
661 | AssertMsg (!audioControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
662 | return audioControllerTypes.value (t);
|
---|
663 | }
|
---|
664 |
|
---|
665 | KAudioControllerType toAudioControllerType (const QString &s) const
|
---|
666 | {
|
---|
667 | QStringVector::const_iterator it =
|
---|
668 | qFind (audioControllerTypes.begin(), audioControllerTypes.end(), s);
|
---|
669 | AssertMsg (it != audioControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
670 | return KAudioControllerType (it - audioControllerTypes.begin());
|
---|
671 | }
|
---|
672 |
|
---|
673 | QString toString (KNetworkAdapterType t) const
|
---|
674 | {
|
---|
675 | AssertMsg (!networkAdapterTypes.value (t).isNull(), ("No text for %d", t));
|
---|
676 | return networkAdapterTypes.value (t);
|
---|
677 | }
|
---|
678 |
|
---|
679 | KNetworkAdapterType toNetworkAdapterType (const QString &s) const
|
---|
680 | {
|
---|
681 | QStringVector::const_iterator it =
|
---|
682 | qFind (networkAdapterTypes.begin(), networkAdapterTypes.end(), s);
|
---|
683 | AssertMsg (it != networkAdapterTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
684 | return KNetworkAdapterType (it - networkAdapterTypes.begin());
|
---|
685 | }
|
---|
686 |
|
---|
687 | QString toString (KNetworkAttachmentType t) const
|
---|
688 | {
|
---|
689 | AssertMsg (!networkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
|
---|
690 | return networkAttachmentTypes.value (t);
|
---|
691 | }
|
---|
692 |
|
---|
693 | KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
|
---|
694 | {
|
---|
695 | QStringVector::const_iterator it =
|
---|
696 | qFind (networkAttachmentTypes.begin(), networkAttachmentTypes.end(), s);
|
---|
697 | AssertMsg (it != networkAttachmentTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
|
---|
698 | return KNetworkAttachmentType (it - networkAttachmentTypes.begin());
|
---|
699 | }
|
---|
700 |
|
---|
701 | QString toString (KUSBDeviceState aState) const
|
---|
702 | {
|
---|
703 | AssertMsg (!USBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
|
---|
704 | return USBDeviceStates.value (aState);
|
---|
705 | }
|
---|
706 |
|
---|
707 | QStringList COMPortNames() const;
|
---|
708 | QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
709 | bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
710 |
|
---|
711 | QStringList LPTPortNames() const;
|
---|
712 | QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
713 | bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
714 |
|
---|
715 | QPixmap snapshotIcon (bool online) const
|
---|
716 | {
|
---|
717 | return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
|
---|
718 | }
|
---|
719 |
|
---|
720 | QPixmap warningIcon() const { return mWarningIcon; }
|
---|
721 | QPixmap errorIcon() const { return mErrorIcon; }
|
---|
722 |
|
---|
723 | /* details generators */
|
---|
724 |
|
---|
725 | QString details (const CHardDisk2 &aHD, bool aPredictDiff);
|
---|
726 |
|
---|
727 | QString details (const CUSBDevice &aDevice) const;
|
---|
728 | QString toolTip (const CUSBDevice &aDevice) const;
|
---|
729 | QString toolTip (const CUSBDeviceFilter &aFilter) const;
|
---|
730 |
|
---|
731 | QString detailsReport (const CMachine &aMachine, bool aIsNewVM,
|
---|
732 | bool aWithLinks);
|
---|
733 |
|
---|
734 | QString platformInfo();
|
---|
735 |
|
---|
736 | /* VirtualBox helpers */
|
---|
737 |
|
---|
738 | #if defined(Q_WS_X11) && !defined(VBOX_OSE)
|
---|
739 | double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
|
---|
740 | bool showVirtualBoxLicense();
|
---|
741 | #endif
|
---|
742 |
|
---|
743 | void checkForAutoConvertedSettings();
|
---|
744 |
|
---|
745 | CSession openSession (const QUuid &aId, bool aExisting = false);
|
---|
746 |
|
---|
747 | /** Shortcut to openSession (aId, true). */
|
---|
748 | CSession openExistingSession (const QUuid &aId) { return openSession (aId, true); }
|
---|
749 |
|
---|
750 | bool startMachine (const QUuid &id);
|
---|
751 |
|
---|
752 | void startEnumeratingMedia();
|
---|
753 |
|
---|
754 | /**
|
---|
755 | * Returns a list of all currently registered media. This list is used to
|
---|
756 | * globally track the accessiblity state of all media on a dedicated thread.
|
---|
757 | *
|
---|
758 | * Note that the media list is initially empty (i.e. before the enumeration
|
---|
759 | * process is started for the first time using #startEnumeratingMedia()).
|
---|
760 | * See #startEnumeratingMedia() for more information about how meida are
|
---|
761 | * sorted in the returned list.
|
---|
762 | */
|
---|
763 | const VBoxMediaList ¤tMediaList() const { return mMediaList; }
|
---|
764 |
|
---|
765 | /** Returns true if the media enumeration is in progress. */
|
---|
766 | bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }
|
---|
767 |
|
---|
768 | void addMedium (const VBoxMedium &);
|
---|
769 | void updateMedium (const VBoxMedium &);
|
---|
770 | void removeMedium (VBoxDefs::MediaType, const QUuid &);
|
---|
771 |
|
---|
772 | bool findMedium (const CMedium &, VBoxMedium &) const;
|
---|
773 |
|
---|
774 | /** Compact version of #findMediumTo(). Asserts if not found. */
|
---|
775 | VBoxMedium getMedium (const CMedium &aObj) const
|
---|
776 | {
|
---|
777 | VBoxMedium medium;
|
---|
778 | if (!findMedium (aObj, medium))
|
---|
779 | AssertFailed();
|
---|
780 | return medium;
|
---|
781 | }
|
---|
782 |
|
---|
783 | /* various helpers */
|
---|
784 |
|
---|
785 | QString languageName() const;
|
---|
786 | QString languageCountry() const;
|
---|
787 | QString languageNameEnglish() const;
|
---|
788 | QString languageCountryEnglish() const;
|
---|
789 | QString languageTranslators() const;
|
---|
790 |
|
---|
791 | void retranslateUi();
|
---|
792 |
|
---|
793 | /** @internal made public for internal purposes */
|
---|
794 | void cleanup();
|
---|
795 |
|
---|
796 | /* public static stuff */
|
---|
797 |
|
---|
798 | static bool isDOSType (const QString &aOSTypeId);
|
---|
799 |
|
---|
800 | static void adoptLabelPixmap (QLabel *);
|
---|
801 |
|
---|
802 | static QString languageId();
|
---|
803 | static void loadLanguage (const QString &aLangId = QString::null);
|
---|
804 | QString helpFile() const;
|
---|
805 |
|
---|
806 | static QIcon iconSet (const char *aNormal,
|
---|
807 | const char *aDisabled = NULL,
|
---|
808 | const char *aActive = NULL);
|
---|
809 | static QIcon iconSetFull (const QSize &aNormalSize, const QSize &aSmallSize,
|
---|
810 | const char *aNormal, const char *aSmallNormal,
|
---|
811 | const char *aDisabled = NULL,
|
---|
812 | const char *aSmallDisabled = NULL,
|
---|
813 | const char *aActive = NULL,
|
---|
814 | const char *aSmallActive = NULL);
|
---|
815 |
|
---|
816 | static QIcon standardIcon (QStyle::StandardPixmap aStandard, QWidget *aWidget = NULL);
|
---|
817 |
|
---|
818 | static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
|
---|
819 |
|
---|
820 | static QRect normalizeGeometry (const QRect &aRect, const QRect &aBoundRect,
|
---|
821 | bool aCanResize = true);
|
---|
822 |
|
---|
823 | static void centerWidget (QWidget *aWidget, QWidget *aRelative,
|
---|
824 | bool aCanResize = true);
|
---|
825 |
|
---|
826 | static QChar decimalSep();
|
---|
827 | static QString sizeRegexp();
|
---|
828 |
|
---|
829 | static quint64 parseSize (const QString &);
|
---|
830 | static QString formatSize (quint64, int aMode = 0);
|
---|
831 |
|
---|
832 | static QString locationForHTML (const QString &aFileName);
|
---|
833 |
|
---|
834 | static QString highlight (const QString &aStr, bool aToolTip = false);
|
---|
835 |
|
---|
836 | static QString systemLanguageId();
|
---|
837 |
|
---|
838 | static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
|
---|
839 | const QString &aCaption = QString::null,
|
---|
840 | bool aDirOnly = TRUE,
|
---|
841 | bool resolveSymlinks = TRUE);
|
---|
842 |
|
---|
843 | static QString getOpenFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
|
---|
844 | const QString &aCaption, QString *aSelectedFilter = NULL,
|
---|
845 | bool aResolveSymLinks = true);
|
---|
846 |
|
---|
847 | static QStringList getOpenFileNames (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
|
---|
848 | const QString &aCaption, QString *aSelectedFilter = NULL,
|
---|
849 | bool aResolveSymLinks = true,
|
---|
850 | bool aSingleFile = false);
|
---|
851 |
|
---|
852 | static QString getFirstExistingDir (const QString &);
|
---|
853 |
|
---|
854 | static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
|
---|
855 |
|
---|
856 | static QString removeAccelMark (const QString &aText);
|
---|
857 |
|
---|
858 | static QString insertKeyToActionText (const QString &aText, const QString &aKey);
|
---|
859 | static QString extractKeyFromActionText (const QString &aText);
|
---|
860 |
|
---|
861 | static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
|
---|
862 |
|
---|
863 | static QWidget *findWidget (QWidget *aParent, const char *aName,
|
---|
864 | const char *aClassName = NULL,
|
---|
865 | bool aRecursive = false);
|
---|
866 |
|
---|
867 | static QList< QPair<QString, QString> > HDDBackends();
|
---|
868 |
|
---|
869 | /* Qt 4.2.0 support function */
|
---|
870 | static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
|
---|
871 | {
|
---|
872 | #if QT_VERSION < 0x040300
|
---|
873 | /* Deprecated since > 4.2 */
|
---|
874 | aLayout->setMargin (aMargin);
|
---|
875 | #else
|
---|
876 | /* New since > 4.2 */
|
---|
877 | aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
|
---|
878 | #endif
|
---|
879 | }
|
---|
880 |
|
---|
881 | signals:
|
---|
882 |
|
---|
883 | /**
|
---|
884 | * Emitted at the beginning of the enumeration process started by
|
---|
885 | * #startEnumeratingMedia().
|
---|
886 | */
|
---|
887 | void mediumEnumStarted();
|
---|
888 |
|
---|
889 | /**
|
---|
890 | * Emitted when a new medium item from the list has updated its
|
---|
891 | * accessibility state.
|
---|
892 | */
|
---|
893 | void mediumEnumerated (const VBoxMedium &aMedum);
|
---|
894 |
|
---|
895 | /**
|
---|
896 | * Emitted at the end of the enumeration process started by
|
---|
897 | * #startEnumeratingMedia(). The @a aList argument is passed for
|
---|
898 | * convenience, it is exactly the same as returned by #currentMediaList().
|
---|
899 | */
|
---|
900 | void mediumEnumFinished (const VBoxMediaList &aList);
|
---|
901 |
|
---|
902 | /** Emitted when a new media is added using #addMedia(). */
|
---|
903 | void mediumAdded (const VBoxMedium &);
|
---|
904 |
|
---|
905 | /** Emitted when the media is updated using #updateMedia(). */
|
---|
906 | void mediumUpdated (const VBoxMedium &);
|
---|
907 |
|
---|
908 | /** Emitted when the media is removed using #removeMedia(). */
|
---|
909 | void mediumRemoved (VBoxDefs::MediaType, const QUuid &);
|
---|
910 |
|
---|
911 | /* signals emitted when the VirtualBox callback is called by the server
|
---|
912 | * (not that currently these signals are emitted only when the application
|
---|
913 | * is the in the VM selector mode) */
|
---|
914 |
|
---|
915 | void machineStateChanged (const VBoxMachineStateChangeEvent &e);
|
---|
916 | void machineDataChanged (const VBoxMachineDataChangeEvent &e);
|
---|
917 | void machineRegistered (const VBoxMachineRegisteredEvent &e);
|
---|
918 | void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
|
---|
919 | void snapshotChanged (const VBoxSnapshotEvent &e);
|
---|
920 |
|
---|
921 | void canShowRegDlg (bool aCanShow);
|
---|
922 | void canShowUpdDlg (bool aCanShow);
|
---|
923 |
|
---|
924 | public slots:
|
---|
925 |
|
---|
926 | bool openURL (const QString &aURL);
|
---|
927 |
|
---|
928 | void showRegistrationDialog (bool aForce = true);
|
---|
929 | void showUpdateDialog (bool aForce = true);
|
---|
930 |
|
---|
931 | protected:
|
---|
932 |
|
---|
933 | bool event (QEvent *e);
|
---|
934 | bool eventFilter (QObject *, QEvent *);
|
---|
935 |
|
---|
936 | private:
|
---|
937 |
|
---|
938 | VBoxGlobal();
|
---|
939 | ~VBoxGlobal();
|
---|
940 |
|
---|
941 | void init();
|
---|
942 |
|
---|
943 | bool mValid;
|
---|
944 |
|
---|
945 | CVirtualBox mVBox;
|
---|
946 |
|
---|
947 | VBoxGlobalSettings gset;
|
---|
948 |
|
---|
949 | VBoxSelectorWnd *mSelectorWnd;
|
---|
950 | VBoxConsoleWnd *mConsoleWnd;
|
---|
951 | QWidget* mMainWindow;
|
---|
952 |
|
---|
953 | #ifdef VBOX_WITH_REGISTRATION
|
---|
954 | VBoxRegistrationDlg *mRegDlg;
|
---|
955 | #endif
|
---|
956 | VBoxUpdateDlg *mUpdDlg;
|
---|
957 |
|
---|
958 | QUuid vmUuid;
|
---|
959 |
|
---|
960 | QThread *mMediaEnumThread;
|
---|
961 | VBoxMediaList mMediaList;
|
---|
962 | VBoxMediaList::iterator mCurrentMediumIterator;
|
---|
963 |
|
---|
964 | VBoxDefs::RenderMode vm_render_mode;
|
---|
965 | const char * vm_render_mode_str;
|
---|
966 |
|
---|
967 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
968 | /** Whether the debugger should be accessible or not.
|
---|
969 | * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.
|
---|
970 | * VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
971 | bool mDbgEnabled;
|
---|
972 | /** Whether to show the debugger automatically with the console.
|
---|
973 | * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
974 | bool mDbgAutoShow;
|
---|
975 | /** VBoxDbg module handle. */
|
---|
976 | RTLDRMOD mhVBoxDbg;
|
---|
977 | #endif
|
---|
978 |
|
---|
979 | #if defined (Q_WS_WIN32)
|
---|
980 | DWORD dwHTMLHelpCookie;
|
---|
981 | #endif
|
---|
982 |
|
---|
983 | CVirtualBoxCallback callback;
|
---|
984 |
|
---|
985 | typedef QVector <QString> QStringVector;
|
---|
986 |
|
---|
987 | QString verString;
|
---|
988 |
|
---|
989 | QVector <CGuestOSType> vm_os_types;
|
---|
990 | QHash <QString, QPixmap *> vm_os_type_icons;
|
---|
991 | QVector <QColor *> vm_state_color;
|
---|
992 |
|
---|
993 | QHash <long int, QPixmap *> mStateIcons;
|
---|
994 | QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
|
---|
995 |
|
---|
996 | QStringVector machineStates;
|
---|
997 | QStringVector sessionStates;
|
---|
998 | QStringVector deviceTypes;
|
---|
999 |
|
---|
1000 | QStringVector storageBuses;
|
---|
1001 | QStringVector storageBusDevices;
|
---|
1002 | QStringVector storageBusChannels;
|
---|
1003 |
|
---|
1004 | QStringVector diskTypes;
|
---|
1005 | QString diskTypes_Differencing;
|
---|
1006 |
|
---|
1007 | QStringVector vrdpAuthTypes;
|
---|
1008 | QStringVector portModeTypes;
|
---|
1009 | QStringVector usbFilterActionTypes;
|
---|
1010 | QStringVector audioDriverTypes;
|
---|
1011 | QStringVector audioControllerTypes;
|
---|
1012 | QStringVector networkAdapterTypes;
|
---|
1013 | QStringVector networkAttachmentTypes;
|
---|
1014 | QStringVector clipboardTypes;
|
---|
1015 | QStringVector ideControllerTypes;
|
---|
1016 | QStringVector USBDeviceStates;
|
---|
1017 |
|
---|
1018 | QString mUserDefinedPortName;
|
---|
1019 |
|
---|
1020 | QPixmap mWarningIcon, mErrorIcon;
|
---|
1021 |
|
---|
1022 | mutable bool detailReportTemplatesReady;
|
---|
1023 |
|
---|
1024 | friend VBoxGlobal &vboxGlobal();
|
---|
1025 | friend class VBoxCallback;
|
---|
1026 | };
|
---|
1027 |
|
---|
1028 | inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
|
---|
1029 |
|
---|
1030 | // Helper classes
|
---|
1031 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1032 |
|
---|
1033 | /**
|
---|
1034 | * Generic asyncronous event.
|
---|
1035 | *
|
---|
1036 | * This abstract class is intended to provide a conveinent way to execute
|
---|
1037 | * code on the main GUI thread asynchronously to the calling party. This is
|
---|
1038 | * done by putting necessary actions to the #handle() function in a subclass
|
---|
1039 | * and then posting an instance of the subclass using #post(). The instance
|
---|
1040 | * must be allocated on the heap using the <tt>new</tt> operation and will be
|
---|
1041 | * automatically deleted after processing. Note that if you don't call #post()
|
---|
1042 | * on the created instance, you have to delete it yourself.
|
---|
1043 | */
|
---|
1044 | class VBoxAsyncEvent : public QEvent
|
---|
1045 | {
|
---|
1046 | public:
|
---|
1047 |
|
---|
1048 | VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {}
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * Worker function. Gets executed on the GUI thread when the posted event
|
---|
1052 | * is processed by the main event loop.
|
---|
1053 | */
|
---|
1054 | virtual void handle() = 0;
|
---|
1055 |
|
---|
1056 | /**
|
---|
1057 | * Posts this event to the main event loop.
|
---|
1058 | * The caller loses ownership of this object after this method returns
|
---|
1059 | * and must not delete the object.
|
---|
1060 | */
|
---|
1061 | void post()
|
---|
1062 | {
|
---|
1063 | QApplication::postEvent (&vboxGlobal(), this);
|
---|
1064 | }
|
---|
1065 | };
|
---|
1066 |
|
---|
1067 | /**
|
---|
1068 | * USB Popup Menu class.
|
---|
1069 | * This class provides the list of USB devices attached to the host.
|
---|
1070 | */
|
---|
1071 | class VBoxUSBMenu : public QMenu
|
---|
1072 | {
|
---|
1073 | Q_OBJECT
|
---|
1074 |
|
---|
1075 | public:
|
---|
1076 |
|
---|
1077 | VBoxUSBMenu (QWidget *);
|
---|
1078 |
|
---|
1079 | const CUSBDevice& getUSB (QAction *aAction);
|
---|
1080 |
|
---|
1081 | void setConsole (const CConsole &);
|
---|
1082 |
|
---|
1083 | private slots:
|
---|
1084 |
|
---|
1085 | void processAboutToShow();
|
---|
1086 |
|
---|
1087 | private:
|
---|
1088 | bool event(QEvent *aEvent);
|
---|
1089 |
|
---|
1090 | QMap <QAction *, CUSBDevice> mUSBDevicesMap;
|
---|
1091 | CConsole mConsole;
|
---|
1092 | };
|
---|
1093 |
|
---|
1094 | /**
|
---|
1095 | * Enable/Disable Menu class.
|
---|
1096 | * This class provides enable/disable menu items.
|
---|
1097 | */
|
---|
1098 | class VBoxSwitchMenu : public QMenu
|
---|
1099 | {
|
---|
1100 | Q_OBJECT
|
---|
1101 |
|
---|
1102 | public:
|
---|
1103 |
|
---|
1104 | VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
|
---|
1105 |
|
---|
1106 | void setToolTip (const QString &);
|
---|
1107 |
|
---|
1108 | private slots:
|
---|
1109 |
|
---|
1110 | void processAboutToShow();
|
---|
1111 |
|
---|
1112 | private:
|
---|
1113 |
|
---|
1114 | QAction *mAction;
|
---|
1115 | bool mInverted;
|
---|
1116 | };
|
---|
1117 |
|
---|
1118 | #endif /* __VBoxGlobal_h__ */
|
---|