VirtualBox

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

Last change on this file since 72432 was 72432, checked in by vboxsync, 7 years ago

FE/Qt: bugref:9049: Huge overhaul for VBoxGlobal class: Remove obsolete code, move implementation for large parts to source file.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.0 KB
Line 
1/* $Id: VBoxGlobal.h 72432 2018-06-04 16:35:07Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - VBoxGlobal class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___VBoxGlobal_h___
19#define ___VBoxGlobal_h___
20
21/* Qt includes: */
22#include <QFileIconProvider>
23#include <QReadWriteLock>
24
25/* GUI includes: */
26#include "UIDefs.h"
27#include "UILibraryDefs.h"
28#include "UIMediumDefs.h"
29#ifdef VBOX_WS_X11
30# include "VBoxX11Helper.h"
31#endif
32
33/* COM includes: */
34#include "VBox/com/Guid.h"
35#include "CHost.h"
36#include "CVirtualBoxClient.h"
37#include "CVirtualBox.h"
38#include "CSession.h"
39#include "CGuestOSType.h"
40
41/* Other includes: */
42#ifdef VBOX_WS_X11
43# include <X11/Xdefs.h>
44#endif
45
46/* Forward declarations: */
47class QMenu;
48class QToolButton;
49class QSessionManager;
50class QSpinBox;
51class CHostVideoInputDevice;
52class CMachine;
53class CMedium;
54class CUSBDevice;
55class UIMedium;
56class UIMediumEnumerator;
57class UIIconPoolGeneral;
58class UIThreadPool;
59
60/** QObject subclass containing common GUI functionality. */
61class SHARED_LIBRARY_STUFF VBoxGlobal : public QObject
62{
63 Q_OBJECT
64
65signals:
66
67 /** @name Common stuff.
68 * @{ */
69 /** Asks #UIStarter listener to commit data. */
70 void sigAskToCommitData();
71 /** @} */
72
73 /** @name Process arguments stuff.
74 * @{ */
75 /** Asks #UIStarter listener to open URLs. */
76 void sigAskToOpenURLs();
77 /** @} */
78
79 /** @name COM stuff.
80 * @{ */
81 /** Asks #UIStarter listener to restart UI. */
82 void sigAskToRestartUI();
83
84 /** Notifies listeners about the VBoxSVC availability change. */
85 void sigVBoxSVCAvailabilityChange();
86 /** @} */
87
88 /** @name COM: Virtual Media stuff.
89 * @{ */
90 /** Notifies listeners about medium with certain @a strMediumID created. */
91 void sigMediumCreated(const QString &strMediumID);
92 /** Notifies listeners about medium with certain @a strMediumID deleted. */
93 void sigMediumDeleted(const QString &strMediumID);
94
95 /** Notifies listeners about medium enumeration started. */
96 void sigMediumEnumerationStarted();
97 /** Notifies listeners about medium with certain @a strMediumID enumerated. */
98 void sigMediumEnumerated(const QString &strMediumID);
99 /** Notifies listeners about medium enumeration finished. */
100 void sigMediumEnumerationFinished();
101 /** @} */
102
103public:
104
105#ifdef VBOX_GUI_WITH_SHARED_LIBRARY
106 /** UI types. */
107 enum UIType
108 {
109 UIType_SelectorUI,
110 UIType_RuntimeUI
111 };
112#endif
113
114 /** VM launch modes. */
115 enum LaunchMode
116 {
117 LaunchMode_Invalid,
118 LaunchMode_Default,
119 LaunchMode_Headless,
120 LaunchMode_Separate
121 };
122
123 /** VM launch running options. */
124 enum StartRunning
125 {
126 StartRunning_Default, /**< Default (depends on debug settings). */
127 StartRunning_No, /**< Start the VM paused. */
128 StartRunning_Yes /**< Start the VM running. */
129 };
130
131 /** Returns VBoxGlobal instance. */
132 static VBoxGlobal *instance() { return s_pInstance; }
133#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
134 /** Creates VBoxGlobal instance. */
135 static void create();
136#else
137 /** Creates VBoxGlobal instance of passed @a enmType. */
138 static void create(UIType enmType);
139#endif
140 /** Destroys VBoxGlobal instance. */
141 static void destroy();
142
143 /** @name Common stuff.
144 * @{ */
145 /** Returns whether VBoxGlobal cleanup is in progress. */
146 bool isCleaningUp() { return s_fCleanupInProgress; }
147
148 /** Returns Qt runtime version string. */
149 static QString qtRTVersionString();
150 /** Returns Qt runtime version. */
151 static uint qtRTVersion();
152 /** Returns Qt compiled version string. */
153 static QString qtCTVersionString();
154 /** Returns Qt compiled version. */
155 static uint qtCTVersion();
156
157 /** Returns whether VBoxGlobal instance is properly initialized. */
158 bool isValid() { return mValid; }
159
160 /** Returns VBox version string. */
161 QString vboxVersionString() const;
162 /** Returns normalized VBox version string. */
163 QString vboxVersionStringNormalized() const;
164 /** Returns whether VBox version string contains BETA word. */
165 bool isBeta() const;
166
167#ifdef VBOX_WS_MAC
168 /** Mac OS X: Returns #MacOSXRelease determined by <i>uname</i> call. */
169 static MacOSXRelease determineOsRelease();
170 /** Mac OS X: Returns #MacOSXRelease determined during VBoxGlobal prepare routine. */
171 MacOSXRelease osRelease() const { return m_osRelease; }
172#endif /* VBOX_WS_MAC */
173
174#ifdef VBOX_WS_X11
175 /** X11: Returns whether the Window Manager we are running under is composition one. */
176 bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
177 /** X11: Returns the type of the Window Manager we are running under. */
178 X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }
179#endif /* VBOX_WS_X11 */
180
181 /** Returns whether branding is active. */
182 bool brandingIsActive (bool aForce = false);
183 /** Returns value for certain branding @a strKey from custom.ini file. */
184 QString brandingGetKey (QString aKey);
185 /** @} */
186
187 /** @name Process arguments stuff.
188 * @{ */
189 /** Returns whether passed @a strExt ends with one of allowed extension in the @a extList. */
190 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList);
191
192 /** Process application args. */
193 bool processArgs();
194
195 /** Returns the URL arguments list. */
196 QList<QUrl> &argUrlList() { return m_ArgUrlList; }
197
198 /** Returns the --startvm option value (managed VM id). */
199 QString managedVMUuid() const { return vmUuid; }
200 /** Returns whether this is VM console process. */
201 bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
202 /** Returns the --separate option value (whether GUI process is separate from VM process). */
203 bool isSeparateProcess() const { return m_fSeparateProcess; }
204 /** Returns the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
205 bool showStartVMErrors() const { return mShowStartVMErrors; }
206
207 /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
208 bool agressiveCaching() const { return mAgressiveCaching; }
209
210 /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */
211 bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; }
212 /** Defines whether we should fRestore current snapshot before VM started. */
213 void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; }
214
215 /** Returns the --fda option value (whether we have floppy image). */
216 bool hasFloppyImageToMount() const { return !m_strFloppyImage.isEmpty(); }
217 /** Returns the --dvd | --cdrom option value (whether we have DVD image). */
218 bool hasDvdImageToMount() const { return !m_strDvdImage.isEmpty(); }
219 /** Returns floppy image name. */
220 QString const &getFloppyImage() const { return m_strFloppyImage; }
221 /** Returns DVD image name. */
222 QString const &getDvdImage() const { return m_strDvdImage; }
223
224 /** Returns the --disable-patm option value. */
225 bool isPatmDisabled() const { return mDisablePatm; }
226 /** Returns the --disable-csam option value. */
227 bool isCsamDisabled() const { return mDisableCsam; }
228 /** Returns the --recompile-supervisor option value. */
229 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
230 /** Returns the --recompile-user option value. */
231 bool isUserCodeExecedRecompiled() const { return mRecompileUser; }
232 /** Returns the --execute-all-in-iem option value. */
233 bool areWeToExecuteAllInIem() const { return mExecuteAllInIem; }
234 /** Returns whether --warp-factor option value is equal to 100. */
235 bool isDefaultWarpPct() const { return mWarpPct == 100; }
236 /** Returns the --warp-factor option value. */
237 uint32_t getWarpPct() const { return mWarpPct; }
238
239#ifdef VBOX_WITH_DEBUGGER_GUI
240 /** Holds whether the debugger should be accessible. */
241 bool isDebuggerEnabled() const;
242 /** Holds whether to show the debugger automatically with the console. */
243 bool isDebuggerAutoShowEnabled() const;
244 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
245 bool isDebuggerAutoShowCommandLineEnabled() const;
246 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
247 bool isDebuggerAutoShowStatisticsEnabled() const;
248
249 /** VBoxDbg module handle. */
250 RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
251#endif /* VBOX_WITH_DEBUGGER_GUI */
252
253 /** Returns whether VM should start paused. */
254 bool shouldStartPaused() const;
255
256#ifdef VBOX_GUI_WITH_PIDFILE
257 /** Creates PID file. */
258 void createPidfile();
259 /** Deletes PID file. */
260 void deletePidfile();
261#endif
262 /** @} */
263
264 /** @name Localization stuff.
265 * @{ */
266 /** Native language name of the currently installed translation. */
267 QString languageName() const;
268 /** Native language country name of the currently installed translation. */
269 QString languageCountry() const;
270 /** Language name of the currently installed translation, in English. */
271 QString languageNameEnglish() const;
272 /** Language country name of the currently installed translation, in English. */
273 QString languageCountryEnglish() const;
274 /** Comma-separated list of authors of the currently installed translation. */
275 QString languageTranslators() const;
276
277 /** Returns VBox language sub-directory. */
278 static QString vboxLanguageSubDirectory();
279 /** Returns VBox language file-base. */
280 static QString vboxLanguageFileBase();
281 /** Returns VBox language file-extension. */
282 static QString vboxLanguageFileExtension();
283 /** Returns VBox language ID reg-exp. */
284 static QString vboxLanguageIdRegExp();
285 /** Returns built in language name. */
286 static QString vboxBuiltInLanguageName();
287
288 /** Returns the loaded (active) language ID. */
289 static QString languageId();
290 /** Returns the system language ID. */
291 static QString systemLanguageId();
292
293 /** Loads the language by language ID.
294 * @param strLangId Brings the language ID in in form of xx_YY.
295 * QString() means the system default language. */
296 static void loadLanguage (const QString &aLangId = QString::null);
297
298 /** Returns tr("%n year(s)"). */
299 static QString yearsToString(uint32_t cVal);
300 /** Returns tr("%n month(s)"). */
301 static QString monthsToString(uint32_t cVal);
302 /** Returns tr("%n day(s)"). */
303 static QString daysToString(uint32_t cVal);
304 /** Returns tr("%n hour(s)"). */
305 static QString hoursToString(uint32_t cVal);
306 /** Returns tr("%n minute(s)"). */
307 static QString minutesToString(uint32_t cVal);
308 /** Returns tr("%n second(s)"). */
309 static QString secondsToString(uint32_t cVal);
310
311 /** Returns the decimal separator for the current locale. */
312 static QChar decimalSep();
313 /** Returns the regexp string that defines the format of the human-readable size representation. */
314 static QString sizeRegexp();
315 /** Parses the given size strText and returns the size value in bytes. */
316 static quint64 parseSize (const QString &);
317 /** Formats the given @a uSize value in bytes to a human readable string.
318 * @param uSize Brings the size value in bytes.
319 * @param enmMode Brings the conversion mode.
320 * @param cDecimal Brings the number of decimal digits in result. */
321 static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round);
322
323 /** Returns full medium-format name for the given @a strBaseMediumFormatName. */
324 static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
325
326 /** Returns the list of the standard COM port names (i.e. "COMx"). */
327 QStringList COMPortNames() const;
328 /** Returns the name of the standard COM port corresponding to the given parameters,
329 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */
330 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
331 /** Returns port parameters corresponding to the given standard COM name.
332 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "COMx"). */
333 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
334 /** Returns the list of the standard LPT port names (i.e. "LPTx"). */
335 QStringList LPTPortNames() const;
336 /** Returns the name of the standard LPT port corresponding to the given parameters,
337 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */
338 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
339 /** Returns port parameters corresponding to the given standard LPT name.
340 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "LPTx"). */
341 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
342
343 /** Reformats the input @a strText to highlight it. */
344 static QString highlight (const QString &aStr, bool aToolTip = false);
345 /** Reformats the input @a strText to emphasize it. */
346 static QString emphasize (const QString &aStr);
347 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */
348 static QString removeAccelMark (const QString &aText);
349 /** Inserts a passed @a strKey into action @a strText. */
350 static QString insertKeyToActionText (const QString &aText, const QString &aKey);
351 /** @} */
352
353 /** @name File-system stuff.
354 * @{ */
355 /** Returns full help file name. */
356 QString helpFile() const;
357
358 /** Returns documents path. */
359 static QString documentsPath();
360 /** @} */
361
362 /** @name Window/widget geometry stuff.
363 * @{ */
364 /** Search position for @a rectangle to make sure it is fully contained @a boundRegion. */
365 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
366 bool aCanResize = true);
367 /** Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion. */
368 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
369 bool aCanResize = true);
370 /** Returns the flipped (transposed) @a region. */
371 static QRegion flip (const QRegion &aRegion);
372
373 /** Aligns the center of @a pWidget with the center of @a pRelative. */
374 static void centerWidget (QWidget *aWidget, QWidget *aRelative,
375 bool aCanResize = true);
376
377 /** Assigns top-level @a pWidget geometry passed as QRect coordinates.
378 * @note Take into account that this request may fail on X11. */
379 static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h);
380 /** Assigns top-level @a pWidget geometry passed as @a rect.
381 * @note Take into account that this request may fail on X11. */
382 static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
383
384 /** Activates the specified window with given @a wId. Can @a fSwitchDesktop if requested. */
385 static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
386
387#ifdef VBOX_WS_X11
388 /** X11: Test whether the current window manager supports full screen mode. */
389 static bool supportsFullScreenMonitorsProtocolX11();
390 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */
391 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);
392
393 /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */
394 static QVector<Atom> flagsNetWmState(QWidget *pWidget);
395 /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */
396 static bool isFullScreenFlagSet(QWidget *pWidget);
397 /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */
398 static void setFullScreenFlag(QWidget *pWidget);
399 /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */
400 static void setSkipTaskBarFlag(QWidget *pWidget);
401 /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */
402 static void setSkipPagerFlag(QWidget *pWidget);
403
404 /** Assigns WM_CLASS property for passed @a pWidget. */
405 static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
406#endif /* VBOX_WS_X11 */
407
408 /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */
409 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
410 /** @} */
411
412 /** @name COM stuff.
413 * @{ */
414 /** Try to acquire COM cleanup protection token for reading. */
415 bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
416 /** Unlock previously acquired COM cleanup protection token. */
417 void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
418
419 /** Returns the copy of VirtualBox client wrapper. */
420 CVirtualBoxClient virtualBoxClient() const { return m_client; }
421 /** Returns the copy of VirtualBox object wrapper. */
422 CVirtualBox virtualBox() const { return m_vbox; }
423 /** Returns the copy of VirtualBox host-object wrapper. */
424 CHost host() const { return m_host; }
425 /** Returns the symbolic VirtualBox home-folder representation. */
426 QString homeFolder() const { return m_strHomeFolder; }
427
428 /** Returns the VBoxSVC availability value. */
429 bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
430 /** @} */
431
432 /** @name COM: Guest OS Type.
433 * @{ */
434 /** Returns the list of few guest OS types, queried from
435 * IVirtualBox corresponding to every family id. */
436 QList <CGuestOSType> vmGuestOSFamilyList() const;
437 /** Returns the list of all guest OS types, queried from
438 * IVirtualBox corresponding to passed family id. */
439 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
440
441 /** Returns the guest OS type object corresponding to the given type id of list
442 * containing OS types related to OS family determined by family id attribute.
443 * If the index is invalid a null object is returned. */
444 CGuestOSType vmGuestOSType (const QString &aTypeId,
445 const QString &aFamilyId = QString::null) const;
446 /** Returns the description corresponding to the given guest OS type id. */
447 QString vmGuestOSTypeDescription (const QString &aTypeId) const;
448
449 /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */
450 static bool isDOSType (const QString &aOSTypeId);
451 /** @} */
452
453 /** @name COM: Virtual Machine stuff.
454 * @{ */
455 /** Switches to certain @a comMachine. */
456 bool switchToMachine(CMachine &machine);
457 /** Launches certain @a comMachine in specified @a enmLaunchMode. */
458 bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default);
459
460 /** Opens session of certain @a enmLockType for VM with certain @a strId. */
461 CSession openSession(const QString &aId, KLockType aLockType = KLockType_Write);
462 /** Opens session of KLockType_Shared type for VM with certain @a strId. */
463 CSession openExistingSession(const QString &aId) { return openSession(aId, KLockType_Shared); }
464 /** @} */
465
466 /** @name COM: Virtual Media stuff.
467 * @{ */
468 /** Returns medium formats which are currently supported by VirtualBox for the given @a enmDeviceType. */
469 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
470 /** Returns which hard disk formats are currently supported by VirtualBox. */
471 static QList <QPair <QString, QString> > HDDBackends();
472 /** Returns which optical disk formats are currently supported by VirtualBox. */
473 static QList <QPair <QString, QString> > DVDBackends();
474 /** Returns which floppy disk formats are currently supported by VirtualBox. */
475 static QList <QPair <QString, QString> > FloppyBackends();
476
477 /** Starts medium enumeration. */
478 void startMediumEnumeration();
479 /** Returns whether medium enumeration is in progress. */
480 bool isMediumEnumerationInProgress() const;
481 /** Returns enumerated medium with certain @a strMediumID. */
482 UIMedium medium(const QString &strMediumID) const;
483 /** Returns enumerated medium IDs. */
484 QList<QString> mediumIDs() const;
485 /** Creates medium on the basis of passed @a guiMedium description. */
486 void createMedium(const UIMedium &medium);
487 /** Deletes medium with certain @a strMediumID. */
488 void deleteMedium(const QString &strMediumID);
489
490 /** Opens external medium by passed @a strMediumLocation.
491 * @param enmMediumType Brings the medium type.
492 * @param pParent Brings the dialog parent.
493 * @param strMediumLocation Brings the file path to load medium from.
494 * @param pParent Brings the dialog parent. */
495 QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);
496
497 /** Opens external medium using file-open dialog.
498 * @param enmMediumType Brings the medium type.
499 * @param pParent Brings the dialog parent.
500 * @param strDefaultFolder Brings the folder to browse for medium.
501 * @param fUseLastFolder Brings whether we should propose to use last used folder. */
502 QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0,
503 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
504
505 /** Creates a VISO using the file-open dialog.
506 * @param pParent Brings the dialog parent.
507 * @param strFolder Brings the folder to browse for VISO file contents. */
508 QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder);
509
510 /** Prepares storage menu according passed parameters.
511 * @param menu Brings the #QMenu to be prepared.
512 * @param pListener Brings the listener #QObject, this @a menu being prepared for.
513 * @param pszSlotName Brings the name of the SLOT in the @a pListener above, this menu will be handled with.
514 * @param machine Brings the #CMachine object, this @a menu being prepared for.
515 * @param strControllerName Brings the name of the #CStorageController in the @a machine above.
516 * @param storageSlot Brings the #StorageSlot of the storage controller with @a strControllerName above. */
517 void prepareStorageMenu(QMenu &menu,
518 QObject *pListener, const char *pszSlotName,
519 const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot);
520 /** Updates @a comConstMachine storage with data described by @a target. */
521 void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target);
522
523 /** Generates details for passed @a comMedium.
524 * @param fPredictDiff Brings whether medium will be marked differencing on attaching.
525 * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */
526 QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true);
527 /** @} */
528
529 /** @name COM: USB stuff.
530 * @{ */
531#ifdef RT_OS_LINUX
532 /** Verifies that USB drivers are properly configured on Linux. */
533 static void checkForWrongUSBMounted();
534#endif /* RT_OS_LINUX */
535
536 /** Generates details for passed USB @a comDevice. */
537 QString details (const CUSBDevice &aDevice) const;
538 /** Generates tool-tip for passed USB @a comDevice. */
539 QString toolTip (const CUSBDevice &aDevice) const;
540 /** Generates tool-tip for passed USB @a comFilter. */
541 QString toolTip (const CUSBDeviceFilter &aFilter) const;
542 /** Generates tool-tip for passed USB @a comWebcam. */
543 QString toolTip(const CHostVideoInputDevice &webcam) const;
544 /** @} */
545
546 /** @name COM: Extension Pack stuff.
547 * @{ */
548 /** Initiates the extension pack installation process.
549 * @param strFilePath Brings the extension pack file path.
550 * @param strDigest Brings the extension pack file digest.
551 * @param pParent Brings the parent dialog reference.
552 * @param pstrExtPackName Brings the extension pack name. */
553 static void doExtPackInstallation(QString const &strFilePath,
554 QString const &strDigest,
555 QWidget *pParent,
556 QString *pstrExtPackName);
557
558 /** @todo remove */
559 bool isEPInstallationRequested() const { return m_fEPInstallationRequested; }
560 /** @todo remove */
561 void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; }
562 /** @} */
563
564 /** @name Display stuff.
565 * @{ */
566 /** Inner worker for lazily querying for 3D support. */
567 bool is3DAvailableWorker() const;
568 /** Returns whether 3D is available, runs worker above if necessary. */
569 bool is3DAvailable() const;
570
571#ifdef VBOX_WITH_CRHGSMI
572 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
573 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
574#endif /* VBOX_WITH_CRHGSMI */
575 /** Returns the required video memory in bytes for the current desktop
576 * resolution at maximum possible screen depth in bpp. */
577 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
578 /** @} */
579
580 /** @name Thread stuff.
581 * @{ */
582 /** Returns the thread-pool instance. */
583 UIThreadPool* threadPool() const { return m_pThreadPool; }
584 /** @} */
585
586 /** @name Icon/Pixmap stuff.
587 * @{ */
588 /** Returns icon defined for a passed @a comMachine. */
589 QIcon vmUserIcon(const CMachine &comMachine) const;
590 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
591 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
592 /** Returns pixmap defined for a passed @a comMachine.
593 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
594 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
595
596 /** Returns pixmap corresponding to passed @a strOSTypeID. */
597 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
598 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
599 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
600 /** Returns pixmap corresponding to passed @a strOSTypeID.
601 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
602 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
603
604 /** Returns default icon of certain @a enmType. */
605 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }
606 /** Returns file icon fetched from passed file @a info. */
607 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }
608
609 /** Returns cached default warning pixmap. */
610 QPixmap warningIcon() const { return mWarningIcon; }
611 /** Returns cached default error pixmap. */
612 QPixmap errorIcon() const { return mErrorIcon; }
613
614 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */
615 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
616 /** @} */
617
618public slots:
619
620 /** @name Process arguments stuff.
621 * @{ */
622 /** Opens the specified URL using OS/Desktop capabilities. */
623 bool openURL (const QString &aURL);
624 /** @} */
625
626 /** @name Localization stuff.
627 * @{ */
628 /** Handles language change to new @a strLanguage. */
629 void sltGUILanguageChange(QString strLang);
630 /** @} */
631
632protected:
633
634 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
635 bool eventFilter (QObject *, QEvent *);
636
637 /** Handles translation event. */
638 void retranslateUi();
639
640protected slots:
641
642 /** Prepares all. */
643 void prepare();
644 /** Cleanups all. */
645 void cleanup();
646
647 /** @name Common stuff.
648 * @{ */
649 /** Handles @a manager request for emergency session shutdown. */
650 void sltHandleCommitDataRequest(QSessionManager &manager);
651 /** @} */
652
653 /** @name COM stuff.
654 * @{ */
655 /** Handles the VBoxSVC availability change. */
656 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
657 /** @} */
658
659private:
660
661#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
662 /** Construcs global VirtualBox object. */
663 VBoxGlobal();
664#else
665 /** Construcs global VirtualBox object of passed @a enmType. */
666 VBoxGlobal(UIType enmType);
667#endif
668
669 /** Destrucs global VirtualBox object. */
670 virtual ~VBoxGlobal() /* override */;
671
672 /** @name Common stuff.
673 * @{ */
674#ifdef VBOX_WS_WIN
675 /** Wraps WinAPI ShutdownBlockReasonCreate function. */
676 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
677#endif
678 /** @} */
679
680 /** @name Process arguments stuff.
681 * @{ */
682#ifdef VBOX_WITH_DEBUGGER_GUI
683 /** Initializes a debugger config variable.
684 * @param piDbgCfgVar Brings the debugger config variable to init.
685 * @param pszEnvVar Brings the environment variable name relating to this variable.
686 * @param pszExtraDataName Brings the extra data name relating to this variable.
687 * @param fDefault Brings the default value. */
688 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
689 /** Set a debugger config variable according according to start up argument.
690 * @param piDbgCfgVar Brings the debugger config variable to set.
691 * @param fState Brings the value from the command line. */
692 void setDebuggerVar(int *piDbgCfgVar, bool fState);
693 /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
694 * @param piDbgCfgVar Brings the debugger config variable to consult.
695 * @param pszExtraDataName Brings the extra data name relating to this variable. */
696 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
697#endif
698 /** @} */
699
700 /** @name COM stuff.
701 * @{ */
702 /** Re-initializes COM wrappers and containers. */
703 void comWrappersReinit();
704 /** @} */
705
706 /** Holds the singleton VBoxGlobal instance. */
707 static VBoxGlobal *s_pInstance;
708
709 /** @name Common stuff.
710 * @{ */
711 /** Holds whether VBoxGlobal cleanup is in progress. */
712 static bool s_fCleanupInProgress;
713
714 /** Holds the currently loaded language ID. */
715 static QString s_strLoadedLanguageId;
716
717#ifdef VBOX_GUI_WITH_SHARED_LIBRARY
718 /** Holds the UI type. */
719 UIType m_enmType;
720#endif
721
722 /** Holds whether VBoxGlobal instance is properly initialized. */
723 bool mValid;
724
725#ifdef VBOX_WS_MAC
726 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */
727 MacOSXRelease m_osRelease;
728#endif /* VBOX_WS_MAC */
729
730#ifdef VBOX_WS_X11
731 /** X11: Holds the #X11WMType of the Window Manager we are running under. */
732 X11WMType m_enmWindowManagerType;
733 /** X11: Holds whether the Window Manager we are running at is composition one. */
734 bool m_fCompositingManagerRunning;
735#endif /* VBOX_WS_X11 */
736
737 /** Holds the VBox branding config file path. */
738 QString mBrandingConfig;
739 /** @} */
740
741 /** @name Process arguments stuff.
742 * @{ */
743 /** Holds the URL arguments list. */
744 QList<QUrl> m_ArgUrlList;
745
746 /** Holds the --startvm option value (managed VM id). */
747 QString vmUuid;
748 /** Holds the --separate option value (whether GUI process is separate from VM process). */
749 bool m_fSeparateProcess;
750 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
751 bool mShowStartVMErrors;
752
753 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
754 bool mAgressiveCaching;
755
756 /** Holds the --restore-current option value. */
757 bool mRestoreCurrentSnapshot;
758
759 /** Holds the --fda option value (floppy image). */
760 QString m_strFloppyImage;
761 /** Holds the --dvd | --cdrom option value (DVD image). */
762 QString m_strDvdImage;
763
764 /** Holds the --disable-patm option value. */
765 bool mDisablePatm;
766 /** Holds the --disable-csam option value. */
767 bool mDisableCsam;
768 /** Holds the --recompile-supervisor option value. */
769 bool mRecompileSupervisor;
770 /** Holds the --recompile-user option value. */
771 bool mRecompileUser;
772 /** Holds the --execute-all-in-iem option value. */
773 bool mExecuteAllInIem;
774 /** Holds the --warp-factor option value. */
775 uint32_t mWarpPct;
776
777#ifdef VBOX_WITH_DEBUGGER_GUI
778 /** Holds whether the debugger should be accessible. */
779 mutable int m_fDbgEnabled;
780 /** Holds whether to show the debugger automatically with the console. */
781 mutable int m_fDbgAutoShow;
782 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
783 mutable int m_fDbgAutoShowCommandLine;
784 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
785 mutable int m_fDbgAutoShowStatistics;
786 /** VBoxDbg module handle. */
787 RTLDRMOD m_hVBoxDbg;
788
789 /** Holds whether --start-running, --start-paused or nothing was given. */
790 enum StartRunning m_enmStartRunning;
791#endif
792
793 /** Holds the --settingspw option value. */
794 char mSettingsPw[256];
795 /** Holds the --settingspwfile option value. */
796 bool mSettingsPwSet;
797
798#ifdef VBOX_GUI_WITH_PIDFILE
799 /** Holds the --pidfile option value (application PID file path). */
800 QString m_strPidfile;
801#endif
802
803 /** @todo remove */
804 QString mUserDefinedPortName;
805 /** @} */
806
807 /** @name COM stuff.
808 * @{ */
809 /** Holds the COM cleanup protection token. */
810 QReadWriteLock m_comCleanupProtectionToken;
811
812 /** Holds the instance of VirtualBox client wrapper. */
813 CVirtualBoxClient m_client;
814 /** Holds the copy of VirtualBox object wrapper. */
815 CVirtualBox m_vbox;
816 /** Holds the copy of VirtualBox host-object wrapper. */
817 CHost m_host;
818 /** Holds the symbolic VirtualBox home-folder representation. */
819 QString m_strHomeFolder;
820
821 /** Holds whether acquired COM wrappers are currently valid. */
822 bool m_fWrappersValid;
823 /** Holds whether VBoxSVC is currently available. */
824 bool m_fVBoxSVCAvailable;
825
826 /** Holds the guest OS family IDs. */
827 QList<QString> m_guestOSFamilyIDs;
828 /** Holds the guest OS types for each family ID. */
829 QList<QList<CGuestOSType> > m_guestOSTypes;
830 /** @} */
831
832 /** @name Display stuff.
833 * @{ */
834 /** Holds whether 3D is available. */
835 int m3DAvailable;
836 /** @} */
837
838 /** @name Thread stuff.
839 * @{ */
840 /** Holds the thread-pool instance. */
841 UIThreadPool *m_pThreadPool;
842 /** @} */
843
844 /** @name Icon/Pixmap stuff.
845 * @{ */
846 /** Holds the general icon-pool instance. */
847 UIIconPoolGeneral *m_pIconPool;
848
849 /** Holds the global file icon provider instance. */
850 QFileIconProvider m_globalIconProvider;
851
852 /** Holds the warning pixmap. */
853 QPixmap mWarningIcon;
854 /** Holds the error pixmap. */
855 QPixmap mErrorIcon;
856 /** @} */
857
858 /** @name Media related stuff.
859 * @{ */
860 /** Holds the medium enumerator cleanup protection token. */
861 mutable QReadWriteLock m_mediumEnumeratorDtorRwLock;
862
863 /** Holds the medium enumerator. */
864 UIMediumEnumerator *m_pMediumEnumerator;
865 /** @} */
866
867 /** @todo remove */
868 bool m_fEPInstallationRequested;
869
870#if defined(VBOX_WS_WIN) && defined(VBOX_GUI_WITH_SHARED_LIBRARY)
871 /** @name ATL stuff.
872 * @{ */
873 /** Holds the ATL module instance (for use with VBoxGlobal shared library only).
874 * @note Required internally by ATL (constructor records instance in global variable). */
875 ATL::CComModule _Module;
876 /** @} */
877#endif
878
879 /** Allows for shortcut access. */
880 friend VBoxGlobal &vboxGlobal();
881};
882
883/** Singleton VBoxGlobal 'official' name. */
884inline VBoxGlobal &vboxGlobal() { return *VBoxGlobal::instance(); }
885
886#endif /* !___VBoxGlobal_h___ */
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