1 | /* $Id: UICommon.h 102482 2023-12-05 16:10:24Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UICommon class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_globals_UICommon_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UICommon_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QMap>
|
---|
36 | #include <QReadWriteLock>
|
---|
37 | #include <QObject>
|
---|
38 |
|
---|
39 | /* GUI includes: */
|
---|
40 | #include "UIDefs.h"
|
---|
41 | #include "UILibraryDefs.h"
|
---|
42 | #include "UIMediumDefs.h"
|
---|
43 | #ifdef VBOX_WS_NIX
|
---|
44 | # include "VBoxUtils-nix.h"
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | /* COM includes: */
|
---|
48 | #include "CHost.h"
|
---|
49 | #include "CMedium.h"
|
---|
50 | #include "CSession.h"
|
---|
51 | #include "CVirtualBox.h"
|
---|
52 | #include "CVirtualBoxClient.h"
|
---|
53 |
|
---|
54 | /* Other VBox includes: */
|
---|
55 | #include "VBox/com/Guid.h"
|
---|
56 |
|
---|
57 | /* Forward declarations: */
|
---|
58 | class QGraphicsWidget;
|
---|
59 | class QMenu;
|
---|
60 | class QSessionManager;
|
---|
61 | class QSpinBox;
|
---|
62 | class QToolButton;
|
---|
63 | class CCloudMachine;
|
---|
64 | class CHostVideoInputDevice;
|
---|
65 | class CMachine;
|
---|
66 | class CUSBDevice;
|
---|
67 | class UIActionPool;
|
---|
68 | class UIGuestOSTypeManager;
|
---|
69 | class UIMedium;
|
---|
70 | class UIMediumEnumerator;
|
---|
71 | class UIThreadPool;
|
---|
72 |
|
---|
73 | /** QObject subclass containing common GUI functionality. */
|
---|
74 | class SHARED_LIBRARY_STUFF UICommon : public QObject
|
---|
75 | {
|
---|
76 | Q_OBJECT;
|
---|
77 |
|
---|
78 | signals:
|
---|
79 |
|
---|
80 | /** @name Common stuff.
|
---|
81 | * @{ */
|
---|
82 | /** Asks #UIStarter listener to restart UI. */
|
---|
83 | void sigAskToRestartUI();
|
---|
84 | /** Asks #UIStarter listener to close UI. */
|
---|
85 | void sigAskToCloseUI();
|
---|
86 |
|
---|
87 | /** Notifies listeners about the VBoxSVC availability change. */
|
---|
88 | void sigVBoxSVCAvailabilityChange();
|
---|
89 |
|
---|
90 | /** Asks listeners to commit data. */
|
---|
91 | void sigAskToCommitData();
|
---|
92 | /** Asks listeners to detach COM. */
|
---|
93 | void sigAskToDetachCOM();
|
---|
94 | /** @} */
|
---|
95 |
|
---|
96 | /** @name Theme stuff.
|
---|
97 | * @{ */
|
---|
98 | /** Notifies listeners about theme change. */
|
---|
99 | void sigThemeChange();
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | /** @name COM: Extension Pack stuff.
|
---|
103 | * @{ */
|
---|
104 | /** Notifies listeners about extension pack @a strName was installed. */
|
---|
105 | void sigExtensionPackInstalled(const QString &strName);
|
---|
106 | /** Notifies listeners about extension pack @a strName was uninstalled. */
|
---|
107 | void sigExtensionPackUninstalled(const QString &strName);
|
---|
108 | /** @} */
|
---|
109 |
|
---|
110 | /** @name Cloud Virtual Machine stuff.
|
---|
111 | * @{ */
|
---|
112 | /** Notifies listeners about cloud VM was unregistered.
|
---|
113 | * @param strProviderShortName Brings provider short name.
|
---|
114 | * @param strProfileName Brings profile name.
|
---|
115 | * @param uId Brings cloud VM id. */
|
---|
116 | void sigCloudMachineUnregistered(const QString &strProviderShortName,
|
---|
117 | const QString &strProfileName,
|
---|
118 | const QUuid &uId);
|
---|
119 | /** Notifies listeners about cloud VM was registered.
|
---|
120 | * @param strProviderShortName Brings provider short name.
|
---|
121 | * @param strProfileName Brings profile name.
|
---|
122 | * @param comMachine Brings cloud VM. */
|
---|
123 | void sigCloudMachineRegistered(const QString &strProviderShortName,
|
---|
124 | const QString &strProfileName,
|
---|
125 | const CCloudMachine &comMachine);
|
---|
126 | /** @} */
|
---|
127 |
|
---|
128 | /** @name COM: Virtual Media stuff.
|
---|
129 | * @{ */
|
---|
130 | /** Notifies listeners about medium with certain @a uMediumID created. */
|
---|
131 | void sigMediumCreated(const QUuid &uMediumID);
|
---|
132 | /** Notifies listeners about medium with certain @a uMediumID deleted. */
|
---|
133 | void sigMediumDeleted(const QUuid &uMediumID);
|
---|
134 |
|
---|
135 | /** Notifies listeners about medium-enumeration started. */
|
---|
136 | void sigMediumEnumerationStarted();
|
---|
137 | /** Notifies listeners about medium with certain @a uMediumID enumerated. */
|
---|
138 | void sigMediumEnumerated(const QUuid &uMediumID);
|
---|
139 | /** Notifies listeners about medium-enumeration finished. */
|
---|
140 | void sigMediumEnumerationFinished();
|
---|
141 | /** Notifies listeners about update of recently media list. */
|
---|
142 | void sigRecentMediaListUpdated(UIMediumDeviceType enmMediumType);
|
---|
143 | /** @} */
|
---|
144 |
|
---|
145 | public:
|
---|
146 |
|
---|
147 | /** UI types. */
|
---|
148 | enum UIType
|
---|
149 | {
|
---|
150 | UIType_SelectorUI,
|
---|
151 | UIType_RuntimeUI
|
---|
152 | };
|
---|
153 |
|
---|
154 | /** VM launch running options. */
|
---|
155 | enum LaunchRunning
|
---|
156 | {
|
---|
157 | LaunchRunning_Default, /**< Default (depends on debug settings). */
|
---|
158 | LaunchRunning_No, /**< Start the VM paused. */
|
---|
159 | LaunchRunning_Yes /**< Start the VM running. */
|
---|
160 | };
|
---|
161 |
|
---|
162 | /** Returns UICommon instance. */
|
---|
163 | static UICommon *instance() { return s_pInstance; }
|
---|
164 | /** Creates UICommon instance of passed @a enmType. */
|
---|
165 | static void create(UIType enmType);
|
---|
166 | /** Destroys UICommon instance. */
|
---|
167 | static void destroy();
|
---|
168 |
|
---|
169 | /** @name General stuff.
|
---|
170 | * @{ */
|
---|
171 | /** Returns the UI type. */
|
---|
172 | UIType uiType() const { return m_enmType; }
|
---|
173 |
|
---|
174 | /** Returns whether UICommon instance is properly initialized. */
|
---|
175 | bool isValid() const { return m_fValid; }
|
---|
176 | /** Returns whether UICommon instance cleanup is in progress. */
|
---|
177 | bool isCleaningUp() const { return m_fCleaningUp; }
|
---|
178 |
|
---|
179 | #ifdef VBOX_WS_MAC
|
---|
180 | /** Returns whether macOS is in Dark mode. */
|
---|
181 | bool isInDarkMode() const { return m_fDarkMode; }
|
---|
182 | #endif
|
---|
183 | /** @} */
|
---|
184 |
|
---|
185 | /** @name Versioning stuff.
|
---|
186 | * @{ */
|
---|
187 | /** Returns Qt runtime version string. */
|
---|
188 | static QString qtRTVersionString();
|
---|
189 | /** Returns Qt runtime version. */
|
---|
190 | static uint qtRTVersion();
|
---|
191 | /** Returns Qt runtime major version. */
|
---|
192 | static uint qtRTMajorVersion();
|
---|
193 | /** Returns Qt runtime minor version. */
|
---|
194 | static uint qtRTMinorVersion();
|
---|
195 | /** Returns Qt runtime revision number. */
|
---|
196 | static uint qtRTRevisionNumber();
|
---|
197 |
|
---|
198 | /** Returns Qt compiled version string. */
|
---|
199 | static QString qtCTVersionString();
|
---|
200 | /** Returns Qt compiled version. */
|
---|
201 | static uint qtCTVersion();
|
---|
202 |
|
---|
203 | /** Returns VBox version string. */
|
---|
204 | QString vboxVersionString() const;
|
---|
205 | /** Returns normalized VBox version string. */
|
---|
206 | QString vboxVersionStringNormalized() const;
|
---|
207 | /** Returns whether VBox version string contains BETA word. */
|
---|
208 | bool isBeta() const;
|
---|
209 | /** Returns whether BETA label should be shown. */
|
---|
210 | bool showBetaLabel() const;
|
---|
211 |
|
---|
212 | /** Returns whether branding is active. */
|
---|
213 | bool brandingIsActive(bool fForce = false);
|
---|
214 | /** Returns value for certain branding @a strKey from custom.ini file. */
|
---|
215 | QString brandingGetKey(QString strKey) const;
|
---|
216 | /** @} */
|
---|
217 |
|
---|
218 | /** @name Host OS stuff.
|
---|
219 | * @{ */
|
---|
220 | /** Loads the color theme. */
|
---|
221 | void loadColorTheme();
|
---|
222 |
|
---|
223 | #ifdef VBOX_WS_NIX
|
---|
224 | /** X11: Returns the type of the Window Manager we are running under. */
|
---|
225 | X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }
|
---|
226 | /** X11: Returns whether the Window Manager we are running under is composition one. */
|
---|
227 | bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
|
---|
228 | /** Returns true if the detected display server type is either xorg or xwayland. */
|
---|
229 | bool X11ServerAvailable() const;
|
---|
230 | /** Returns display server type. */
|
---|
231 | VBGHDISPLAYSERVERTYPE displayServerType() const;
|
---|
232 | #endif
|
---|
233 | /** Returns the name of the host OS by using IHost::getOperatingSystem. */
|
---|
234 | QString hostOperatingSystem() const;
|
---|
235 | /** @} */
|
---|
236 |
|
---|
237 | /** @name Process arguments stuff.
|
---|
238 | * @{ */
|
---|
239 | /** Process application args. */
|
---|
240 | bool processArgs();
|
---|
241 |
|
---|
242 | /** Returns whether there are unhandled URL arguments present. */
|
---|
243 | bool argumentUrlsPresent() const;
|
---|
244 | /** Takes and returns the URL argument list while clearing the source. */
|
---|
245 | QList<QUrl> takeArgumentUrls();
|
---|
246 |
|
---|
247 | /** Returns the --startvm option value (managed VM id). */
|
---|
248 | QUuid managedVMUuid() const { return m_uManagedVMId; }
|
---|
249 | /** Returns the --separate option value (whether GUI process is separate from VM process). */
|
---|
250 | bool isSeparateProcess() const { return m_fSeparateProcess; }
|
---|
251 | /** Returns the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
|
---|
252 | bool showStartVMErrors() const { return m_fShowStartVMErrors; }
|
---|
253 |
|
---|
254 | /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
|
---|
255 | bool agressiveCaching() const { return m_fAgressiveCaching; }
|
---|
256 |
|
---|
257 | /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */
|
---|
258 | bool shouldRestoreCurrentSnapshot() const { return m_fRestoreCurrentSnapshot; }
|
---|
259 | /** Defines whether we should fRestore current snapshot before VM started. */
|
---|
260 | void setShouldRestoreCurrentSnapshot(bool fRestore) { m_fRestoreCurrentSnapshot = fRestore; }
|
---|
261 |
|
---|
262 | /** Returns the --fda option value (whether we have floppy image). */
|
---|
263 | bool hasFloppyImageToMount() const { return !m_uFloppyImage.isNull(); }
|
---|
264 | /** Returns the --dvd | --cdrom option value (whether we have DVD image). */
|
---|
265 | bool hasDvdImageToMount() const { return !m_uDvdImage.isNull(); }
|
---|
266 | /** Returns floppy image name. */
|
---|
267 | QUuid getFloppyImage() const { return m_uFloppyImage; }
|
---|
268 | /** Returns DVD image name. */
|
---|
269 | QUuid getDvdImage() const { return m_uDvdImage; }
|
---|
270 |
|
---|
271 | /** Returns the --execute-all-in-iem option value. */
|
---|
272 | bool areWeToExecuteAllInIem() const { return m_fExecuteAllInIem; }
|
---|
273 | /** Returns whether --warp-factor option value is equal to 100. */
|
---|
274 | bool isDefaultWarpPct() const { return m_uWarpPct == 100; }
|
---|
275 | /** Returns the --warp-factor option value. */
|
---|
276 | uint32_t getWarpPct() const { return m_uWarpPct; }
|
---|
277 |
|
---|
278 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
279 | /** Holds whether the debugger should be accessible. */
|
---|
280 | bool isDebuggerEnabled() const;
|
---|
281 | /** Holds whether to show the debugger automatically with the console. */
|
---|
282 | bool isDebuggerAutoShowEnabled() const;
|
---|
283 | /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
|
---|
284 | bool isDebuggerAutoShowCommandLineEnabled() const;
|
---|
285 | /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
|
---|
286 | bool isDebuggerAutoShowStatisticsEnabled() const;
|
---|
287 | /** Returns the combined --statistics-expand values. */
|
---|
288 | QString const getDebuggerStatisticsExpand() const { return m_strDbgStatisticsExpand; }
|
---|
289 | /** Returns the --statistics-filter value. */
|
---|
290 | QString const getDebuggerStatisticsFilter() const { return m_strDbgStatisticsFilter; }
|
---|
291 |
|
---|
292 | /** VBoxDbg module handle. */
|
---|
293 | RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
|
---|
294 | #endif
|
---|
295 |
|
---|
296 | /** Returns whether VM should start paused. */
|
---|
297 | bool shouldStartPaused() const;
|
---|
298 |
|
---|
299 | #ifdef VBOX_GUI_WITH_PIDFILE
|
---|
300 | /** Creates PID file. */
|
---|
301 | void createPidfile();
|
---|
302 | /** Deletes PID file. */
|
---|
303 | void deletePidfile();
|
---|
304 | #endif
|
---|
305 | /** @} */
|
---|
306 |
|
---|
307 | /** @name COM stuff.
|
---|
308 | * @{ */
|
---|
309 | /** Try to acquire COM cleanup protection token for reading. */
|
---|
310 | bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
|
---|
311 | /** Unlock previously acquired COM cleanup protection token. */
|
---|
312 | void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
|
---|
313 |
|
---|
314 | /** Returns the copy of VirtualBox client wrapper. */
|
---|
315 | CVirtualBoxClient virtualBoxClient() const { return m_comVBoxClient; }
|
---|
316 | /** Returns the copy of VirtualBox object wrapper. */
|
---|
317 | CVirtualBox virtualBox() const { return m_comVBox; }
|
---|
318 | /** Returns the copy of VirtualBox host-object wrapper. */
|
---|
319 | CHost host() const { return m_comHost; }
|
---|
320 | /** Returns the symbolic VirtualBox home-folder representation. */
|
---|
321 | QString homeFolder() const { return m_strHomeFolder; }
|
---|
322 |
|
---|
323 | /** Returns the VBoxSVC availability value. */
|
---|
324 | bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
|
---|
325 | /** @} */
|
---|
326 |
|
---|
327 | /** @name COM: Virtual Machine stuff.
|
---|
328 | * @{ */
|
---|
329 | /** Switches to certain @a comMachine. */
|
---|
330 | static bool switchToMachine(CMachine &comMachine);
|
---|
331 | /** Launches certain @a comMachine in specified @a enmLaunchMode. */
|
---|
332 | static bool launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode = UILaunchMode_Default);
|
---|
333 |
|
---|
334 | /** Opens session of certain @a enmLockType for VM with certain @a uId. */
|
---|
335 | CSession openSession(QUuid uId, KLockType enmLockType = KLockType_Write);
|
---|
336 | /** Opens session of certain @a enmLockType for currently chosen VM. */
|
---|
337 | CSession openSession(KLockType enmLockType = KLockType_Write);
|
---|
338 | /** Opens session of KLockType_Shared type for VM with certain @a uId. */
|
---|
339 | CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
|
---|
340 | /** Tries to guess if new @a comSession needs to be opened for certain @a comMachine,
|
---|
341 | * if yes, new session of required type will be opened and machine will be updated,
|
---|
342 | * otherwise, no session will be created and machine will be left unchanged. */
|
---|
343 | CSession tryToOpenSessionFor(CMachine &comMachine);
|
---|
344 | /** @} */
|
---|
345 |
|
---|
346 | /** @name COM: Cloud Virtual Machine stuff.
|
---|
347 | * @{ */
|
---|
348 | /** Notifies listeners about cloud VM was unregistered.
|
---|
349 | * @param strProviderShortName Brings provider short name.
|
---|
350 | * @param strProfileName Brings profile name.
|
---|
351 | * @param uId Brings cloud VM id. */
|
---|
352 | void notifyCloudMachineUnregistered(const QString &strProviderShortName,
|
---|
353 | const QString &strProfileName,
|
---|
354 | const QUuid &uId);
|
---|
355 | /** Notifies listeners about cloud VM was registered.
|
---|
356 | * @param strProviderShortName Brings provider short name.
|
---|
357 | * @param strProfileName Brings profile name.
|
---|
358 | * @param comMachine Brings cloud VM. */
|
---|
359 | void notifyCloudMachineRegistered(const QString &strProviderShortName,
|
---|
360 | const QString &strProfileName,
|
---|
361 | const CCloudMachine &comMachine);
|
---|
362 | /** @} */
|
---|
363 |
|
---|
364 | /** @name COM: Guest OS type stuff.
|
---|
365 | * @{ */
|
---|
366 | const UIGuestOSTypeManager &guestOSTypeManager();
|
---|
367 | /** @} */
|
---|
368 |
|
---|
369 | /** @name COM: Virtual Media stuff.
|
---|
370 | * @{ */
|
---|
371 | /** Enumerates passed @a comMedia. */
|
---|
372 | void enumerateMedia(const CMediumVector &comMedia = CMediumVector());
|
---|
373 | /** Calls refresh for each medium which has been already enumerated. */
|
---|
374 | void refreshMedia();
|
---|
375 | /** Returns whether full medium-enumeration is requested. */
|
---|
376 | bool isFullMediumEnumerationRequested() const;
|
---|
377 | /** Returns whether any medium-enumeration is in progress. */
|
---|
378 | bool isMediumEnumerationInProgress() const;
|
---|
379 | /** Returns enumerated medium with certain @a uMediumID. */
|
---|
380 | UIMedium medium(const QUuid &uMediumID) const;
|
---|
381 | /** Returns enumerated medium IDs. */
|
---|
382 | QList<QUuid> mediumIDs() const;
|
---|
383 | /** Creates medium on the basis of passed @a guiMedium description. */
|
---|
384 | void createMedium(const UIMedium &guiMedium);
|
---|
385 |
|
---|
386 | /** Opens external medium by passed @a strMediumLocation.
|
---|
387 | * @param enmMediumType Brings the medium type.
|
---|
388 | * @param pParent Brings the dialog parent.
|
---|
389 | * @param strMediumLocation Brings the file path to load medium from.
|
---|
390 | * @param pParent Brings the dialog parent. */
|
---|
391 | QUuid openMedium(UIMediumDeviceType enmMediumType, QString strMediumLocation, QWidget *pParent = 0);
|
---|
392 |
|
---|
393 | /** Opens external medium using file-open dialog.
|
---|
394 | * @param enmMediumType Brings the medium type.
|
---|
395 | * @param pParent Brings the dialog parent.
|
---|
396 | * @param strDefaultFolder Brings the folder to browse for medium.
|
---|
397 | * @param fUseLastFolder Brings whether we should propose to use last used folder. */
|
---|
398 | QUuid openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent = 0,
|
---|
399 | const QString &strDefaultFolder = QString(), bool fUseLastFolder = false);
|
---|
400 |
|
---|
401 | /** Creates and shows a dialog (wizard) to create a medium of type @a enmMediumType.
|
---|
402 | * @param pParent Passes the parent of the dialog,
|
---|
403 | * @param enmMediumType Passes the medium type,
|
---|
404 | * @param strMachineName Passes the name of the machine,
|
---|
405 | * @param strMachineFolder Passes the machine folder,
|
---|
406 | * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os,
|
---|
407 | * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog,
|
---|
408 | * returns QUuid of the new medium */
|
---|
409 | QUuid openMediumCreatorDialog(UIActionPool *pActionPool, QWidget *pParent, UIMediumDeviceType enmMediumType,
|
---|
410 | const QString &strMachineFolder = QString(), const QString &strMachineName = QString(),
|
---|
411 | const QString &strMachineGuestOSTypeId = QString());
|
---|
412 |
|
---|
413 | /** Prepares storage menu according passed parameters.
|
---|
414 | * @param menu Brings the #QMenu to be prepared.
|
---|
415 | * @param pListener Brings the listener #QObject, this @a menu being prepared for.
|
---|
416 | * @param pszSlotName Brings the name of the SLOT in the @a pListener above, this menu will be handled with.
|
---|
417 | * @param comMachine Brings the #CMachine object, this @a menu being prepared for.
|
---|
418 | * @param strControllerName Brings the name of the #CStorageController in the @a machine above.
|
---|
419 | * @param storageSlot Brings the #StorageSlot of the storage controller with @a strControllerName above. */
|
---|
420 | void prepareStorageMenu(QMenu *pMenu,
|
---|
421 | QObject *pListener, const char *pszSlotName,
|
---|
422 | const CMachine &comMachine, const QString &strControllerName, const StorageSlot &storageSlot);
|
---|
423 | /** Updates @a comConstMachine storage with data described by @a target. */
|
---|
424 | void updateMachineStorage(const CMachine &comConstMachine, const UIMediumTarget &target, UIActionPool *pActionPool);
|
---|
425 |
|
---|
426 | /** Generates details for passed @a comMedium.
|
---|
427 | * @param fPredictDiff Brings whether medium will be marked differencing on attaching.
|
---|
428 | * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */
|
---|
429 | QString storageDetails(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml = true);
|
---|
430 |
|
---|
431 | /** Update extra data related to recently used/referred media.
|
---|
432 | * @param enmMediumType Passes the medium type.
|
---|
433 | * @param strMediumLocation Passes the medium location. */
|
---|
434 | void updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType enmMediumType, QString strMediumLocation);
|
---|
435 |
|
---|
436 | /** Searches extra data for the recently used folder path which corresponds to @a enmMediumType. When that search fails
|
---|
437 | it looks for recent folder extra data for other medium types. As the last resort returns default vm folder path.
|
---|
438 | * @param enmMediumType Passes the medium type. */
|
---|
439 | QString defaultFolderPathForType(UIMediumDeviceType enmMediumType);
|
---|
440 |
|
---|
441 | /** Calculates @a cAmount of immutable images used by @a comMachine specified. */
|
---|
442 | static bool acquireAmountOfImmutableImages(const CMachine &comMachine, ulong &cAmount);
|
---|
443 | /** @} */
|
---|
444 |
|
---|
445 | /** @name COM: USB stuff.
|
---|
446 | * @{ */
|
---|
447 | #ifdef RT_OS_LINUX
|
---|
448 | /** Verifies that USB drivers are properly configured on Linux. */
|
---|
449 | static void checkForWrongUSBMounted();
|
---|
450 | #endif
|
---|
451 |
|
---|
452 | /** Generates details for passed USB @a comDevice. */
|
---|
453 | static QString usbDetails(const CUSBDevice &comDevice);
|
---|
454 | /** Generates tool-tip for passed USB @a comDevice. */
|
---|
455 | static QString usbToolTip(const CUSBDevice &comDevice);
|
---|
456 | /** Generates tool-tip for passed USB @a comFilter. */
|
---|
457 | static QString usbToolTip(const CUSBDeviceFilter &comFilter);
|
---|
458 | /** Generates tool-tip for passed USB @a comWebcam. */
|
---|
459 | static QString usbToolTip(const CHostVideoInputDevice &comWebcam);
|
---|
460 | /** @} */
|
---|
461 |
|
---|
462 | /** @name COM: Recording stuff.
|
---|
463 | * @{ */
|
---|
464 | /** Returns supported recording features flag. */
|
---|
465 | int supportedRecordingFeatures() const;
|
---|
466 | /** @} */
|
---|
467 |
|
---|
468 | /** @name File-system stuff.
|
---|
469 | * @{ */
|
---|
470 | /** Returns full help file name. */
|
---|
471 | static QString helpFile();
|
---|
472 |
|
---|
473 | /** Returns documents path. */
|
---|
474 | static QString documentsPath();
|
---|
475 |
|
---|
476 | /** Returns whether passed @a strFileName ends with one of allowed extension in the @a extensions list. */
|
---|
477 | static bool hasAllowedExtension(const QString &strFileName, const QStringList &extensions);
|
---|
478 |
|
---|
479 | /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts
|
---|
480 | * searching strBaseFileName and adds suffixes until a unique file name is found. */
|
---|
481 | static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName);
|
---|
482 | /** @} */
|
---|
483 |
|
---|
484 | /** @name Widget stuff.
|
---|
485 | * @{ */
|
---|
486 | /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */
|
---|
487 | static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
|
---|
488 | /** @} */
|
---|
489 |
|
---|
490 | /** @name Display stuff.
|
---|
491 | * @{ */
|
---|
492 | #ifdef VBOX_WITH_3D_ACCELERATION
|
---|
493 | /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
|
---|
494 | static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
|
---|
495 | #endif
|
---|
496 | /** Returns the required video memory in bytes for the current desktop
|
---|
497 | * resolution at maximum possible screen depth in bpp. */
|
---|
498 | static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
|
---|
499 | KGraphicsControllerType getRecommendedGraphicsController(const QString &strGuestOSTypeId) const;
|
---|
500 | /** @} */
|
---|
501 |
|
---|
502 | /** @name Thread stuff.
|
---|
503 | * @{ */
|
---|
504 | /** Returns the thread-pool instance. */
|
---|
505 | UIThreadPool *threadPool() const { return m_pThreadPool; }
|
---|
506 | /** Returns the thread-pool instance for cloud needs. */
|
---|
507 | UIThreadPool *threadPoolCloud() const { return m_pThreadPoolCloud; }
|
---|
508 | /** @} */
|
---|
509 |
|
---|
510 | /** @name Context sensitive help related functionality
|
---|
511 | * @{ */
|
---|
512 | /** Sets the property for help keyword on a QObject
|
---|
513 | * @param pObject The object to set the help keyword property on
|
---|
514 | * @param strKeyword The values of the key word property. */
|
---|
515 | static void setHelpKeyword(QObject *pObject, const QString &strHelpKeyword);
|
---|
516 | /** Returns the property for help keyword of a QObject. If no such property exists returns an empty QString.
|
---|
517 | * @param pWidget The object to get the help keyword property from. */
|
---|
518 | static QString helpKeyword(const QObject *pWidget);
|
---|
519 | /** @} */
|
---|
520 |
|
---|
521 | /** @name COM: Extension Pack stuff.
|
---|
522 | * @{ */
|
---|
523 | /** Returns true if it can find at least one usable ext. pack. Else returns false. */
|
---|
524 | bool isExtentionPackInstalled() const;
|
---|
525 | /** @} */
|
---|
526 |
|
---|
527 | public slots:
|
---|
528 |
|
---|
529 | /** @name Process arguments stuff.
|
---|
530 | * @{ */
|
---|
531 | /** Opens the specified URL using OS/Desktop capabilities. */
|
---|
532 | bool openURL(const QString &strURL) const;
|
---|
533 | /** @} */
|
---|
534 |
|
---|
535 | /** @name Localization stuff.
|
---|
536 | * @{ */
|
---|
537 | /** Handles language change to new @a strLanguage. */
|
---|
538 | void sltGUILanguageChange(QString strLanguage);
|
---|
539 | /** @} */
|
---|
540 |
|
---|
541 | /** @name Media related stuff.
|
---|
542 | * @{ */
|
---|
543 | /** Handles signal about medium was created. */
|
---|
544 | void sltHandleMediumCreated(const CMedium &comMedium);
|
---|
545 | /** @} */
|
---|
546 |
|
---|
547 | /** @name Machine related stuff.
|
---|
548 | * @{ */
|
---|
549 | /** Handles signal about machine was created. */
|
---|
550 | void sltHandleMachineCreated(const CMachine &comMachine);
|
---|
551 | /** @} */
|
---|
552 |
|
---|
553 | /** @name Cloud Machine related stuff.
|
---|
554 | * @{ */
|
---|
555 | /** Handles signal about cloud machine was added. */
|
---|
556 | void sltHandleCloudMachineAdded(const QString &strProviderShortName,
|
---|
557 | const QString &strProfileName,
|
---|
558 | const CCloudMachine &comMachine);
|
---|
559 | /** @} */
|
---|
560 |
|
---|
561 | protected:
|
---|
562 |
|
---|
563 | /** Preprocesses any Qt @a pEvent for passed @a pObject. */
|
---|
564 | virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
|
---|
565 |
|
---|
566 | /** Handles translation event. */
|
---|
567 | virtual void retranslateUi();
|
---|
568 |
|
---|
569 | protected slots:
|
---|
570 |
|
---|
571 | /** Calls for cleanup() functionality. */
|
---|
572 | void sltCleanup() { cleanup(); }
|
---|
573 |
|
---|
574 | #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
|
---|
575 | /** @name Common stuff.
|
---|
576 | * @{ */
|
---|
577 | /** Handles @a manager request for emergency session shutdown. */
|
---|
578 | void sltHandleCommitDataRequest(QSessionManager &manager);
|
---|
579 | /** @} */
|
---|
580 | #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
|
---|
581 |
|
---|
582 | /** @name COM stuff.
|
---|
583 | * @{ */
|
---|
584 | /** Handles the VBoxSVC availability change. */
|
---|
585 | void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
|
---|
586 | /** @} */
|
---|
587 |
|
---|
588 | /* Handle font scale factor change. */
|
---|
589 | void sltHandleFontScaleFactorChanged(int iFontScaleFactor);
|
---|
590 |
|
---|
591 | private:
|
---|
592 |
|
---|
593 | /** Construcs global VirtualBox object of passed @a enmType. */
|
---|
594 | UICommon(UIType enmType);
|
---|
595 | /** Destrucs global VirtualBox object. */
|
---|
596 | virtual ~UICommon() /* override final */;
|
---|
597 |
|
---|
598 | /** Prepares all. */
|
---|
599 | void prepare();
|
---|
600 | /** Cleanups all. */
|
---|
601 | void cleanup();
|
---|
602 |
|
---|
603 | /** @name Process arguments stuff.
|
---|
604 | * @{ */
|
---|
605 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
606 | /** Initializes a debugger config variable.
|
---|
607 | * @param piDbgCfgVar Brings the debugger config variable to init.
|
---|
608 | * @param pszEnvVar Brings the environment variable name relating to this variable.
|
---|
609 | * @param pszExtraDataName Brings the extra data name relating to this variable.
|
---|
610 | * @param fDefault Brings the default value. */
|
---|
611 | void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
|
---|
612 | /** Set a debugger config variable according according to start up argument.
|
---|
613 | * @param piDbgCfgVar Brings the debugger config variable to set.
|
---|
614 | * @param fState Brings the value from the command line. */
|
---|
615 | void setDebuggerVar(int *piDbgCfgVar, bool fState);
|
---|
616 | /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
|
---|
617 | * @param piDbgCfgVar Brings the debugger config variable to consult.
|
---|
618 | * @param pszExtraDataName Brings the extra data name relating to this variable. */
|
---|
619 | bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
|
---|
620 | #endif
|
---|
621 | /** @} */
|
---|
622 |
|
---|
623 | /** @name COM stuff.
|
---|
624 | * @{ */
|
---|
625 | /** Re-initializes COM wrappers and containers. */
|
---|
626 | void comWrappersReinit();
|
---|
627 | /** @} */
|
---|
628 |
|
---|
629 | /** Holds the singleton UICommon instance. */
|
---|
630 | static UICommon *s_pInstance;
|
---|
631 |
|
---|
632 | /** @name General stuff.
|
---|
633 | * @{ */
|
---|
634 | /** Holds the UI type. */
|
---|
635 | UIType m_enmType;
|
---|
636 |
|
---|
637 | /** Holds whether UICommon instance is properly initialized. */
|
---|
638 | bool m_fValid;
|
---|
639 | /** Holds whether UICommon instance cleanup is in progress. */
|
---|
640 | bool m_fCleaningUp;
|
---|
641 | #ifdef VBOX_WS_WIN
|
---|
642 | /** Holds whether overall GUI data is committed. */
|
---|
643 | bool m_fDataCommitted;
|
---|
644 | #endif
|
---|
645 |
|
---|
646 | #ifdef VBOX_WS_MAC
|
---|
647 | /** Holds whether macOS is in Dark mode. */
|
---|
648 | bool m_fDarkMode;
|
---|
649 | #endif
|
---|
650 | /** @} */
|
---|
651 |
|
---|
652 | /** @name Versioning stuff.
|
---|
653 | * @{ */
|
---|
654 | /** Holds the VBox branding config file path. */
|
---|
655 | QString m_strBrandingConfigFilePath;
|
---|
656 | /** @} */
|
---|
657 |
|
---|
658 | /** @name Host OS stuff.
|
---|
659 | * @{ */
|
---|
660 | #ifdef VBOX_WS_NIX
|
---|
661 | /** X11: Holds the #X11WMType of the Window Manager we are running under. */
|
---|
662 | X11WMType m_enmWindowManagerType;
|
---|
663 | /** X11: Holds whether the Window Manager we are running at is composition one. */
|
---|
664 | bool m_fCompositingManagerRunning;
|
---|
665 | /** Unixes: Holds the display server type. */
|
---|
666 | VBGHDISPLAYSERVERTYPE m_enmDisplayServerType;
|
---|
667 | #endif
|
---|
668 | /** @} */
|
---|
669 |
|
---|
670 | /** @name Process arguments stuff.
|
---|
671 | * @{ */
|
---|
672 | /** Holds the URL arguments list. */
|
---|
673 | QList<QUrl> m_listArgUrls;
|
---|
674 |
|
---|
675 | /** Holds the --startvm option value (managed VM id). */
|
---|
676 | QUuid m_uManagedVMId;
|
---|
677 | /** Holds the --separate option value (whether GUI process is separate from VM process). */
|
---|
678 | bool m_fSeparateProcess;
|
---|
679 | /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
|
---|
680 | bool m_fShowStartVMErrors;
|
---|
681 |
|
---|
682 | /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
|
---|
683 | bool m_fAgressiveCaching;
|
---|
684 |
|
---|
685 | /** Holds the --restore-current option value. */
|
---|
686 | bool m_fRestoreCurrentSnapshot;
|
---|
687 |
|
---|
688 | /** Holds the --fda option value (floppy image). */
|
---|
689 | QUuid m_uFloppyImage;
|
---|
690 | /** Holds the --dvd | --cdrom option value (DVD image). */
|
---|
691 | QUuid m_uDvdImage;
|
---|
692 |
|
---|
693 | /** Holds the --execute-all-in-iem option value. */
|
---|
694 | bool m_fExecuteAllInIem;
|
---|
695 | /** Holds the --warp-factor option value. */
|
---|
696 | uint32_t m_uWarpPct;
|
---|
697 |
|
---|
698 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
699 | /** Holds whether the debugger should be accessible. */
|
---|
700 | mutable int m_fDbgEnabled;
|
---|
701 | /** Holds whether to show the debugger automatically with the console. */
|
---|
702 | mutable int m_fDbgAutoShow;
|
---|
703 | /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
|
---|
704 | mutable int m_fDbgAutoShowCommandLine;
|
---|
705 | /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
|
---|
706 | mutable int m_fDbgAutoShowStatistics;
|
---|
707 | /** Pattern of statistics to expand when opening the viewer. */
|
---|
708 | QString m_strDbgStatisticsExpand;
|
---|
709 | /** The statistics viewer filter. */
|
---|
710 | QString m_strDbgStatisticsFilter;
|
---|
711 |
|
---|
712 | /** VBoxDbg module handle. */
|
---|
713 | RTLDRMOD m_hVBoxDbg;
|
---|
714 |
|
---|
715 | /** Holds whether --start-running, --start-paused or nothing was given. */
|
---|
716 | LaunchRunning m_enmLaunchRunning;
|
---|
717 | #endif
|
---|
718 |
|
---|
719 | /** Holds the --settingspw option value or the content of --settingspwfile. */
|
---|
720 | char m_astrSettingsPw[256];
|
---|
721 | /** Holds the --settingspwfile option value. */
|
---|
722 | bool m_fSettingsPwSet;
|
---|
723 |
|
---|
724 | #ifdef VBOX_GUI_WITH_PIDFILE
|
---|
725 | /** Holds the --pidfile option value (application PID file path). */
|
---|
726 | QString m_strPidFile;
|
---|
727 | #endif
|
---|
728 | /** @} */
|
---|
729 |
|
---|
730 | /** @name COM stuff.
|
---|
731 | * @{ */
|
---|
732 | /** Holds the COM cleanup protection token. */
|
---|
733 | QReadWriteLock m_comCleanupProtectionToken;
|
---|
734 |
|
---|
735 | /** Holds the instance of VirtualBox client wrapper. */
|
---|
736 | CVirtualBoxClient m_comVBoxClient;
|
---|
737 | /** Holds the copy of VirtualBox object wrapper. */
|
---|
738 | CVirtualBox m_comVBox;
|
---|
739 | /** Holds the copy of VirtualBox host-object wrapper. */
|
---|
740 | CHost m_comHost;
|
---|
741 | /** Holds the symbolic VirtualBox home-folder representation. */
|
---|
742 | QString m_strHomeFolder;
|
---|
743 |
|
---|
744 | /** Holds whether acquired COM wrappers are currently valid. */
|
---|
745 | bool m_fWrappersValid;
|
---|
746 | /** Holds whether VBoxSVC is currently available. */
|
---|
747 | bool m_fVBoxSVCAvailable;
|
---|
748 | /** @} */
|
---|
749 |
|
---|
750 | /** @name Thread stuff.
|
---|
751 | * @{ */
|
---|
752 | /** Holds the thread-pool instance. */
|
---|
753 | UIThreadPool *m_pThreadPool;
|
---|
754 | /** Holds the thread-pool instance for cloud needs. */
|
---|
755 | UIThreadPool *m_pThreadPoolCloud;
|
---|
756 | /** @} */
|
---|
757 |
|
---|
758 | /** @name Guest OS type related stuff.
|
---|
759 | * @{ */
|
---|
760 | /** Holds the guest OS type manager instance. */
|
---|
761 | UIGuestOSTypeManager *m_pGuestOSTypeManager;
|
---|
762 | /** @} */
|
---|
763 |
|
---|
764 | /** @name Media related stuff.
|
---|
765 | * @{ */
|
---|
766 | /** Holds the medium enumerator cleanup protection token. */
|
---|
767 | mutable QReadWriteLock m_meCleanupProtectionToken;
|
---|
768 |
|
---|
769 | /** Holds the medium enumerator. */
|
---|
770 | UIMediumEnumerator *m_pMediumEnumerator;
|
---|
771 | /** List of medium names that should not appears in the recently used media extra data. */
|
---|
772 | QStringList m_recentMediaExcludeList;
|
---|
773 | /** @} */
|
---|
774 |
|
---|
775 | #ifdef VBOX_WS_WIN
|
---|
776 | /** @name ATL stuff.
|
---|
777 | * @{ */
|
---|
778 | /** Holds the ATL module instance (for use with UICommon shared library only).
|
---|
779 | * @note Required internally by ATL (constructor records instance in global variable). */
|
---|
780 | ATL::CComModule _Module;
|
---|
781 | /** @} */
|
---|
782 | #endif
|
---|
783 | /** @name Font scaling related variables.
|
---|
784 | * @{ */
|
---|
785 | int iOriginalFontPixelSize;
|
---|
786 | int iOriginalFontPointSize;
|
---|
787 | /** @} */
|
---|
788 |
|
---|
789 | /** Allows for shortcut access. */
|
---|
790 | friend UICommon &uiCommon();
|
---|
791 | };
|
---|
792 |
|
---|
793 | /** Singleton UICommon 'official' name. */
|
---|
794 | inline UICommon &uiCommon() { return *UICommon::instance(); }
|
---|
795 |
|
---|
796 | #endif /* !FEQT_INCLUDED_SRC_globals_UICommon_h */
|
---|