VirtualBox

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

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

FE/Qt: bugref:9241: Allow VBoxGlobal library to distinguish whether it is used from VM or VBox Manager UI; (s.a. r122849, missed part).

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