VirtualBox

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

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

FE/Qt: bugref:9080: Adding a VISO creation dialog

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