VirtualBox

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

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

FE/Qt: bugref:7127: Delete medium stuff is superfluous VBOX_GUI_WITH_NEW_MEDIA_EVENTS defined, corresponding event goes through GUI anyway.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 43.0 KB
Line 
1/* $Id: VBoxGlobal.h 79337 2019-06-25 17:49:15Z 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 /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts
188 * searching strBaseFileName and adds suffixes until a unique file name is found. */
189 static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName);
190 /** @} */
191
192 /** @name Process arguments stuff.
193 * @{ */
194 /** Returns whether passed @a strExt ends with one of allowed extension in the @a extList. */
195 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList);
196
197 /** Process application args. */
198 bool processArgs();
199
200 /** Returns whether there are unhandled URL arguments present. */
201 bool argumentUrlsPresent() const;
202 /** Takes and returns the URL argument list while clearing the source. */
203 QList<QUrl> takeArgumentUrls();
204
205 /** Returns the --startvm option value (managed VM id). */
206 QUuid managedVMUuid() const { return m_strManagedVMId; }
207 /** Returns the --separate option value (whether GUI process is separate from VM process). */
208 bool isSeparateProcess() const { return m_fSeparateProcess; }
209 /** Returns the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
210 bool showStartVMErrors() const { return m_fShowStartVMErrors; }
211
212 /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
213 bool agressiveCaching() const { return m_fAgressiveCaching; }
214
215 /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */
216 bool shouldRestoreCurrentSnapshot() const { return m_fRestoreCurrentSnapshot; }
217 /** Defines whether we should fRestore current snapshot before VM started. */
218 void setShouldRestoreCurrentSnapshot(bool fRestore) { m_fRestoreCurrentSnapshot = fRestore; }
219
220 /** Returns the --fda option value (whether we have floppy image). */
221 bool hasFloppyImageToMount() const { return !m_strFloppyImage.isNull(); }
222 /** Returns the --dvd | --cdrom option value (whether we have DVD image). */
223 bool hasDvdImageToMount() const { return !m_strDvdImage.isNull(); }
224 /** Returns floppy image name. */
225 QUuid const &getFloppyImage() const { return m_strFloppyImage; }
226 /** Returns DVD image name. */
227 QUuid const &getDvdImage() const { return m_strDvdImage; }
228
229 /** Returns the --disable-patm option value. */
230 bool isPatmDisabled() const { return m_fDisablePatm; }
231 /** Returns the --disable-csam option value. */
232 bool isCsamDisabled() const { return m_fDisableCsam; }
233 /** Returns the --recompile-supervisor option value. */
234 bool isSupervisorCodeExecedRecompiled() const { return m_fRecompileSupervisor; }
235 /** Returns the --recompile-user option value. */
236 bool isUserCodeExecedRecompiled() const { return m_fRecompileUser; }
237 /** Returns the --execute-all-in-iem option value. */
238 bool areWeToExecuteAllInIem() const { return m_fExecuteAllInIem; }
239 /** Returns whether --warp-factor option value is equal to 100. */
240 bool isDefaultWarpPct() const { return m_uWarpPct == 100; }
241 /** Returns the --warp-factor option value. */
242 uint32_t getWarpPct() const { return m_uWarpPct; }
243
244#ifdef VBOX_WITH_DEBUGGER_GUI
245 /** Holds whether the debugger should be accessible. */
246 bool isDebuggerEnabled() const;
247 /** Holds whether to show the debugger automatically with the console. */
248 bool isDebuggerAutoShowEnabled() const;
249 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
250 bool isDebuggerAutoShowCommandLineEnabled() const;
251 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
252 bool isDebuggerAutoShowStatisticsEnabled() const;
253
254 /** VBoxDbg module handle. */
255 RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
256#endif
257
258 /** Returns whether VM should start paused. */
259 bool shouldStartPaused() const;
260
261#ifdef VBOX_GUI_WITH_PIDFILE
262 /** Creates PID file. */
263 void createPidfile();
264 /** Deletes PID file. */
265 void deletePidfile();
266#endif
267 /** @} */
268
269 /** @name Localization stuff.
270 * @{ */
271 /** Native language name of the currently installed translation. */
272 static QString languageName();
273 /** Native language country name of the currently installed translation. */
274 static QString languageCountry();
275 /** Language name of the currently installed translation, in English. */
276 static QString languageNameEnglish();
277 /** Language country name of the currently installed translation, in English. */
278 static QString languageCountryEnglish();
279 /** Comma-separated list of authors of the currently installed translation. */
280 static QString languageTranslators();
281
282 /** Returns VBox language sub-directory. */
283 static QString vboxLanguageSubDirectory();
284 /** Returns VBox language file-base. */
285 static QString vboxLanguageFileBase();
286 /** Returns VBox language file-extension. */
287 static QString vboxLanguageFileExtension();
288 /** Returns VBox language ID reg-exp. */
289 static QString vboxLanguageIdRegExp();
290 /** Returns built in language name. */
291 static QString vboxBuiltInLanguageName();
292
293 /** Returns the loaded (active) language ID. */
294 static QString languageId();
295 /** Returns the system language ID. */
296 static QString systemLanguageId();
297
298 /** Loads the language by language ID.
299 * @param strLangId Brings the language ID in in form of xx_YY.
300 * QString() means the system default language. */
301 static void loadLanguage(const QString &strLangId = QString());
302
303 /** Returns tr("%n year(s)"). */
304 static QString yearsToString(uint32_t cVal);
305 /** Returns tr("%n month(s)"). */
306 static QString monthsToString(uint32_t cVal);
307 /** Returns tr("%n day(s)"). */
308 static QString daysToString(uint32_t cVal);
309 /** Returns tr("%n hour(s)"). */
310 static QString hoursToString(uint32_t cVal);
311 /** Returns tr("%n minute(s)"). */
312 static QString minutesToString(uint32_t cVal);
313 /** Returns tr("%n second(s)"). */
314 static QString secondsToString(uint32_t cVal);
315
316 /** Returns the decimal separator for the current locale. */
317 static QChar decimalSep();
318 /** Returns the regexp string that defines the format of the human-readable size representation. */
319 static QString sizeRegexp();
320 /** Parses the given size strText and returns the size value in bytes. */
321 static quint64 parseSize(const QString &strText);
322 /** Parses the given size strText and returns the size suffix. */
323 static SizeSuffix parseSizeSuffix(const QString &strText);
324 /** Parses the given string @a strText and returns true if it includes a size suffix. */
325 static bool hasSizeSuffix(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 uId. */
471 CSession openSession(const QUuid &uId, KLockType enmLockType = KLockType_Write);
472 /** Opens session of KLockType_Shared type for VM with certain @a uId. */
473 CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
474 /** @} */
475
476 /** @name COM: Virtual Media stuff.
477 * @{ */
478 /** Starts medium-enumeration. */
479 void startMediumEnumeration(const CMediumVector &mediaList = CMediumVector());
480 /** Enumerates additional medium. */
481 void enumerateAdditionalMedium(const CMedium &comMedium);
482 /** Calls refresh for each medium which has been already enumerated. */
483 void refreshMedia();
484 /** Returns whether medium-enumeration is in progress. */
485 bool isMediumEnumerationInProgress() const;
486#ifdef VBOX_GUI_WITH_NEW_MEDIA_EVENTS
487 /** Returns whether full medium-enumeration is requested. */
488 bool isFullMediumEnumerationRequested() const;
489#endif
490 /** Returns enumerated medium with certain @a uMediumID. */
491 UIMedium medium(const QUuid &uMediumID) const;
492 /** Returns enumerated medium IDs. */
493 QList<QUuid> mediumIDs() const;
494 /** Creates medium on the basis of passed @a guiMedium description. */
495 void createMedium(const UIMedium &guiMedium);
496#ifndef VBOX_GUI_WITH_NEW_MEDIA_EVENTS
497 /** Deletes medium with certain @a uMediumID. */
498 void deleteMedium(const QUuid &uMediumID);
499#endif
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 = false);
515
516
517 /** Creates and shows a UIMediumSelector dialog.
518 * @param parent Passes the parent of the dialog,
519 * @param enmMediumType Passes the medium type.
520 * @param strMachineName Passes the name of the machine,
521 * @param strMachineFolder Passes the machine folder,
522 * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os,
523 * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog,
524 * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
525 * UUID of the selected medium is stored in @param outUuid.*/
526 int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType, QUuid &outUuid,
527 const QString &strMachineFolder, const QString &strMachineName,
528 const QString &strMachineGuestOSTypeId, bool fEnableCreate);
529
530 /** Creates and shows a dialog (wizard) to create a medium of type @a enmMediumType.
531 * @param parent Passes the parent of the dialog,
532 * @param enmMediumType Passes the medium type.
533 * @param strMachineName Passes the name of the machine,
534 * @param strMachineFolder Passes the machine folder,
535 * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os,
536 * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog,
537 * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
538 * UUID of the selected medium is stored in @param outUuid.*/
539 QUuid openMediumCreatorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType,
540 const QString &strMachineFolder = QString(), const QString &strMachineName = QString(),
541 const QString &strMachineGuestOSTypeId = QString());
542
543
544 /** Prepares storage menu according passed parameters.
545 * @param menu Brings the #QMenu to be prepared.
546 * @param pListener Brings the listener #QObject, this @a menu being prepared for.
547 * @param pszSlotName Brings the name of the SLOT in the @a pListener above, this menu will be handled with.
548 * @param comMachine Brings the #CMachine object, this @a menu being prepared for.
549 * @param strControllerName Brings the name of the #CStorageController in the @a machine above.
550 * @param storageSlot Brings the #StorageSlot of the storage controller with @a strControllerName above. */
551 void prepareStorageMenu(QMenu &menu,
552 QObject *pListener, const char *pszSlotName,
553 const CMachine &comMachine, const QString &strControllerName, const StorageSlot &storageSlot);
554 /** Updates @a comConstMachine storage with data described by @a target. */
555 void updateMachineStorage(const CMachine &comConstMachine, const UIMediumTarget &target);
556
557 /** Generates details for passed @a comMedium.
558 * @param fPredictDiff Brings whether medium will be marked differencing on attaching.
559 * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */
560 QString details(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml = true);
561
562 /** Update extra data related to recently used/referred media.
563 * @param enmMediumType Passes the medium type.
564 * @param strMediumLocation Passes the medium location. */
565 void updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType enmMediumType, QString strMediumLocation);
566
567 /** Searches extra data for the recently used folder path which corresponds to @a enmMediumType. When that search fails
568 it looks for recent folder extra data for other medium types. As the last resort returns default vm folder path.
569 * @param enmMediumType Passes the medium type. */
570 QString defaultFolderPathForType(UIMediumDeviceType enmMediumType);
571 /** @} */
572
573 /** @name COM: USB stuff.
574 * @{ */
575#ifdef RT_OS_LINUX
576 /** Verifies that USB drivers are properly configured on Linux. */
577 static void checkForWrongUSBMounted();
578#endif
579
580 /** Generates details for passed USB @a comDevice. */
581 static QString details(const CUSBDevice &comDevice);
582 /** Generates tool-tip for passed USB @a comDevice. */
583 static QString toolTip(const CUSBDevice &comDevice);
584 /** Generates tool-tip for passed USB @a comFilter. */
585 static QString toolTip(const CUSBDeviceFilter &comFilter);
586 /** Generates tool-tip for passed USB @a comWebcam. */
587 static QString toolTip(const CHostVideoInputDevice &comWebcam);
588 /** @} */
589
590 /** @name COM: Extension Pack stuff.
591 * @{ */
592 /** Initiates the extension pack installation process.
593 * @param strFilePath Brings the extension pack file path.
594 * @param strDigest Brings the extension pack file digest.
595 * @param pParent Brings the parent dialog reference.
596 * @param pstrExtPackName Brings the extension pack name. */
597 void doExtPackInstallation(QString const &strFilePath,
598 QString const &strDigest,
599 QWidget *pParent,
600 QString *pstrExtPackName) const;
601 /** @} */
602
603 /** @name Display stuff.
604 * @{ */
605 /** Inner worker for lazily querying for 3D support. */
606 bool is3DAvailableWorker() const;
607 /** Returns whether 3D is available, runs worker above if necessary. */
608 bool is3DAvailable() const;
609
610#ifdef VBOX_WITH_CRHGSMI
611 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
612 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
613#endif
614 /** Returns the required video memory in bytes for the current desktop
615 * resolution at maximum possible screen depth in bpp. */
616 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
617 /** @} */
618
619 /** @name Thread stuff.
620 * @{ */
621 /** Returns the thread-pool instance. */
622 UIThreadPool *threadPool() const { return m_pThreadPool; }
623 /** @} */
624
625 /** @name Icon/Pixmap stuff.
626 * @{ */
627 /** Returns icon defined for a passed @a comMachine. */
628 QIcon vmUserIcon(const CMachine &comMachine) const;
629 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
630 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
631 /** Returns pixmap defined for a passed @a comMachine.
632 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
633 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
634
635 /** Returns pixmap corresponding to passed @a strOSTypeID. */
636 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
637 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
638 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
639 /** Returns pixmap corresponding to passed @a strOSTypeID.
640 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
641 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
642
643 /** Returns default icon of certain @a enmType. */
644 QIcon icon(QFileIconProvider::IconType enmType) { return m_fileIconProvider.icon(enmType); }
645 /** Returns file icon fetched from passed file @a info. */
646 QIcon icon(const QFileInfo &info) { return m_fileIconProvider.icon(info); }
647
648 /** Returns cached default warning pixmap. */
649 QPixmap warningIcon() const { return m_pixWarning; }
650 /** Returns cached default error pixmap. */
651 QPixmap errorIcon() const { return m_pixError; }
652
653 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */
654 static QPixmap joinPixmaps(const QPixmap &pixmap1, const QPixmap &pixmap2);
655 /** @} */
656
657public slots:
658
659 /** @name Process arguments stuff.
660 * @{ */
661 /** Opens the specified URL using OS/Desktop capabilities. */
662 bool openURL(const QString &strURL) const;
663 /** @} */
664
665 /** @name Localization stuff.
666 * @{ */
667 /** Handles language change to new @a strLanguage. */
668 void sltGUILanguageChange(QString strLanguage);
669 /** @} */
670
671protected:
672
673 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
674 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
675
676 /** Handles translation event. */
677 virtual void retranslateUi() /* override */;
678
679protected slots:
680
681 /** Prepares all. */
682 void prepare();
683 /** Cleanups all. */
684 void cleanup();
685
686 /** @name Common stuff.
687 * @{ */
688 /** Handles @a manager request for emergency session shutdown. */
689 void sltHandleCommitDataRequest(QSessionManager &manager);
690 /** @} */
691
692 /** @name COM stuff.
693 * @{ */
694 /** Handles the VBoxSVC availability change. */
695 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
696 /** @} */
697
698private:
699
700 /** Construcs global VirtualBox object of passed @a enmType. */
701 VBoxGlobal(UIType enmType);
702
703 /** Destrucs global VirtualBox object. */
704 virtual ~VBoxGlobal() /* override */;
705
706
707 /** @name COM: Virtual Media create functions.
708 * @{ */
709
710 /** Creates a VISO by using the VISO creator dialog.
711 * @param pParent Passes the dialog parent.
712 * @param strDefaultFolder Passes the folder to save the VISO file.
713 * @param strMachineName Passes the name of the machine, */
714 QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder = QString(), const QString &strMachineName = QString());
715
716 /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
717 * @param parent Passes the parent of the dialog,
718 * @param strDefaultFolder Passes the default folder,
719 * @param strMachineName Passes the name of the machine,
720 * returns the ID of the newly created medium if successful, a null QUuid otherwise.*/
721 QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder = QString(),
722 const QString &strMachineName = QString());
723
724 /** Creates and shows a UIWizardNewVD wizard.
725 * @param parent Passes the parent of the wizard,
726 * @param strMachineFolder Passes the machine folder,
727 * @param strMachineName Passes the name of the machine,
728 * @param strMachineGuestOSTypeId Passes the string of machine's guest OS type ID,
729 * returns the ID of the created hard disk if successful, a null QUuid otherwise.*/
730 QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineFolder = QString(),
731 const QString &strMachineName = QString(), const QString &strMachineGuestOSTypeId = QString());
732 /** @} */
733
734 /** @name Common stuff.
735 * @{ */
736#ifdef VBOX_WS_WIN
737 /** Wraps WinAPI ShutdownBlockReasonCreate function. */
738 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
739#endif
740 /** @} */
741
742 /** @name Process arguments stuff.
743 * @{ */
744#ifdef VBOX_WITH_DEBUGGER_GUI
745 /** Initializes a debugger config variable.
746 * @param piDbgCfgVar Brings the debugger config variable to init.
747 * @param pszEnvVar Brings the environment variable name relating to this variable.
748 * @param pszExtraDataName Brings the extra data name relating to this variable.
749 * @param fDefault Brings the default value. */
750 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
751 /** Set a debugger config variable according according to start up argument.
752 * @param piDbgCfgVar Brings the debugger config variable to set.
753 * @param fState Brings the value from the command line. */
754 void setDebuggerVar(int *piDbgCfgVar, bool fState);
755 /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
756 * @param piDbgCfgVar Brings the debugger config variable to consult.
757 * @param pszExtraDataName Brings the extra data name relating to this variable. */
758 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
759#endif
760 /** @} */
761
762 /** @name COM stuff.
763 * @{ */
764 /** Re-initializes COM wrappers and containers. */
765 void comWrappersReinit();
766 /** @} */
767
768 /** Holds the singleton VBoxGlobal instance. */
769 static VBoxGlobal *s_pInstance;
770
771 /** @name Common stuff.
772 * @{ */
773 /** Holds whether VBoxGlobal cleanup is in progress. */
774 static bool s_fCleaningUp;
775
776 /** Holds the currently loaded language ID. */
777 static QString s_strLoadedLanguageId;
778
779 /** Holds the tr("User Defined") port name. */
780 static QString s_strUserDefinedPortName;
781
782 /** Holds the UI type. */
783 UIType m_enmType;
784
785 /** Holds whether VBoxGlobal instance is properly initialized. */
786 bool m_fValid;
787
788#ifdef VBOX_WS_MAC
789 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */
790 MacOSXRelease m_enmMacOSVersion;
791#endif
792
793#ifdef VBOX_WS_X11
794 /** X11: Holds the #X11WMType of the Window Manager we are running under. */
795 X11WMType m_enmWindowManagerType;
796 /** X11: Holds whether the Window Manager we are running at is composition one. */
797 bool m_fCompositingManagerRunning;
798#endif
799
800 /** Holds the VBox branding config file path. */
801 QString m_strBrandingConfigFilePath;
802 /** @} */
803
804 /** @name Process arguments stuff.
805 * @{ */
806 /** Holds the URL arguments list. */
807 QList<QUrl> m_listArgUrls;
808
809 /** Holds the --startvm option value (managed VM id). */
810 QUuid m_strManagedVMId;
811 /** Holds the --separate option value (whether GUI process is separate from VM process). */
812 bool m_fSeparateProcess;
813 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
814 bool m_fShowStartVMErrors;
815
816 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
817 bool m_fAgressiveCaching;
818
819 /** Holds the --restore-current option value. */
820 bool m_fRestoreCurrentSnapshot;
821
822 /** Holds the --fda option value (floppy image). */
823 QUuid m_strFloppyImage;
824 /** Holds the --dvd | --cdrom option value (DVD image). */
825 QUuid m_strDvdImage;
826
827 /** Holds the --disable-patm option value. */
828 bool m_fDisablePatm;
829 /** Holds the --disable-csam option value. */
830 bool m_fDisableCsam;
831 /** Holds the --recompile-supervisor option value. */
832 bool m_fRecompileSupervisor;
833 /** Holds the --recompile-user option value. */
834 bool m_fRecompileUser;
835 /** Holds the --execute-all-in-iem option value. */
836 bool m_fExecuteAllInIem;
837 /** Holds the --warp-factor option value. */
838 uint32_t m_uWarpPct;
839
840#ifdef VBOX_WITH_DEBUGGER_GUI
841 /** Holds whether the debugger should be accessible. */
842 mutable int m_fDbgEnabled;
843 /** Holds whether to show the debugger automatically with the console. */
844 mutable int m_fDbgAutoShow;
845 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
846 mutable int m_fDbgAutoShowCommandLine;
847 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
848 mutable int m_fDbgAutoShowStatistics;
849 /** VBoxDbg module handle. */
850 RTLDRMOD m_hVBoxDbg;
851
852 /** Holds whether --start-running, --start-paused or nothing was given. */
853 enum LaunchRunning m_enmLaunchRunning;
854#endif
855
856 /** Holds the --settingspw option value or the content of --settingspwfile. */
857 char m_astrSettingsPw[256];
858 /** Holds the --settingspwfile option value. */
859 bool m_fSettingsPwSet;
860
861#ifdef VBOX_GUI_WITH_PIDFILE
862 /** Holds the --pidfile option value (application PID file path). */
863 QString m_strPidFile;
864#endif
865 /** @} */
866
867 /** @name COM stuff.
868 * @{ */
869 /** Holds the COM cleanup protection token. */
870 QReadWriteLock m_comCleanupProtectionToken;
871
872 /** Holds the instance of VirtualBox client wrapper. */
873 CVirtualBoxClient m_comVBoxClient;
874 /** Holds the copy of VirtualBox object wrapper. */
875 CVirtualBox m_comVBox;
876 /** Holds the copy of VirtualBox host-object wrapper. */
877 CHost m_comHost;
878 /** Holds the symbolic VirtualBox home-folder representation. */
879 QString m_strHomeFolder;
880
881 /** Holds whether acquired COM wrappers are currently valid. */
882 bool m_fWrappersValid;
883 /** Holds whether VBoxSVC is currently available. */
884 bool m_fVBoxSVCAvailable;
885
886 /** Holds the guest OS family IDs. */
887 QList<QString> m_guestOSFamilyIDs;
888 /** Holds the guest OS family descriptions. */
889 QMap<QString, QString> m_guestOSFamilyDescriptions;
890 /** Holds the guest OS types for each family ID. */
891 QList<QList<CGuestOSType> > m_guestOSTypes;
892 /** @} */
893
894 /** @name Display stuff.
895 * @{ */
896 /** Holds whether 3D is available. */
897 mutable int m_i3DAvailable;
898 /** @} */
899
900 /** @name Thread stuff.
901 * @{ */
902 /** Holds the thread-pool instance. */
903 UIThreadPool *m_pThreadPool;
904 /** @} */
905
906 /** @name Icon/Pixmap stuff.
907 * @{ */
908 /** Holds the general icon-pool instance. */
909 UIIconPoolGeneral *m_pIconPool;
910
911 /** Holds the global file icon provider instance. */
912 QFileIconProvider m_fileIconProvider;
913
914 /** Holds the warning pixmap. */
915 QPixmap m_pixWarning;
916 /** Holds the error pixmap. */
917 QPixmap m_pixError;
918 /** @} */
919
920 /** @name Media related stuff.
921 * @{ */
922 /** Holds the medium enumerator cleanup protection token. */
923 mutable QReadWriteLock m_meCleanupProtectionToken;
924
925 /** Holds the medium enumerator. */
926 UIMediumEnumerator *m_pMediumEnumerator;
927 /** List of medium names that should not appears in the recently used media extra data. */
928 QStringList m_recentMediaExcludeList;
929 /** @} */
930
931#if defined(VBOX_WS_WIN)
932 /** @name ATL stuff.
933 * @{ */
934 /** Holds the ATL module instance (for use with VBoxGlobal shared library only).
935 * @note Required internally by ATL (constructor records instance in global variable). */
936 ATL::CComModule _Module;
937 /** @} */
938#endif
939
940 /** Allows for shortcut access. */
941 friend VBoxGlobal &vboxGlobal();
942};
943
944/** Singleton VBoxGlobal 'official' name. */
945inline VBoxGlobal &vboxGlobal() { return *VBoxGlobal::instance(); }
946
947#endif /* !FEQT_INCLUDED_SRC_globals_VBoxGlobal_h */
Note: See TracBrowser for help on using the repository browser.

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