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 CHardDisk &hardDisk() const { return mHardDisk; }
|
---|
149 | const CDVDImage &dvdImage() const { return mDVDImage; }
|
---|
150 | const CFloppyImage &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 | CHardDisk mHardDisk;
|
---|
249 | CDVDImage mDVDImage;
|
---|
250 | CFloppyImage 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 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
393 | class VBoxMainWindowCountChangeEvent : public QEvent
|
---|
394 | {
|
---|
395 | public:
|
---|
396 | VBoxMainWindowCountChangeEvent (int aCount)
|
---|
397 | : QEvent ((QEvent::Type) VBoxDefs::MainWindowCountChangeEventType)
|
---|
398 | , mCount (aCount)
|
---|
399 | {}
|
---|
400 |
|
---|
401 | const int mCount;
|
---|
402 | };
|
---|
403 |
|
---|
404 | class VBoxCanShowTrayIconEvent : public QEvent
|
---|
405 | {
|
---|
406 | public:
|
---|
407 | VBoxCanShowTrayIconEvent (bool aCanShow)
|
---|
408 | : QEvent ((QEvent::Type) VBoxDefs::CanShowTrayIconEventType)
|
---|
409 | , mCanShow (aCanShow)
|
---|
410 | {}
|
---|
411 |
|
---|
412 | const bool mCanShow;
|
---|
413 | };
|
---|
414 |
|
---|
415 | class VBoxShowTrayIconEvent : public QEvent
|
---|
416 | {
|
---|
417 | public:
|
---|
418 | VBoxShowTrayIconEvent (bool aShow)
|
---|
419 | : QEvent ((QEvent::Type) VBoxDefs::ShowTrayIconEventType)
|
---|
420 | , mShow (aShow)
|
---|
421 | {}
|
---|
422 |
|
---|
423 | const bool mShow;
|
---|
424 | };
|
---|
425 |
|
---|
426 | class VBoxChangeTrayIconEvent : public QEvent
|
---|
427 | {
|
---|
428 | public:
|
---|
429 | VBoxChangeTrayIconEvent (bool aChanged)
|
---|
430 | : QEvent ((QEvent::Type) VBoxDefs::TrayIconChangeEventType)
|
---|
431 | , mChanged (aChanged)
|
---|
432 | {}
|
---|
433 |
|
---|
434 | const bool mChanged;
|
---|
435 | };
|
---|
436 | #endif
|
---|
437 |
|
---|
438 | class VBoxChangeDockIconUpdateEvent : public QEvent
|
---|
439 | {
|
---|
440 | public:
|
---|
441 | VBoxChangeDockIconUpdateEvent (bool aChanged)
|
---|
442 | : QEvent ((QEvent::Type) VBoxDefs::ChangeDockIconUpdateEventType)
|
---|
443 | , mChanged (aChanged)
|
---|
444 | {}
|
---|
445 |
|
---|
446 | const bool mChanged;
|
---|
447 | };
|
---|
448 |
|
---|
449 | class Process : public QProcess
|
---|
450 | {
|
---|
451 | Q_OBJECT;
|
---|
452 |
|
---|
453 | public:
|
---|
454 |
|
---|
455 | static QByteArray singleShot (const QString &aProcessName,
|
---|
456 | int aTimeout = 5000
|
---|
457 | /* wait for data maximum 5 seconds */)
|
---|
458 | {
|
---|
459 | /* Why is it really needed is because of Qt4.3 bug with QProcess.
|
---|
460 | * This bug is about QProcess sometimes (~70%) do not receive
|
---|
461 | * notification about process was finished, so this makes
|
---|
462 | * 'bool QProcess::waitForFinished (int)' block the GUI thread and
|
---|
463 | * never dismissed with 'true' result even if process was really
|
---|
464 | * started&finished. So we just waiting for some information
|
---|
465 | * on process output and destroy the process with force. Due to
|
---|
466 | * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
|
---|
467 | * we have to change process state to QProcess::NotRunning. */
|
---|
468 |
|
---|
469 | QByteArray result;
|
---|
470 | Process process;
|
---|
471 | process.start (aProcessName);
|
---|
472 | bool firstShotReady = process.waitForReadyRead (aTimeout);
|
---|
473 | if (firstShotReady)
|
---|
474 | result = process.readAllStandardOutput();
|
---|
475 | process.setProcessState (QProcess::NotRunning);
|
---|
476 | return result;
|
---|
477 | }
|
---|
478 |
|
---|
479 | protected:
|
---|
480 |
|
---|
481 | Process (QWidget *aParent = 0) : QProcess (aParent) {}
|
---|
482 | };
|
---|
483 |
|
---|
484 | // VBoxGlobal class
|
---|
485 | ////////////////////////////////////////////////////////////////////////////////
|
---|
486 |
|
---|
487 | class VBoxSelectorWnd;
|
---|
488 | class VBoxConsoleWnd;
|
---|
489 | class VBoxRegistrationDlg;
|
---|
490 | class VBoxUpdateDlg;
|
---|
491 |
|
---|
492 | class VBoxGlobal : public QObject
|
---|
493 | {
|
---|
494 | Q_OBJECT
|
---|
495 |
|
---|
496 | public:
|
---|
497 |
|
---|
498 | typedef QHash <ulong, QString> QULongStringHash;
|
---|
499 | typedef QHash <long, QString> QLongStringHash;
|
---|
500 |
|
---|
501 | static VBoxGlobal &instance();
|
---|
502 |
|
---|
503 | bool isValid() { return mValid; }
|
---|
504 |
|
---|
505 | QString versionString() { return mVerString; }
|
---|
506 |
|
---|
507 | CVirtualBox virtualBox() const { return mVBox; }
|
---|
508 |
|
---|
509 | const VBoxGlobalSettings &settings() const { return gset; }
|
---|
510 | bool setSettings (const VBoxGlobalSettings &gs);
|
---|
511 |
|
---|
512 | VBoxSelectorWnd &selectorWnd();
|
---|
513 | VBoxConsoleWnd &consoleWnd();
|
---|
514 |
|
---|
515 | /* main window handle storage */
|
---|
516 | void setMainWindow (QWidget *aMainWindow) { mMainWindow = aMainWindow; }
|
---|
517 | QWidget *mainWindow() const { return mMainWindow; }
|
---|
518 |
|
---|
519 | bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
|
---|
520 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
521 | bool isTrayMenu() const;
|
---|
522 | void setTrayMenu(bool aIsTrayMenu);
|
---|
523 | void trayIconShowSelector();
|
---|
524 | bool trayIconInstall();
|
---|
525 | #endif
|
---|
526 | QUuid managedVMUuid() const { return vmUuid; }
|
---|
527 |
|
---|
528 | VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
|
---|
529 | const char *vmRenderModeStr() const { return vm_render_mode_str; }
|
---|
530 |
|
---|
531 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
532 | bool isDebuggerEnabled() const { return mDbgEnabled; }
|
---|
533 | bool isDebuggerAutoShowEnabled() const { return mDbgAutoShow; }
|
---|
534 | RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }
|
---|
535 | #else
|
---|
536 | bool isDebuggerAutoShowEnabled() const { return false; }
|
---|
537 | #endif
|
---|
538 |
|
---|
539 | /* VBox enum to/from string/icon/color convertors */
|
---|
540 |
|
---|
541 | QList <CGuestOSType> vmGuestOSFamilyList() const;
|
---|
542 | QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
|
---|
543 | QPixmap vmGuestOSTypeIcon (const QString &aTypeId) const;
|
---|
544 | CGuestOSType vmGuestOSType (const QString &aTypeId,
|
---|
545 | const QString &aFamilyId = QString::null) const;
|
---|
546 | QString vmGuestOSTypeDescription (const QString &aTypeId) const;
|
---|
547 |
|
---|
548 | QPixmap toIcon (KMachineState s) const
|
---|
549 | {
|
---|
550 | QPixmap *pm = mVMStateIcons.value (s);
|
---|
551 | AssertMsg (pm, ("Icon for VM state %d must be defined", s));
|
---|
552 | return pm ? *pm : QPixmap();
|
---|
553 | }
|
---|
554 |
|
---|
555 | const QColor &toColor (KMachineState s) const
|
---|
556 | {
|
---|
557 | static const QColor none;
|
---|
558 | AssertMsg (mVMStateColors.value (s), ("No color for %d", s));
|
---|
559 | return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;
|
---|
560 | }
|
---|
561 |
|
---|
562 | QString toString (KMachineState s) const
|
---|
563 | {
|
---|
564 | AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));
|
---|
565 | return mMachineStates.value (s);
|
---|
566 | }
|
---|
567 |
|
---|
568 | QString toString (KSessionState s) const
|
---|
569 | {
|
---|
570 | AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));
|
---|
571 | return mSessionStates.value (s);
|
---|
572 | }
|
---|
573 |
|
---|
574 | /**
|
---|
575 | * Returns a string representation of the given KStorageBus enum value.
|
---|
576 | * Complementary to #toStorageBusType (const QString &) const.
|
---|
577 | */
|
---|
578 | QString toString (KStorageBus aBus) const
|
---|
579 | {
|
---|
580 | AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));
|
---|
581 | return mStorageBuses [aBus];
|
---|
582 | }
|
---|
583 |
|
---|
584 | /**
|
---|
585 | * Returns a KStorageBus enum value corresponding to the given string
|
---|
586 | * representation. Complementary to #toString (KStorageBus) const.
|
---|
587 | */
|
---|
588 | KStorageBus toStorageBusType (const QString &aBus) const
|
---|
589 | {
|
---|
590 | QULongStringHash::const_iterator it =
|
---|
591 | qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);
|
---|
592 | AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",
|
---|
593 | aBus.toLatin1().constData()));
|
---|
594 | return KStorageBus (it.key());
|
---|
595 | }
|
---|
596 |
|
---|
597 | QString toString (KStorageBus aBus, LONG aChannel) const;
|
---|
598 | LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;
|
---|
599 |
|
---|
600 | QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
|
---|
601 | LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
|
---|
602 |
|
---|
603 | QString toFullString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
|
---|
604 |
|
---|
605 | QString toString (KHardDiskType t) const
|
---|
606 | {
|
---|
607 | AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));
|
---|
608 | return mDiskTypes.value (t);
|
---|
609 | }
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * Similar to toString (KHardDiskType), but returns 'Differencing' for
|
---|
613 | * normal hard disks that have a parent.
|
---|
614 | */
|
---|
615 | QString hardDiskTypeString (const CHardDisk &aHD) const
|
---|
616 | {
|
---|
617 | if (!aHD.GetParent().isNull())
|
---|
618 | {
|
---|
619 | Assert (aHD.GetType() == KHardDiskType_Normal);
|
---|
620 | return mDiskTypes_Differencing;
|
---|
621 | }
|
---|
622 | return toString (aHD.GetType());
|
---|
623 | }
|
---|
624 |
|
---|
625 | QString toString (KVRDPAuthType t) const
|
---|
626 | {
|
---|
627 | AssertMsg (!mVRDPAuthTypes.value (t).isNull(), ("No text for %d", t));
|
---|
628 | return mVRDPAuthTypes.value (t);
|
---|
629 | }
|
---|
630 |
|
---|
631 | QString toString (KPortMode t) const
|
---|
632 | {
|
---|
633 | AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));
|
---|
634 | return mPortModeTypes.value (t);
|
---|
635 | }
|
---|
636 |
|
---|
637 | QString toString (KUSBDeviceFilterAction t) const
|
---|
638 | {
|
---|
639 | AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));
|
---|
640 | return mUSBFilterActionTypes.value (t);
|
---|
641 | }
|
---|
642 |
|
---|
643 | QString toString (KClipboardMode t) const
|
---|
644 | {
|
---|
645 | AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));
|
---|
646 | return mClipboardTypes.value (t);
|
---|
647 | }
|
---|
648 |
|
---|
649 | KClipboardMode toClipboardModeType (const QString &s) const
|
---|
650 | {
|
---|
651 | QULongStringHash::const_iterator it =
|
---|
652 | qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);
|
---|
653 | AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",
|
---|
654 | s.toLatin1().constData()));
|
---|
655 | return KClipboardMode (it.key());
|
---|
656 | }
|
---|
657 |
|
---|
658 | QString toString (KIDEControllerType t) const
|
---|
659 | {
|
---|
660 | AssertMsg (!mIDEControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
661 | return mIDEControllerTypes.value (t);
|
---|
662 | }
|
---|
663 |
|
---|
664 | KIDEControllerType toIDEControllerType (const QString &s) const
|
---|
665 | {
|
---|
666 | QULongStringHash::const_iterator it =
|
---|
667 | qFind (mIDEControllerTypes.begin(), mIDEControllerTypes.end(), s);
|
---|
668 | AssertMsg (it != mIDEControllerTypes.end(), ("No value for {%s}",
|
---|
669 | s.toLatin1().constData()));
|
---|
670 | return KIDEControllerType (it.key());
|
---|
671 | }
|
---|
672 |
|
---|
673 | KVRDPAuthType toVRDPAuthType (const QString &s) const
|
---|
674 | {
|
---|
675 | QULongStringHash::const_iterator it =
|
---|
676 | qFind (mVRDPAuthTypes.begin(), mVRDPAuthTypes.end(), s);
|
---|
677 | AssertMsg (it != mVRDPAuthTypes.end(), ("No value for {%s}",
|
---|
678 | s.toLatin1().constData()));
|
---|
679 | return KVRDPAuthType (it.key());
|
---|
680 | }
|
---|
681 |
|
---|
682 | KPortMode toPortMode (const QString &s) const
|
---|
683 | {
|
---|
684 | QULongStringHash::const_iterator it =
|
---|
685 | qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);
|
---|
686 | AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",
|
---|
687 | s.toLatin1().constData()));
|
---|
688 | return KPortMode (it.key());
|
---|
689 | }
|
---|
690 |
|
---|
691 | KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
|
---|
692 | {
|
---|
693 | QULongStringHash::const_iterator it =
|
---|
694 | qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);
|
---|
695 | AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",
|
---|
696 | s.toLatin1().constData()));
|
---|
697 | return KUSBDeviceFilterAction (it.key());
|
---|
698 | }
|
---|
699 |
|
---|
700 | QString toString (KDeviceType t) const
|
---|
701 | {
|
---|
702 | AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));
|
---|
703 | return mDeviceTypes.value (t);
|
---|
704 | }
|
---|
705 |
|
---|
706 | KDeviceType toDeviceType (const QString &s) const
|
---|
707 | {
|
---|
708 | QULongStringHash::const_iterator it =
|
---|
709 | qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);
|
---|
710 | AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",
|
---|
711 | s.toLatin1().constData()));
|
---|
712 | return KDeviceType (it.key());
|
---|
713 | }
|
---|
714 |
|
---|
715 | QStringList deviceTypeStrings() const;
|
---|
716 |
|
---|
717 | QString toString (KAudioDriverType t) const
|
---|
718 | {
|
---|
719 | AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));
|
---|
720 | return mAudioDriverTypes.value (t);
|
---|
721 | }
|
---|
722 |
|
---|
723 | KAudioDriverType toAudioDriverType (const QString &s) const
|
---|
724 | {
|
---|
725 | QULongStringHash::const_iterator it =
|
---|
726 | qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);
|
---|
727 | AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",
|
---|
728 | s.toLatin1().constData()));
|
---|
729 | return KAudioDriverType (it.key());
|
---|
730 | }
|
---|
731 |
|
---|
732 | QString toString (KAudioControllerType t) const
|
---|
733 | {
|
---|
734 | AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));
|
---|
735 | return mAudioControllerTypes.value (t);
|
---|
736 | }
|
---|
737 |
|
---|
738 | KAudioControllerType toAudioControllerType (const QString &s) const
|
---|
739 | {
|
---|
740 | QULongStringHash::const_iterator it =
|
---|
741 | qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);
|
---|
742 | AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",
|
---|
743 | s.toLatin1().constData()));
|
---|
744 | return KAudioControllerType (it.key());
|
---|
745 | }
|
---|
746 |
|
---|
747 | QString toString (KNetworkAdapterType t) const
|
---|
748 | {
|
---|
749 | AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));
|
---|
750 | return mNetworkAdapterTypes.value (t);
|
---|
751 | }
|
---|
752 |
|
---|
753 | KNetworkAdapterType toNetworkAdapterType (const QString &s) const
|
---|
754 | {
|
---|
755 | QULongStringHash::const_iterator it =
|
---|
756 | qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);
|
---|
757 | AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",
|
---|
758 | s.toLatin1().constData()));
|
---|
759 | return KNetworkAdapterType (it.key());
|
---|
760 | }
|
---|
761 |
|
---|
762 | QString toString (KNetworkAttachmentType t) const
|
---|
763 | {
|
---|
764 | AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
|
---|
765 | return mNetworkAttachmentTypes.value (t);
|
---|
766 | }
|
---|
767 |
|
---|
768 | KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
|
---|
769 | {
|
---|
770 | QULongStringHash::const_iterator it =
|
---|
771 | qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);
|
---|
772 | AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",
|
---|
773 | s.toLatin1().constData()));
|
---|
774 | return KNetworkAttachmentType (it.key());
|
---|
775 | }
|
---|
776 |
|
---|
777 | QString toString (KUSBDeviceState aState) const
|
---|
778 | {
|
---|
779 | AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
|
---|
780 | return mUSBDeviceStates.value (aState);
|
---|
781 | }
|
---|
782 |
|
---|
783 | QStringList COMPortNames() const;
|
---|
784 | QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
785 | bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
786 |
|
---|
787 | QStringList LPTPortNames() const;
|
---|
788 | QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
789 | bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
790 |
|
---|
791 | QPixmap snapshotIcon (bool online) const
|
---|
792 | {
|
---|
793 | return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
|
---|
794 | }
|
---|
795 |
|
---|
796 | QPixmap warningIcon() const { return mWarningIcon; }
|
---|
797 | QPixmap errorIcon() const { return mErrorIcon; }
|
---|
798 |
|
---|
799 | /* details generators */
|
---|
800 |
|
---|
801 | QString details (const CHardDisk &aHD, bool aPredictDiff);
|
---|
802 |
|
---|
803 | QString details (const CUSBDevice &aDevice) const;
|
---|
804 | QString toolTip (const CUSBDevice &aDevice) const;
|
---|
805 | QString toolTip (const CUSBDeviceFilter &aFilter) const;
|
---|
806 |
|
---|
807 | QString detailsReport (const CMachine &aMachine, bool aIsNewVM,
|
---|
808 | bool aWithLinks);
|
---|
809 |
|
---|
810 | QString platformInfo();
|
---|
811 |
|
---|
812 | /* VirtualBox helpers */
|
---|
813 |
|
---|
814 | #if defined(Q_WS_X11) && !defined(VBOX_OSE)
|
---|
815 | double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
|
---|
816 | bool showVirtualBoxLicense();
|
---|
817 | #endif
|
---|
818 |
|
---|
819 | bool checkForAutoConvertedSettings (bool aAfterRefresh = false);
|
---|
820 |
|
---|
821 | void checkForAutoConvertedSettingsAfterRefresh()
|
---|
822 | { checkForAutoConvertedSettings (true); }
|
---|
823 |
|
---|
824 | CSession openSession (const QUuid &aId, bool aExisting = false);
|
---|
825 |
|
---|
826 | /** Shortcut to openSession (aId, true). */
|
---|
827 | CSession openExistingSession (const QUuid &aId) { return openSession (aId, true); }
|
---|
828 |
|
---|
829 | bool startMachine (const QUuid &id);
|
---|
830 |
|
---|
831 | void startEnumeratingMedia();
|
---|
832 |
|
---|
833 | /**
|
---|
834 | * Returns a list of all currently registered media. This list is used to
|
---|
835 | * globally track the accessiblity state of all media on a dedicated thread.
|
---|
836 | *
|
---|
837 | * Note that the media list is initially empty (i.e. before the enumeration
|
---|
838 | * process is started for the first time using #startEnumeratingMedia()).
|
---|
839 | * See #startEnumeratingMedia() for more information about how meida are
|
---|
840 | * sorted in the returned list.
|
---|
841 | */
|
---|
842 | const VBoxMediaList ¤tMediaList() const { return mMediaList; }
|
---|
843 |
|
---|
844 | /** Returns true if the media enumeration is in progress. */
|
---|
845 | bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }
|
---|
846 |
|
---|
847 | void addMedium (const VBoxMedium &);
|
---|
848 | void updateMedium (const VBoxMedium &);
|
---|
849 | void removeMedium (VBoxDefs::MediaType, const QUuid &);
|
---|
850 |
|
---|
851 | bool findMedium (const CMedium &, VBoxMedium &) const;
|
---|
852 |
|
---|
853 | /** Compact version of #findMediumTo(). Asserts if not found. */
|
---|
854 | VBoxMedium getMedium (const CMedium &aObj) const
|
---|
855 | {
|
---|
856 | VBoxMedium medium;
|
---|
857 | if (!findMedium (aObj, medium))
|
---|
858 | AssertFailed();
|
---|
859 | return medium;
|
---|
860 | }
|
---|
861 |
|
---|
862 | /* Returns the number of current running Fe/Qt4 main windows. */
|
---|
863 | int mainWindowCount();
|
---|
864 |
|
---|
865 | /* various helpers */
|
---|
866 |
|
---|
867 | QString languageName() const;
|
---|
868 | QString languageCountry() const;
|
---|
869 | QString languageNameEnglish() const;
|
---|
870 | QString languageCountryEnglish() const;
|
---|
871 | QString languageTranslators() const;
|
---|
872 |
|
---|
873 | void retranslateUi();
|
---|
874 |
|
---|
875 | /** @internal made public for internal purposes */
|
---|
876 | void cleanup();
|
---|
877 |
|
---|
878 | /* public static stuff */
|
---|
879 |
|
---|
880 | static bool isDOSType (const QString &aOSTypeId);
|
---|
881 |
|
---|
882 | static void adoptLabelPixmap (QLabel *);
|
---|
883 |
|
---|
884 | static QString languageId();
|
---|
885 | static void loadLanguage (const QString &aLangId = QString::null);
|
---|
886 | QString helpFile() const;
|
---|
887 |
|
---|
888 | static QIcon iconSet (const char *aNormal,
|
---|
889 | const char *aDisabled = NULL,
|
---|
890 | const char *aActive = NULL);
|
---|
891 | static QIcon iconSetOnOff (const char *aNormal, const char *aNormalOff,
|
---|
892 | const char *aDisabled = NULL,
|
---|
893 | const char *aDisabledOff = NULL,
|
---|
894 | const char *aActive = NULL,
|
---|
895 | const char *aActiveOff = NULL);
|
---|
896 | static QIcon iconSetFull (const QSize &aNormalSize, const QSize &aSmallSize,
|
---|
897 | const char *aNormal, const char *aSmallNormal,
|
---|
898 | const char *aDisabled = NULL,
|
---|
899 | const char *aSmallDisabled = NULL,
|
---|
900 | const char *aActive = NULL,
|
---|
901 | const char *aSmallActive = NULL);
|
---|
902 |
|
---|
903 | static QIcon standardIcon (QStyle::StandardPixmap aStandard, QWidget *aWidget = NULL);
|
---|
904 |
|
---|
905 | static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
|
---|
906 |
|
---|
907 | static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
908 | bool aCanResize = true);
|
---|
909 | static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
910 | bool aCanResize = true);
|
---|
911 | static QRegion flip (const QRegion &aRegion);
|
---|
912 |
|
---|
913 | static void centerWidget (QWidget *aWidget, QWidget *aRelative,
|
---|
914 | bool aCanResize = true);
|
---|
915 |
|
---|
916 | static QChar decimalSep();
|
---|
917 | static QString sizeRegexp();
|
---|
918 |
|
---|
919 | static quint64 parseSize (const QString &);
|
---|
920 | static QString formatSize (quint64 aSize, uint aDecimal = 2,
|
---|
921 | VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);
|
---|
922 |
|
---|
923 | static quint64 requiredVideoMemory (CMachine *aMachine = 0);
|
---|
924 |
|
---|
925 | static QString locationForHTML (const QString &aFileName);
|
---|
926 |
|
---|
927 | static QString highlight (const QString &aStr, bool aToolTip = false);
|
---|
928 |
|
---|
929 | static QString systemLanguageId();
|
---|
930 |
|
---|
931 | static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
|
---|
932 | const QString &aCaption = QString::null,
|
---|
933 | bool aDirOnly = TRUE,
|
---|
934 | bool resolveSymlinks = TRUE);
|
---|
935 |
|
---|
936 | static QString getOpenFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
|
---|
937 | const QString &aCaption, QString *aSelectedFilter = NULL,
|
---|
938 | bool aResolveSymLinks = true);
|
---|
939 |
|
---|
940 | static QStringList getOpenFileNames (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
|
---|
941 | const QString &aCaption, QString *aSelectedFilter = NULL,
|
---|
942 | bool aResolveSymLinks = true,
|
---|
943 | bool aSingleFile = false);
|
---|
944 |
|
---|
945 | static QString getFirstExistingDir (const QString &);
|
---|
946 |
|
---|
947 | static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
|
---|
948 |
|
---|
949 | static QString removeAccelMark (const QString &aText);
|
---|
950 |
|
---|
951 | static QString insertKeyToActionText (const QString &aText, const QString &aKey);
|
---|
952 | static QString extractKeyFromActionText (const QString &aText);
|
---|
953 |
|
---|
954 | static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
|
---|
955 |
|
---|
956 | static QWidget *findWidget (QWidget *aParent, const char *aName,
|
---|
957 | const char *aClassName = NULL,
|
---|
958 | bool aRecursive = false);
|
---|
959 |
|
---|
960 | static QList <QPair <QString, QString> > HDDBackends();
|
---|
961 |
|
---|
962 | /* Qt 4.2.0 support function */
|
---|
963 | static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
|
---|
964 | {
|
---|
965 | #if QT_VERSION < 0x040300
|
---|
966 | /* Deprecated since > 4.2 */
|
---|
967 | aLayout->setMargin (aMargin);
|
---|
968 | #else
|
---|
969 | /* New since > 4.2 */
|
---|
970 | aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
|
---|
971 | #endif
|
---|
972 | }
|
---|
973 |
|
---|
974 | signals:
|
---|
975 |
|
---|
976 | /**
|
---|
977 | * Emitted at the beginning of the enumeration process started by
|
---|
978 | * #startEnumeratingMedia().
|
---|
979 | */
|
---|
980 | void mediumEnumStarted();
|
---|
981 |
|
---|
982 | /**
|
---|
983 | * Emitted when a new medium item from the list has updated its
|
---|
984 | * accessibility state.
|
---|
985 | */
|
---|
986 | void mediumEnumerated (const VBoxMedium &aMedum);
|
---|
987 |
|
---|
988 | /**
|
---|
989 | * Emitted at the end of the enumeration process started by
|
---|
990 | * #startEnumeratingMedia(). The @a aList argument is passed for
|
---|
991 | * convenience, it is exactly the same as returned by #currentMediaList().
|
---|
992 | */
|
---|
993 | void mediumEnumFinished (const VBoxMediaList &aList);
|
---|
994 |
|
---|
995 | /** Emitted when a new media is added using #addMedia(). */
|
---|
996 | void mediumAdded (const VBoxMedium &);
|
---|
997 |
|
---|
998 | /** Emitted when the media is updated using #updateMedia(). */
|
---|
999 | void mediumUpdated (const VBoxMedium &);
|
---|
1000 |
|
---|
1001 | /** Emitted when the media is removed using #removeMedia(). */
|
---|
1002 | void mediumRemoved (VBoxDefs::MediaType, const QUuid &);
|
---|
1003 |
|
---|
1004 | /* signals emitted when the VirtualBox callback is called by the server
|
---|
1005 | * (note that currently these signals are emitted only when the application
|
---|
1006 | * is the in the VM selector mode) */
|
---|
1007 |
|
---|
1008 | void machineStateChanged (const VBoxMachineStateChangeEvent &e);
|
---|
1009 | void machineDataChanged (const VBoxMachineDataChangeEvent &e);
|
---|
1010 | void machineRegistered (const VBoxMachineRegisteredEvent &e);
|
---|
1011 | void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
|
---|
1012 | void snapshotChanged (const VBoxSnapshotEvent &e);
|
---|
1013 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
1014 | void mainWindowCountChanged (const VBoxMainWindowCountChangeEvent &e);
|
---|
1015 | void trayIconCanShow (const VBoxCanShowTrayIconEvent &e);
|
---|
1016 | void trayIconShow (const VBoxShowTrayIconEvent &e);
|
---|
1017 | void trayIconChanged (const VBoxChangeTrayIconEvent &e);
|
---|
1018 | #endif
|
---|
1019 | void dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &e);
|
---|
1020 |
|
---|
1021 | void canShowRegDlg (bool aCanShow);
|
---|
1022 | void canShowUpdDlg (bool aCanShow);
|
---|
1023 |
|
---|
1024 | public slots:
|
---|
1025 |
|
---|
1026 | bool openURL (const QString &aURL);
|
---|
1027 |
|
---|
1028 | void showRegistrationDialog (bool aForce = true);
|
---|
1029 | void showUpdateDialog (bool aForce = true);
|
---|
1030 | void perDayNewVersionNotifier();
|
---|
1031 |
|
---|
1032 | protected:
|
---|
1033 |
|
---|
1034 | bool event (QEvent *e);
|
---|
1035 | bool eventFilter (QObject *, QEvent *);
|
---|
1036 |
|
---|
1037 | private:
|
---|
1038 |
|
---|
1039 | VBoxGlobal();
|
---|
1040 | ~VBoxGlobal();
|
---|
1041 |
|
---|
1042 | void init();
|
---|
1043 |
|
---|
1044 | bool mValid;
|
---|
1045 |
|
---|
1046 | CVirtualBox mVBox;
|
---|
1047 |
|
---|
1048 | VBoxGlobalSettings gset;
|
---|
1049 |
|
---|
1050 | VBoxSelectorWnd *mSelectorWnd;
|
---|
1051 | VBoxConsoleWnd *mConsoleWnd;
|
---|
1052 | QWidget* mMainWindow;
|
---|
1053 |
|
---|
1054 | #ifdef VBOX_WITH_REGISTRATION
|
---|
1055 | VBoxRegistrationDlg *mRegDlg;
|
---|
1056 | #endif
|
---|
1057 | VBoxUpdateDlg *mUpdDlg;
|
---|
1058 |
|
---|
1059 | QUuid vmUuid;
|
---|
1060 |
|
---|
1061 | #ifdef VBOX_GUI_WITH_SYSTRAY
|
---|
1062 | bool mIsTrayMenu : 1; /*< Tray icon active/desired? */
|
---|
1063 | bool mIncreasedWindowCounter : 1;
|
---|
1064 | #endif
|
---|
1065 |
|
---|
1066 | QThread *mMediaEnumThread;
|
---|
1067 | VBoxMediaList mMediaList;
|
---|
1068 |
|
---|
1069 | VBoxDefs::RenderMode vm_render_mode;
|
---|
1070 | const char * vm_render_mode_str;
|
---|
1071 |
|
---|
1072 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1073 | /** Whether the debugger should be accessible or not.
|
---|
1074 | * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.
|
---|
1075 | * VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
1076 | bool mDbgEnabled;
|
---|
1077 | /** Whether to show the debugger automatically with the console.
|
---|
1078 | * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
1079 | bool mDbgAutoShow;
|
---|
1080 | /** VBoxDbg module handle. */
|
---|
1081 | RTLDRMOD mhVBoxDbg;
|
---|
1082 | #endif
|
---|
1083 |
|
---|
1084 | #if defined (Q_WS_WIN32)
|
---|
1085 | DWORD dwHTMLHelpCookie;
|
---|
1086 | #endif
|
---|
1087 |
|
---|
1088 | CVirtualBoxCallback callback;
|
---|
1089 |
|
---|
1090 | QString mVerString;
|
---|
1091 |
|
---|
1092 | QList <QString> mFamilyIDs;
|
---|
1093 | QList <QList <CGuestOSType> > mTypes;
|
---|
1094 | QHash <QString, QPixmap *> mOsTypeIcons;
|
---|
1095 |
|
---|
1096 | QHash <ulong, QPixmap *> mVMStateIcons;
|
---|
1097 | QHash <ulong, QColor *> mVMStateColors;
|
---|
1098 |
|
---|
1099 | QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
|
---|
1100 |
|
---|
1101 | QULongStringHash mMachineStates;
|
---|
1102 | QULongStringHash mSessionStates;
|
---|
1103 | QULongStringHash mDeviceTypes;
|
---|
1104 |
|
---|
1105 | QULongStringHash mStorageBuses;
|
---|
1106 | QLongStringHash mStorageBusChannels;
|
---|
1107 | QLongStringHash mStorageBusDevices;
|
---|
1108 |
|
---|
1109 | QULongStringHash mDiskTypes;
|
---|
1110 | QString mDiskTypes_Differencing;
|
---|
1111 |
|
---|
1112 | QULongStringHash mVRDPAuthTypes;
|
---|
1113 | QULongStringHash mPortModeTypes;
|
---|
1114 | QULongStringHash mUSBFilterActionTypes;
|
---|
1115 | QULongStringHash mAudioDriverTypes;
|
---|
1116 | QULongStringHash mAudioControllerTypes;
|
---|
1117 | QULongStringHash mNetworkAdapterTypes;
|
---|
1118 | QULongStringHash mNetworkAttachmentTypes;
|
---|
1119 | QULongStringHash mClipboardTypes;
|
---|
1120 | QULongStringHash mIDEControllerTypes;
|
---|
1121 | QULongStringHash mUSBDeviceStates;
|
---|
1122 |
|
---|
1123 | QString mUserDefinedPortName;
|
---|
1124 |
|
---|
1125 | QPixmap mWarningIcon, mErrorIcon;
|
---|
1126 |
|
---|
1127 | mutable bool mDetailReportTemplatesReady;
|
---|
1128 |
|
---|
1129 | friend VBoxGlobal &vboxGlobal();
|
---|
1130 | friend class VBoxCallback;
|
---|
1131 | };
|
---|
1132 |
|
---|
1133 | inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
|
---|
1134 |
|
---|
1135 | // Helper classes
|
---|
1136 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1137 |
|
---|
1138 | /**
|
---|
1139 | * Generic asyncronous event.
|
---|
1140 | *
|
---|
1141 | * This abstract class is intended to provide a conveinent way to execute
|
---|
1142 | * code on the main GUI thread asynchronously to the calling party. This is
|
---|
1143 | * done by putting necessary actions to the #handle() function in a subclass
|
---|
1144 | * and then posting an instance of the subclass using #post(). The instance
|
---|
1145 | * must be allocated on the heap using the <tt>new</tt> operation and will be
|
---|
1146 | * automatically deleted after processing. Note that if you don't call #post()
|
---|
1147 | * on the created instance, you have to delete it yourself.
|
---|
1148 | */
|
---|
1149 | class VBoxAsyncEvent : public QEvent
|
---|
1150 | {
|
---|
1151 | public:
|
---|
1152 |
|
---|
1153 | VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {}
|
---|
1154 |
|
---|
1155 | /**
|
---|
1156 | * Worker function. Gets executed on the GUI thread when the posted event
|
---|
1157 | * is processed by the main event loop.
|
---|
1158 | */
|
---|
1159 | virtual void handle() = 0;
|
---|
1160 |
|
---|
1161 | /**
|
---|
1162 | * Posts this event to the main event loop.
|
---|
1163 | * The caller loses ownership of this object after this method returns
|
---|
1164 | * and must not delete the object.
|
---|
1165 | */
|
---|
1166 | void post()
|
---|
1167 | {
|
---|
1168 | QApplication::postEvent (&vboxGlobal(), this);
|
---|
1169 | }
|
---|
1170 | };
|
---|
1171 |
|
---|
1172 | /**
|
---|
1173 | * USB Popup Menu class.
|
---|
1174 | * This class provides the list of USB devices attached to the host.
|
---|
1175 | */
|
---|
1176 | class VBoxUSBMenu : public QMenu
|
---|
1177 | {
|
---|
1178 | Q_OBJECT
|
---|
1179 |
|
---|
1180 | public:
|
---|
1181 |
|
---|
1182 | VBoxUSBMenu (QWidget *);
|
---|
1183 |
|
---|
1184 | const CUSBDevice& getUSB (QAction *aAction);
|
---|
1185 |
|
---|
1186 | void setConsole (const CConsole &);
|
---|
1187 |
|
---|
1188 | private slots:
|
---|
1189 |
|
---|
1190 | void processAboutToShow();
|
---|
1191 |
|
---|
1192 | private:
|
---|
1193 | bool event(QEvent *aEvent);
|
---|
1194 |
|
---|
1195 | QMap <QAction *, CUSBDevice> mUSBDevicesMap;
|
---|
1196 | CConsole mConsole;
|
---|
1197 | };
|
---|
1198 |
|
---|
1199 | /**
|
---|
1200 | * Enable/Disable Menu class.
|
---|
1201 | * This class provides enable/disable menu items.
|
---|
1202 | */
|
---|
1203 | class VBoxSwitchMenu : public QMenu
|
---|
1204 | {
|
---|
1205 | Q_OBJECT
|
---|
1206 |
|
---|
1207 | public:
|
---|
1208 |
|
---|
1209 | VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
|
---|
1210 |
|
---|
1211 | void setToolTip (const QString &);
|
---|
1212 |
|
---|
1213 | private slots:
|
---|
1214 |
|
---|
1215 | void processAboutToShow();
|
---|
1216 |
|
---|
1217 | private:
|
---|
1218 |
|
---|
1219 | QAction *mAction;
|
---|
1220 | bool mInverted;
|
---|
1221 | };
|
---|
1222 |
|
---|
1223 | #endif /* __VBoxGlobal_h__ */
|
---|