VirtualBox

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

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

FE/Qt: bugref:9080: Dont put the ac-hoc.viso to recent media extra data

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