VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h@ 103131

Last change on this file since 103131 was 102750, checked in by vboxsync, 13 months ago

FE/Qt: Extend UICommon with stuff to detect dark/light mode at GUI startup for platforms other than macOS or Windows; This time it's based purely on palette Window color luminance.

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

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