VirtualBox

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

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

FE/Qt: bugref:9049: Huge overhaul for VBoxGlobal class: Full code refactoring according to coding-style and latest achievements.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.9 KB
Line 
1/* $Id: VBoxGlobal.h 72628 2018-06-20 13:57:27Z 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 LaunchRunning
125 {
126 LaunchRunning_Default, /**< Default (depends on debug settings). */
127 LaunchRunning_No, /**< Start the VM paused. */
128 LaunchRunning_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 static bool isCleaningUp() { return s_fCleaningUp; }
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() const { return m_fValid; }
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_enmMacOSVersion; }
172#endif
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
180
181 /** Returns whether branding is active. */
182 bool brandingIsActive(bool fForce = false);
183 /** Returns value for certain branding @a strKey from custom.ini file. */
184 QString brandingGetKey(QString strKey);
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_listArgUrls; }
197
198 /** Returns the --startvm option value (managed VM id). */
199 QString managedVMUuid() const { return m_strManagedVMId; }
200 /** Returns whether this is VM console process. */
201 bool isVMConsoleProcess() const { return !m_strManagedVMId.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 m_fShowStartVMErrors; }
206
207 /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
208 bool agressiveCaching() const { return m_fAgressiveCaching; }
209
210 /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */
211 bool shouldRestoreCurrentSnapshot() const { return m_fRestoreCurrentSnapshot; }
212 /** Defines whether we should fRestore current snapshot before VM started. */
213 void setShouldRestoreCurrentSnapshot(bool fRestore) { m_fRestoreCurrentSnapshot = 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 m_fDisablePatm; }
226 /** Returns the --disable-csam option value. */
227 bool isCsamDisabled() const { return m_fDisableCsam; }
228 /** Returns the --recompile-supervisor option value. */
229 bool isSupervisorCodeExecedRecompiled() const { return m_fRecompileSupervisor; }
230 /** Returns the --recompile-user option value. */
231 bool isUserCodeExecedRecompiled() const { return m_fRecompileUser; }
232 /** Returns the --execute-all-in-iem option value. */
233 bool areWeToExecuteAllInIem() const { return m_fExecuteAllInIem; }
234 /** Returns whether --warp-factor option value is equal to 100. */
235 bool isDefaultWarpPct() const { return m_uWarpPct == 100; }
236 /** Returns the --warp-factor option value. */
237 uint32_t getWarpPct() const { return m_uWarpPct; }
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
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 static QString languageName();
268 /** Native language country name of the currently installed translation. */
269 static QString languageCountry();
270 /** Language name of the currently installed translation, in English. */
271 static QString languageNameEnglish();
272 /** Language country name of the currently installed translation, in English. */
273 static QString languageCountryEnglish();
274 /** Comma-separated list of authors of the currently installed translation. */
275 static QString languageTranslators();
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 &strLangId = QString());
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 &strText);
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 uSize, uint cDecimal = 2, FormatSize enmMode = 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 static QStringList COMPortNames();
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 static QString toCOMPortName(ulong uIRQ, ulong uIOBase);
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 static bool toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase);
334 /** Returns the list of the standard LPT port names (i.e. "LPTx"). */
335 static QStringList LPTPortNames();
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 static QString toLPTPortName(ulong uIRQ, ulong uIOBase);
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 static bool toLPTPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase);
342
343 /** Reformats the input @a strText to highlight it. */
344 static QString highlight(QString strText, bool fToolTip = false);
345 /** Reformats the input @a strText to emphasize it. */
346 static QString emphasize(QString strText);
347 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */
348 static QString removeAccelMark(QString strText);
349 /** Inserts a passed @a strKey into action @a strText. */
350 static QString insertKeyToActionText (const QString &strText, const QString &strKey);
351 /** @} */
352
353 /** @name File-system stuff.
354 * @{ */
355 /** Returns full help file name. */
356 static QString helpFile();
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 &rectangle, const QRegion &boundRegion,
366 bool fCanResize = true);
367 /** Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion. */
368 static QRect getNormalized(const QRect &rectangle, const QRegion &boundRegion,
369 bool fCanResize = true);
370 /** Returns the flipped (transposed) @a region. */
371 static QRegion flip(const QRegion &region);
372
373 /** Aligns the center of @a pWidget with the center of @a pRelative. */
374 static void centerWidget(QWidget *pWidget, QWidget *pRelative, bool fCanResize = true);
375
376 /** Assigns top-level @a pWidget geometry passed as QRect coordinates.
377 * @note Take into account that this request may fail on X11. */
378 static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h);
379 /** Assigns top-level @a pWidget geometry passed as @a rect.
380 * @note Take into account that this request may fail on X11. */
381 static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
382
383 /** Activates the specified window with given @a wId. Can @a fSwitchDesktop if requested. */
384 static bool activateWindow(WId wId, bool fSwitchDesktop = true);
385
386#ifdef VBOX_WS_X11
387 /** X11: Test whether the current window manager supports full screen mode. */
388 static bool supportsFullScreenMonitorsProtocolX11();
389 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */
390 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);
391
392 /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */
393 static QVector<Atom> flagsNetWmState(QWidget *pWidget);
394 /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */
395 static bool isFullScreenFlagSet(QWidget *pWidget);
396 /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */
397 static void setFullScreenFlag(QWidget *pWidget);
398 /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */
399 static void setSkipTaskBarFlag(QWidget *pWidget);
400 /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */
401 static void setSkipPagerFlag(QWidget *pWidget);
402
403 /** Assigns WM_CLASS property for passed @a pWidget. */
404 static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
405#endif /* VBOX_WS_X11 */
406
407 /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */
408 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
409 /** @} */
410
411 /** @name COM stuff.
412 * @{ */
413 /** Try to acquire COM cleanup protection token for reading. */
414 bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
415 /** Unlock previously acquired COM cleanup protection token. */
416 void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
417
418 /** Returns the copy of VirtualBox client wrapper. */
419 CVirtualBoxClient virtualBoxClient() const { return m_comVBoxClient; }
420 /** Returns the copy of VirtualBox object wrapper. */
421 CVirtualBox virtualBox() const { return m_comVBox; }
422 /** Returns the copy of VirtualBox host-object wrapper. */
423 CHost host() const { return m_comHost; }
424 /** Returns the symbolic VirtualBox home-folder representation. */
425 QString homeFolder() const { return m_strHomeFolder; }
426
427 /** Returns the VBoxSVC availability value. */
428 bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
429 /** @} */
430
431 /** @name COM: Guest OS Type.
432 * @{ */
433 /** Returns the list of few guest OS types, queried from
434 * IVirtualBox corresponding to every family id. */
435 QList<CGuestOSType> vmGuestOSFamilyList() const;
436 /** Returns the list of all guest OS types, queried from
437 * IVirtualBox corresponding to passed family id. */
438 QList<CGuestOSType> vmGuestOSTypeList(const QString &strFamilyId) const;
439
440 /** Returns the guest OS type object corresponding to the given type id of list
441 * containing OS types related to OS family determined by family id attribute.
442 * If the index is invalid a null object is returned. */
443 CGuestOSType vmGuestOSType(const QString &strTypeId, const QString &strFamilyId = QString()) const;
444 /** Returns the description corresponding to the given guest OS type id. */
445 QString vmGuestOSTypeDescription(const QString &strTypeId) const;
446
447 /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */
448 static bool isDOSType(const QString &strOSTypeId);
449 /** @} */
450
451 /** @name COM: Virtual Machine stuff.
452 * @{ */
453 /** Switches to certain @a comMachine. */
454 static bool switchToMachine(CMachine &comMachine);
455 /** Launches certain @a comMachine in specified @a enmLaunchMode. */
456 bool launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode = LaunchMode_Default);
457
458 /** Opens session of certain @a enmLockType for VM with certain @a strId. */
459 CSession openSession(const QString &strId, KLockType enmLockType = KLockType_Write);
460 /** Opens session of KLockType_Shared type for VM with certain @a strId. */
461 CSession openExistingSession(const QString &strId) { return openSession(strId, KLockType_Shared); }
462 /** @} */
463
464 /** @name COM: Virtual Media stuff.
465 * @{ */
466 /** Returns medium formats which are currently supported by VirtualBox for the given @a enmDeviceType. */
467 QList<QPair<QString, QString> > MediumBackends(KDeviceType enmDeviceType) const;
468 /** Returns which hard disk formats are currently supported by VirtualBox. */
469 QList<QPair<QString, QString> > HDDBackends() const;
470 /** Returns which optical disk formats are currently supported by VirtualBox. */
471 QList<QPair<QString, QString> > DVDBackends() const;
472 /** Returns which floppy disk formats are currently supported by VirtualBox. */
473 QList<QPair<QString, QString> > FloppyBackends() const;
474
475 /** Starts medium enumeration. */
476 void startMediumEnumeration();
477 /** Returns whether medium enumeration is in progress. */
478 bool isMediumEnumerationInProgress() const;
479 /** Returns enumerated medium with certain @a strMediumID. */
480 UIMedium medium(const QString &strMediumID) const;
481 /** Returns enumerated medium IDs. */
482 QList<QString> mediumIDs() const;
483 /** Creates medium on the basis of passed @a guiMedium description. */
484 void createMedium(const UIMedium &guiMedium);
485 /** Deletes medium with certain @a strMediumID. */
486 void deleteMedium(const QString &strMediumID);
487
488 /** Opens external medium by passed @a strMediumLocation.
489 * @param enmMediumType Brings the medium type.
490 * @param pParent Brings the dialog parent.
491 * @param strMediumLocation Brings the file path to load medium from.
492 * @param pParent Brings the dialog parent. */
493 QString openMedium(UIMediumType enmMediumType, QString strMediumLocation, QWidget *pParent = 0);
494
495 /** Opens external medium using file-open dialog.
496 * @param enmMediumType Brings the medium type.
497 * @param pParent Brings the dialog parent.
498 * @param strDefaultFolder Brings the folder to browse for medium.
499 * @param fUseLastFolder Brings whether we should propose to use last used folder. */
500 QString openMediumWithFileOpenDialog(UIMediumType enmMediumType, QWidget *pParent = 0,
501 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
502
503 /** Creates a VISO using the file-open dialog.
504 * @param pParent Brings the dialog parent.
505 * @param strFolder Brings the folder to browse for VISO file contents. */
506 QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strFolder);
507
508 /** Prepares storage menu according passed parameters.
509 * @param menu Brings the #QMenu to be prepared.
510 * @param pListener Brings the listener #QObject, this @a menu being prepared for.
511 * @param pszSlotName Brings the name of the SLOT in the @a pListener above, this menu will be handled with.
512 * @param comMachine Brings the #CMachine object, this @a menu being prepared for.
513 * @param strControllerName Brings the name of the #CStorageController in the @a machine above.
514 * @param storageSlot Brings the #StorageSlot of the storage controller with @a strControllerName above. */
515 void prepareStorageMenu(QMenu &menu,
516 QObject *pListener, const char *pszSlotName,
517 const CMachine &comMachine, const QString &strControllerName, const StorageSlot &storageSlot);
518 /** Updates @a comConstMachine storage with data described by @a target. */
519 void updateMachineStorage(const CMachine &comConstMachine, const UIMediumTarget &target);
520
521 /** Generates details for passed @a comMedium.
522 * @param fPredictDiff Brings whether medium will be marked differencing on attaching.
523 * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */
524 QString details(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml = true);
525 /** @} */
526
527 /** @name COM: USB stuff.
528 * @{ */
529#ifdef RT_OS_LINUX
530 /** Verifies that USB drivers are properly configured on Linux. */
531 static void checkForWrongUSBMounted();
532#endif
533
534 /** Generates details for passed USB @a comDevice. */
535 static QString details(const CUSBDevice &comDevice);
536 /** Generates tool-tip for passed USB @a comDevice. */
537 static QString toolTip(const CUSBDevice &comDevice);
538 /** Generates tool-tip for passed USB @a comFilter. */
539 static QString toolTip(const CUSBDeviceFilter &comFilter);
540 /** Generates tool-tip for passed USB @a comWebcam. */
541 static QString toolTip(const CHostVideoInputDevice &comWebcam);
542 /** @} */
543
544 /** @name COM: Extension Pack stuff.
545 * @{ */
546 /** Initiates the extension pack installation process.
547 * @param strFilePath Brings the extension pack file path.
548 * @param strDigest Brings the extension pack file digest.
549 * @param pParent Brings the parent dialog reference.
550 * @param pstrExtPackName Brings the extension pack name. */
551 void doExtPackInstallation(QString const &strFilePath,
552 QString const &strDigest,
553 QWidget *pParent,
554 QString *pstrExtPackName) const;
555 /** @} */
556
557 /** @name Display stuff.
558 * @{ */
559 /** Inner worker for lazily querying for 3D support. */
560 bool is3DAvailableWorker() const;
561 /** Returns whether 3D is available, runs worker above if necessary. */
562 bool is3DAvailable() const;
563
564#ifdef VBOX_WITH_CRHGSMI
565 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
566 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
567#endif
568 /** Returns the required video memory in bytes for the current desktop
569 * resolution at maximum possible screen depth in bpp. */
570 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
571 /** @} */
572
573 /** @name Thread stuff.
574 * @{ */
575 /** Returns the thread-pool instance. */
576 UIThreadPool *threadPool() const { return m_pThreadPool; }
577 /** @} */
578
579 /** @name Icon/Pixmap stuff.
580 * @{ */
581 /** Returns icon defined for a passed @a comMachine. */
582 QIcon vmUserIcon(const CMachine &comMachine) const;
583 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
584 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
585 /** Returns pixmap defined for a passed @a comMachine.
586 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
587 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
588
589 /** Returns pixmap corresponding to passed @a strOSTypeID. */
590 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
591 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
592 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
593 /** Returns pixmap corresponding to passed @a strOSTypeID.
594 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
595 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
596
597 /** Returns default icon of certain @a enmType. */
598 QIcon icon(QFileIconProvider::IconType enmType) { return m_fileIconProvider.icon(enmType); }
599 /** Returns file icon fetched from passed file @a info. */
600 QIcon icon(const QFileInfo &info) { return m_fileIconProvider.icon(info); }
601
602 /** Returns cached default warning pixmap. */
603 QPixmap warningIcon() const { return m_pixWarning; }
604 /** Returns cached default error pixmap. */
605 QPixmap errorIcon() const { return m_pixError; }
606
607 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */
608 static QPixmap joinPixmaps(const QPixmap &pixmap1, const QPixmap &pixmap2);
609 /** @} */
610
611public slots:
612
613 /** @name Process arguments stuff.
614 * @{ */
615 /** Opens the specified URL using OS/Desktop capabilities. */
616 bool openURL(const QString &strURL) const;
617 /** @} */
618
619 /** @name Localization stuff.
620 * @{ */
621 /** Handles language change to new @a strLanguage. */
622 void sltGUILanguageChange(QString strLanguage);
623 /** @} */
624
625protected:
626
627 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
628 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
629
630 /** Handles translation event. */
631 virtual void retranslateUi() /* override */;
632
633protected slots:
634
635 /** Prepares all. */
636 void prepare();
637 /** Cleanups all. */
638 void cleanup();
639
640 /** @name Common stuff.
641 * @{ */
642 /** Handles @a manager request for emergency session shutdown. */
643 void sltHandleCommitDataRequest(QSessionManager &manager);
644 /** @} */
645
646 /** @name COM stuff.
647 * @{ */
648 /** Handles the VBoxSVC availability change. */
649 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
650 /** @} */
651
652private:
653
654#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
655 /** Construcs global VirtualBox object. */
656 VBoxGlobal();
657#else
658 /** Construcs global VirtualBox object of passed @a enmType. */
659 VBoxGlobal(UIType enmType);
660#endif
661
662 /** Destrucs global VirtualBox object. */
663 virtual ~VBoxGlobal() /* override */;
664
665 /** @name Common stuff.
666 * @{ */
667#ifdef VBOX_WS_WIN
668 /** Wraps WinAPI ShutdownBlockReasonCreate function. */
669 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
670#endif
671 /** @} */
672
673 /** @name Process arguments stuff.
674 * @{ */
675#ifdef VBOX_WITH_DEBUGGER_GUI
676 /** Initializes a debugger config variable.
677 * @param piDbgCfgVar Brings the debugger config variable to init.
678 * @param pszEnvVar Brings the environment variable name relating to this variable.
679 * @param pszExtraDataName Brings the extra data name relating to this variable.
680 * @param fDefault Brings the default value. */
681 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
682 /** Set a debugger config variable according according to start up argument.
683 * @param piDbgCfgVar Brings the debugger config variable to set.
684 * @param fState Brings the value from the command line. */
685 void setDebuggerVar(int *piDbgCfgVar, bool fState);
686 /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
687 * @param piDbgCfgVar Brings the debugger config variable to consult.
688 * @param pszExtraDataName Brings the extra data name relating to this variable. */
689 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
690#endif
691 /** @} */
692
693 /** @name COM stuff.
694 * @{ */
695 /** Re-initializes COM wrappers and containers. */
696 void comWrappersReinit();
697 /** @} */
698
699 /** Holds the singleton VBoxGlobal instance. */
700 static VBoxGlobal *s_pInstance;
701
702 /** @name Common stuff.
703 * @{ */
704 /** Holds whether VBoxGlobal cleanup is in progress. */
705 static bool s_fCleaningUp;
706
707 /** Holds the currently loaded language ID. */
708 static QString s_strLoadedLanguageId;
709
710 /** Holds the tr("User Defined") port name. */
711 static QString s_strUserDefinedPortName;
712
713#ifdef VBOX_GUI_WITH_SHARED_LIBRARY
714 /** Holds the UI type. */
715 UIType m_enmType;
716#endif
717
718 /** Holds whether VBoxGlobal instance is properly initialized. */
719 bool m_fValid;
720
721#ifdef VBOX_WS_MAC
722 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */
723 MacOSXRelease m_enmMacOSVersion;
724#endif
725
726#ifdef VBOX_WS_X11
727 /** X11: Holds the #X11WMType of the Window Manager we are running under. */
728 X11WMType m_enmWindowManagerType;
729 /** X11: Holds whether the Window Manager we are running at is composition one. */
730 bool m_fCompositingManagerRunning;
731#endif
732
733 /** Holds the VBox branding config file path. */
734 QString m_strBrandingConfigFilePath;
735 /** @} */
736
737 /** @name Process arguments stuff.
738 * @{ */
739 /** Holds the URL arguments list. */
740 QList<QUrl> m_listArgUrls;
741
742 /** Holds the --startvm option value (managed VM id). */
743 QString m_strManagedVMId;
744 /** Holds the --separate option value (whether GUI process is separate from VM process). */
745 bool m_fSeparateProcess;
746 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
747 bool m_fShowStartVMErrors;
748
749 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
750 bool m_fAgressiveCaching;
751
752 /** Holds the --restore-current option value. */
753 bool m_fRestoreCurrentSnapshot;
754
755 /** Holds the --fda option value (floppy image). */
756 QString m_strFloppyImage;
757 /** Holds the --dvd | --cdrom option value (DVD image). */
758 QString m_strDvdImage;
759
760 /** Holds the --disable-patm option value. */
761 bool m_fDisablePatm;
762 /** Holds the --disable-csam option value. */
763 bool m_fDisableCsam;
764 /** Holds the --recompile-supervisor option value. */
765 bool m_fRecompileSupervisor;
766 /** Holds the --recompile-user option value. */
767 bool m_fRecompileUser;
768 /** Holds the --execute-all-in-iem option value. */
769 bool m_fExecuteAllInIem;
770 /** Holds the --warp-factor option value. */
771 uint32_t m_uWarpPct;
772
773#ifdef VBOX_WITH_DEBUGGER_GUI
774 /** Holds whether the debugger should be accessible. */
775 mutable int m_fDbgEnabled;
776 /** Holds whether to show the debugger automatically with the console. */
777 mutable int m_fDbgAutoShow;
778 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
779 mutable int m_fDbgAutoShowCommandLine;
780 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
781 mutable int m_fDbgAutoShowStatistics;
782 /** VBoxDbg module handle. */
783 RTLDRMOD m_hVBoxDbg;
784
785 /** Holds whether --start-running, --start-paused or nothing was given. */
786 enum LaunchRunning m_enmLaunchRunning;
787#endif
788
789 /** Holds the --settingspw option value. */
790 char m_astrSettingsPw[256];
791 /** Holds the --settingspwfile option value. */
792 bool m_fSettingsPwSet;
793
794#ifdef VBOX_GUI_WITH_PIDFILE
795 /** Holds the --pidfile option value (application PID file path). */
796 QString m_strPidFile;
797#endif
798 /** @} */
799
800 /** @name COM stuff.
801 * @{ */
802 /** Holds the COM cleanup protection token. */
803 QReadWriteLock m_comCleanupProtectionToken;
804
805 /** Holds the instance of VirtualBox client wrapper. */
806 CVirtualBoxClient m_comVBoxClient;
807 /** Holds the copy of VirtualBox object wrapper. */
808 CVirtualBox m_comVBox;
809 /** Holds the copy of VirtualBox host-object wrapper. */
810 CHost m_comHost;
811 /** Holds the symbolic VirtualBox home-folder representation. */
812 QString m_strHomeFolder;
813
814 /** Holds whether acquired COM wrappers are currently valid. */
815 bool m_fWrappersValid;
816 /** Holds whether VBoxSVC is currently available. */
817 bool m_fVBoxSVCAvailable;
818
819 /** Holds the guest OS family IDs. */
820 QList<QString> m_guestOSFamilyIDs;
821 /** Holds the guest OS types for each family ID. */
822 QList<QList<CGuestOSType> > m_guestOSTypes;
823 /** @} */
824
825 /** @name Display stuff.
826 * @{ */
827 /** Holds whether 3D is available. */
828 mutable int m_i3DAvailable;
829 /** @} */
830
831 /** @name Thread stuff.
832 * @{ */
833 /** Holds the thread-pool instance. */
834 UIThreadPool *m_pThreadPool;
835 /** @} */
836
837 /** @name Icon/Pixmap stuff.
838 * @{ */
839 /** Holds the general icon-pool instance. */
840 UIIconPoolGeneral *m_pIconPool;
841
842 /** Holds the global file icon provider instance. */
843 QFileIconProvider m_fileIconProvider;
844
845 /** Holds the warning pixmap. */
846 QPixmap m_pixWarning;
847 /** Holds the error pixmap. */
848 QPixmap m_pixError;
849 /** @} */
850
851 /** @name Media related stuff.
852 * @{ */
853 /** Holds the medium enumerator cleanup protection token. */
854 mutable QReadWriteLock m_meCleanupProtectionToken;
855
856 /** Holds the medium enumerator. */
857 UIMediumEnumerator *m_pMediumEnumerator;
858 /** @} */
859
860#if defined(VBOX_WS_WIN) && defined(VBOX_GUI_WITH_SHARED_LIBRARY)
861 /** @name ATL stuff.
862 * @{ */
863 /** Holds the ATL module instance (for use with VBoxGlobal shared library only).
864 * @note Required internally by ATL (constructor records instance in global variable). */
865 ATL::CComModule _Module;
866 /** @} */
867#endif
868
869 /** Allows for shortcut access. */
870 friend VBoxGlobal &vboxGlobal();
871};
872
873/** Singleton VBoxGlobal 'official' name. */
874inline VBoxGlobal &vboxGlobal() { return *VBoxGlobal::instance(); }
875
876#endif /* !___VBoxGlobal_h___ */
Note: See TracBrowser for help on using the repository browser.

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