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