1 | /* $Id: VBoxGlobal.h 69552 2017-11-02 14:30:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - VBoxGlobal class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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 <QApplication>
|
---|
23 | #include <QLayout>
|
---|
24 | #include <QMenu>
|
---|
25 | #include <QStyle>
|
---|
26 | #include <QHash>
|
---|
27 | #include <QFileIconProvider>
|
---|
28 | #include <QReadWriteLock>
|
---|
29 | #ifdef VBOX_WS_MAC
|
---|
30 | # include <QSet>
|
---|
31 | #endif /* VBOX_WS_MAC */
|
---|
32 |
|
---|
33 | /* GUI includes: */
|
---|
34 | #include "UIDefs.h"
|
---|
35 | #include "UIMediumDefs.h"
|
---|
36 | #ifdef VBOX_WS_X11
|
---|
37 | # include "VBoxX11Helper.h"
|
---|
38 | #endif /* VBOX_WS_X11 */
|
---|
39 |
|
---|
40 | /* COM includes: */
|
---|
41 | #include "VBox/com/Guid.h"
|
---|
42 | #include "CHost.h"
|
---|
43 | #include "CVirtualBoxClient.h"
|
---|
44 | #include "CVirtualBox.h"
|
---|
45 | #include "CSession.h"
|
---|
46 | #include "CGuestOSType.h"
|
---|
47 |
|
---|
48 | /* Other includes: */
|
---|
49 | #ifdef VBOX_WS_X11
|
---|
50 | # include <X11/Xdefs.h>
|
---|
51 | #endif /* VBOX_WS_X11 */
|
---|
52 |
|
---|
53 | /* Forward declarations: */
|
---|
54 | class QAction;
|
---|
55 | class QLabel;
|
---|
56 | class QToolButton;
|
---|
57 | class UIMachine;
|
---|
58 | class CMachine;
|
---|
59 | class CMedium;
|
---|
60 | class CUSBDevice;
|
---|
61 | class CHostVideoInputDevice;
|
---|
62 | class QSpinBox;
|
---|
63 | class UIMediumEnumerator;
|
---|
64 | class UIMedium;
|
---|
65 | class UIIconPoolGeneral;
|
---|
66 | class UIThreadPool;
|
---|
67 |
|
---|
68 | // VBoxGlobal class
|
---|
69 | ////////////////////////////////////////////////////////////////////////////////
|
---|
70 |
|
---|
71 | class VBoxUpdateDlg;
|
---|
72 |
|
---|
73 | class VBoxGlobal : public QObject
|
---|
74 | {
|
---|
75 | Q_OBJECT
|
---|
76 |
|
---|
77 | public:
|
---|
78 |
|
---|
79 | /** VM launch modes. */
|
---|
80 | enum LaunchMode
|
---|
81 | {
|
---|
82 | LaunchMode_Invalid,
|
---|
83 | LaunchMode_Default,
|
---|
84 | LaunchMode_Headless,
|
---|
85 | LaunchMode_Separate
|
---|
86 | };
|
---|
87 |
|
---|
88 | /** Whether to start the VM running. */
|
---|
89 | enum StartRunning
|
---|
90 | {
|
---|
91 | StartRunning_Default, /**< Default (depends on debug settings). */
|
---|
92 | StartRunning_No, /**< Start the VM paused. */
|
---|
93 | StartRunning_Yes /**< Start the VM running. */
|
---|
94 | };
|
---|
95 |
|
---|
96 | /* Static API: Create/destroy stuff: */
|
---|
97 | static VBoxGlobal* instance();
|
---|
98 | static void create();
|
---|
99 | static void destroy();
|
---|
100 |
|
---|
101 | bool isValid() { return mValid; }
|
---|
102 | bool isCleaningUp() { return m_sfCleanupInProgress; }
|
---|
103 |
|
---|
104 | static QString qtRTVersionString();
|
---|
105 | static uint qtRTVersion();
|
---|
106 | static QString qtCTVersionString();
|
---|
107 | static uint qtCTVersion();
|
---|
108 |
|
---|
109 | QString vboxVersionString() const;
|
---|
110 | QString vboxVersionStringNormalized() const;
|
---|
111 |
|
---|
112 | QString versionString() const { return mVerString; }
|
---|
113 | bool isBeta() const;
|
---|
114 |
|
---|
115 | /** Returns whether GUI is separate (from VM) process. */
|
---|
116 | bool isSeparateProcess() const { return m_fSeparateProcess; }
|
---|
117 |
|
---|
118 | #ifdef VBOX_WS_MAC
|
---|
119 | /** Mac OS X: Returns #MacOSXRelease determined using <i>uname</i> call. */
|
---|
120 | static MacOSXRelease determineOsRelease();
|
---|
121 | /** Mac OS X: Returns #MacOSXRelease determined during VBoxGlobal prepare routine. */
|
---|
122 | MacOSXRelease osRelease() const { return m_osRelease; }
|
---|
123 | #endif /* VBOX_WS_MAC */
|
---|
124 |
|
---|
125 | /** Try to acquire COM cleanup protection token for reading. */
|
---|
126 | bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
|
---|
127 | /** Unlock previously acquired COM cleanup protection token. */
|
---|
128 | void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
|
---|
129 |
|
---|
130 | /** Returns the copy of VirtualBox client wrapper. */
|
---|
131 | CVirtualBoxClient virtualBoxClient() const { return m_client; }
|
---|
132 | /** Returns the copy of VirtualBox object wrapper. */
|
---|
133 | CVirtualBox virtualBox() const { return m_vbox; }
|
---|
134 | /** Returns the copy of VirtualBox host-object wrapper. */
|
---|
135 | CHost host() const { return m_host; }
|
---|
136 | /** Returns the symbolic VirtualBox home-folder representation. */
|
---|
137 | QString homeFolder() const { return m_strHomeFolder; }
|
---|
138 |
|
---|
139 | /** Returns the VBoxSVC availability value. */
|
---|
140 | bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
|
---|
141 |
|
---|
142 | /** Returns the thread-pool instance. */
|
---|
143 | UIThreadPool* threadPool() const { return m_pThreadPool; }
|
---|
144 |
|
---|
145 | /** Returns currently active virtual machine window. */
|
---|
146 | QWidget* activeMachineWindow() const;
|
---|
147 |
|
---|
148 | bool is3DAvailableWorker() const;
|
---|
149 | bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; }
|
---|
150 |
|
---|
151 | #ifdef VBOX_GUI_WITH_PIDFILE
|
---|
152 | void createPidfile();
|
---|
153 | void deletePidfile();
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | /* branding */
|
---|
157 | bool brandingIsActive (bool aForce = false);
|
---|
158 | QString brandingGetKey (QString aKey);
|
---|
159 |
|
---|
160 | bool processArgs();
|
---|
161 |
|
---|
162 | bool switchToMachine(CMachine &machine);
|
---|
163 |
|
---|
164 | bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default);
|
---|
165 |
|
---|
166 | bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
|
---|
167 | bool showStartVMErrors() const { return mShowStartVMErrors; }
|
---|
168 | QString managedVMUuid() const { return vmUuid; }
|
---|
169 | QList<QUrl> &argUrlList() { return m_ArgUrlList; }
|
---|
170 |
|
---|
171 | /** Returns whether the Extension Pack installation was requested at startup. */
|
---|
172 | bool isEPInstallationRequested() const { return m_fEPInstallationRequested; }
|
---|
173 | /** Defines whether the Extension Pack installation was @a fRequested at startup. */
|
---|
174 | void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; }
|
---|
175 |
|
---|
176 | #ifdef VBOX_WS_X11
|
---|
177 | /** X11: Returns whether the Window Manager we are running at 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 /* VBOX_WS_X11 */
|
---|
182 |
|
---|
183 | /** Returns whether we should restore current snapshot before VM started. */
|
---|
184 | bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; }
|
---|
185 | /** Defines whether we should fRestore current snapshot before VM started. */
|
---|
186 | void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; }
|
---|
187 |
|
---|
188 | bool hasFloppyImageToMount() const { return !m_strFloppyImage.isEmpty(); }
|
---|
189 | bool hasDvdImageToMount() const { return !m_strDvdImage.isEmpty(); }
|
---|
190 | QString const &getFloppyImage() const { return m_strFloppyImage; }
|
---|
191 | QString const &getDvdImage() const { return m_strDvdImage; }
|
---|
192 |
|
---|
193 | bool isPatmDisabled() const { return mDisablePatm; }
|
---|
194 | bool isCsamDisabled() const { return mDisableCsam; }
|
---|
195 | bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
|
---|
196 | bool isUserCodeExecedRecompiled() const { return mRecompileUser; }
|
---|
197 | bool areWeToExecuteAllInIem() const { return mExecuteAllInIem; }
|
---|
198 | bool isDefaultWarpPct() const { return mWarpPct == 100; }
|
---|
199 | uint32_t getWarpPct() const { return mWarpPct; }
|
---|
200 |
|
---|
201 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
202 | bool isDebuggerEnabled() const;
|
---|
203 | bool isDebuggerAutoShowEnabled() const;
|
---|
204 | bool isDebuggerAutoShowCommandLineEnabled() const;
|
---|
205 | bool isDebuggerAutoShowStatisticsEnabled() const;
|
---|
206 |
|
---|
207 | RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
|
---|
208 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
209 |
|
---|
210 | bool shouldStartPaused() const
|
---|
211 | {
|
---|
212 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
213 | return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No;
|
---|
214 | #else
|
---|
215 | return false;
|
---|
216 | #endif
|
---|
217 | }
|
---|
218 |
|
---|
219 | /* VBox enum to/from string/icon/color convertors */
|
---|
220 |
|
---|
221 | QList <CGuestOSType> vmGuestOSFamilyList() const;
|
---|
222 | QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
|
---|
223 |
|
---|
224 | /** Returns icon defined for a passed @a comMachine. */
|
---|
225 | QIcon vmUserIcon(const CMachine &comMachine) const;
|
---|
226 | /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
|
---|
227 | QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
|
---|
228 | /** Returns pixmap defined for a passed @a comMachine.
|
---|
229 | * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
|
---|
230 | QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
|
---|
231 |
|
---|
232 | /** Returns pixmap corresponding to passed @a strOSTypeID. */
|
---|
233 | QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
|
---|
234 | /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
|
---|
235 | QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
|
---|
236 | /** Returns pixmap corresponding to passed @a strOSTypeID.
|
---|
237 | * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
|
---|
238 | QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
|
---|
239 |
|
---|
240 | CGuestOSType vmGuestOSType (const QString &aTypeId,
|
---|
241 | const QString &aFamilyId = QString::null) const;
|
---|
242 | QString vmGuestOSTypeDescription (const QString &aTypeId) const;
|
---|
243 |
|
---|
244 | static inline QString yearsToString (uint32_t cVal)
|
---|
245 | {
|
---|
246 | return tr("%n year(s)", "", cVal);
|
---|
247 | }
|
---|
248 |
|
---|
249 | static inline QString monthsToString (uint32_t cVal)
|
---|
250 | {
|
---|
251 | return tr("%n month(s)", "", cVal);
|
---|
252 | }
|
---|
253 |
|
---|
254 | static inline QString daysToString (uint32_t cVal)
|
---|
255 | {
|
---|
256 | return tr("%n day(s)", "", cVal);
|
---|
257 | }
|
---|
258 |
|
---|
259 | static inline QString hoursToString (uint32_t cVal)
|
---|
260 | {
|
---|
261 | return tr("%n hour(s)", "", cVal);
|
---|
262 | }
|
---|
263 |
|
---|
264 | static inline QString minutesToString (uint32_t cVal)
|
---|
265 | {
|
---|
266 | return tr("%n minute(s)", "", cVal);
|
---|
267 | }
|
---|
268 |
|
---|
269 | static inline QString secondsToString (uint32_t cVal)
|
---|
270 | {
|
---|
271 | return tr("%n second(s)", "", cVal);
|
---|
272 | }
|
---|
273 |
|
---|
274 | QStringList COMPortNames() const;
|
---|
275 | QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
276 | bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
277 |
|
---|
278 | QStringList LPTPortNames() const;
|
---|
279 | QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
|
---|
280 | bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
|
---|
281 |
|
---|
282 | static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)
|
---|
283 | {
|
---|
284 | for (int i = 0; i < extList.size(); ++i)
|
---|
285 | if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))
|
---|
286 | return true;
|
---|
287 | return false;
|
---|
288 | }
|
---|
289 |
|
---|
290 | QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }
|
---|
291 | QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }
|
---|
292 |
|
---|
293 | QPixmap warningIcon() const { return mWarningIcon; }
|
---|
294 | QPixmap errorIcon() const { return mErrorIcon; }
|
---|
295 |
|
---|
296 | /* details generators */
|
---|
297 |
|
---|
298 | QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true);
|
---|
299 |
|
---|
300 | QString details (const CUSBDevice &aDevice) const;
|
---|
301 | QString toolTip (const CUSBDevice &aDevice) const;
|
---|
302 | QString toolTip (const CUSBDeviceFilter &aFilter) const;
|
---|
303 | QString toolTip(const CHostVideoInputDevice &webcam) const;
|
---|
304 |
|
---|
305 | /* VirtualBox helpers */
|
---|
306 |
|
---|
307 | CSession openSession(const QString &aId, KLockType aLockType = KLockType_Write);
|
---|
308 |
|
---|
309 | /** Shortcut to openSession (aId, true). */
|
---|
310 | CSession openExistingSession(const QString &aId) { return openSession(aId, KLockType_Shared); }
|
---|
311 |
|
---|
312 | /* API: Medium-processing stuff: */
|
---|
313 | void createMedium(const UIMedium &medium);
|
---|
314 | void deleteMedium(const QString &strMediumID);
|
---|
315 | QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0,
|
---|
316 | const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
|
---|
317 | QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);
|
---|
318 |
|
---|
319 | /* API: Medium-enumeration stuff: */
|
---|
320 | void startMediumEnumeration();
|
---|
321 | bool agressiveCaching() const { return mAgressiveCaching; }
|
---|
322 | bool isMediumEnumerationInProgress() const;
|
---|
323 | UIMedium medium(const QString &strMediumID) const;
|
---|
324 | QList<QString> mediumIDs() const;
|
---|
325 |
|
---|
326 | /** Prepares storage menu according passed parameters.
|
---|
327 | * @param menu QMenu being prepared.
|
---|
328 | * @param pListener Listener QObject, this menu being prepared for.
|
---|
329 | * @param pszSlotName SLOT in the @a pListener above, this menu will be handled with.
|
---|
330 | * @param machine CMachine object, this menu being prepared for.
|
---|
331 | * @param strControllerName The name of the CStorageController in the @a machine above.
|
---|
332 | * @param storageSlot The StorageSlot of the CStorageController called @a strControllerName above. */
|
---|
333 | void prepareStorageMenu(QMenu &menu,
|
---|
334 | QObject *pListener, const char *pszSlotName,
|
---|
335 | const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot);
|
---|
336 | /** Updates @a constMachine storage with data described by @a target. */
|
---|
337 | void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target);
|
---|
338 |
|
---|
339 | /* various helpers */
|
---|
340 |
|
---|
341 | QString languageName() const;
|
---|
342 | QString languageCountry() const;
|
---|
343 | QString languageNameEnglish() const;
|
---|
344 | QString languageCountryEnglish() const;
|
---|
345 | QString languageTranslators() const;
|
---|
346 |
|
---|
347 | void retranslateUi();
|
---|
348 |
|
---|
349 | /* public static stuff */
|
---|
350 |
|
---|
351 | static bool isDOSType (const QString &aOSTypeId);
|
---|
352 |
|
---|
353 | static QString languageId();
|
---|
354 | static void loadLanguage (const QString &aLangId = QString::null);
|
---|
355 | QString helpFile() const;
|
---|
356 |
|
---|
357 | static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
|
---|
358 |
|
---|
359 | static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
360 | bool aCanResize = true);
|
---|
361 | static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
|
---|
362 | bool aCanResize = true);
|
---|
363 | static QRegion flip (const QRegion &aRegion);
|
---|
364 |
|
---|
365 | static void centerWidget (QWidget *aWidget, QWidget *aRelative,
|
---|
366 | bool aCanResize = true);
|
---|
367 |
|
---|
368 | static QChar decimalSep();
|
---|
369 | static QString sizeRegexp();
|
---|
370 |
|
---|
371 | static quint64 parseSize (const QString &);
|
---|
372 | static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round);
|
---|
373 |
|
---|
374 | static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
|
---|
375 |
|
---|
376 | static QString locationForHTML (const QString &aFileName);
|
---|
377 |
|
---|
378 | static QString highlight (const QString &aStr, bool aToolTip = false);
|
---|
379 |
|
---|
380 | static QString replaceHtmlEntities(QString strText);
|
---|
381 | static QString emphasize (const QString &aStr);
|
---|
382 |
|
---|
383 | static QString systemLanguageId();
|
---|
384 |
|
---|
385 | static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
|
---|
386 |
|
---|
387 | #ifdef VBOX_WS_X11
|
---|
388 | /** X11: Test whether the current window manager supports full screen mode. */
|
---|
389 | static bool supportsFullScreenMonitorsProtocolX11();
|
---|
390 | /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */
|
---|
391 | static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);
|
---|
392 |
|
---|
393 | /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */
|
---|
394 | static QVector<Atom> flagsNetWmState(QWidget *pWidget);
|
---|
395 | /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */
|
---|
396 | static bool isFullScreenFlagSet(QWidget *pWidget);
|
---|
397 | /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */
|
---|
398 | static void setFullScreenFlag(QWidget *pWidget);
|
---|
399 | /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */
|
---|
400 | static void setSkipTaskBarFlag(QWidget *pWidget);
|
---|
401 | /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */
|
---|
402 | static void setSkipPagerFlag(QWidget *pWidget);
|
---|
403 | #endif /* VBOX_WS_X11 */
|
---|
404 |
|
---|
405 | static QString removeAccelMark (const QString &aText);
|
---|
406 |
|
---|
407 | static QString insertKeyToActionText (const QString &aText, const QString &aKey);
|
---|
408 |
|
---|
409 | static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
|
---|
410 |
|
---|
411 | static QWidget *findWidget (QWidget *aParent, const char *aName,
|
---|
412 | const char *aClassName = NULL,
|
---|
413 | bool aRecursive = false);
|
---|
414 |
|
---|
415 | static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
|
---|
416 | static QList <QPair <QString, QString> > HDDBackends();
|
---|
417 | static QList <QPair <QString, QString> > DVDBackends();
|
---|
418 | static QList <QPair <QString, QString> > FloppyBackends();
|
---|
419 |
|
---|
420 | static QString documentsPath();
|
---|
421 |
|
---|
422 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
423 | static bool isAcceleration2DVideoAvailable();
|
---|
424 |
|
---|
425 | /** additional video memory required for the best 2D support performance
|
---|
426 | * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
|
---|
427 | static quint64 required2DOffscreenVideoMemory();
|
---|
428 | #endif
|
---|
429 |
|
---|
430 | #ifdef VBOX_WITH_CRHGSMI
|
---|
431 | static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
|
---|
432 | #endif /* VBOX_WITH_CRHGSMI */
|
---|
433 |
|
---|
434 | /* Returns full medium-format name for the given base medium-format name: */
|
---|
435 | static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
|
---|
436 |
|
---|
437 |
|
---|
438 | #ifdef RT_OS_LINUX
|
---|
439 | static void checkForWrongUSBMounted();
|
---|
440 | #endif /* RT_OS_LINUX */
|
---|
441 |
|
---|
442 | /* Shame on Qt it hasn't stuff for tuning
|
---|
443 | * widget size suitable for reflecting content of desired size.
|
---|
444 | * For example QLineEdit, QSpinBox and similar widgets should have a methods
|
---|
445 | * to strict the minimum width to reflect at least [n] symbols. */
|
---|
446 | static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
|
---|
447 |
|
---|
448 | /** Assigns top-level @a pWidget geometry passed as QRect coordinates.
|
---|
449 | * @note Take into account that this request may fail on X11. */
|
---|
450 | static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h);
|
---|
451 | /** Assigns top-level @a pWidget geometry passed as @a rect.
|
---|
452 | * @note Take into account that this request may fail on X11. */
|
---|
453 | static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
|
---|
454 |
|
---|
455 | #ifdef VBOX_WS_X11
|
---|
456 | /** Assigns WM_CLASS property for passed @a pWidget. */
|
---|
457 | static void setWMClass(QWidget *pWidget, const char *pStrName, const char *pStrClass);
|
---|
458 | #endif
|
---|
459 |
|
---|
460 | signals:
|
---|
461 |
|
---|
462 | /** Notifies listeners about the VBoxSVC availability change. */
|
---|
463 | void sigVBoxSVCAvailabilityChange();
|
---|
464 |
|
---|
465 | /* Notifiers: Medium-processing stuff: */
|
---|
466 | void sigMediumCreated(const QString &strMediumID);
|
---|
467 | void sigMediumDeleted(const QString &strMediumID);
|
---|
468 |
|
---|
469 | /* Notifiers: Medium-enumeration stuff: */
|
---|
470 | void sigMediumEnumerationStarted();
|
---|
471 | void sigMediumEnumerated(const QString &strMediumID);
|
---|
472 | void sigMediumEnumerationFinished();
|
---|
473 |
|
---|
474 | public slots:
|
---|
475 |
|
---|
476 | bool openURL (const QString &aURL);
|
---|
477 |
|
---|
478 | void sltGUILanguageChange(QString strLang);
|
---|
479 |
|
---|
480 | protected slots:
|
---|
481 |
|
---|
482 | /* Handlers: Prepare/cleanup stuff: */
|
---|
483 | void prepare();
|
---|
484 | void cleanup();
|
---|
485 |
|
---|
486 | /** Handles @a manager request for emergency session shutdown. */
|
---|
487 | void sltHandleCommitDataRequest(QSessionManager &manager);
|
---|
488 |
|
---|
489 | /** Shows UI. */
|
---|
490 | void showUI();
|
---|
491 |
|
---|
492 | /** Handles the VBoxSVC availability change. */
|
---|
493 | void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
|
---|
494 |
|
---|
495 | protected:
|
---|
496 |
|
---|
497 | bool eventFilter (QObject *, QEvent *);
|
---|
498 |
|
---|
499 | private:
|
---|
500 |
|
---|
501 | /* Constructor/destructor: */
|
---|
502 | VBoxGlobal();
|
---|
503 | ~VBoxGlobal();
|
---|
504 |
|
---|
505 | /** Re-initializes COM wrappers and containers. */
|
---|
506 | void comWrappersReinit();
|
---|
507 |
|
---|
508 | #ifdef VBOX_WS_WIN
|
---|
509 | /** Wraps WinAPI ShutdownBlockReasonCreate function.
|
---|
510 | * @remark This function defined starting from Vista only. */
|
---|
511 | static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason);
|
---|
512 | #endif
|
---|
513 |
|
---|
514 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
515 | void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
|
---|
516 | void setDebuggerVar(int *piDbgCfgVar, bool fState);
|
---|
517 | bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
|
---|
518 | #endif
|
---|
519 |
|
---|
520 | bool mValid;
|
---|
521 |
|
---|
522 | #ifdef VBOX_WS_MAC
|
---|
523 | /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */
|
---|
524 | MacOSXRelease m_osRelease;
|
---|
525 | #endif /* VBOX_WS_MAC */
|
---|
526 |
|
---|
527 | /** COM cleanup protection token. */
|
---|
528 | QReadWriteLock m_comCleanupProtectionToken;
|
---|
529 |
|
---|
530 | /** Holds the instance of VirtualBox client wrapper. */
|
---|
531 | CVirtualBoxClient m_client;
|
---|
532 | /** Holds the copy of VirtualBox object wrapper. */
|
---|
533 | CVirtualBox m_vbox;
|
---|
534 | /** Holds the copy of VirtualBox host-object wrapper. */
|
---|
535 | CHost m_host;
|
---|
536 | /** Holds the symbolic VirtualBox home-folder representation. */
|
---|
537 | QString m_strHomeFolder;
|
---|
538 | /** Holds the guest OS family IDs. */
|
---|
539 | QList<QString> m_guestOSFamilyIDs;
|
---|
540 | /** Holds the guest OS types for each family ID. */
|
---|
541 | QList<QList<CGuestOSType> > m_guestOSTypes;
|
---|
542 |
|
---|
543 | /** Holds whether acquired COM wrappers are currently valid. */
|
---|
544 | bool m_fWrappersValid;
|
---|
545 | /** Holds whether VBoxSVC is currently available. */
|
---|
546 | bool m_fVBoxSVCAvailable;
|
---|
547 |
|
---|
548 | /** Holds whether GUI is separate (from VM) process. */
|
---|
549 | bool m_fSeparateProcess;
|
---|
550 |
|
---|
551 | QString vmUuid;
|
---|
552 | QList<QUrl> m_ArgUrlList;
|
---|
553 |
|
---|
554 | /** Whether to show error message boxes for VM start errors. */
|
---|
555 | bool mShowStartVMErrors;
|
---|
556 |
|
---|
557 | /* Variable: Medium-enumeration stuff: */
|
---|
558 | UIMediumEnumerator *m_pMediumEnumerator;
|
---|
559 | mutable QReadWriteLock m_mediumEnumeratorDtorRwLock;
|
---|
560 |
|
---|
561 | /** Holds whether the Extension Pack installation was requested at startup. */
|
---|
562 | bool m_fEPInstallationRequested;
|
---|
563 |
|
---|
564 | #ifdef VBOX_WS_X11
|
---|
565 | /** X11: Holds whether the Window Manager we are running at is composition one. */
|
---|
566 | bool m_fCompositingManagerRunning;
|
---|
567 | /** X11: Holds the type of the Window Manager we are running under. */
|
---|
568 | X11WMType m_enmWindowManagerType;
|
---|
569 | #endif /* VBOX_WS_X11 */
|
---|
570 |
|
---|
571 | /** The --aggressive-caching / --no-aggressive-caching option. */
|
---|
572 | bool mAgressiveCaching;
|
---|
573 | /** The --restore-current option. */
|
---|
574 | bool mRestoreCurrentSnapshot;
|
---|
575 |
|
---|
576 | /** @name Ad-hoc VM reconfiguration.
|
---|
577 | * @{ */
|
---|
578 | /** Floppy image. */
|
---|
579 | QString m_strFloppyImage;
|
---|
580 | /** DVD image. */
|
---|
581 | QString m_strDvdImage;
|
---|
582 | /** @} */
|
---|
583 |
|
---|
584 | /** @name VMM options
|
---|
585 | * @{ */
|
---|
586 | /** The --disable-patm option. */
|
---|
587 | bool mDisablePatm;
|
---|
588 | /** The --disable-csam option. */
|
---|
589 | bool mDisableCsam;
|
---|
590 | /** The --recompile-supervisor option. */
|
---|
591 | bool mRecompileSupervisor;
|
---|
592 | /** The --recompile-user option. */
|
---|
593 | bool mRecompileUser;
|
---|
594 | /** The --execute-all-in-iem option. */
|
---|
595 | bool mExecuteAllInIem;
|
---|
596 | /** The --warp-factor option value. */
|
---|
597 | uint32_t mWarpPct;
|
---|
598 | /** @} */
|
---|
599 |
|
---|
600 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
601 | /** Whether the debugger should be accessible or not.
|
---|
602 | * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED,
|
---|
603 | * --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
604 | mutable int m_fDbgEnabled;
|
---|
605 | /** Whether to show the debugger automatically with the console.
|
---|
606 | * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
|
---|
607 | mutable int m_fDbgAutoShow;
|
---|
608 | /** Whether to show the command line window when m_fDbgAutoShow is set. */
|
---|
609 | mutable int m_fDbgAutoShowCommandLine;
|
---|
610 | /** Whether to show the statistics window when m_fDbgAutoShow is set. */
|
---|
611 | mutable int m_fDbgAutoShowStatistics;
|
---|
612 | /** VBoxDbg module handle. */
|
---|
613 | RTLDRMOD m_hVBoxDbg;
|
---|
614 |
|
---|
615 | /** Whether --start-running, --start-paused or nothing was given. */
|
---|
616 | enum StartRunning m_enmStartRunning;
|
---|
617 | #endif
|
---|
618 |
|
---|
619 | #if defined (VBOX_WS_WIN)
|
---|
620 | DWORD dwHTMLHelpCookie;
|
---|
621 | #endif
|
---|
622 |
|
---|
623 | QString mVerString;
|
---|
624 | QString mBrandingConfig;
|
---|
625 |
|
---|
626 | int m3DAvailable;
|
---|
627 |
|
---|
628 | QString mUserDefinedPortName;
|
---|
629 |
|
---|
630 | QPixmap mWarningIcon, mErrorIcon;
|
---|
631 |
|
---|
632 | QFileIconProvider m_globalIconProvider;
|
---|
633 |
|
---|
634 | #ifdef VBOX_GUI_WITH_PIDFILE
|
---|
635 | QString m_strPidfile;
|
---|
636 | #endif
|
---|
637 |
|
---|
638 | char mSettingsPw[256];
|
---|
639 | bool mSettingsPwSet;
|
---|
640 |
|
---|
641 | /** General icon-pool. */
|
---|
642 | UIIconPoolGeneral *m_pIconPool;
|
---|
643 | /** Holds the thread-pool instance. */
|
---|
644 | UIThreadPool *m_pThreadPool;
|
---|
645 |
|
---|
646 | /* API: Instance stuff: */
|
---|
647 | static bool m_sfCleanupInProgress;
|
---|
648 | static VBoxGlobal* m_spInstance;
|
---|
649 | friend VBoxGlobal& vboxGlobal();
|
---|
650 | };
|
---|
651 |
|
---|
652 | /* Shortcut to the static VBoxGlobal::instance() method: */
|
---|
653 | inline VBoxGlobal& vboxGlobal() { return *VBoxGlobal::instance(); }
|
---|
654 |
|
---|
655 | #endif /* !___VBoxGlobal_h___ */
|
---|
656 |
|
---|