VirtualBox

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

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

FE/Qt: Move/rework fullMediumFormatName functionality out of VBoxGlobal to UIMediumDefs and UIConverter.

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