VirtualBox

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

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

FE/Qt: VBoxGlobal todo fix: Make sure url argument list being cleared on return.

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