VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h@ 41590

Last change on this file since 41590 was 41590, checked in by vboxsync, 13 years ago

FE/Qt: Move QIProcess out of VBoxGlobal into separate file.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 31.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxGlobal class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2011 Oracle Corporation
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
19#ifndef __VBoxGlobal_h__
20#define __VBoxGlobal_h__
21
22/* Qt includes: */
23#include <QApplication>
24#include <QLayout>
25#include <QMenu>
26#include <QStyle>
27#include <QHash>
28#include <QFileIconProvider>
29
30/* GUI includes: */
31#include "VBoxGlobalSettings.h"
32#include "VBoxMedium.h"
33
34/* COM includes: */
35#include "VBox/com/Guid.h"
36#include "COMEnums.h"
37#include "CHost.h"
38#include "CVirtualBox.h"
39#include "CSession.h"
40#include "CConsole.h"
41#include "CMachine.h"
42#include "CMedium.h"
43#include "CGuestOSType.h"
44#include "CUSBDevice.h"
45
46/* Forward declarations: */
47class QAction;
48class QLabel;
49class QToolButton;
50class UIMachine;
51
52struct StorageSlot
53{
54 StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {}
55 StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {}
56 StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {}
57 StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; }
58 bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; }
59 bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; }
60 bool operator< (const StorageSlot &aOther) const { return (bus < aOther.bus) ||
61 (bus == aOther.bus && port < aOther.port) ||
62 (bus == aOther.bus && port == aOther.port && device < aOther.device); }
63 bool operator> (const StorageSlot &aOther) const { return (bus > aOther.bus) ||
64 (bus == aOther.bus && port > aOther.port) ||
65 (bus == aOther.bus && port == aOther.port && device > aOther.device); }
66 bool isNull() { return bus == KStorageBus_Null; }
67 KStorageBus bus; LONG port; LONG device;
68};
69Q_DECLARE_METATYPE (StorageSlot);
70
71// VBoxGlobal class
72////////////////////////////////////////////////////////////////////////////////
73
74class UISelectorWindow;
75class UIRegistrationWzd;
76class VBoxUpdateDlg;
77
78class VBoxGlobal : public QObject
79{
80 Q_OBJECT
81
82public:
83
84 typedef QHash <ulong, QString> QULongStringHash;
85 typedef QHash <long, QString> QLongStringHash;
86
87 static VBoxGlobal &instance();
88
89 bool isValid() { return mValid; }
90
91 static QString qtRTVersionString();
92 static uint qtRTVersion();
93 static QString qtCTVersionString();
94 static uint qtCTVersion();
95
96 QString vboxVersionString() const;
97 QString vboxVersionStringNormalized() const;
98
99 QString versionString() const { return mVerString; }
100 bool isBeta() const;
101
102 CVirtualBox virtualBox() const { return mVBox; }
103 CHost host() const { return mHost; }
104
105 VBoxGlobalSettings &settings() { return gset; }
106 bool setSettings (VBoxGlobalSettings &gs);
107
108 UISelectorWindow &selectorWnd();
109
110 /* VM stuff: */
111 bool startMachine(const QString &strMachineId);
112 UIMachine* virtualMachine();
113 QWidget* vmWindow();
114
115 /* Main application window storage: */
116 void setMainWindow(QWidget *pMainWindow) { mMainWindow = pMainWindow; }
117 QWidget* mainWindow() const { return mMainWindow; }
118
119 bool is3DAvailable() const { return m3DAvailable; }
120
121#ifdef VBOX_GUI_WITH_PIDFILE
122 void createPidfile();
123 void deletePidfile();
124#endif
125
126 /* branding */
127 bool brandingIsActive (bool aForce = false);
128 QString brandingGetKey (QString aKey);
129
130 bool processArgs();
131
132 bool switchToMachine(CMachine &machine);
133 bool launchMachine(CMachine &machine, bool fHeadless = false);
134
135 bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
136 bool showStartVMErrors() const { return mShowStartVMErrors; }
137#ifdef VBOX_GUI_WITH_SYSTRAY
138 bool isTrayMenu() const;
139 void setTrayMenu(bool aIsTrayMenu);
140 void trayIconShowSelector();
141 bool trayIconInstall();
142#endif
143 QString managedVMUuid() const { return vmUuid; }
144 QList<QUrl> &argUrlList() { return m_ArgUrlList; }
145
146 VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
147 const char *vmRenderModeStr() const { return vm_render_mode_str; }
148 bool isKWinManaged() const { return mIsKWinManaged; }
149
150 const QRect availableGeometry(int iScreen = 0) const;
151
152 bool isPatmDisabled() const { return mDisablePatm; }
153 bool isCsamDisabled() const { return mDisableCsam; }
154 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
155 bool isUserCodeExecedRecompiled() const { return mRecompileUser; }
156
157#ifdef VBOX_WITH_DEBUGGER_GUI
158 bool isDebuggerEnabled(CMachine &aMachine);
159 bool isDebuggerAutoShowEnabled(CMachine &aMachine);
160 bool isDebuggerAutoShowCommandLineEnabled(CMachine &aMachine);
161 bool isDebuggerAutoShowStatisticsEnabled(CMachine &aMachine);
162 RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }
163
164 bool isStartPausedEnabled() const { return mStartPaused; }
165#else
166 bool isDebuggerAutoShowEnabled(CMachine & /*aMachine*/) const { return false; }
167 bool isDebuggerAutoShowCommandLineEnabled(CMachine & /*aMachine*/) const { return false; }
168 bool isDebuggerAutoShowStatisticsEnabled(CMachine & /*aMachine*/) const { return false; }
169
170 bool isStartPausedEnabled() const { return false; }
171#endif
172
173 /* VBox enum to/from string/icon/color convertors */
174
175 QList <CGuestOSType> vmGuestOSFamilyList() const;
176 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
177 QPixmap vmGuestOSTypeIcon (const QString &aTypeId) const;
178 CGuestOSType vmGuestOSType (const QString &aTypeId,
179 const QString &aFamilyId = QString::null) const;
180 QString vmGuestOSTypeDescription (const QString &aTypeId) const;
181
182 QPixmap toIcon (KMachineState s) const
183 {
184 QPixmap *pm = mVMStateIcons.value (s);
185 AssertMsg (pm, ("Icon for VM state %d must be defined", s));
186 return pm ? *pm : QPixmap();
187 }
188
189 static inline QString yearsToString (uint32_t cVal)
190 {
191 return tr("%n year(s)", "", cVal);
192 }
193
194 static inline QString monthsToString (uint32_t cVal)
195 {
196 return tr("%n month(s)", "", cVal);
197 }
198
199 static inline QString daysToString (uint32_t cVal)
200 {
201 return tr("%n day(s)", "", cVal);
202 }
203
204 static inline QString hoursToString (uint32_t cVal)
205 {
206 return tr("%n hour(s)", "", cVal);
207 }
208
209 static inline QString minutesToString (uint32_t cVal)
210 {
211 return tr("%n minute(s)", "", cVal);
212 }
213
214 static inline QString secondsToString (uint32_t cVal)
215 {
216 return tr("%n second(s)", "", cVal);
217 }
218
219 const QColor &toColor (KMachineState s) const
220 {
221 static const QColor none;
222 AssertMsg (mVMStateColors.value (s), ("No color for %d", s));
223 return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;
224 }
225
226 QString toString (KMachineState s) const
227 {
228 AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));
229 return mMachineStates.value (s);
230 }
231
232 QString toString (KSessionState s) const
233 {
234 AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));
235 return mSessionStates.value (s);
236 }
237
238 /**
239 * Returns a string representation of the given KStorageBus enum value.
240 * Complementary to #toStorageBusType (const QString &) const.
241 */
242 QString toString (KStorageBus aBus) const
243 {
244 AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));
245 return mStorageBuses [aBus];
246 }
247
248 /**
249 * Returns a KStorageBus enum value corresponding to the given string
250 * representation. Complementary to #toString (KStorageBus) const.
251 */
252 KStorageBus toStorageBusType (const QString &aBus) const
253 {
254 QULongStringHash::const_iterator it =
255 qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);
256 AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",
257 aBus.toLatin1().constData()));
258 return KStorageBus (it.key());
259 }
260
261 KStorageBus toStorageBusType (KStorageControllerType aControllerType) const
262 {
263 KStorageBus sb = KStorageBus_Null;
264 switch (aControllerType)
265 {
266 case KStorageControllerType_Null: sb = KStorageBus_Null; break;
267 case KStorageControllerType_PIIX3:
268 case KStorageControllerType_PIIX4:
269 case KStorageControllerType_ICH6: sb = KStorageBus_IDE; break;
270 case KStorageControllerType_IntelAhci: sb = KStorageBus_SATA; break;
271 case KStorageControllerType_LsiLogic:
272 case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break;
273 case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break;
274 default:
275 AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break;
276 }
277 return sb;
278 }
279
280 QString toString (KStorageBus aBus, LONG aChannel) const;
281 LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;
282
283 QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
284 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
285
286 QString toString (StorageSlot aSlot) const;
287 StorageSlot toStorageSlot (const QString &aSlot) const;
288
289 QString toString (KMediumType t) const
290 {
291 AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));
292 return mDiskTypes.value (t);
293 }
294 QString differencingMediumTypeName() const { return mDiskTypes_Differencing; }
295
296 QString toString(KMediumVariant mediumVariant) const;
297
298 /**
299 * Similar to toString (KMediumType), but returns 'Differencing' for
300 * normal hard disks that have a parent.
301 */
302 QString mediumTypeString (const CMedium &aHD) const
303 {
304 if (!aHD.GetParent().isNull())
305 {
306 Assert (aHD.GetType() == KMediumType_Normal);
307 return mDiskTypes_Differencing;
308 }
309 return toString (aHD.GetType());
310 }
311
312 QString toString (KAuthType t) const
313 {
314 AssertMsg (!mAuthTypes.value (t).isNull(), ("No text for %d", t));
315 return mAuthTypes.value (t);
316 }
317
318 QString toString (KPortMode t) const
319 {
320 AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));
321 return mPortModeTypes.value (t);
322 }
323
324 QString toString (KUSBDeviceFilterAction t) const
325 {
326 AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));
327 return mUSBFilterActionTypes.value (t);
328 }
329
330 QString toString (KClipboardMode t) const
331 {
332 AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));
333 return mClipboardTypes.value (t);
334 }
335
336 KClipboardMode toClipboardModeType (const QString &s) const
337 {
338 QULongStringHash::const_iterator it =
339 qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);
340 AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",
341 s.toLatin1().constData()));
342 return KClipboardMode (it.key());
343 }
344
345 QString toString (KStorageControllerType t) const
346 {
347 AssertMsg (!mStorageControllerTypes.value (t).isNull(), ("No text for %d", t));
348 return mStorageControllerTypes.value (t);
349 }
350
351 KStorageControllerType toControllerType (const QString &s) const
352 {
353 QULongStringHash::const_iterator it =
354 qFind (mStorageControllerTypes.begin(), mStorageControllerTypes.end(), s);
355 AssertMsg (it != mStorageControllerTypes.end(), ("No value for {%s}",
356 s.toLatin1().constData()));
357 return KStorageControllerType (it.key());
358 }
359
360 KAuthType toAuthType (const QString &s) const
361 {
362 QULongStringHash::const_iterator it =
363 qFind (mAuthTypes.begin(), mAuthTypes.end(), s);
364 AssertMsg (it != mAuthTypes.end(), ("No value for {%s}",
365 s.toLatin1().constData()));
366 return KAuthType (it.key());
367 }
368
369 KPortMode toPortMode (const QString &s) const
370 {
371 QULongStringHash::const_iterator it =
372 qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);
373 AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",
374 s.toLatin1().constData()));
375 return KPortMode (it.key());
376 }
377
378 KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
379 {
380 QULongStringHash::const_iterator it =
381 qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);
382 AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",
383 s.toLatin1().constData()));
384 return KUSBDeviceFilterAction (it.key());
385 }
386
387 QString toString (KDeviceType t) const
388 {
389 AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));
390 return mDeviceTypes.value (t);
391 }
392
393 KDeviceType toDeviceType (const QString &s) const
394 {
395 QULongStringHash::const_iterator it =
396 qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);
397 AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",
398 s.toLatin1().constData()));
399 return KDeviceType (it.key());
400 }
401
402 QStringList deviceTypeStrings() const;
403
404 QString toString (KAudioDriverType t) const
405 {
406 AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));
407 return mAudioDriverTypes.value (t);
408 }
409
410 KAudioDriverType toAudioDriverType (const QString &s) const
411 {
412 QULongStringHash::const_iterator it =
413 qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);
414 AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",
415 s.toLatin1().constData()));
416 return KAudioDriverType (it.key());
417 }
418
419 QString toString (KAudioControllerType t) const
420 {
421 AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));
422 return mAudioControllerTypes.value (t);
423 }
424
425 KAudioControllerType toAudioControllerType (const QString &s) const
426 {
427 QULongStringHash::const_iterator it =
428 qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);
429 AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",
430 s.toLatin1().constData()));
431 return KAudioControllerType (it.key());
432 }
433
434 QString toString (KNetworkAdapterType t) const
435 {
436 AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));
437 return mNetworkAdapterTypes.value (t);
438 }
439
440 KNetworkAdapterType toNetworkAdapterType (const QString &s) const
441 {
442 QULongStringHash::const_iterator it =
443 qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);
444 AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",
445 s.toLatin1().constData()));
446 return KNetworkAdapterType (it.key());
447 }
448
449 QString toString (KNetworkAttachmentType t) const
450 {
451 AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
452 return mNetworkAttachmentTypes.value (t);
453 }
454
455 KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
456 {
457 QULongStringHash::const_iterator it =
458 qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);
459 AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",
460 s.toLatin1().constData()));
461 return KNetworkAttachmentType (it.key());
462 }
463
464 QString toString (KNetworkAdapterPromiscModePolicy t) const
465 {
466 AssertMsg (!mNetworkAdapterPromiscModePolicyTypes.value (t).isNull(), ("No text for %d", t));
467 return mNetworkAdapterPromiscModePolicyTypes.value (t);
468 }
469
470 KNetworkAdapterPromiscModePolicy toNetworkAdapterPromiscModePolicyType (const QString &s) const
471 {
472 QULongStringHash::const_iterator it =
473 qFind (mNetworkAdapterPromiscModePolicyTypes.begin(), mNetworkAdapterPromiscModePolicyTypes.end(), s);
474 AssertMsg (it != mNetworkAdapterPromiscModePolicyTypes.end(), ("No value for {%s}",
475 s.toLatin1().constData()));
476 return KNetworkAdapterPromiscModePolicy (it.key());
477 }
478
479 QString toString (KNATProtocol t) const
480 {
481 AssertMsg (!mNATProtocolTypes.value (t).isNull(), ("No text for %d", t));
482 return mNATProtocolTypes.value (t);
483 }
484
485 KNATProtocol toNATProtocolType (const QString &s) const
486 {
487 QULongStringHash::const_iterator it =
488 qFind (mNATProtocolTypes.begin(), mNATProtocolTypes.end(), s);
489 AssertMsg (it != mNATProtocolTypes.end(), ("No value for {%s}",
490 s.toLatin1().constData()));
491 return KNATProtocol (it.key());
492 }
493
494 QString toString (KUSBDeviceState aState) const
495 {
496 AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
497 return mUSBDeviceStates.value (aState);
498 }
499
500 QString toString (KChipsetType t) const
501 {
502 AssertMsg (!mChipsetTypes.value (t).isNull(), ("No text for %d", t));
503 return mChipsetTypes.value (t);
504 }
505
506 KChipsetType toChipsetType (const QString &s) const
507 {
508 QULongStringHash::const_iterator it =
509 qFind (mChipsetTypes.begin(), mChipsetTypes.end(), s);
510 AssertMsg (it != mChipsetTypes.end(), ("No value for {%s}",
511 s.toLatin1().constData()));
512 return KChipsetType (it.key());
513 }
514
515 QStringList COMPortNames() const;
516 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
517 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
518
519 QStringList LPTPortNames() const;
520 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
521 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
522
523 QPixmap snapshotIcon (bool online) const
524 {
525 return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
526 }
527
528 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)
529 {
530 for (int i = 0; i < extList.size(); ++i)
531 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))
532 return true;
533 return false;
534 }
535
536 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }
537 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }
538
539 QPixmap warningIcon() const { return mWarningIcon; }
540 QPixmap errorIcon() const { return mErrorIcon; }
541
542 /* details generators */
543
544 QString details (const CMedium &aHD, bool aPredictDiff);
545
546 QString details (const CUSBDevice &aDevice) const;
547 QString toolTip (const CUSBDevice &aDevice) const;
548 QString toolTip (const CUSBDeviceFilter &aFilter) const;
549
550 QString detailsReport (const CMachine &aMachine, bool aWithLinks);
551
552 QString platformInfo();
553
554 /* VirtualBox helpers */
555
556#if defined(Q_WS_X11) && !defined(VBOX_OSE)
557 double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
558 bool showVirtualBoxLicense();
559#endif
560
561 CSession openSession(const QString &aId, bool aExisting = false);
562
563 /** Shortcut to openSession (aId, true). */
564 CSession openExistingSession(const QString &aId) { return openSession (aId, true); }
565
566 void startEnumeratingMedia();
567
568 void reloadProxySettings();
569
570 /**
571 * Returns a list of all currently registered media. This list is used to
572 * globally track the accessibility state of all media on a dedicated thread.
573 *
574 * Note that the media list is initially empty (i.e. before the enumeration
575 * process is started for the first time using #startEnumeratingMedia()).
576 * See #startEnumeratingMedia() for more information about how meida are
577 * sorted in the returned list.
578 */
579 const VBoxMediaList &currentMediaList() const { return mMediaList; }
580
581 /** Returns true if the media enumeration is in progress. */
582 bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }
583
584 VBoxDefs::MediumType mediumTypeToLocal(KDeviceType globalType);
585 KDeviceType mediumTypeToGlobal(VBoxDefs::MediumType localType);
586
587 void addMedium (const VBoxMedium &);
588 void updateMedium (const VBoxMedium &);
589 void removeMedium (VBoxDefs::MediumType, const QString &);
590
591 bool findMedium (const CMedium &, VBoxMedium &) const;
592 VBoxMedium findMedium (const QString &aMediumId) const;
593
594 /** Compact version of #findMediumTo(). Asserts if not found. */
595 VBoxMedium getMedium (const CMedium &aObj) const
596 {
597 VBoxMedium medium;
598 if (!findMedium (aObj, medium))
599 AssertFailed();
600 return medium;
601 }
602
603 QString openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent = 0,
604 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
605 QString openMedium(VBoxDefs::MediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);
606
607 /* Returns the number of current running Fe/Qt4 main windows. */
608 int mainWindowCount();
609
610 /* various helpers */
611
612 QString languageName() const;
613 QString languageCountry() const;
614 QString languageNameEnglish() const;
615 QString languageCountryEnglish() const;
616 QString languageTranslators() const;
617
618 void retranslateUi();
619
620 /** @internal made public for internal purposes */
621 void cleanup();
622
623 /* public static stuff */
624
625 static bool isDOSType (const QString &aOSTypeId);
626
627 static QString languageId();
628 static void loadLanguage (const QString &aLangId = QString::null);
629 QString helpFile() const;
630
631 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
632
633 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
634 bool aCanResize = true);
635 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
636 bool aCanResize = true);
637 static QRegion flip (const QRegion &aRegion);
638
639 static void centerWidget (QWidget *aWidget, QWidget *aRelative,
640 bool aCanResize = true);
641
642 static QChar decimalSep();
643 static QString sizeRegexp();
644
645 static QString toHumanReadableList(const QStringList &list);
646
647 static quint64 parseSize (const QString &);
648 static QString formatSize (quint64 aSize, uint aDecimal = 2,
649 VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);
650
651 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
652
653 static QString locationForHTML (const QString &aFileName);
654
655 static QString highlight (const QString &aStr, bool aToolTip = false);
656
657 static QString replaceHtmlEntities(QString strText);
658 static QString emphasize (const QString &aStr);
659
660 static QString systemLanguageId();
661
662 static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
663
664 static QString removeAccelMark (const QString &aText);
665
666 static QString insertKeyToActionText (const QString &aText, const QString &aKey);
667 static QString extractKeyFromActionText (const QString &aText);
668
669 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
670
671 static QWidget *findWidget (QWidget *aParent, const char *aName,
672 const char *aClassName = NULL,
673 bool aRecursive = false);
674
675 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
676 static QList <QPair <QString, QString> > HDDBackends();
677 static QList <QPair <QString, QString> > DVDBackends();
678 static QList <QPair <QString, QString> > FloppyBackends();
679
680 /* Qt 4.2.0 support function */
681 static inline void setLayoutMargin (QLayout *aLayout, int aMargin)
682 {
683#if QT_VERSION < 0x040300
684 /* Deprecated since > 4.2 */
685 aLayout->setMargin (aMargin);
686#else
687 /* New since > 4.2 */
688 aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);
689#endif
690 }
691
692 static QString documentsPath();
693
694#ifdef VBOX_WITH_VIDEOHWACCEL
695 static bool isAcceleration2DVideoAvailable();
696
697 /** additional video memory required for the best 2D support performance
698 * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
699 static quint64 required2DOffscreenVideoMemory();
700#endif
701
702#ifdef VBOX_WITH_CRHGSMI
703 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
704 static quint64 required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
705#endif /* VBOX_WITH_CRHGSMI */
706
707#ifdef Q_WS_MAC
708 bool isSheetWindowsAllowed(QWidget *pParent) const;
709#endif /* Q_WS_MAC */
710
711 /* Returns full medium-format name for the given base medium-format name: */
712 static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
713
714signals:
715
716 /**
717 * Emitted at the beginning of the enumeration process started by
718 * #startEnumeratingMedia().
719 */
720 void mediumEnumStarted();
721
722 /**
723 * Emitted when a new medium item from the list has updated its
724 * accessibility state.
725 */
726 void mediumEnumerated (const VBoxMedium &aMedum);
727
728 /**
729 * Emitted at the end of the enumeration process started by
730 * #startEnumeratingMedia(). The @a aList argument is passed for
731 * convenience, it is exactly the same as returned by #currentMediaList().
732 */
733 void mediumEnumFinished (const VBoxMediaList &aList);
734
735 /** Emitted when a new media is added using #addMedia(). */
736 void mediumAdded (const VBoxMedium &);
737
738 /** Emitted when the media is updated using #updateMedia(). */
739 void mediumUpdated (const VBoxMedium &);
740
741 /** Emitted when the media is removed using #removeMedia(). */
742 void mediumRemoved (VBoxDefs::MediumType, const QString &);
743
744#ifdef VBOX_GUI_WITH_SYSTRAY
745 void sigTrayIconShow(bool fEnabled);
746#endif
747
748public slots:
749
750 bool openURL (const QString &aURL);
751
752 void showRegistrationDialog (bool aForce = true);
753 void sltGUILanguageChange(QString strLang);
754 void sltProcessGlobalSettingChange();
755
756protected:
757
758 bool event (QEvent *e);
759 bool eventFilter (QObject *, QEvent *);
760
761private:
762
763 VBoxGlobal();
764 ~VBoxGlobal();
765
766 void init();
767#ifdef VBOX_WITH_DEBUGGER_GUI
768 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
769 void setDebuggerVar(int *piDbgCfgVar, bool fState);
770 bool isDebuggerWorker(int *piDbgCfgVar, CMachine &rMachine, const char *pszExtraDataName);
771#endif
772
773 bool mValid;
774
775 CVirtualBox mVBox;
776 CHost mHost;
777
778 VBoxGlobalSettings gset;
779
780 UISelectorWindow *mSelectorWnd;
781 UIMachine *m_pVirtualMachine;
782 QWidget* mMainWindow;
783
784#ifdef VBOX_WITH_REGISTRATION
785 UIRegistrationWzd *mRegDlg;
786#endif
787
788 QString vmUuid;
789 QList<QUrl> m_ArgUrlList;
790
791#ifdef VBOX_GUI_WITH_SYSTRAY
792 bool mIsTrayMenu : 1; /*< Tray icon active/desired? */
793 bool mIncreasedWindowCounter : 1;
794#endif
795
796 /** Whether to show error message boxes for VM start errors. */
797 bool mShowStartVMErrors;
798
799 QThread *mMediaEnumThread;
800 VBoxMediaList mMediaList;
801
802 VBoxDefs::RenderMode vm_render_mode;
803 const char * vm_render_mode_str;
804 bool mIsKWinManaged;
805
806 /** The --disable-patm option. */
807 bool mDisablePatm;
808 /** The --disable-csam option. */
809 bool mDisableCsam;
810 /** The --recompile-supervisor option. */
811 bool mRecompileSupervisor;
812 /** The --recompile-user option. */
813 bool mRecompileUser;
814
815#ifdef VBOX_WITH_DEBUGGER_GUI
816 /** Whether the debugger should be accessible or not.
817 * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.
818 * VBOX_GUI_DBG_AUTO_SHOW to enable. */
819 int mDbgEnabled;
820 /** Whether to show the debugger automatically with the console.
821 * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
822 int mDbgAutoShow;
823 /** Whether to show the command line window when mDbgAutoShow is set. */
824 int mDbgAutoShowCommandLine;
825 /** Whether to show the statistics window when mDbgAutoShow is set. */
826 int mDbgAutoShowStatistics;
827 /** VBoxDbg module handle. */
828 RTLDRMOD mhVBoxDbg;
829
830 /** Whether to start the VM in paused state or not. */
831 bool mStartPaused;
832#endif
833
834#if defined (Q_WS_WIN32)
835 DWORD dwHTMLHelpCookie;
836#endif
837
838 QString mVerString;
839 QString mBrandingConfig;
840
841 int m3DAvailable;
842
843 QList <QString> mFamilyIDs;
844 QList <QList <CGuestOSType> > mTypes;
845 QHash <QString, QPixmap *> mOsTypeIcons;
846
847 QHash <ulong, QPixmap *> mVMStateIcons;
848 QHash <ulong, QColor *> mVMStateColors;
849
850 QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
851
852 QULongStringHash mMachineStates;
853 QULongStringHash mSessionStates;
854 QULongStringHash mDeviceTypes;
855
856 QULongStringHash mStorageBuses;
857 QLongStringHash mStorageBusChannels;
858 QLongStringHash mStorageBusDevices;
859 QULongStringHash mSlotTemplates;
860
861 QULongStringHash mDiskTypes;
862 QString mDiskTypes_Differencing;
863
864 QULongStringHash mAuthTypes;
865 QULongStringHash mPortModeTypes;
866 QULongStringHash mUSBFilterActionTypes;
867 QULongStringHash mAudioDriverTypes;
868 QULongStringHash mAudioControllerTypes;
869 QULongStringHash mNetworkAdapterTypes;
870 QULongStringHash mNetworkAttachmentTypes;
871 QULongStringHash mNetworkAdapterPromiscModePolicyTypes;
872 QULongStringHash mNATProtocolTypes;
873 QULongStringHash mClipboardTypes;
874 QULongStringHash mStorageControllerTypes;
875 QULongStringHash mUSBDeviceStates;
876 QULongStringHash mChipsetTypes;
877
878 QString mUserDefinedPortName;
879
880 QPixmap mWarningIcon, mErrorIcon;
881
882 QFileIconProvider m_globalIconProvider;
883
884#ifdef VBOX_GUI_WITH_PIDFILE
885 QString m_strPidfile;
886#endif
887
888 friend VBoxGlobal &vboxGlobal();
889};
890
891inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
892
893// Helper classes
894////////////////////////////////////////////////////////////////////////////////
895
896/**
897 * USB Popup Menu class.
898 * This class provides the list of USB devices attached to the host.
899 */
900class VBoxUSBMenu : public QMenu
901{
902 Q_OBJECT
903
904public:
905
906 VBoxUSBMenu (QWidget *);
907
908 const CUSBDevice& getUSB (QAction *aAction);
909
910 void setConsole (const CConsole &);
911
912private slots:
913
914 void processAboutToShow();
915
916private:
917 bool event(QEvent *aEvent);
918
919 QMap <QAction *, CUSBDevice> mUSBDevicesMap;
920 CConsole mConsole;
921};
922
923/**
924 * Enable/Disable Menu class.
925 * This class provides enable/disable menu items.
926 */
927class VBoxSwitchMenu : public QMenu
928{
929 Q_OBJECT
930
931public:
932
933 VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
934
935 void setToolTip (const QString &);
936
937private slots:
938
939 void processAboutToShow();
940
941private:
942
943 QAction *mAction;
944 bool mInverted;
945};
946
947#endif /* __VBoxGlobal_h__ */
948
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette