VirtualBox

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

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

FE/Qt: bugref:9049: Huge overhaul for VBoxGlobal class: Code renaming according to coding-style.

  • 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 72626 2018-06-20 13:28:15Z 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 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() { 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 /* 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 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 /* 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 &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 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 uIRQ, ulong uIOBase) 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 &strName, ulong &uIRQ, ulong &uIOBase) 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 uIRQ, ulong uIOBase) 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 &strName, ulong &uIRQ, ulong &uIOBase) const;
342
343 /** Reformats the input @a strText to highlight it. */
344 static QString highlight (const QString &strText, bool fToolTip = false);
345 /** Reformats the input @a strText to emphasize it. */
346 static QString emphasize (const QString &strText);
347 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */
348 static QString removeAccelMark (const 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 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 &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,
375 bool fCanResize = 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 wId, bool fSwitchDesktop = 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_comVBoxClient; }
421 /** Returns the copy of VirtualBox object wrapper. */
422 CVirtualBox virtualBox() const { return m_comVBox; }
423 /** Returns the copy of VirtualBox host-object wrapper. */
424 CHost host() const { return m_comHost; }
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 &strFamilyId) 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 &strTypeId,
445 const QString &strFamilyId = QString()) const;
446 /** Returns the description corresponding to the given guest OS type id. */
447 QString vmGuestOSTypeDescription (const QString &strTypeId) const;
448
449 /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */
450 static bool isDOSType (const QString &strOSTypeId);
451 /** @} */
452
453 /** @name COM: Virtual Machine stuff.
454 * @{ */
455 /** Switches to certain @a comMachine. */
456 bool switchToMachine(CMachine &comMachine);
457 /** Launches certain @a comMachine in specified @a enmLaunchMode. */
458 bool launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode = LaunchMode_Default);
459
460 /** Opens session of certain @a enmLockType for VM with certain @a strId. */
461 CSession openSession(const QString &strId, KLockType enmLockType = KLockType_Write);
462 /** Opens session of KLockType_Shared type for VM with certain @a strId. */
463 CSession openExistingSession(const QString &strId) { return openSession(strId, 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 &guiMedium);
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 enmMediumType, 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 enmMediumType, 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 &strFolder);
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 comMachine 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 &comMachine, const QString &strControllerName, const StorageSlot &storageSlot);
520 /** Updates @a comConstMachine storage with data described by @a target. */
521 void updateMachineStorage(const CMachine &comConstMachine, 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 &comMedium, 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 &comDevice) const;
538 /** Generates tool-tip for passed USB @a comDevice. */
539 QString toolTip(const CUSBDevice &comDevice) const;
540 /** Generates tool-tip for passed USB @a comFilter. */
541 QString toolTip(const CUSBDeviceFilter &comFilter) const;
542 /** Generates tool-tip for passed USB @a comWebcam. */
543 QString toolTip(const CHostVideoInputDevice &comWebcam) 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
559 /** @name Display stuff.
560 * @{ */
561 /** Inner worker for lazily querying for 3D support. */
562 bool is3DAvailableWorker() const;
563 /** Returns whether 3D is available, runs worker above if necessary. */
564 bool is3DAvailable() const;
565
566#ifdef VBOX_WITH_CRHGSMI
567 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
568 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
569#endif /* VBOX_WITH_CRHGSMI */
570 /** Returns the required video memory in bytes for the current desktop
571 * resolution at maximum possible screen depth in bpp. */
572 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
573 /** @} */
574
575 /** @name Thread stuff.
576 * @{ */
577 /** Returns the thread-pool instance. */
578 UIThreadPool* threadPool() const { return m_pThreadPool; }
579 /** @} */
580
581 /** @name Icon/Pixmap stuff.
582 * @{ */
583 /** Returns icon defined for a passed @a comMachine. */
584 QIcon vmUserIcon(const CMachine &comMachine) const;
585 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
586 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
587 /** Returns pixmap defined for a passed @a comMachine.
588 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
589 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
590
591 /** Returns pixmap corresponding to passed @a strOSTypeID. */
592 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
593 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
594 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
595 /** Returns pixmap corresponding to passed @a strOSTypeID.
596 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
597 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
598
599 /** Returns default icon of certain @a enmType. */
600 QIcon icon(QFileIconProvider::IconType enmType) { return m_fileIconProvider.icon(enmType); }
601 /** Returns file icon fetched from passed file @a info. */
602 QIcon icon(const QFileInfo &info) { return m_fileIconProvider.icon(info); }
603
604 /** Returns cached default warning pixmap. */
605 QPixmap warningIcon() const { return m_pixWarning; }
606 /** Returns cached default error pixmap. */
607 QPixmap errorIcon() const { return m_pixError; }
608
609 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */
610 static QPixmap joinPixmaps (const QPixmap &pixmap1, const QPixmap &pixmap2);
611 /** @} */
612
613public slots:
614
615 /** @name Process arguments stuff.
616 * @{ */
617 /** Opens the specified URL using OS/Desktop capabilities. */
618 bool openURL (const QString &strURL);
619 /** @} */
620
621 /** @name Localization stuff.
622 * @{ */
623 /** Handles language change to new @a strLanguage. */
624 void sltGUILanguageChange(QString strLanguage);
625 /** @} */
626
627protected:
628
629 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
630 bool eventFilter (QObject *pObject, QEvent *pEvent);
631
632 /** Handles translation event. */
633 void retranslateUi();
634
635protected slots:
636
637 /** Prepares all. */
638 void prepare();
639 /** Cleanups all. */
640 void cleanup();
641
642 /** @name Common stuff.
643 * @{ */
644 /** Handles @a manager request for emergency session shutdown. */
645 void sltHandleCommitDataRequest(QSessionManager &manager);
646 /** @} */
647
648 /** @name COM stuff.
649 * @{ */
650 /** Handles the VBoxSVC availability change. */
651 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
652 /** @} */
653
654private:
655
656#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
657 /** Construcs global VirtualBox object. */
658 VBoxGlobal();
659#else
660 /** Construcs global VirtualBox object of passed @a enmType. */
661 VBoxGlobal(UIType enmType);
662#endif
663
664 /** Destrucs global VirtualBox object. */
665 virtual ~VBoxGlobal() /* override */;
666
667 /** @name Common stuff.
668 * @{ */
669#ifdef VBOX_WS_WIN
670 /** Wraps WinAPI ShutdownBlockReasonCreate function. */
671 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
672#endif
673 /** @} */
674
675 /** @name Process arguments stuff.
676 * @{ */
677#ifdef VBOX_WITH_DEBUGGER_GUI
678 /** Initializes a debugger config variable.
679 * @param piDbgCfgVar Brings the debugger config variable to init.
680 * @param pszEnvVar Brings the environment variable name relating to this variable.
681 * @param pszExtraDataName Brings the extra data name relating to this variable.
682 * @param fDefault Brings the default value. */
683 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
684 /** Set a debugger config variable according according to start up argument.
685 * @param piDbgCfgVar Brings the debugger config variable to set.
686 * @param fState Brings the value from the command line. */
687 void setDebuggerVar(int *piDbgCfgVar, bool fState);
688 /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
689 * @param piDbgCfgVar Brings the debugger config variable to consult.
690 * @param pszExtraDataName Brings the extra data name relating to this variable. */
691 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
692#endif
693 /** @} */
694
695 /** @name COM stuff.
696 * @{ */
697 /** Re-initializes COM wrappers and containers. */
698 void comWrappersReinit();
699 /** @} */
700
701 /** Holds the singleton VBoxGlobal instance. */
702 static VBoxGlobal *s_pInstance;
703
704 /** @name Common stuff.
705 * @{ */
706 /** Holds whether VBoxGlobal cleanup is in progress. */
707 static bool s_fCleaningUp;
708
709 /** Holds the currently loaded language ID. */
710 static QString s_strLoadedLanguageId;
711
712#ifdef VBOX_GUI_WITH_SHARED_LIBRARY
713 /** Holds the UI type. */
714 UIType m_enmType;
715#endif
716
717 /** Holds whether VBoxGlobal instance is properly initialized. */
718 bool m_fValid;
719
720#ifdef VBOX_WS_MAC
721 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */
722 MacOSXRelease m_enmMacOSVersion;
723#endif /* VBOX_WS_MAC */
724
725#ifdef VBOX_WS_X11
726 /** X11: Holds the #X11WMType of the Window Manager we are running under. */
727 X11WMType m_enmWindowManagerType;
728 /** X11: Holds whether the Window Manager we are running at is composition one. */
729 bool m_fCompositingManagerRunning;
730#endif /* VBOX_WS_X11 */
731
732 /** Holds the VBox branding config file path. */
733 QString m_strBrandingConfigFilePath;
734 /** @} */
735
736 /** @name Process arguments stuff.
737 * @{ */
738 /** Holds the URL arguments list. */
739 QList<QUrl> m_listArgUrls;
740
741 /** Holds the --startvm option value (managed VM id). */
742 QString m_strManagedVMId;
743 /** Holds the --separate option value (whether GUI process is separate from VM process). */
744 bool m_fSeparateProcess;
745 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
746 bool m_fShowStartVMErrors;
747
748 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
749 bool m_fAgressiveCaching;
750
751 /** Holds the --restore-current option value. */
752 bool m_fRestoreCurrentSnapshot;
753
754 /** Holds the --fda option value (floppy image). */
755 QString m_strFloppyImage;
756 /** Holds the --dvd | --cdrom option value (DVD image). */
757 QString m_strDvdImage;
758
759 /** Holds the --disable-patm option value. */
760 bool m_fDisablePatm;
761 /** Holds the --disable-csam option value. */
762 bool m_fDisableCsam;
763 /** Holds the --recompile-supervisor option value. */
764 bool m_fRecompileSupervisor;
765 /** Holds the --recompile-user option value. */
766 bool m_fRecompileUser;
767 /** Holds the --execute-all-in-iem option value. */
768 bool m_fExecuteAllInIem;
769 /** Holds the --warp-factor option value. */
770 uint32_t m_uWarpPct;
771
772#ifdef VBOX_WITH_DEBUGGER_GUI
773 /** Holds whether the debugger should be accessible. */
774 mutable int m_fDbgEnabled;
775 /** Holds whether to show the debugger automatically with the console. */
776 mutable int m_fDbgAutoShow;
777 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
778 mutable int m_fDbgAutoShowCommandLine;
779 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
780 mutable int m_fDbgAutoShowStatistics;
781 /** VBoxDbg module handle. */
782 RTLDRMOD m_hVBoxDbg;
783
784 /** Holds whether --start-running, --start-paused or nothing was given. */
785 enum LaunchRunning m_enmLaunchRunning;
786#endif
787
788 /** Holds the --settingspw option value. */
789 char m_astrSettingsPw[256];
790 /** Holds the --settingspwfile option value. */
791 bool m_fSettingsPwSet;
792
793#ifdef VBOX_GUI_WITH_PIDFILE
794 /** Holds the --pidfile option value (application PID file path). */
795 QString m_strPidFile;
796#endif
797
798 /** @todo remove */
799 QString m_strUserDefinedPortName;
800 /** @} */
801
802 /** @name COM stuff.
803 * @{ */
804 /** Holds the COM cleanup protection token. */
805 QReadWriteLock m_comCleanupProtectionToken;
806
807 /** Holds the instance of VirtualBox client wrapper. */
808 CVirtualBoxClient m_comVBoxClient;
809 /** Holds the copy of VirtualBox object wrapper. */
810 CVirtualBox m_comVBox;
811 /** Holds the copy of VirtualBox host-object wrapper. */
812 CHost m_comHost;
813 /** Holds the symbolic VirtualBox home-folder representation. */
814 QString m_strHomeFolder;
815
816 /** Holds whether acquired COM wrappers are currently valid. */
817 bool m_fWrappersValid;
818 /** Holds whether VBoxSVC is currently available. */
819 bool m_fVBoxSVCAvailable;
820
821 /** Holds the guest OS family IDs. */
822 QList<QString> m_guestOSFamilyIDs;
823 /** Holds the guest OS types for each family ID. */
824 QList<QList<CGuestOSType> > m_guestOSTypes;
825 /** @} */
826
827 /** @name Display stuff.
828 * @{ */
829 /** Holds whether 3D is available. */
830 int m_i3DAvailable;
831 /** @} */
832
833 /** @name Thread stuff.
834 * @{ */
835 /** Holds the thread-pool instance. */
836 UIThreadPool *m_pThreadPool;
837 /** @} */
838
839 /** @name Icon/Pixmap stuff.
840 * @{ */
841 /** Holds the general icon-pool instance. */
842 UIIconPoolGeneral *m_pIconPool;
843
844 /** Holds the global file icon provider instance. */
845 QFileIconProvider m_fileIconProvider;
846
847 /** Holds the warning pixmap. */
848 QPixmap m_pixWarning;
849 /** Holds the error pixmap. */
850 QPixmap m_pixError;
851 /** @} */
852
853 /** @name Media related stuff.
854 * @{ */
855 /** Holds the medium enumerator cleanup protection token. */
856 mutable QReadWriteLock m_meCleanupProtectionToken;
857
858 /** Holds the medium enumerator. */
859 UIMediumEnumerator *m_pMediumEnumerator;
860 /** @} */
861
862#if defined(VBOX_WS_WIN) && defined(VBOX_GUI_WITH_SHARED_LIBRARY)
863 /** @name ATL stuff.
864 * @{ */
865 /** Holds the ATL module instance (for use with VBoxGlobal shared library only).
866 * @note Required internally by ATL (constructor records instance in global variable). */
867 ATL::CComModule _Module;
868 /** @} */
869#endif
870
871 /** Allows for shortcut access. */
872 friend VBoxGlobal &vboxGlobal();
873};
874
875/** Singleton VBoxGlobal 'official' name. */
876inline VBoxGlobal &vboxGlobal() { return *VBoxGlobal::instance(); }
877
878#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