VirtualBox

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

Last change on this file since 76532 was 76532, checked in by vboxsync, 6 years ago

Frontends: scm --fix-header-guards. bugref:9344

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

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