VirtualBox

Changeset 105081 in vbox


Ignore:
Timestamp:
Jul 1, 2024 3:38:32 PM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163701
Message:

FE/Qt: Moving local machine related stuff from UICommon to new UILocalMachineStuff namespace; Reworking GUI to use it accordingly; Dependencies and includes cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
29 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r104922 r105081  
    14051405        src/globals/UIIconPool.cpp \
    14061406        src/globals/UIImageTools.cpp \
     1407        src/globals/UILocalMachineStuff.cpp \
    14071408        src/globals/UIMachineAttributeSetter.cpp \
    14081409        src/globals/UIMainEventListener.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewModelView.cpp

    r105062 r105081  
    3434/* GUI includes: */
    3535#include "UIConverter.h"
    36 #include "UICommon.h"
    3736#include "UIExtraDataDefs.h"
    3837#include "UIGlobalSession.h"
     38#include "UILocalMachineStuff.h"
    3939#include "UIMonitorCommon.h"
    4040#include "UITranslator.h"
     
    380380void UIVMActivityOverviewRowLocal::resetDebugger()
    381381{
    382     m_comSession = uiCommon().openSession(m_uMachineId, KLockType_Shared);
     382    m_comSession = openSession(m_uMachineId, KLockType_Shared);
    383383    if (!m_comSession.isNull())
    384384    {
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp

    r105062 r105081  
    5050#include "UIGlobalSession.h"
    5151#include "UIIconPool.h"
     52#include "UILocalMachineStuff.h"
    5253#include "UIMessageCenter.h"
    5354#include "UITranslator.h"
     
    885886void UIVMActivityOverviewItemLocal::resetDebugger()
    886887{
    887     m_comSession = uiCommon().openSession(m_VMuid, KLockType_Shared);
     888    m_comSession = openSession(m_VMuid, KLockType_Shared);
    888889    if (!m_comSession.isNull())
    889890    {
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r104912 r105081  
    4848#include "UIGlobalSession.h"
    4949#include "UIIconPool.h"
     50#include "UILocalMachineStuff.h"
    5051#include "UITranslator.h"
    5152#include "UITranslationEventListener.h"
     
    13461347    if (!m_comSession.isNull())
    13471348        return;
    1348     m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);
     1349    m_comSession = UILocalMachineStuff::openSession(m_comMachine.GetId(), KLockType_Shared);
    13491350    AssertReturnVoid(!m_comSession.isNull());
    13501351
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r104968 r105081  
    5959#include "UIGlobalSession.h"
    6060#include "UIHostComboEditor.h"
     61#include "UILocalMachineStuff.h"
    6162#include "UILoggingDefs.h"
    6263#include "UIMainEventListener.h"
     
    21532154        CSession comSession;
    21542155        if (enmLevel == ConfigurationAccessLevel_Full)
    2155             comSession = uiCommon().openSession(uID);
     2156            comSession = openSession(uID);
    21562157        else
    2157             comSession = uiCommon().openExistingSession(uID);
     2158            comSession = openExistingSession(uID);
    21582159        AssertReturnVoid(!comSession.isNull());
    21592160        /* Get machine from that session: */
     
    22502251        CSession comSession;
    22512252        if (enmLevel == ConfigurationAccessLevel_Full)
    2252             comSession = uiCommon().openSession(uID);
     2253            comSession = openSession(uID);
    22532254        else
    2254             comSession = uiCommon().openExistingSession(uID);
     2255            comSession = openExistingSession(uID);
    22552256        AssertReturnVoid(!comSession.isNull());
    22562257        /* Get machine from that session: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r104967 r105081  
    3232#include <QLocale>
    3333#include <QSessionManager>
    34 #include <QSettings>
    3534#include <QSpinBox>
    3635#include <QStandardPaths>
    3736#include <QStyleOptionSpinBox>
    3837#include <QThread>
    39 #include <QToolTip>
    4038#include <QUrl>
    4139#ifdef VBOX_WS_WIN
     40# include <QSettings>
    4241# include <QStyleFactory>
    4342#endif
     
    5554#include "UIExtraDataManager.h"
    5655#include "UIIconPool.h"
     56#include "UILocalMachineStuff.h"
    5757#include "UILoggingDefs.h"
    5858#include "UIMediumEnumerator.h"
     
    9090#include "CUSBDevice.h"
    9191#include "CUSBDeviceFilter.h"
    92 #include <VBox/com/VirtualBox.h> /* For GUEST_OS_ID_STR_PARTIAL. */
    9392
    9493/* Other VBox includes: */
    95 #include <iprt/asm.h>
    96 #include <iprt/ctype.h>
    97 #include <iprt/env.h>
    98 #include <iprt/err.h>
    99 #include <iprt/file.h>
    100 #include <iprt/ldr.h>
    101 #include <iprt/param.h>
     94#include <iprt/ctype.h> /* for RT_C_IS_CNTRL */
    10295#include <iprt/path.h>
    10396#include <iprt/stream.h>
    104 #include <iprt/system.h>
    105 #include <VBox/sup.h>
    106 #include <VBox/VBoxOGL.h>
    10797#include <VBox/vd.h>
    10898#include <VBox/com/Guid.h>
     99#ifdef VBOX_WITH_DEBUGGER_GUI
     100# include <iprt/env.h> /* for RTEnvExist & RTENV_DEFAULT */
     101# include <iprt/ldr.h>
     102# include <VBox/sup.h> /* for SUPR3HardenedLdrLoadAppPriv */
     103#endif
    109104
    110105/* VirtualBox interface declarations: */
     
    11531148#endif /* VBOX_GUI_WITH_PIDFILE */
    11541149
    1155 /* static */
    1156 bool UICommon::switchToMachine(CMachine &comMachine)
    1157 {
    1158 #ifdef VBOX_WS_MAC
    1159     const ULONG64 id = comMachine.ShowConsoleWindow();
    1160 #else
    1161     const WId id = (WId)comMachine.ShowConsoleWindow();
    1162 #endif
    1163     Assert(comMachine.isOk());
    1164     if (!comMachine.isOk())
    1165         return false;
    1166 
    1167     // WORKAROUND:
    1168     // id == 0 means the console window has already done everything
    1169     // necessary to implement the "show window" semantics.
    1170     if (id == 0)
    1171         return true;
    1172 
    1173 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_NIX)
    1174 
    1175     return UIDesktopWidgetWatchdog::activateWindow(id, true);
    1176 
    1177 #elif defined(VBOX_WS_MAC)
    1178 
    1179     // WORKAROUND:
    1180     // This is just for the case were the other process cannot steal
    1181     // the focus from us. It will send us a PSN so we can try.
    1182     ProcessSerialNumber psn;
    1183     psn.highLongOfPSN = id >> 32;
    1184     psn.lowLongOfPSN = (UInt32)id;
    1185 # ifdef __clang__
    1186 #  pragma GCC diagnostic push
    1187 #  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    1188     OSErr rc = ::SetFrontProcess(&psn);
    1189 #  pragma GCC diagnostic pop
    1190 # else
    1191     OSErr rc = ::SetFrontProcess(&psn);
    1192 # endif
    1193     if (!rc)
    1194         Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
    1195     else
    1196         Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
    1197     return !rc;
    1198 
    1199 #else
    1200 
    1201     return false;
    1202 
    1203 #endif
    1204 }
    1205 
    1206 /* static */
    1207 bool UICommon::launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode /* = UILaunchMode_Default */)
    1208 {
    1209     /* Switch to machine window(s) if possible: */
    1210     if (   comMachine.GetSessionState() == KSessionState_Locked /* precondition for CanShowConsoleWindow() */
    1211         && comMachine.CanShowConsoleWindow())
    1212     {
    1213         switch (uiCommon().uiType())
    1214         {
    1215             /* For Selector UI: */
    1216             case UIType_ManagerUI:
    1217             {
    1218                 /* Just switch to existing VM window: */
    1219                 return switchToMachine(comMachine);
    1220             }
    1221             /* For Runtime UI: */
    1222             case UIType_RuntimeUI:
    1223             {
    1224                 /* Only separate UI process can reach that place.
    1225                  * Switch to existing VM window and exit. */
    1226                 switchToMachine(comMachine);
    1227                 return false;
    1228             }
    1229         }
    1230     }
    1231 
    1232     /* Not for separate UI (which can connect to machine in any state): */
    1233     if (enmLaunchMode != UILaunchMode_Separate)
    1234     {
    1235         /* Make sure machine-state is one of required: */
    1236         const KMachineState enmState = comMachine.GetState(); NOREF(enmState);
    1237         AssertMsg(   enmState == KMachineState_PoweredOff
    1238                   || enmState == KMachineState_Saved
    1239                   || enmState == KMachineState_Teleported
    1240                   || enmState == KMachineState_Aborted
    1241                   || enmState == KMachineState_AbortedSaved
    1242                   , ("Machine must be PoweredOff/Saved/Teleported/Aborted (%d)", enmState));
    1243     }
    1244 
    1245     /* Create empty session instance: */
    1246     CSession comSession;
    1247     comSession.createInstance(CLSID_Session);
    1248     if (comSession.isNull())
    1249     {
    1250         msgCenter().cannotOpenSession(comSession);
    1251         return false;
    1252     }
    1253 
    1254     /* Configure environment: */
    1255     QVector<QString> astrEnv;
    1256 #ifdef VBOX_WS_WIN
    1257     /* Allow started VM process to be foreground window: */
    1258     AllowSetForegroundWindow(ASFW_ANY);
    1259 #endif
    1260 #ifdef VBOX_WS_NIX
    1261     /* Make sure VM process will start on the same
    1262      * display as window this wrapper is called from: */
    1263     const char *pDisplay = RTEnvGet("DISPLAY");
    1264     if (pDisplay)
    1265         astrEnv.append(QString("DISPLAY=%1").arg(pDisplay));
    1266     const char *pXauth = RTEnvGet("XAUTHORITY");
    1267     if (pXauth)
    1268         astrEnv.append(QString("XAUTHORITY=%1").arg(pXauth));
    1269 #endif
    1270     QString strType;
    1271     switch (enmLaunchMode)
    1272     {
    1273         case UILaunchMode_Default:  strType = ""; break;
    1274         case UILaunchMode_Separate: strType = uiCommon().isSeparateProcess() ? "headless" : "separate"; break;
    1275         case UILaunchMode_Headless: strType = "headless"; break;
    1276         default: AssertFailedReturn(false);
    1277     }
    1278 
    1279     /* Prepare "VM spawning" progress: */
    1280     CProgress comProgress = comMachine.LaunchVMProcess(comSession, strType, astrEnv);
    1281     if (!comMachine.isOk())
    1282     {
    1283         /* If the VM is started separately and the VM process is already running, then it is OK. */
    1284         if (enmLaunchMode == UILaunchMode_Separate)
    1285         {
    1286             const KMachineState enmState = comMachine.GetState();
    1287             if (   enmState >= KMachineState_FirstOnline
    1288                 && enmState <= KMachineState_LastOnline)
    1289             {
    1290                 /* Already running: */
    1291                 return true;
    1292             }
    1293         }
    1294 
    1295         msgCenter().cannotOpenSession(comMachine);
    1296         return false;
    1297     }
    1298 
    1299     /* Show "VM spawning" progress: */
    1300     msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(),
    1301                                         ":/progress_start_90px.png", 0, 0);
    1302     if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1303         msgCenter().cannotOpenSession(comProgress, comMachine.GetName());
    1304 
    1305     /* Unlock machine, close session: */
    1306     comSession.UnlockMachine();
    1307 
    1308     /* True finally: */
    1309     return true;
    1310 }
    1311 
    1312 CSession UICommon::openSession(QUuid uId, KLockType enmLockType /* = KLockType_Write */)
    1313 {
    1314     /* Prepare session: */
    1315     CSession comSession;
    1316 
    1317     /* Make sure uId isn't null: */
    1318     if (uId.isNull())
    1319         uId = managedVMUuid();
    1320     if (uId.isNull())
    1321         return comSession;
    1322 
    1323     /* Simulate try-catch block: */
    1324     bool fSuccess = false;
    1325     do
    1326     {
    1327         /* Create empty session instance: */
    1328         comSession.createInstance(CLSID_Session);
    1329         if (comSession.isNull())
    1330         {
    1331             msgCenter().cannotOpenSession(comSession);
    1332             break;
    1333         }
    1334 
    1335         /* Search for the corresponding machine: */
    1336         const CVirtualBox comVBox = gpGlobalSession->virtualBox();
    1337         CMachine comMachine = comVBox.FindMachine(uId.toString());
    1338         if (comMachine.isNull())
    1339         {
    1340             msgCenter().cannotFindMachineById(comVBox, uId);
    1341             break;
    1342         }
    1343 
    1344         if (enmLockType == KLockType_VM)
    1345             comSession.SetName("GUI/Qt");
    1346 
    1347         /* Lock found machine to session: */
    1348         comMachine.LockMachine(comSession, enmLockType);
    1349         if (!comMachine.isOk())
    1350         {
    1351             msgCenter().cannotOpenSession(comMachine);
    1352             break;
    1353         }
    1354 
    1355         /* Pass the language ID as the property to the guest: */
    1356         if (comSession.GetType() == KSessionType_Shared)
    1357         {
    1358             CMachine comStartedMachine = comSession.GetMachine();
    1359             /* Make sure that the language is in two letter code.
    1360              * Note: if languageId() returns an empty string lang.name() will
    1361              * return "C" which is an valid language code. */
    1362             QLocale lang(UITranslator::languageId());
    1363             comStartedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name());
    1364         }
    1365 
    1366         /* Success finally: */
    1367         fSuccess = true;
    1368     }
    1369     while (0);
    1370     /* Cleanup try-catch block: */
    1371     if (!fSuccess)
    1372         comSession.detach();
    1373 
    1374     /* Return session: */
    1375     return comSession;
    1376 }
    1377 
    1378 CSession UICommon::openSession(KLockType enmLockType /* = KLockType_Write */)
    1379 {
    1380     /* Pass to function above: */
    1381     return openSession(managedVMUuid(), enmLockType);
    1382 }
    1383 
    1384 CSession UICommon::tryToOpenSessionFor(CMachine &comMachine)
    1385 {
    1386     /* Prepare session: */
    1387     CSession comSession;
    1388 
    1389     /* Session state unlocked? */
    1390     if (comMachine.GetSessionState() == KSessionState_Unlocked)
    1391     {
    1392         /* Open own 'write' session: */
    1393         comSession = openSession(comMachine.GetId());
    1394         AssertReturn(!comSession.isNull(), CSession());
    1395         comMachine = comSession.GetMachine();
    1396     }
    1397     /* Is this a Selector UI call? */
    1398     else if (uiType() == UIType_ManagerUI)
    1399     {
    1400         /* Open existing 'shared' session: */
    1401         comSession = openExistingSession(comMachine.GetId());
    1402         AssertReturn(!comSession.isNull(), CSession());
    1403         comMachine = comSession.GetMachine();
    1404     }
    1405     /* Else this is Runtime UI call
    1406      * which has session locked for itself. */
    1407 
    1408     /* Return session: */
    1409     return comSession;
    1410 }
    1411 
    14121150void UICommon::notifyCloudMachineUnregistered(const QString &strProviderShortName,
    14131151                                              const QString &strProfileName,
     
    19051643    /* Load passed language: */
    19061644    UITranslator::loadLanguage(strLanguage);
    1907 }
    1908 
    1909 void UICommon::sltHandleMachineCreated(const CMachine &comMachine)
    1910 {
    1911     /* Register created machine. */
    1912     CVirtualBox comVBox = gpGlobalSession->virtualBox();
    1913     comVBox.RegisterMachine(comMachine);
    1914     if (!comVBox.isOk())
    1915         UINotificationMessage::cannotRegisterMachine(comVBox, comMachine.GetName());
    19161645}
    19171646
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r104904 r105081  
    3434/* Qt includes: */
    3535#include <QObject>
     36#include <QUuid>
    3637
    3738/* GUI includes: */
     
    4344
    4445/* COM includes: */
    45 #include "CSession.h"
    4646#include "KGraphicsControllerType.h"
    47 #include "KLockType.h"
     47
     48/* Other VBox includes: */
     49#include <iprt/types.h>
    4850
    4951/* Forward declarations: */
     
    5254class CCloudMachine;
    5355class CHostVideoInputDevice;
    54 class CMachine;
    5556class CUSBDevice;
     57class CUSBDeviceFilter;
    5658class UIThreadPool;
    5759class UITranslationEventListener;
     
    244246    /** @} */
    245247
    246     /** @name COM: Virtual Machine stuff.
    247      * @{ */
    248         /** Switches to certain @a comMachine. */
    249         static bool switchToMachine(CMachine &comMachine);
    250         /** Launches certain @a comMachine in specified @a enmLaunchMode. */
    251         static bool launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode = UILaunchMode_Default);
    252 
    253         /** Opens session of certain @a enmLockType for VM with certain @a uId. */
    254         CSession openSession(QUuid uId, KLockType enmLockType = KLockType_Write);
    255         /** Opens session of certain @a enmLockType for currently chosen VM. */
    256         CSession openSession(KLockType enmLockType = KLockType_Write);
    257         /** Opens session of KLockType_Shared type for VM with certain @a uId. */
    258         CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
    259         /** Tries to guess if new @a comSession needs to be opened for certain @a comMachine,
    260           * if yes, new session of required type will be opened and machine will be updated,
    261           * otherwise, no session will be created and machine will be left unchanged. */
    262         CSession tryToOpenSessionFor(CMachine &comMachine);
    263     /** @} */
    264 
    265248    /** @name COM: Cloud Virtual Machine stuff.
    266249     * @{ */
     
    369352        /** Handles language change to new @a strLanguage. */
    370353        void sltGUILanguageChange(QString strLanguage);
    371     /** @} */
    372 
    373     /** @name Machine related stuff.
    374      * @{ */
    375         /** Handles signal about machine was created. */
    376         void sltHandleMachineCreated(const CMachine &comMachine);
    377354    /** @} */
    378355
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UILocalMachineStuff.cpp

    r105079 r105081  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UICommon class implementation.
     3 * VBox Qt GUI - UILocalMachineStuff namespace implementation.
    44 */
    55
     
    2727
    2828/* Qt includes: */
    29 #include <QApplication>
    30 #include <QDesktopServices>
    31 #include <QDir>
    3229#include <QLocale>
    33 #include <QSessionManager>
    34 #include <QSettings>
    35 #include <QSpinBox>
    36 #include <QStandardPaths>
    37 #include <QStyleOptionSpinBox>
    38 #include <QThread>
    39 #include <QToolTip>
    40 #include <QUrl>
    41 #ifdef VBOX_WS_WIN
    42 # include <QStyleFactory>
    43 #endif
    44 #ifdef VBOX_GUI_WITH_PIDFILE
    45 # include <QTextStream>
    46 #endif
    4730
    4831/* GUI includes: */
    4932#include "UICommon.h"
    50 #include "UIConverter.h"
    51 #include "UIDesktopWidgetWatchdog.h"
    5233#include "UIGlobalSession.h"
    53 #include "UIGuestOSType.h"
    54 #include "UIExtraDataDefs.h"
    55 #include "UIExtraDataManager.h"
    56 #include "UIIconPool.h"
     34#include "UILocalMachineStuff.h"
    5735#include "UILoggingDefs.h"
    58 #include "UIMediumEnumerator.h"
    5936#include "UIMessageCenter.h"
    60 #include "UIModalWindowManager.h"
    61 #include "UINotificationCenter.h"
    62 #include "UIPopupCenter.h"
    63 #include "UIShortcutPool.h"
    64 #include "UIThreadPool.h"
    6537#include "UITranslator.h"
    66 #include "UITranslationEventListener.h"
    67 #include "UIVersion.h"
    68 #include "UIVirtualBoxClientEventHandler.h"
    69 #include "UIVirtualBoxEventHandler.h"
    7038#ifdef VBOX_WS_MAC
    71 # include "UICocoaApplication.h"
    72 #endif
    73 #ifdef VBOX_WS_WIN
    74 # include "VBoxUtils-win.h"
    75 #endif
     39# include "VBoxUtils-darwin.h"
     40#endif
     41#if defined(VBOX_WS_WIN) || defined(VBOX_WS_NIX)
     42# include "UIDesktopWidgetWatchdog.h"
     43#endif
     44
     45/* COM includes: */
     46#include "CMachine.h"
     47
     48/* Other VBox includes: */
    7649#ifdef VBOX_WS_NIX
    77 # include "UIHostComboEditor.h"
    78 #endif
    79 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    80 # include "UINetworkRequestManager.h"
    81 # include "UIUpdateManager.h"
    82 #endif
    83 
    84 /* COM includes: */
    85 #include "CCloudMachine.h"
    86 #include "CHostUSBDevice.h"
    87 #include "CHostVideoInputDevice.h"
    88 #include "CMachine.h"
    89 #include "CSystemProperties.h"
    90 #include "CUSBDevice.h"
    91 #include "CUSBDeviceFilter.h"
    92 #include <VBox/com/VirtualBox.h> /* For GUEST_OS_ID_STR_PARTIAL. */
    93 
    94 /* Other VBox includes: */
    95 #include <iprt/asm.h>
    96 #include <iprt/ctype.h>
    97 #include <iprt/env.h>
    98 #include <iprt/err.h>
    99 #include <iprt/file.h>
    100 #include <iprt/ldr.h>
    101 #include <iprt/param.h>
    102 #include <iprt/path.h>
    103 #include <iprt/stream.h>
    104 #include <iprt/system.h>
    105 #include <VBox/sup.h>
    106 #include <VBox/VBoxOGL.h>
    107 #include <VBox/vd.h>
    108 #include <VBox/com/Guid.h>
     50# include <iprt/env.h>
     51#endif
    10952
    11053/* VirtualBox interface declarations: */
    111 #include <VBox/com/VirtualBox.h>
    112 
    113 /* External includes: */
    114 #ifdef VBOX_WS_MAC
    115 # include <sys/utsname.h>
    116 #endif
    117 #ifdef VBOX_WS_NIX
    118 # include <xcb/xcb.h>
    119 #endif
    120 
    121 /* Namespaces: */
    122 using namespace UIExtraDataDefs;
    123 
    124 
    125 /* static */
    126 UICommon *UICommon::s_pInstance = 0;
    127 
    128 /* static */
    129 void UICommon::create(UIType enmType)
    130 {
    131     /* Make sure instance is NOT created yet: */
    132     AssertReturnVoid(!s_pInstance);
    133 
    134     /* Create instance: */
    135     new UICommon(enmType);
    136     /* Prepare instance: */
    137     s_pInstance->prepare();
    138 }
    139 
    140 /* static */
    141 void UICommon::destroy()
    142 {
    143     /* Make sure instance is NOT destroyed yet: */
    144     AssertPtrReturnVoid(s_pInstance);
    145 
    146     /* Cleanup instance:
    147      * 1. By default, automatically on QApplication::aboutToQuit() signal.
    148      * 2. But if QApplication was not started at all and we perform
    149      *    early shutdown, we should do cleanup ourselves. */
    150     if (s_pInstance->isValid())
    151         s_pInstance->cleanup();
    152     /* Destroy instance: */
    153     delete s_pInstance;
    154 }
    155 
    156 UICommon::UICommon(UIType enmType)
    157     : m_enmType(enmType)
    158     , m_fValid(false)
    159     , m_fCleaningUp(false)
    160 #ifdef VBOX_WS_WIN
    161     , m_fDataCommitted(false)
    162 #endif
    163 #ifdef VBOX_WS_MAC
    164     , m_enmMacOSVersion(MacOSXRelease_Old)
    165 #endif
    166 #ifdef VBOX_WS_NIX
    167     , m_enmWindowManagerType(X11WMType_Unknown)
    168     , m_fCompositingManagerRunning(false)
    169     , m_enmDisplayServerType(VBGHDISPLAYSERVERTYPE_NONE)
    170 #endif
    171     , m_fDarkMode(false)
    172     , m_fSeparateProcess(false)
    173     , m_fShowStartVMErrors(true)
    174 #if defined(DEBUG_bird)
    175     , m_fAgressiveCaching(false)
    176 #else
    177     , m_fAgressiveCaching(true)
    178 #endif
    179     , m_fRestoreCurrentSnapshot(false)
    180     , m_fNoKeyboardGrabbing(false)
    181     , m_fExecuteAllInIem(false)
    182     , m_uWarpPct(100)
    183 #ifdef VBOX_WITH_DEBUGGER_GUI
    184     , m_fDbgEnabled(0)
    185     , m_fDbgAutoShow(0)
    186     , m_fDbgAutoShowCommandLine(0)
    187     , m_fDbgAutoShowStatistics(0)
    188     , m_hVBoxDbg(NIL_RTLDRMOD)
    189     , m_enmLaunchRunning(LaunchRunning_Default)
    190 #endif
    191     , m_fSettingsPwSet(false)
    192     , m_pThreadPool(0)
    193     , m_pThreadPoolCloud(0)
    194     , m_pTranlationEventListener(0)
    195 {
    196     /* Assign instance: */
    197     s_pInstance = this;
    198 }
    199 
    200 UICommon::~UICommon()
    201 {
    202     /* Unassign instance: */
    203     s_pInstance = 0;
    204 }
    205 
    206 void UICommon::prepare()
    207 {
    208     /* Make sure QApplication cleanup us on exit: */
    209 #ifndef VBOX_IS_QT6_OR_LATER /** @todo qt6: ... */
    210     qApp->setFallbackSessionManagementEnabled(false);
    211 #endif
    212     connect(qApp, &QGuiApplication::aboutToQuit,
    213             this, &UICommon::sltCleanup);
    214 #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
    215     /* Make sure we handle host OS session shutdown as well: */
    216     connect(qApp, &QGuiApplication::commitDataRequest,
    217             this, &UICommon::sltHandleCommitDataRequest);
    218 #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    219 
    220 #ifdef VBOX_WS_MAC
    221     /* Determine OS release early: */
    222     m_enmMacOSVersion = determineOsRelease();
    223 #endif
    224 
    225 #ifdef VBOX_WS_NIX
    226     /* Detect display server type: */
    227     m_enmDisplayServerType = VBGHDisplayServerTypeDetect();
    228 #endif
    229 
    230     /* Create converter: */
    231     UIConverter::create();
    232 
    233     /* Create desktop-widget watchdog: */
    234     UIDesktopWidgetWatchdog::create();
    235 
    236     /* Create message-center: */
    237     UIMessageCenter::create();
    238     /* Create popup-center: */
    239     UIPopupCenter::create();
    240 
    241     /* Prepare general icon-pool: */
    242     UIIconPoolGeneral::create();
    243 
    244     /* Load translation based on the current locale: */
    245     UITranslator::loadLanguage();
    246 
    247     /* Init COM: */
    248     UIGlobalSession::create();
    249     if (!gpGlobalSession->prepare())
    250         return;
    251     connect(gpGlobalSession, &UIGlobalSession::sigVBoxSVCAvailabilityChange,
    252             this, &UICommon::sltHandleVBoxSVCAvailabilityChange);
    253 
    254     /* Create extra-data manager right after COM init: */
    255     UIExtraDataManager::create();
    256 
    257     /* Prepare thread-pool instances: */
    258     m_pThreadPool = new UIThreadPool(3 /* worker count */, 5000 /* worker timeout */);
    259     m_pThreadPoolCloud = new UIThreadPool(2 /* worker count */, 1000 /* worker timeout */);
    260 
    261     /* Load whether host OS is in Dark mode: */
    262 #if defined(VBOX_WS_MAC)
    263     m_fDarkMode = UICocoaApplication::instance()->isDarkMode();
    264 #elif defined(VBOX_WS_WIN)
    265     m_fDarkMode = isWindowsInDarkMode();
    266 #else /* Linux, BSD, Solaris */
    267     m_fDarkMode = isPaletteInDarkMode();
    268 #endif /* Linux, BSD, Solaris */
    269     /* Load color theme: */
    270     loadColorTheme();
    271 
    272     /* Load translation based on the user settings: */
    273     QString strLanguageId = gEDataManager->languageId();
    274     if (!strLanguageId.isNull())
    275         UITranslator::loadLanguage(strLanguageId);
    276 
    277     retranslateUi();
    278 
    279     /* Create translation event listener instance: */
    280     UITranslationEventListener::create();
    281 
    282     connect(gEDataManager, &UIExtraDataManager::sigLanguageChange,
    283             this, &UICommon::sltGUILanguageChange);
    284     connect(gEDataManager, &UIExtraDataManager::sigFontScaleFactorChanged,
    285             this, &UICommon::sltHandleFontScaleFactorChanged);
    286 
    287     qApp->installEventFilter(this);
    288 
    289     /* process command line */
    290 
    291     UIVisualStateType visualStateType = UIVisualStateType_Invalid;
    292 
    293 #ifdef VBOX_WS_NIX
    294     /* Check whether we have compositing manager running: */
    295     m_fCompositingManagerRunning = NativeWindowSubsystem::isCompositingManagerRunning(X11ServerAvailable());
    296 
    297     /* Acquire current Window Manager type: */
    298     m_enmWindowManagerType = NativeWindowSubsystem::windowManagerType(X11ServerAvailable());
    299 #endif /* VBOX_WS_NIX */
    300 
    301 #ifdef VBOX_WITH_DEBUGGER_GUI
    302 # ifdef VBOX_WITH_DEBUGGER_GUI_MENU
    303     initDebuggerVar(&m_fDbgEnabled, "VBOX_GUI_DBG_ENABLED", GUI_Dbg_Enabled, true);
    304 # else
    305     initDebuggerVar(&m_fDbgEnabled, "VBOX_GUI_DBG_ENABLED", GUI_Dbg_Enabled, false);
    306 # endif
    307     initDebuggerVar(&m_fDbgAutoShow, "VBOX_GUI_DBG_AUTO_SHOW", GUI_Dbg_AutoShow, false);
    308     m_fDbgAutoShowCommandLine = m_fDbgAutoShowStatistics = m_fDbgAutoShow;
    309 #endif
    310 
    311     /*
    312      * Parse the command line options.
    313      *
    314      * This is a little sloppy but we're trying to tighten it up.  Unfortuately,
    315      * both on X11 and darwin (IIRC) there might be additional arguments aimed
    316      * for client libraries with GUI processes.  So, using RTGetOpt or similar
    317      * is a bit hard since we have to cope with unknown options.
    318      */
    319     m_fShowStartVMErrors = true;
    320     bool startVM = false;
    321     bool fSeparateProcess = false;
    322     QString vmNameOrUuid;
    323 
    324     const QStringList &arguments = QCoreApplication::arguments();
    325     const int argc = arguments.size();
    326     int i = 1;
    327     while (i < argc)
    328     {
    329         const QByteArray &argBytes = arguments.at(i).toUtf8();
    330         const char *arg = argBytes.constData();
    331         enum { OptType_Unknown, OptType_VMRunner, OptType_VMSelector, OptType_MaybeBoth } enmOptType = OptType_Unknown;
    332         /* NOTE: the check here must match the corresponding check for the
    333          * options to start a VM in main.cpp and hardenedmain.cpp exactly,
    334          * otherwise there will be weird error messages. */
    335         if (   !::strcmp(arg, "--startvm")
    336             || !::strcmp(arg, "-startvm"))
    337         {
    338             enmOptType = OptType_VMRunner;
    339             if (++i < argc)
    340             {
    341                 vmNameOrUuid = arguments.at(i);
    342                 startVM = true;
    343             }
    344         }
    345         else if (!::strcmp(arg, "-separate") || !::strcmp(arg, "--separate"))
    346         {
    347             enmOptType = OptType_VMRunner;
    348             fSeparateProcess = true;
    349         }
    350 #ifdef VBOX_GUI_WITH_PIDFILE
    351         else if (!::strcmp(arg, "-pidfile") || !::strcmp(arg, "--pidfile"))
    352         {
    353             enmOptType = OptType_MaybeBoth;
    354             if (++i < argc)
    355                 m_strPidFile = arguments.at(i);
    356         }
    357 #endif /* VBOX_GUI_WITH_PIDFILE */
    358         /* Visual state type options: */
    359         else if (!::strcmp(arg, "-normal") || !::strcmp(arg, "--normal"))
    360         {
    361             enmOptType = OptType_MaybeBoth;
    362             visualStateType = UIVisualStateType_Normal;
    363         }
    364         else if (!::strcmp(arg, "-fullscreen") || !::strcmp(arg, "--fullscreen"))
    365         {
    366             enmOptType = OptType_MaybeBoth;
    367             visualStateType = UIVisualStateType_Fullscreen;
    368         }
    369         else if (!::strcmp(arg, "-seamless") || !::strcmp(arg, "--seamless"))
    370         {
    371             enmOptType = OptType_MaybeBoth;
    372             visualStateType = UIVisualStateType_Seamless;
    373         }
    374         else if (!::strcmp(arg, "-scale") || !::strcmp(arg, "--scale"))
    375         {
    376             enmOptType = OptType_MaybeBoth;
    377             visualStateType = UIVisualStateType_Scale;
    378         }
    379         /* Passwords: */
    380         else if (!::strcmp(arg, "--settingspw"))
    381         {
    382             enmOptType = OptType_MaybeBoth;
    383             if (++i < argc)
    384             {
    385                 RTStrCopy(m_astrSettingsPw, sizeof(m_astrSettingsPw), arguments.at(i).toLocal8Bit().constData());
    386                 m_fSettingsPwSet = true;
    387             }
    388         }
    389         else if (!::strcmp(arg, "--settingspwfile"))
    390         {
    391             enmOptType = OptType_MaybeBoth;
    392             if (++i < argc)
    393             {
    394                 const QByteArray &argFileBytes = arguments.at(i).toLocal8Bit();
    395                 const char *pszFile = argFileBytes.constData();
    396                 bool fStdIn = !::strcmp(pszFile, "stdin");
    397                 int vrc = VINF_SUCCESS;
    398                 PRTSTREAM pStrm;
    399                 if (!fStdIn)
    400                     vrc = RTStrmOpen(pszFile, "r", &pStrm);
    401                 else
    402                     pStrm = g_pStdIn;
    403                 if (RT_SUCCESS(vrc))
    404                 {
    405                     size_t cbFile;
    406                     vrc = RTStrmReadEx(pStrm, m_astrSettingsPw, sizeof(m_astrSettingsPw) - 1, &cbFile);
    407                     if (RT_SUCCESS(vrc))
    408                     {
    409                         if (cbFile >= sizeof(m_astrSettingsPw) - 1)
    410                             cbFile = sizeof(m_astrSettingsPw) - 1;
    411                         unsigned i;
    412                         for (i = 0; i < cbFile && !RT_C_IS_CNTRL(m_astrSettingsPw[i]); i++)
    413                             ;
    414                         m_astrSettingsPw[i] = '\0';
    415                         m_fSettingsPwSet = true;
    416                     }
    417                     if (!fStdIn)
    418                         RTStrmClose(pStrm);
    419                 }
    420             }
    421         }
    422         /* Misc options: */
    423         else if (!::strcmp(arg, "-comment") || !::strcmp(arg, "--comment"))
    424         {
    425             enmOptType = OptType_MaybeBoth;
    426             ++i;
    427         }
    428         else if (!::strcmp(arg, "--no-startvm-errormsgbox"))
    429         {
    430             enmOptType = OptType_VMRunner;
    431             m_fShowStartVMErrors = false;
    432         }
    433         else if (!::strcmp(arg, "--aggressive-caching"))
    434         {
    435             enmOptType = OptType_MaybeBoth;
    436             m_fAgressiveCaching = true;
    437         }
    438         else if (!::strcmp(arg, "--no-aggressive-caching"))
    439         {
    440             enmOptType = OptType_MaybeBoth;
    441             m_fAgressiveCaching = false;
    442         }
    443         else if (!::strcmp(arg, "--restore-current"))
    444         {
    445             enmOptType = OptType_VMRunner;
    446             m_fRestoreCurrentSnapshot = true;
    447         }
    448         else if (!::strcmp(arg, "--no-keyboard-grabbing"))
    449         {
    450             enmOptType = OptType_VMRunner;
    451             m_fNoKeyboardGrabbing = true;
    452         }
    453         /* Ad hoc VM reconfig options: */
    454         else if (!::strcmp(arg, "--fda"))
    455         {
    456             enmOptType = OptType_VMRunner;
    457             if (++i < argc)
    458                 m_uFloppyImage = QUuid(arguments.at(i));
    459         }
    460         else if (!::strcmp(arg, "--dvd") || !::strcmp(arg, "--cdrom"))
    461         {
    462             enmOptType = OptType_VMRunner;
    463             if (++i < argc)
    464                 m_uDvdImage = QUuid(arguments.at(i));
    465         }
    466         /* VMM Options: */
    467         else if (!::strcmp(arg, "--execute-all-in-iem"))
    468         {
    469             enmOptType = OptType_VMRunner;
    470             m_fExecuteAllInIem = true;
    471         }
    472         else if (!::strcmp(arg, "--driverless"))
    473             enmOptType = OptType_VMRunner;
    474         else if (!::strcmp(arg, "--warp-pct"))
    475         {
    476             enmOptType = OptType_VMRunner;
    477             if (++i < argc)
    478                 m_uWarpPct = RTStrToUInt32(arguments.at(i).toLocal8Bit().constData());
    479         }
    480 #ifdef VBOX_WITH_DEBUGGER_GUI
    481         /* Debugger/Debugging options: */
    482         else if (!::strcmp(arg, "-dbg") || !::strcmp(arg, "--dbg"))
    483         {
    484             enmOptType = OptType_VMRunner;
    485             setDebuggerVar(&m_fDbgEnabled, true);
    486         }
    487         else if (!::strcmp( arg, "-debug") || !::strcmp(arg, "--debug"))
    488         {
    489             enmOptType = OptType_VMRunner;
    490             setDebuggerVar(&m_fDbgEnabled, true);
    491             setDebuggerVar(&m_fDbgAutoShow, true);
    492             setDebuggerVar(&m_fDbgAutoShowCommandLine, true);
    493             setDebuggerVar(&m_fDbgAutoShowStatistics, true);
    494         }
    495         else if (!::strcmp(arg, "--debug-command-line"))
    496         {
    497             enmOptType = OptType_VMRunner;
    498             setDebuggerVar(&m_fDbgEnabled, true);
    499             setDebuggerVar(&m_fDbgAutoShow, true);
    500             setDebuggerVar(&m_fDbgAutoShowCommandLine, true);
    501         }
    502         else if (!::strcmp(arg, "--debug-statistics"))
    503         {
    504             enmOptType = OptType_VMRunner;
    505             setDebuggerVar(&m_fDbgEnabled, true);
    506             setDebuggerVar(&m_fDbgAutoShow, true);
    507             setDebuggerVar(&m_fDbgAutoShowStatistics, true);
    508         }
    509         else if (!::strcmp(arg, "--statistics-expand") || !::strcmp(arg, "--stats-expand"))
    510         {
    511             enmOptType = OptType_VMRunner;
    512             if (++i < argc)
    513             {
    514                 if (!m_strDbgStatisticsExpand.isEmpty())
    515                     m_strDbgStatisticsExpand.append('|');
    516                 m_strDbgStatisticsExpand.append(arguments.at(i));
    517             }
    518         }
    519         else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-expand=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-expand=")))
    520         {
    521             enmOptType = OptType_VMRunner;
    522             if (!m_strDbgStatisticsExpand.isEmpty())
    523                 m_strDbgStatisticsExpand.append('|');
    524             m_strDbgStatisticsExpand.append(arguments.at(i).section('=', 1));
    525         }
    526         else if (!::strcmp(arg, "--statistics-filter") || !::strcmp(arg, "--stats-filter"))
    527         {
    528             enmOptType = OptType_VMRunner;
    529             if (++i < argc)
    530                 m_strDbgStatisticsFilter = arguments.at(i);
    531         }
    532         else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-filter=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-filter=")))
    533         {
    534             enmOptType = OptType_VMRunner;
    535             m_strDbgStatisticsFilter = arguments.at(i).section('=', 1);
    536         }
    537         else if (!::strcmp(arg, "--statistics-config") || !::strcmp(arg, "--stats-config"))
    538         {
    539             enmOptType = OptType_VMRunner;
    540             if (++i < argc)
    541                 m_strDbgStatisticsConfig = arguments.at(i);
    542         }
    543         else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-config=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-config=")))
    544         {
    545             enmOptType = OptType_VMRunner;
    546             m_strDbgStatisticsConfig = arguments.at(i).section('=', 1);
    547         }
    548         else if (!::strcmp(arg, "-no-debug") || !::strcmp(arg, "--no-debug"))
    549         {
    550             enmOptType = OptType_VMRunner;
    551             setDebuggerVar(&m_fDbgEnabled, false);
    552             setDebuggerVar(&m_fDbgAutoShow, false);
    553             setDebuggerVar(&m_fDbgAutoShowCommandLine, false);
    554             setDebuggerVar(&m_fDbgAutoShowStatistics, false);
    555         }
    556         /* Not quite debug options, but they're only useful with the debugger bits. */
    557         else if (!::strcmp(arg, "--start-paused"))
    558         {
    559             enmOptType = OptType_VMRunner;
    560             m_enmLaunchRunning = LaunchRunning_No;
    561         }
    562         else if (!::strcmp(arg, "--start-running"))
    563         {
    564             enmOptType = OptType_VMRunner;
    565             m_enmLaunchRunning = LaunchRunning_Yes;
    566         }
    567 #endif
    568         if (enmOptType == OptType_VMRunner && m_enmType != UIType_RuntimeUI)
    569             msgCenter().cannotHandleRuntimeOption(arg);
    570 
    571         i++;
    572     }
    573 
    574     if (uiType() == UIType_RuntimeUI && startVM)
    575     {
    576         /* m_fSeparateProcess makes sense only if a VM is started. */
    577         m_fSeparateProcess = fSeparateProcess;
    578 
    579         /* Search for corresponding VM: */
    580         QUuid uuid = QUuid(vmNameOrUuid);
    581         const CVirtualBox comVBox = gpGlobalSession->virtualBox();
    582         const CMachine comMachine = comVBox.FindMachine(vmNameOrUuid);
    583         if (!uuid.isNull())
    584         {
    585             if (comMachine.isNull() && showStartVMErrors())
    586                 return msgCenter().cannotFindMachineById(comVBox, uuid);
    587         }
    588         else
    589         {
    590             if (comMachine.isNull() && showStartVMErrors())
    591                 return msgCenter().cannotFindMachineByName(comVBox, vmNameOrUuid);
    592         }
    593         m_uManagedVMId = comMachine.GetId();
    594 
    595         if (m_fSeparateProcess)
    596         {
    597             /* Create a log file for VirtualBoxVM process. */
    598             QString str = comMachine.GetLogFolder();
    599             com::Utf8Str logDir(str.toUtf8().constData());
    600 
    601             /* make sure the Logs folder exists */
    602             if (!RTDirExists(logDir.c_str()))
    603                 RTDirCreateFullPath(logDir.c_str(), 0700);
    604 
    605             com::Utf8Str logFile = com::Utf8StrFmt("%s%cVBoxUI.log",
    606                                                    logDir.c_str(), RTPATH_DELIMITER);
    607 
    608             com::VBoxLogRelCreate("GUI (separate)", logFile.c_str(),
    609                                   RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_RESTRICT_GROUPS,
    610                                   "all all.restrict -default.restrict",
    611                                   "VBOX_RELEASE_LOG", RTLOGDEST_FILE,
    612                                   32768 /* cMaxEntriesPerGroup */,
    613                                   0 /* cHistory */, 0 /* uHistoryFileTime */,
    614                                   0 /* uHistoryFileSize */, NULL);
    615         }
    616     }
    617 
    618     /* For Selector UI: */
    619     if (uiType() == UIType_ManagerUI)
    620     {
    621         /* We should create separate logging file for VM selector: */
    622         char szLogFile[RTPATH_MAX];
    623         const char *pszLogFile = NULL;
    624         com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
    625         RTPathAppend(szLogFile, sizeof(szLogFile), "selectorwindow.log");
    626         pszLogFile = szLogFile;
    627         /* Create release logger, to file: */
    628         com::VBoxLogRelCreate("GUI VM Selector Window",
    629                               pszLogFile,
    630                               RTLOGFLAGS_PREFIX_TIME_PROG,
    631                               "all",
    632                               "VBOX_GUI_SELECTORWINDOW_RELEASE_LOG",
    633                               RTLOGDEST_FILE | RTLOGDEST_F_NO_DENY,
    634                               UINT32_MAX,
    635                               10,
    636                               60 * 60,
    637                               _1M,
    638                               NULL /*pErrInfo*/);
    639 
    640         LogRel(("Qt version: %s\n", UIVersionInfo::qtRTVersionString().toUtf8().constData()));
    641     }
    642 
    643     if (m_fSettingsPwSet)
    644     {
    645         CVirtualBox comVBox = gpGlobalSession->virtualBox();
    646         comVBox.SetSettingsSecret(m_astrSettingsPw);
    647     }
    648 
    649     if (visualStateType != UIVisualStateType_Invalid && !m_uManagedVMId.isNull())
    650         gEDataManager->setRequestedVisualState(visualStateType, m_uManagedVMId);
    651 
    652 #ifdef VBOX_WITH_DEBUGGER_GUI
    653     /* For Runtime UI: */
    654     if (uiType() == UIType_RuntimeUI)
    655     {
    656         /* Setup the debugger GUI: */
    657         if (RTEnvExist("VBOX_GUI_NO_DEBUGGER"))
    658             m_fDbgEnabled = m_fDbgAutoShow =  m_fDbgAutoShowCommandLine = m_fDbgAutoShowStatistics = false;
    659         if (m_fDbgEnabled)
    660         {
    661             RTERRINFOSTATIC ErrInfo;
    662             RTErrInfoInitStatic(&ErrInfo);
    663             int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &m_hVBoxDbg, RTLDRLOAD_FLAGS_LOCAL, &ErrInfo.Core);
    664             if (RT_FAILURE(vrc))
    665             {
    666                 m_hVBoxDbg = NIL_RTLDRMOD;
    667                 m_fDbgAutoShow = m_fDbgAutoShowCommandLine = m_fDbgAutoShowStatistics = false;
    668                 LogRel(("Failed to load VBoxDbg, rc=%Rrc - %s\n", vrc, ErrInfo.Core.pszMsg));
    669             }
    670         }
    671     }
    672 #endif
    673 
    674     m_fValid = true;
    675 
    676     /* Create medium-enumerator but don't do any immediate caching: */
    677     UIMediumEnumerator::create();
    678 
    679     /* Create shortcut pool: */
    680     UIShortcutPool::create(uiType());
    681 
    682 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    683     /* Create network manager: */
    684     UINetworkRequestManager::create();
    685 
    686     /* Schedule update manager: */
    687     UIUpdateManager::schedule();
    688 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    689 
    690 #ifdef RT_OS_LINUX
    691     /* Make sure no wrong USB mounted: */
    692     checkForWrongUSBMounted();
    693 #endif /* RT_OS_LINUX */
    694 
    695     iOriginalFontPixelSize = qApp->font().pixelSize();
    696     iOriginalFontPointSize = qApp->font().pointSize();
    697     sltHandleFontScaleFactorChanged(gEDataManager->fontScaleFactor());
    698 }
    699 
    700 void UICommon::cleanup()
    701 {
    702     LogRel(("GUI: UICommon: Handling aboutToQuit request..\n"));
    703 
    704     /// @todo Shouldn't that be protected with a mutex or something?
    705     /* Remember that the cleanup is in progress preventing any unwanted
    706      * stuff which could be called from the other threads: */
    707     m_fCleaningUp = true;
    708 
    709 #ifdef VBOX_WS_WIN
    710     /* Ask listeners to commit data if haven't yet: */
    711     if (!m_fDataCommitted)
    712     {
    713         emit sigAskToCommitData();
    714         m_fDataCommitted = true;
    715     }
    716 #else
    717     /* Ask listeners to commit data: */
    718     emit sigAskToCommitData();
    719 #endif
    720 
    721 #ifdef VBOX_WITH_DEBUGGER_GUI
    722     /* For Runtime UI: */
    723     if (   uiType() == UIType_RuntimeUI
    724         && m_hVBoxDbg != NIL_RTLDRMOD)
    725     {
    726         RTLdrClose(m_hVBoxDbg);
    727         m_hVBoxDbg = NIL_RTLDRMOD;
    728     }
    729 #endif
    730 
    731 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    732     /* Shutdown update manager: */
    733     UIUpdateManager::shutdown();
    734 
    735     /* Destroy network manager: */
    736     UINetworkRequestManager::destroy();
    737 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    738 
    739     /* Destroy shortcut pool: */
    740     UIShortcutPool::destroy();
    741 
    742 #ifdef VBOX_GUI_WITH_PIDFILE
    743     deletePidfile();
    744 #endif /* VBOX_GUI_WITH_PIDFILE */
    745 
    746     /* Destroy medium-enumerator: */
    747     UIMediumEnumerator::destroy();
    748 
    749     /* Destroy the global (VirtualBox and VirtualBoxClient) Main event
    750      * handlers which are used in both Manager and Runtime UIs. */
    751     UIVirtualBoxEventHandler::destroy();
    752     UIVirtualBoxClientEventHandler::destroy();
    753 
    754     /* Destroy the extra-data manager finally after everything
    755      * above which could use it already destroyed: */
    756     UIExtraDataManager::destroy();
    757 
    758     /* Destroy converter: */
    759     UIConverter::destroy();
    760 
    761     /* Cleanup thread-pools: */
    762     delete m_pThreadPool;
    763     m_pThreadPool = 0;
    764     delete m_pThreadPoolCloud;
    765     m_pThreadPoolCloud = 0;
    766 
    767     /* First, make sure we don't use COM any more: */
    768     emit sigAskToDetachCOM();
    769 
    770     /* Cleanup COM: */
    771     gpGlobalSession->cleanup();
    772     UIGlobalSession::destroy();
    773 
    774     /* Notify listener it can close UI now: */
    775     emit sigAskToCloseUI();
    776 
    777     /* Cleanup general icon-pool: */
    778     UIIconPoolGeneral::destroy();
    779 
    780     /* Destroy popup-center: */
    781     UIPopupCenter::destroy();
    782     /* Destroy message-center: */
    783     UIMessageCenter::destroy();
    784 
    785     /* Destroy desktop-widget watchdog: */
    786     UIDesktopWidgetWatchdog::destroy();
    787 
    788     /* Destroy translation event listener instance: */
    789     UITranslationEventListener::destroy();
    790 
    791     m_fValid = false;
    792 
    793     LogRel(("GUI: UICommon: aboutToQuit request handled!\n"));
    794 }
    795 
    796 #ifdef VBOX_WS_MAC
    797 /* static */
    798 MacOSXRelease UICommon::determineOsRelease()
    799 {
    800     /* Prepare 'utsname' struct: */
    801     utsname info;
    802     if (uname(&info) != -1)
    803     {
    804         /* Cut the major release index of the string we have, s.a. 'man uname': */
    805         const int iRelease = QString(info.release).section('.', 0, 0).toInt();
    806         /* Check boundaries: */
    807         if (iRelease <= MacOSXRelease_FirstUnknown)
    808             return MacOSXRelease_Old;
    809         else if (iRelease >= MacOSXRelease_LastUnknown)
    810             return MacOSXRelease_New;
    811         else
    812             return (MacOSXRelease)iRelease;
    813     }
    814     /* Return 'Old' by default: */
    815     return MacOSXRelease_Old;
    816 }
    817 #endif /* VBOX_WS_MAC */
    818 
    819 #ifdef VBOX_WS_NIX
    820 bool UICommon::X11ServerAvailable() const
    821 {
    822     return VBGHDisplayServerTypeIsXAvailable(m_enmDisplayServerType);
    823 }
    824 
    825 VBGHDISPLAYSERVERTYPE UICommon::displayServerType() const
    826 {
    827     return m_enmDisplayServerType;
    828 }
    829 #endif
    830 
    831 QString UICommon::hostOperatingSystem() const
    832 {
    833     const CHost comHost = gpGlobalSession->host();
    834     return comHost.GetOperatingSystem();
    835 }
    836 
    837 #if defined(VBOX_WS_MAC)
    838 // Provided by UICocoaApplication ..
    839 
    840 #elif defined(VBOX_WS_WIN)
    841 
    842 bool UICommon::isWindowsInDarkMode() const
    843 {
    844     /* Load saved color theme: */
    845     UIColorThemeType enmColorTheme = gEDataManager->colorTheme();
    846 
    847     /* Check whether we have dark system theme requested: */
    848     if (enmColorTheme == UIColorThemeType_Auto)
    849     {
    850         QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
    851                            QSettings::NativeFormat);
    852         if (settings.value("AppsUseLightTheme") == 0)
    853             enmColorTheme = UIColorThemeType_Dark;
    854     }
    855 
    856     /* Return result: */
    857     return enmColorTheme == UIColorThemeType_Dark;
    858 }
    859 
    860 #else /* Linux, BSD, Solaris */
    861 
    862 bool UICommon::isPaletteInDarkMode() const
    863 {
    864     const QPalette pal = qApp->palette();
    865     const QColor background = pal.color(QPalette::Active, QPalette::Window);
    866     const double dLuminance = (0.299 * background.red() + 0.587 * background.green() + 0.114 * background.blue()) / 255;
    867     return dLuminance < 0.5;
    868 }
    869 #endif /* Linux, BSD, Solaris */
    870 
    871 void UICommon::loadColorTheme()
    872 {
    873 #if defined (VBOX_WS_MAC)
    874     /* macOS has Window color hardcoded somewhere inside, Qt has no access to it,
    875      * moreover these colors are influenced by window background blending,
    876      * making Qt default colors incredibly inconsistent with native macOS apps. */
    877 
    878     /* Redefine colors for known OS types: */
    879     enum ColorSlot
    880     {
    881         ColorSlot_DarkActive,
    882         ColorSlot_DarkInactive,
    883         ColorSlot_DarkAlternate,
    884         ColorSlot_LightActive,
    885         ColorSlot_LightInactive,
    886         ColorSlot_LightAlternate,
    887     };
    888     QMap<ColorSlot, QColor> colors;
    889     switch (osRelease())
    890     {
    891         case MacOSXRelease_BigSur:
    892         {
    893             colors[ColorSlot_DarkActive] = QColor("#282628");
    894             colors[ColorSlot_DarkInactive] = QColor("#2E292E");
    895             colors[ColorSlot_LightActive] = QColor("#E7E2E3");
    896             colors[ColorSlot_LightInactive] = QColor("#EEE9EA");
    897             break;
    898         }
    899         case MacOSXRelease_Monterey:
    900         {
    901             colors[ColorSlot_DarkActive] = QColor("#252328");
    902             colors[ColorSlot_DarkInactive] = QColor("#2A2630");
    903             colors[ColorSlot_LightActive] = QColor("#E1DEE4");
    904             colors[ColorSlot_LightInactive] = QColor("#EEE8E9");
    905             break;
    906         }
    907         case MacOSXRelease_Ventura:
    908         {
    909             colors[ColorSlot_DarkActive] = QColor("#322827");
    910             colors[ColorSlot_DarkInactive] = QColor("#332A28");
    911             colors[ColorSlot_LightActive] = QColor("#E5E0DF");
    912             colors[ColorSlot_LightInactive] = QColor("#ECE7E5");
    913             break;
    914         }
    915         default:
    916             break;
    917     }
    918     /* Redefine colors common for various OS types: */
    919     // we do it only if we have redefined something above:
    920     if (!colors.isEmpty())
    921     {
    922         colors[ColorSlot_DarkAlternate] = QColor("#2F2A2F");
    923         colors[ColorSlot_LightAlternate] = QColor("#F4F5F5");
    924     }
    925 
    926     /* Do we have redefined colors? */
    927     if (!colors.isEmpty())
    928     {
    929         QPalette pal = qApp->palette();
    930         if (isInDarkMode())
    931         {
    932             pal.setColor(QPalette::Active, QPalette::Window, colors.value(ColorSlot_DarkActive));
    933             pal.setColor(QPalette::Inactive, QPalette::Window, colors.value(ColorSlot_DarkInactive));
    934             pal.setColor(QPalette::Active, QPalette::AlternateBase, colors.value(ColorSlot_DarkAlternate));
    935             pal.setColor(QPalette::Inactive, QPalette::AlternateBase, colors.value(ColorSlot_DarkAlternate));
    936         }
    937         else
    938         {
    939             pal.setColor(QPalette::Active, QPalette::Window, colors.value(ColorSlot_LightActive));
    940             pal.setColor(QPalette::Inactive, QPalette::Window, colors.value(ColorSlot_LightInactive));
    941             pal.setColor(QPalette::Active, QPalette::AlternateBase, colors.value(ColorSlot_LightAlternate));
    942             pal.setColor(QPalette::Inactive, QPalette::AlternateBase, colors.value(ColorSlot_LightAlternate));
    943         }
    944         qApp->setPalette(pal);
    945     }
    946 
    947 #elif defined(VBOX_WS_WIN)
    948 
    949     /* For the Dark mode! */
    950     if (isInDarkMode())
    951     {
    952         qApp->setStyle(QStyleFactory::create("Fusion"));
    953         QPalette darkPalette;
    954         QColor windowColor1 = QColor(59, 60, 61);
    955         QColor windowColor2 = QColor(63, 64, 65);
    956         QColor baseColor1 = QColor(46, 47, 48);
    957         QColor baseColor2 = QColor(56, 57, 58);
    958         QColor disabledColor = QColor(113, 114, 115);
    959         darkPalette.setColor(QPalette::Window, windowColor1);
    960         darkPalette.setColor(QPalette::WindowText, Qt::white);
    961         darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, disabledColor);
    962         darkPalette.setColor(QPalette::Base, baseColor1);
    963         darkPalette.setColor(QPalette::AlternateBase, baseColor2);
    964         darkPalette.setColor(QPalette::PlaceholderText, disabledColor);
    965         darkPalette.setColor(QPalette::Text, Qt::white);
    966         darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
    967         darkPalette.setColor(QPalette::Button, windowColor2);
    968         darkPalette.setColor(QPalette::ButtonText, Qt::white);
    969         darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
    970         darkPalette.setColor(QPalette::BrightText, Qt::red);
    971         darkPalette.setColor(QPalette::Link, QColor(179, 214, 242));
    972         darkPalette.setColor(QPalette::Highlight, QColor(29, 84, 92));
    973         darkPalette.setColor(QPalette::HighlightedText, Qt::white);
    974         darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
    975         qApp->setPalette(darkPalette);
    976         qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2b2b2b; border: 1px solid #737373; }");
    977     }
    978 
    979 #else /* Linux, BSD, Solaris */
    980 
    981     /* For the Dark mode! */
    982     if (isInDarkMode())
    983     {
    984         // WORKAROUND:
    985         // Have seen it on Linux with Qt5 but still see it with Qt6.
    986         // In Dark themes on KDE (at least) PlaceholderText foreground
    987         // is indistinguishable on Base background.
    988 
    989         /* Acquire global palette: */
    990         QPalette darkPalette = qApp->palette();
    991 
    992         /* Get text base color: */
    993         const QColor base = darkPalette.color(QPalette::Active, QPalette::Base);
    994 
    995         /* Get possible foreground colors: */
    996         const QColor simpleText = darkPalette.color(QPalette::Active, QPalette::Text);
    997         const QColor placeholderText = darkPalette.color(QPalette::Active, QPalette::PlaceholderText);
    998         QColor lightText = simpleText.black() < placeholderText.black() ? simpleText : placeholderText;
    999         QColor darkText = simpleText.black() > placeholderText.black() ? simpleText : placeholderText;
    1000         if (lightText.black() > 128)
    1001             lightText = QColor(Qt::white);
    1002         lightText = lightText.darker(150);
    1003         if (darkText.black() < 128)
    1004             darkText = QColor(Qt::black);
    1005         darkText = darkText.lighter(150);
    1006 
    1007         /* Measure base luminance: */
    1008         double dLuminance = (0.299 * base.red() + 0.587 * base.green() + 0.114 * base.blue()) / 255;
    1009 
    1010         /* Adjust color accordingly: */
    1011         darkPalette.setColor(QPalette::Active, QPalette::PlaceholderText,
    1012                              dLuminance > 0.5 ? darkText : lightText);
    1013 
    1014         /* Put palette back: */
    1015         qApp->setPalette(darkPalette);
    1016     }
    1017 
    1018 #endif /* Linux, BSD, Solaris */
    1019 }
    1020 
    1021 bool UICommon::processArgs()
    1022 {
    1023     /* Among those arguments: */
    1024     bool fResult = false;
    1025     const QStringList args = qApp->arguments();
    1026 
    1027     /* We are looking for a list of file URLs passed to the executable: */
    1028     QList<QUrl> listArgUrls;
    1029     for (int i = 1; i < args.size(); ++i)
    1030     {
    1031         /* But we break out after the first parameter, cause there
    1032          * could be parameters with arguments (e.g. --comment comment). */
    1033         if (args.at(i).startsWith("-"))
    1034             break;
    1035 
    1036 #ifdef VBOX_WS_MAC
    1037         const QString strArg = ::darwinResolveAlias(args.at(i));
    1038 #else
    1039         const QString strArg = args.at(i);
    1040 #endif
    1041 
    1042         /* So if the argument file exists, we add it to URL list: */
    1043         if (   !strArg.isEmpty()
    1044             && QFile::exists(strArg))
    1045             listArgUrls << QUrl::fromLocalFile(QFileInfo(strArg).absoluteFilePath());
    1046     }
    1047 
    1048     /* If there are file URLs: */
    1049     if (!listArgUrls.isEmpty())
    1050     {
    1051         /* We enumerate them and: */
    1052         for (int i = 0; i < listArgUrls.size(); ++i)
    1053         {
    1054             /* Check which of them has allowed VM extensions: */
    1055             const QUrl url = listArgUrls.at(i);
    1056             const QString strFile = url.toLocalFile();
    1057             if (UICommon::hasAllowedExtension(strFile, VBoxFileExts))
    1058             {
    1059                 /* So that we could run existing VMs: */
    1060                 CVirtualBox comVBox = gpGlobalSession->virtualBox();
    1061                 CMachine comMachine = comVBox.FindMachine(strFile);
    1062                 if (!comMachine.isNull())
    1063                 {
    1064                     fResult = true;
    1065                     launchMachine(comMachine);
    1066                     /* And remove their URLs from the ULR list: */
    1067                     listArgUrls.removeAll(url);
    1068                 }
    1069             }
    1070         }
    1071     }
    1072 
    1073     /* And if there are *still* URLs: */
    1074     if (!listArgUrls.isEmpty())
    1075     {
    1076         /* We store them, they will be handled later: */
    1077         m_listArgUrls = listArgUrls;
    1078     }
    1079 
    1080     return fResult;
    1081 }
    1082 
    1083 bool UICommon::argumentUrlsPresent() const
    1084 {
    1085     return !m_listArgUrls.isEmpty();
    1086 }
    1087 
    1088 QList<QUrl> UICommon::takeArgumentUrls()
    1089 {
    1090     const QList<QUrl> result = m_listArgUrls;
    1091     m_listArgUrls.clear();
    1092     return result;
    1093 }
    1094 
    1095 #ifdef VBOX_WITH_DEBUGGER_GUI
    1096 
    1097 bool UICommon::isDebuggerEnabled() const
    1098 {
    1099     return isDebuggerWorker(&m_fDbgEnabled, GUI_Dbg_Enabled);
    1100 }
    1101 
    1102 bool UICommon::isDebuggerAutoShowEnabled() const
    1103 {
    1104     return isDebuggerWorker(&m_fDbgAutoShow, GUI_Dbg_AutoShow);
    1105 }
    1106 
    1107 bool UICommon::isDebuggerAutoShowCommandLineEnabled() const
    1108 {
    1109     return isDebuggerWorker(&m_fDbgAutoShowCommandLine, GUI_Dbg_AutoShow);
    1110 }
    1111 
    1112 bool UICommon::isDebuggerAutoShowStatisticsEnabled() const
    1113 {
    1114     return isDebuggerWorker(&m_fDbgAutoShowStatistics, GUI_Dbg_AutoShow);
    1115 }
    1116 
    1117 #endif /* VBOX_WITH_DEBUGGER_GUI */
    1118 
    1119 bool UICommon::shouldStartPaused() const
    1120 {
    1121 #ifdef VBOX_WITH_DEBUGGER_GUI
    1122     return m_enmLaunchRunning == LaunchRunning_Default ? isDebuggerAutoShowEnabled() : m_enmLaunchRunning == LaunchRunning_No;
    1123 #else
    1124     return false;
    1125 #endif
    1126 }
    1127 
    1128 #ifdef VBOX_GUI_WITH_PIDFILE
    1129 
    1130 void UICommon::createPidfile()
    1131 {
    1132     if (!m_strPidFile.isEmpty())
    1133     {
    1134         const qint64 iPid = qApp->applicationPid();
    1135         QFile file(m_strPidFile);
    1136         if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
    1137         {
    1138              QTextStream out(&file);
    1139              out << iPid << endl;
    1140         }
    1141         else
    1142             LogRel(("Failed to create pid file %s\n", m_strPidFile.toUtf8().constData()));
    1143     }
    1144 }
    1145 
    1146 void UICommon::deletePidfile()
    1147 {
    1148     if (   !m_strPidFile.isEmpty()
    1149         && QFile::exists(m_strPidFile))
    1150         QFile::remove(m_strPidFile);
    1151 }
    1152 
    1153 #endif /* VBOX_GUI_WITH_PIDFILE */
    1154 
    1155 /* static */
    1156 bool UICommon::switchToMachine(CMachine &comMachine)
     54#include <VBox/com/VirtualBox.h> /* For CLSID_Session. */
     55
     56
     57bool UILocalMachineStuff::switchToMachine(CMachine &comMachine)
    115758{
    115859#ifdef VBOX_WS_MAC
     
    1204105}
    1205106
    1206 /* static */
    1207 bool UICommon::launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode /* = UILaunchMode_Default */)
     107bool UILocalMachineStuff::launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode /* = UILaunchMode_Default */)
    1208108{
    1209109    /* Switch to machine window(s) if possible: */
     
    1310210}
    1311211
    1312 CSession UICommon::openSession(QUuid uId, KLockType enmLockType /* = KLockType_Write */)
     212CSession UILocalMachineStuff::openSession(QUuid uId, KLockType enmLockType /* = KLockType_Write */)
    1313213{
    1314214    /* Prepare session: */
     
    1317217    /* Make sure uId isn't null: */
    1318218    if (uId.isNull())
    1319         uId = managedVMUuid();
     219        uId = uiCommon().managedVMUuid();
    1320220    if (uId.isNull())
    1321221        return comSession;
     
    1376276}
    1377277
    1378 CSession UICommon::openSession(KLockType enmLockType /* = KLockType_Write */)
     278CSession UILocalMachineStuff::openSession(KLockType enmLockType /* = KLockType_Write */)
    1379279{
    1380280    /* Pass to function above: */
    1381     return openSession(managedVMUuid(), enmLockType);
    1382 }
    1383 
    1384 CSession UICommon::tryToOpenSessionFor(CMachine &comMachine)
     281    return openSession(uiCommon().managedVMUuid(), enmLockType);
     282}
     283
     284CSession UILocalMachineStuff::openExistingSession(const QUuid &uId)
     285{
     286    /* Pass to function above: */
     287    return openSession(uId, KLockType_Shared);
     288}
     289
     290CSession UILocalMachineStuff::tryToOpenSessionFor(CMachine &comMachine)
    1385291{
    1386292    /* Prepare session: */
     
    1396302    }
    1397303    /* Is this a Selector UI call? */
    1398     else if (uiType() == UIType_ManagerUI)
     304    else if (uiCommon().uiType() == UIType_ManagerUI)
    1399305    {
    1400306        /* Open existing 'shared' session: */
     
    1410316}
    1411317
    1412 void UICommon::notifyCloudMachineUnregistered(const QString &strProviderShortName,
    1413                                               const QString &strProfileName,
    1414                                               const QUuid &uId)
    1415 {
    1416     emit sigCloudMachineUnregistered(strProviderShortName, strProfileName, uId);
    1417 }
    1418 
    1419 void UICommon::notifyCloudMachineRegistered(const QString &strProviderShortName,
    1420                                             const QString &strProfileName,
    1421                                             const CCloudMachine &comMachine)
    1422 {
    1423     emit sigCloudMachineRegistered(strProviderShortName, strProfileName, comMachine);
    1424 }
    1425 
    1426 #ifdef RT_OS_LINUX
    1427 /* static */
    1428 void UICommon::checkForWrongUSBMounted()
    1429 {
    1430     /* Make sure '/proc/mounts' exists and can be opened: */
    1431     QFile file("/proc/mounts");
    1432     if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
    1433         return;
    1434 
    1435     /* Fetch contents: */
    1436     QStringList contents;
    1437     for (;;)
    1438     {
    1439         QByteArray line = file.readLine();
    1440         if (line.isEmpty())
    1441             break;
    1442         contents << line;
    1443     }
    1444     /* Grep contents for usbfs presence: */
    1445     QStringList grep1(contents.filter("/sys/bus/usb/drivers"));
    1446     QStringList grep2(grep1.filter("usbfs"));
    1447     if (grep2.isEmpty())
    1448         return;
    1449 
    1450     /* Show corresponding warning: */
    1451     msgCenter().warnAboutWrongUSBMounted();
    1452 }
    1453 #endif /* RT_OS_LINUX */
    1454 
    1455 /* static */
    1456 QString UICommon::usbDetails(const CUSBDevice &comDevice)
    1457 {
    1458     QString strDetails;
    1459     if (comDevice.isNull())
    1460         strDetails = tr("Unknown device", "USB device details");
    1461     else
    1462     {
    1463         QVector<QString> devInfoVector = comDevice.GetDeviceInfo();
    1464         QString strManufacturer;
    1465         QString strProduct;
    1466 
    1467         if (devInfoVector.size() >= 1)
    1468             strManufacturer = devInfoVector[0].trimmed();
    1469         if (devInfoVector.size() >= 2)
    1470             strProduct = devInfoVector[1].trimmed();
    1471 
    1472         if (strManufacturer.isEmpty() && strProduct.isEmpty())
    1473         {
    1474             strDetails =
    1475                 tr("Unknown device %1:%2", "USB device details")
    1476                    .arg(QString::number(comDevice.GetVendorId(),  16).toUpper().rightJustified(4, '0'))
    1477                    .arg(QString::number(comDevice.GetProductId(), 16).toUpper().rightJustified(4, '0'));
    1478         }
    1479         else
    1480         {
    1481             if (strProduct.toUpper().startsWith(strManufacturer.toUpper()))
    1482                 strDetails = strProduct;
    1483             else
    1484                 strDetails = strManufacturer + " " + strProduct;
    1485         }
    1486         ushort iRev = comDevice.GetRevision();
    1487         if (iRev != 0)
    1488         {
    1489             strDetails += " [";
    1490             strDetails += QString::number(iRev, 16).toUpper().rightJustified(4, '0');
    1491             strDetails += "]";
    1492         }
    1493     }
    1494 
    1495     return strDetails.trimmed();
    1496 }
    1497 
    1498 /* static */
    1499 QString UICommon::usbToolTip(const CUSBDevice &comDevice)
    1500 {
    1501     QString strTip =
    1502         tr("<nobr>Vendor ID: %1</nobr><br>"
    1503            "<nobr>Product ID: %2</nobr><br>"
    1504            "<nobr>Revision: %3</nobr>", "USB device tooltip")
    1505            .arg(QString::number(comDevice.GetVendorId(),  16).toUpper().rightJustified(4, '0'))
    1506            .arg(QString::number(comDevice.GetProductId(), 16).toUpper().rightJustified(4, '0'))
    1507            .arg(QString::number(comDevice.GetRevision(),  16).toUpper().rightJustified(4, '0'));
    1508 
    1509     const QString strSerial = comDevice.GetSerialNumber();
    1510     if (!strSerial.isEmpty())
    1511         strTip += QString(tr("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))
    1512                              .arg(strSerial);
    1513 
    1514     /* Add the state field if it's a host USB device: */
    1515     CHostUSBDevice hostDev(comDevice);
    1516     if (!hostDev.isNull())
    1517     {
    1518         strTip += QString(tr("<br><nobr>State: %1</nobr>", "USB device tooltip"))
    1519                              .arg(gpConverter->toString(hostDev.GetState()));
    1520     }
    1521 
    1522     return strTip;
    1523 }
    1524 
    1525 /* static */
    1526 QString UICommon::usbToolTip(const CUSBDeviceFilter &comFilter)
    1527 {
    1528     QString strTip;
    1529 
    1530     const QString strVendorId = comFilter.GetVendorId();
    1531     if (!strVendorId.isEmpty())
    1532         strTip += tr("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip")
    1533                      .arg(strVendorId);
    1534 
    1535     const QString strProductId = comFilter.GetProductId();
    1536     if (!strProductId.isEmpty())
    1537         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product ID: %2</nobr>", "USB filter tooltip")
    1538                                                      .arg(strProductId);
    1539 
    1540     const QString strRevision = comFilter.GetRevision();
    1541     if (!strRevision.isEmpty())
    1542         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Revision: %3</nobr>", "USB filter tooltip")
    1543                                                      .arg(strRevision);
    1544 
    1545     const QString strProduct = comFilter.GetProduct();
    1546     if (!strProduct.isEmpty())
    1547         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product: %4</nobr>", "USB filter tooltip")
    1548                                                      .arg(strProduct);
    1549 
    1550     const QString strManufacturer = comFilter.GetManufacturer();
    1551     if (!strManufacturer.isEmpty())
    1552         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip")
    1553                                                      .arg(strManufacturer);
    1554 
    1555     const QString strSerial = comFilter.GetSerialNumber();
    1556     if (!strSerial.isEmpty())
    1557         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Serial No.: %1</nobr>", "USB filter tooltip")
    1558                                                      .arg(strSerial);
    1559 
    1560     const QString strPort = comFilter.GetPort();
    1561     if (!strPort.isEmpty())
    1562         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Port: %1</nobr>", "USB filter tooltip")
    1563                                                      .arg(strPort);
    1564 
    1565     /* Add the state field if it's a host USB device: */
    1566     CHostUSBDevice hostDev(comFilter);
    1567     if (!hostDev.isNull())
    1568     {
    1569         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>State: %1</nobr>", "USB filter tooltip")
    1570                                                      .arg(gpConverter->toString(hostDev.GetState()));
    1571     }
    1572 
    1573     return strTip;
    1574 }
    1575 
    1576 /* static */
    1577 QString UICommon::usbToolTip(const CHostVideoInputDevice &comWebcam)
    1578 {
    1579     QStringList records;
    1580 
    1581     const QString strName = comWebcam.GetName();
    1582     if (!strName.isEmpty())
    1583         records << strName;
    1584 
    1585     const QString strPath = comWebcam.GetPath();
    1586     if (!strPath.isEmpty())
    1587         records << strPath;
    1588 
    1589     return records.join("<br>");
    1590 }
    1591 
    1592 int UICommon::supportedRecordingFeatures() const
    1593 {
    1594     int iSupportedFlag = 0;
    1595     CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
    1596     foreach (const KRecordingFeature &enmFeature, comProperties.GetSupportedRecordingFeatures())
    1597         iSupportedFlag |= enmFeature;
    1598     return iSupportedFlag;
    1599 }
    1600 
    1601 /* static */
    1602 QString UICommon::helpFile()
    1603 {
    1604     const QString strName = "UserManual";
    1605     const QString strSuffix = "qhc";
    1606 
    1607     /* Where are the docs located? */
    1608     char szDocsPath[RTPATH_MAX];
    1609     int rc = RTPathAppDocs(szDocsPath, sizeof(szDocsPath));
    1610     AssertRC(rc);
    1611 
    1612     /* Make sure that the language is in two letter code.
    1613      * Note: if languageId() returns an empty string lang.name() will
    1614      * return "C" which is an valid language code. */
    1615     QLocale lang(UITranslator::languageId());
    1616 
    1617     /* Construct the path and the filename: */
    1618     QString strManual = QString("%1/%2_%3.%4").arg(szDocsPath)
    1619                                               .arg(strName)
    1620                                               .arg(lang.name())
    1621                                               .arg(strSuffix);
    1622 
    1623     /* Check if a help file with that name exists: */
    1624     QFileInfo fi(strManual);
    1625     if (fi.exists())
    1626         return strManual;
    1627 
    1628     /* Fall back to the standard: */
    1629     strManual = QString("%1/%2.%4").arg(szDocsPath)
    1630                                    .arg(strName)
    1631                                    .arg(strSuffix);
    1632     return strManual;
    1633 }
    1634 
    1635 /* static */
    1636 QString UICommon::documentsPath()
    1637 {
    1638     QString strPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
    1639     QDir dir(strPath);
    1640     if (dir.exists())
    1641         return QDir::cleanPath(dir.canonicalPath());
    1642     else
    1643     {
    1644         dir.setPath(QDir::homePath() + "/Documents");
    1645         if (dir.exists())
    1646             return QDir::cleanPath(dir.canonicalPath());
    1647         else
    1648             return QDir::homePath();
    1649     }
    1650 }
    1651 
    1652 /* static */
    1653 bool UICommon::hasAllowedExtension(const QString &strFileName, const QStringList &extensions)
    1654 {
    1655     foreach (const QString &strExtension, extensions)
    1656         if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))
    1657             return true;
    1658     return false;
    1659 }
    1660 
    1661 /* static */
    1662 QString UICommon::findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName)
    1663 {
    1664     QDir folder(strFullFolderPath);
    1665     if (!folder.exists())
    1666         return strBaseFileName;
    1667     QFileInfoList folderContent = folder.entryInfoList();
    1668     QSet<QString> fileNameSet;
    1669     foreach (const QFileInfo &fileInfo, folderContent)
    1670     {
    1671         /* Remove the extension : */
    1672         fileNameSet.insert(fileInfo.completeBaseName());
    1673     }
    1674     int iSuffix = 0;
    1675     QString strNewName(strBaseFileName);
    1676     while (fileNameSet.contains(strNewName))
    1677     {
    1678         strNewName = strBaseFileName + QString("_") + QString::number(++iSuffix);
    1679     }
    1680     return strNewName;
    1681 }
    1682 
    1683 /* static */
    1684 void UICommon::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount)
    1685 {
    1686     /* Shame on Qt it hasn't stuff for tuning
    1687      * widget size suitable for reflecting content of desired size.
    1688      * For example QLineEdit, QSpinBox and similar widgets should have a methods
    1689      * to strict the minimum width to reflect at least [n] symbols. */
    1690 
    1691     /* Load options: */
    1692     QStyleOptionSpinBox option;
    1693     option.initFrom(pSpinBox);
    1694 
    1695     /* Acquire edit-field rectangle: */
    1696     QRect rect = pSpinBox->style()->subControlRect(QStyle::CC_SpinBox,
    1697                                                    &option,
    1698                                                    QStyle::SC_SpinBoxEditField,
    1699                                                    pSpinBox);
    1700 
    1701     /* Calculate minimum-width magic: */
    1702     const int iSpinBoxWidth = pSpinBox->width();
    1703     const int iSpinBoxEditFieldWidth = rect.width();
    1704     const int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth);
    1705     const QFontMetrics metrics(pSpinBox->font(), pSpinBox);
    1706     const QString strDummy(cCount, '0');
    1707     const int iTextWidth = metrics.horizontalAdvance(strDummy);
    1708 
    1709     /* Tune spin-box minimum-width: */
    1710     pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta);
    1711 }
    1712 
    1713 #ifdef VBOX_WITH_3D_ACCELERATION
    1714 /* static */
    1715 bool UICommon::isWddmCompatibleOsType(const QString &strGuestOSTypeId)
    1716 {
    1717     return    strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("WindowsVista"))
    1718            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows7"))
    1719            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows8"))
    1720            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows81"))
    1721            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows10"))
    1722            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows11"))
    1723            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2008"))
    1724            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2012"))
    1725            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2016"))
    1726            || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2019"));
    1727 }
    1728 #endif /* VBOX_WITH_3D_ACCELERATION */
    1729 
    1730 /* static */
    1731 quint64 UICommon::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
    1732 {
    1733     /* We create a list of the size of all available host monitors. This list
    1734      * is sorted by value and by starting with the biggest one, we calculate
    1735      * the memory requirements for every guest screen. This is of course not
    1736      * correct, but as we can't predict on which host screens the user will
    1737      * open the guest windows, this is the best assumption we can do, cause it
    1738      * is the worst case. */
    1739     const int cHostScreens = UIDesktopWidgetWatchdog::screenCount();
    1740     QVector<int> screenSize(qMax(cMonitors, cHostScreens), 0);
    1741     for (int i = 0; i < cHostScreens; ++i)
    1742     {
    1743         QRect r = gpDesktop->screenGeometry(i);
    1744         screenSize[i] = r.width() * r.height();
    1745     }
    1746     /* Now sort the vector: */
    1747     std::sort(screenSize.begin(), screenSize.end(), std::greater<int>());
    1748     /* For the case that there are more guest screens configured then host
    1749      * screens available, replace all zeros with the greatest value in the
    1750      * vector. */
    1751     for (int i = 0; i < screenSize.size(); ++i)
    1752         if (screenSize.at(i) == 0)
    1753             screenSize.replace(i, screenSize.at(0));
    1754 
    1755     quint64 uNeedBits = 0;
    1756     for (int i = 0; i < cMonitors; ++i)
    1757     {
    1758         /* Calculate summary required memory amount in bits: */
    1759         uNeedBits += (screenSize.at(i) * /* with x height */
    1760                      32 + /* we will take the maximum possible bpp for now */
    1761                      8 * _1M) + /* current cache per screen - may be changed in future */
    1762                      8 * 4096; /* adapter info */
    1763     }
    1764     /* Translate value into megabytes with rounding to highest side: */
    1765     quint64 uNeedMBytes = uNeedBits % (8 * _1M)
    1766                         ? uNeedBits / (8 * _1M) + 1
    1767                         : uNeedBits / (8 * _1M) /* convert to megabytes */;
    1768 
    1769     if (strGuestOSTypeId.startsWith("Windows"))
    1770     {
    1771         /* Windows guests need offscreen VRAM too for graphics acceleration features: */
    1772 #ifdef VBOX_WITH_3D_ACCELERATION
    1773         if (isWddmCompatibleOsType(strGuestOSTypeId))
    1774         {
    1775             /* WDDM mode, there are two surfaces for each screen: shadow & primary: */
    1776             uNeedMBytes *= 3;
    1777         }
    1778         else
    1779 #endif /* VBOX_WITH_3D_ACCELERATION */
    1780         {
    1781             uNeedMBytes *= 2;
    1782         }
    1783     }
    1784 
    1785     return uNeedMBytes * _1M;
    1786 }
    1787 
    1788 KGraphicsControllerType UICommon::getRecommendedGraphicsController(const QString &strGuestOSTypeId) const
    1789 {
    1790     return gpGlobalSession->guestOSTypeManager().getRecommendedGraphicsController(strGuestOSTypeId);
    1791 }
    1792 
    1793 /* static */
    1794 void UICommon::setHelpKeyword(QObject *pObject, const QString &strHelpKeyword)
    1795 {
    1796     if (pObject)
    1797         pObject->setProperty("helpkeyword", strHelpKeyword);
    1798 }
    1799 
    1800 /* static */
    1801 QString UICommon::helpKeyword(const QObject *pObject)
    1802 {
    1803     if (!pObject)
    1804         return QString();
    1805     return pObject->property("helpkeyword").toString();
    1806 }
    1807 
    1808 bool UICommon::openURL(const QString &strUrl) const
    1809 {
    1810     /** Service event. */
    1811     class ServiceEvent : public QEvent
    1812     {
    1813     public:
    1814 
    1815         /** Constructs service event on th basis of passed @a fResult. */
    1816         ServiceEvent(bool fResult)
    1817             : QEvent(QEvent::User)
    1818             , m_fResult(fResult)
    1819         {}
    1820 
    1821         /** Returns the result which event brings. */
    1822         bool result() const { return m_fResult; }
    1823 
    1824     private:
    1825 
    1826         /** Holds the result which event brings. */
    1827         bool m_fResult;
    1828     };
    1829 
    1830     /** Service client object. */
    1831     class ServiceClient : public QEventLoop
    1832     {
    1833     public:
    1834 
    1835         /** Constructs service client on the basis of passed @a fResult. */
    1836         ServiceClient()
    1837             : m_fResult(false)
    1838         {}
    1839 
    1840         /** Returns the result which event brings. */
    1841         bool result() const { return m_fResult; }
    1842 
    1843     private:
    1844 
    1845         /** Handles any Qt @a pEvent. */
    1846         bool event(QEvent *pEvent) RT_OVERRIDE RT_FINAL
    1847         {
    1848             /* Handle service event: */
    1849             if (pEvent->type() == QEvent::User)
    1850             {
    1851                 ServiceEvent *pServiceEvent = static_cast<ServiceEvent*>(pEvent);
    1852                 m_fResult = pServiceEvent->result();
    1853                 pServiceEvent->accept();
    1854                 quit();
    1855                 return true;
    1856             }
    1857             return false;
    1858         }
    1859 
    1860         bool m_fResult;
    1861     };
    1862 
    1863     /** Service server object. */
    1864     class ServiceServer : public QThread
    1865     {
    1866     public:
    1867 
    1868         /** Constructs service server on the basis of passed @a client and @a strUrl. */
    1869         ServiceServer(ServiceClient &client, const QString &strUrl)
    1870             : m_client(client), m_strUrl(strUrl) {}
    1871 
    1872     private:
    1873 
    1874         /** Executes thread task. */
    1875         void run() RT_OVERRIDE RT_FINAL
    1876         {
    1877             QApplication::postEvent(&m_client, new ServiceEvent(QDesktopServices::openUrl(m_strUrl)));
    1878         }
    1879 
    1880         /** Holds the client reference. */
    1881         ServiceClient &m_client;
    1882         /** Holds the URL to be processed. */
    1883         const QString &m_strUrl;
    1884     };
    1885 
    1886     /* Create client & server: */
    1887     ServiceClient client;
    1888     ServiceServer server(client, strUrl);
    1889     server.start();
    1890     client.exec();
    1891     server.wait();
    1892 
    1893     /* Acquire client result: */
    1894     bool fResult = client.result();
    1895     if (!fResult)
    1896         UINotificationMessage::cannotOpenURL(strUrl);
    1897 
    1898     return fResult;
    1899 }
    1900 
    1901 void UICommon::sltGUILanguageChange(QString strLanguage)
    1902 {
    1903     /* Make sure medium-enumeration is not in progress! */
    1904     AssertReturnVoid(!gpMediumEnumerator->isMediumEnumerationInProgress());
    1905     /* Load passed language: */
    1906     UITranslator::loadLanguage(strLanguage);
    1907 }
    1908 
    1909 void UICommon::sltHandleMachineCreated(const CMachine &comMachine)
    1910 {
    1911     /* Register created machine. */
    1912     CVirtualBox comVBox = gpGlobalSession->virtualBox();
    1913     comVBox.RegisterMachine(comMachine);
    1914     if (!comVBox.isOk())
    1915         UINotificationMessage::cannotRegisterMachine(comVBox, comMachine.GetName());
    1916 }
    1917 
    1918 void UICommon::sltHandleCloudMachineAdded(const QString &strProviderShortName,
    1919                                           const QString &strProfileName,
    1920                                           const CCloudMachine &comMachine)
    1921 {
    1922     /* Make sure we cached added cloud VM in GUI: */
    1923     notifyCloudMachineRegistered(strProviderShortName,
    1924                                  strProfileName,
    1925                                  comMachine);
    1926 }
    1927 
    1928 bool UICommon::eventFilter(QObject *pObject, QEvent *pEvent)
    1929 {
    1930     /** @todo Just use the QIWithRetranslateUI3 template wrapper. */
    1931 
    1932     if (   pEvent->type() == QEvent::LanguageChange
    1933         && pObject->isWidgetType()
    1934         && qobject_cast<QWidget*>(pObject)->isWindow())
    1935     {
    1936         /* Catch the language change event before any other widget gets it in
    1937          * order to invalidate cached string resources (like the details view
    1938          * templates) that may be used by other widgets. */
    1939         QWidgetList list = QApplication::topLevelWidgets();
    1940         if (list.first() == pObject)
    1941         {
    1942             /* Call this only once per every language change (see
    1943              * QApplication::installTranslator() for details): */
    1944             retranslateUi();
    1945         }
    1946     }
    1947 
    1948     /* Handle application palette change event: */
    1949     if (   pEvent->type() == QEvent::ApplicationPaletteChange
    1950         && pObject == windowManager().mainWindowShown())
    1951     {
    1952 #if defined(VBOX_WS_MAC)
    1953         const bool fDarkMode = UICocoaApplication::instance()->isDarkMode();
    1954 #elif defined(VBOX_WS_WIN)
    1955         const bool fDarkMode = isWindowsInDarkMode();
    1956 #else /* Linux, BSD, Solaris */
    1957         const bool fDarkMode = isPaletteInDarkMode();
    1958 #endif /* Linux, BSD, Solaris */
    1959         if (m_fDarkMode != fDarkMode)
    1960         {
    1961             m_fDarkMode = fDarkMode;
    1962             loadColorTheme();
    1963             emit sigThemeChange();
    1964         }
    1965     }
    1966 
    1967     /* Call to base-class: */
    1968     return QObject::eventFilter(pObject, pEvent);
    1969 }
    1970 
    1971 void UICommon::sltHandleFontScaleFactorChanged(int iFontScaleFactor)
    1972 {
    1973     QFont appFont = qApp->font();
    1974 
    1975     /* Let's round up some double var: */
    1976     auto roundUp = [](double dValue)
    1977     {
    1978         const int iValue = dValue;
    1979         return dValue > (double)iValue ? iValue + 1 : iValue;
    1980     };
    1981 
    1982     /* Do we have pixel font? */
    1983     if (iOriginalFontPixelSize != -1)
    1984         appFont.setPixelSize(roundUp(iFontScaleFactor / 100.f * iOriginalFontPixelSize));
    1985     /* Point font otherwise: */
    1986     else
    1987         appFont.setPointSize(roundUp(iFontScaleFactor / 100.f * iOriginalFontPointSize));
    1988 
    1989     qApp->setFont(appFont);
    1990 }
    1991 
    1992 void UICommon::retranslateUi()
    1993 {
    1994     /* Re-enumerate uimedium since they contain some translations too: */
    1995     if (isValid())
    1996         gpMediumEnumerator->refreshMedia();
    1997 
    1998 #ifdef VBOX_WS_NIX
    1999     // WORKAROUND:
    2000     // As X11 do not have functionality for providing human readable key names,
    2001     // we keep a table of them, which must be updated when the language is changed.
    2002     UINativeHotKey::retranslateKeyNames();
    2003 #endif
    2004 }
    2005 
    2006 #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
    2007 void UICommon::sltHandleCommitDataRequest(QSessionManager &manager)
    2008 {
    2009     LogRel(("GUI: UICommon: Commit data request...\n"));
    2010 
    2011     /* Ask listener to commit data: */
    2012     emit sigAskToCommitData();
    2013 # ifdef VBOX_WS_WIN
    2014     m_fDataCommitted = true;
    2015 # endif
    2016 
    2017     /* Depending on UI type: */
    2018     switch (uiType())
    2019     {
    2020         /* For Runtime UI: */
    2021         case UIType_RuntimeUI:
    2022         {
    2023             /* Thin clients will be able to shutdown properly,
    2024              * but for fat clients: */
    2025             if (!isSeparateProcess())
    2026             {
    2027 # if defined(VBOX_WS_MAC) && defined(VBOX_IS_QT6_OR_LATER) /** @todo qt6: ... */
    2028                 Q_UNUSED(manager);
    2029                 /* This code prevents QWindowSystemInterface::handleApplicationTermination
    2030                    for running, so among other things QApplication::closeAllWindows isn't
    2031                    called and we're somehow stuck in a half closed down state.  That said,
    2032                    just disabling this isn't sufficent, there we also have to accept() the
    2033                    QCloseEvent in UIMachineWindow. */
    2034                 /** @todo qt6: This isn't quite the right fix, I bet...  I'm sure I haven't
    2035                  *  quite understood all that's going on here.  So, leaving this for
    2036                  *  the real GUI experts to look into... :-)   */
    2037 # else
    2038                 // WORKAROUND:
    2039                 // We can't save VM state in one go for fat clients, so we have to ask session manager to cancel shutdown.
    2040                 // To next major release this should be removed in any case, since there will be no fat clients after all.
    2041                 manager.cancel();
    2042 
    2043 #  ifdef VBOX_WS_WIN
    2044                 // WORKAROUND:
    2045                 // In theory that's Qt5 who should allow us to provide canceling reason as well, but that functionality
    2046                 // seems to be missed in Windows platform plugin, so we are making that ourselves.
    2047                 NativeWindowSubsystem::ShutdownBlockReasonCreateAPI((HWND)windowManager().mainWindowShown()->winId(), L"VM is still running.");
    2048 #  endif
    2049 # endif
    2050             }
    2051 
    2052             break;
    2053         }
    2054         default:
    2055             break;
    2056     }
    2057 }
    2058 #endif /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    2059 
    2060 void UICommon::sltHandleVBoxSVCAvailabilityChange(bool fAvailable)
    2061 {
    2062     /* If VBoxSVC is available: */
    2063     if (fAvailable)
    2064     {
    2065         /* For Selector UI: */
    2066         if (uiType() == UIType_ManagerUI)
    2067         {
    2068             /* Recreate Main event listeners: */
    2069             UIVirtualBoxEventHandler::destroy();
    2070             UIVirtualBoxClientEventHandler::destroy();
    2071             UIExtraDataManager::destroy();
    2072             UIExtraDataManager::instance();
    2073             UIVirtualBoxEventHandler::instance();
    2074             UIVirtualBoxClientEventHandler::instance();
    2075             /* Ask UIStarter to restart UI: */
    2076             emit sigAskToRestartUI();
    2077         }
    2078     }
    2079 }
    2080 
    2081 #ifdef VBOX_WITH_DEBUGGER_GUI
    2082 
    2083 # define UICOMMON_DBG_CFG_VAR_FALSE       (0)
    2084 # define UICOMMON_DBG_CFG_VAR_TRUE        (1)
    2085 # define UICOMMON_DBG_CFG_VAR_MASK        (1)
    2086 # define UICOMMON_DBG_CFG_VAR_CMD_LINE    RT_BIT(3)
    2087 # define UICOMMON_DBG_CFG_VAR_DONE        RT_BIT(4)
    2088 
    2089 void UICommon::initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault)
    2090 {
    2091     QString strEnvValue;
    2092     char    szEnvValue[256];
    2093     int rc = RTEnvGetEx(RTENV_DEFAULT, pszEnvVar, szEnvValue, sizeof(szEnvValue), NULL);
    2094     if (RT_SUCCESS(rc))
    2095     {
    2096         strEnvValue = QString::fromUtf8(&szEnvValue[0]).toLower().trimmed();
    2097         if (strEnvValue.isEmpty())
    2098             strEnvValue = "yes";
    2099     }
    2100     else if (rc != VERR_ENV_VAR_NOT_FOUND)
    2101         strEnvValue = "veto";
    2102 
    2103     CVirtualBox comVBox = gpGlobalSession->virtualBox();
    2104     QString strExtraValue = comVBox.GetExtraData(pszExtraDataName).toLower().trimmed();
    2105     if (strExtraValue.isEmpty())
    2106         strExtraValue = QString();
    2107 
    2108     if ( strEnvValue.contains("veto") || strExtraValue.contains("veto"))
    2109         *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_DONE | UICOMMON_DBG_CFG_VAR_FALSE;
    2110     else if (strEnvValue.isNull() && strExtraValue.isNull())
    2111         *piDbgCfgVar = fDefault ? UICOMMON_DBG_CFG_VAR_TRUE : UICOMMON_DBG_CFG_VAR_FALSE;
    2112     else
    2113     {
    2114         QString *pStr = !strEnvValue.isEmpty() ? &strEnvValue : &strExtraValue;
    2115         if (   pStr->startsWith("y")  // yes
    2116             || pStr->startsWith("e")  // enabled
    2117             || pStr->startsWith("t")  // true
    2118             || pStr->startsWith("on")
    2119             || pStr->toLongLong() != 0)
    2120             *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_TRUE;
    2121         else if (   pStr->startsWith("n")  // o
    2122                  || pStr->startsWith("d")  // disable
    2123                  || pStr->startsWith("f")  // false
    2124                  || pStr->startsWith("off")
    2125                  || pStr->contains("veto") /* paranoia */
    2126                  || pStr->toLongLong() == 0)
    2127             *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_FALSE;
    2128         else
    2129         {
    2130             LogFunc(("Ignoring unknown value '%s' for '%s'\n", pStr->toUtf8().constData(), pStr == &strEnvValue ? pszEnvVar : pszExtraDataName));
    2131             *piDbgCfgVar = fDefault ? UICOMMON_DBG_CFG_VAR_TRUE : UICOMMON_DBG_CFG_VAR_FALSE;
    2132         }
    2133     }
    2134 }
    2135 
    2136 void UICommon::setDebuggerVar(int *piDbgCfgVar, bool fState)
    2137 {
    2138     if (!(*piDbgCfgVar & UICOMMON_DBG_CFG_VAR_DONE))
    2139         *piDbgCfgVar = (fState ? UICOMMON_DBG_CFG_VAR_TRUE : UICOMMON_DBG_CFG_VAR_FALSE)
    2140                      | UICOMMON_DBG_CFG_VAR_CMD_LINE;
    2141 }
    2142 
    2143 bool UICommon::isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const
    2144 {
    2145     if (!(*piDbgCfgVar & UICOMMON_DBG_CFG_VAR_DONE))
    2146     {
    2147         const QString str = gEDataManager->debugFlagValue(pszExtraDataName);
    2148         if (str.contains("veto"))
    2149             *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_DONE | UICOMMON_DBG_CFG_VAR_FALSE;
    2150         else if (str.isEmpty() || (*piDbgCfgVar & UICOMMON_DBG_CFG_VAR_CMD_LINE))
    2151             *piDbgCfgVar |= UICOMMON_DBG_CFG_VAR_DONE;
    2152         else if (   str.startsWith("y")  // yes
    2153                  || str.startsWith("e")  // enabled
    2154                  || str.startsWith("t")  // true
    2155                  || str.startsWith("on")
    2156                  || str.toLongLong() != 0)
    2157             *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_DONE | UICOMMON_DBG_CFG_VAR_TRUE;
    2158         else if (   str.startsWith("n")  // no
    2159                  || str.startsWith("d")  // disable
    2160                  || str.startsWith("f")  // false
    2161                  || str.toLongLong() == 0)
    2162             *piDbgCfgVar = UICOMMON_DBG_CFG_VAR_DONE | UICOMMON_DBG_CFG_VAR_FALSE;
    2163         else
    2164             *piDbgCfgVar |= UICOMMON_DBG_CFG_VAR_DONE;
    2165     }
    2166 
    2167     return (*piDbgCfgVar & UICOMMON_DBG_CFG_VAR_MASK) == UICOMMON_DBG_CFG_VAR_TRUE;
    2168 }
    2169 
    2170 #endif /* VBOX_WITH_DEBUGGER_GUI */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UILocalMachineStuff.h

    r105079 r105081  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UICommon class declaration.
     3 * VBox Qt GUI - UILocalMachineStuff namespace declaration.
    44 */
    55
     
    2626 */
    2727
    28 #ifndef FEQT_INCLUDED_SRC_globals_UICommon_h
    29 #define FEQT_INCLUDED_SRC_globals_UICommon_h
     28#ifndef FEQT_INCLUDED_SRC_globals_UILocalMachineStuff_h
     29#define FEQT_INCLUDED_SRC_globals_UILocalMachineStuff_h
    3030#ifndef RT_WITHOUT_PRAGMA_ONCE
    3131# pragma once
     
    3333
    3434/* Qt includes: */
    35 #include <QObject>
     35#include <QUuid>
    3636
    3737/* GUI includes: */
    3838#include "UIDefs.h"
    39 #include "UILibraryDefs.h"
    40 #ifdef VBOX_WS_NIX
    41 # include "VBoxUtils-nix.h"
    42 #endif
    4339
    4440/* COM includes: */
     41#include "KLockType.h"
    4542#include "CSession.h"
    46 #include "KGraphicsControllerType.h"
    47 #include "KLockType.h"
    4843
    4944/* Forward declarations: */
    50 class QSessionManager;
    51 class QSpinBox;
    52 class CCloudMachine;
    53 class CHostVideoInputDevice;
    5445class CMachine;
    55 class CUSBDevice;
    56 class UIThreadPool;
    57 class UITranslationEventListener;
    5846
    59 /** QObject subclass containing common GUI functionality. */
    60 class SHARED_LIBRARY_STUFF UICommon : public QObject
     47/** Cloud networking stuff namespace. */
     48namespace UILocalMachineStuff
    6149{
    62     Q_OBJECT;
     50    /** Switches to certain @a comMachine. */
     51    SHARED_LIBRARY_STUFF bool switchToMachine(CMachine &comMachine);
     52    /** Launches certain @a comMachine in specified @a enmLaunchMode. */
     53    SHARED_LIBRARY_STUFF bool launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode = UILaunchMode_Default);
    6354
    64 signals:
     55    /** Opens session of certain @a enmLockType for VM with certain @a uId. */
     56    SHARED_LIBRARY_STUFF CSession openSession(QUuid uId, KLockType enmLockType = KLockType_Write);
     57    /** Opens session of certain @a enmLockType for currently chosen VM. */
     58    SHARED_LIBRARY_STUFF CSession openSession(KLockType enmLockType = KLockType_Write);
     59    /** Opens session of KLockType_Shared type for VM with certain @a uId. */
     60    SHARED_LIBRARY_STUFF CSession openExistingSession(const QUuid &uId);
     61    /** Tries to guess if new @a comSession needs to be opened for certain @a comMachine,
     62      * if yes, new session of required type will be opened and machine will be updated,
     63      * otherwise, no session will be created and machine will be left unchanged. */
     64    SHARED_LIBRARY_STUFF CSession tryToOpenSessionFor(CMachine &comMachine);
     65}
    6566
    66     /** @name Common stuff.
    67      * @{ */
    68         /** Asks #UIStarter listener to restart UI. */
    69         void sigAskToRestartUI();
    70         /** Asks #UIStarter listener to close UI. */
    71         void sigAskToCloseUI();
     67/* Using across any module who included us: */
     68using namespace UILocalMachineStuff;
    7269
    73         /** Asks listeners to commit data. */
    74         void sigAskToCommitData();
    75         /** Asks listeners to detach COM. */
    76         void sigAskToDetachCOM();
    77     /** @} */
    78 
    79     /** @name Theme stuff.
    80      * @{ */
    81         /** Notifies listeners about theme change. */
    82         void sigThemeChange();
    83     /** @} */
    84 
    85     /** @name Cloud Virtual Machine stuff.
    86      * @{ */
    87         /** Notifies listeners about cloud VM was unregistered.
    88           * @param  strProviderShortName  Brings provider short name.
    89           * @param  strProfileName        Brings profile name.
    90           * @param  uId                   Brings cloud VM id. */
    91         void sigCloudMachineUnregistered(const QString &strProviderShortName,
    92                                          const QString &strProfileName,
    93                                          const QUuid &uId);
    94         /** Notifies listeners about cloud VM was registered.
    95           * @param  strProviderShortName  Brings provider short name.
    96           * @param  strProfileName        Brings profile name.
    97           * @param  comMachine            Brings cloud VM. */
    98         void sigCloudMachineRegistered(const QString &strProviderShortName,
    99                                        const QString &strProfileName,
    100                                        const CCloudMachine &comMachine);
    101     /** @} */
    102 
    103 public:
    104 
    105     /** VM launch running options. */
    106     enum LaunchRunning
    107     {
    108         LaunchRunning_Default, /**< Default (depends on debug settings). */
    109         LaunchRunning_No,      /**< Start the VM paused. */
    110         LaunchRunning_Yes      /**< Start the VM running. */
    111     };
    112 
    113     /** Returns UICommon instance. */
    114     static UICommon *instance() { return s_pInstance; }
    115     /** Creates UICommon instance of passed @a enmType. */
    116     static void create(UIType enmType);
    117     /** Destroys UICommon instance. */
    118     static void destroy();
    119 
    120     /** @name General stuff.
    121      * @{ */
    122         /** Returns the UI type. */
    123         UIType uiType() const { return m_enmType; }
    124 
    125         /** Returns whether UICommon instance is properly initialized. */
    126         bool isValid() const { return m_fValid; }
    127         /** Returns whether UICommon instance cleanup is in progress. */
    128         bool isCleaningUp() const { return m_fCleaningUp; }
    129     /** @} */
    130 
    131     /** @name Host OS stuff.
    132      * @{ */
    133 #ifdef VBOX_WS_MAC
    134         /** macOS: Returns #MacOSXRelease determined by <i>uname</i> call. */
    135         static MacOSXRelease determineOsRelease();
    136         /** macOS: Returns #MacOSXRelease determined during UICommon prepare routine. */
    137         MacOSXRelease osRelease() const { return m_enmMacOSVersion; }
    138 #endif
    139 
    140 #ifdef VBOX_WS_NIX
    141         /** X11: Returns the type of the Window Manager we are running under. */
    142         X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }
    143         /** X11: Returns whether the Window Manager we are running under is composition one. */
    144         bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
    145         /** Returns true if the detected display server type is either xorg or xwayland. */
    146         bool X11ServerAvailable() const;
    147         /** Returns display server type. */
    148         VBGHDISPLAYSERVERTYPE displayServerType() const;
    149 #endif
    150         /** Returns the name of the host OS by using IHost::getOperatingSystem. */
    151         QString hostOperatingSystem() const;
    152 
    153 #if defined(VBOX_WS_MAC)
    154         // Provided by UICocoaApplication ..
    155 #elif defined(VBOX_WS_WIN)
    156         /** Returns whether Windows host is in Dark mode. */
    157         bool isWindowsInDarkMode() const;
    158 #else /* Linux, BSD, Solaris */
    159         /** Returns whether palette is in Dark mode. */
    160         bool isPaletteInDarkMode() const;
    161 #endif /* Linux, BSD, Solaris */
    162 
    163         /** Returns whether host OS is in Dark mode. */
    164         bool isInDarkMode() const { return m_fDarkMode; }
    165 
    166         /** Loads the color theme. */
    167         void loadColorTheme();
    168     /** @} */
    169 
    170     /** @name Process arguments stuff.
    171      * @{ */
    172         /** Process application args. */
    173         bool processArgs();
    174 
    175         /** Returns whether there are unhandled URL arguments present. */
    176         bool argumentUrlsPresent() const;
    177         /** Takes and returns the URL argument list while clearing the source. */
    178         QList<QUrl> takeArgumentUrls();
    179 
    180         /** Returns the --startvm option value (managed VM id). */
    181         QUuid managedVMUuid() const { return m_uManagedVMId; }
    182         /** Returns the --separate option value (whether GUI process is separate from VM process). */
    183         bool isSeparateProcess() const { return m_fSeparateProcess; }
    184         /** Returns the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
    185         bool showStartVMErrors() const { return m_fShowStartVMErrors; }
    186 
    187         /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
    188         bool agressiveCaching() const { return m_fAgressiveCaching; }
    189 
    190         /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */
    191         bool shouldRestoreCurrentSnapshot() const { return m_fRestoreCurrentSnapshot; }
    192         /** Defines whether we should fRestore current snapshot before VM started. */
    193         void setShouldRestoreCurrentSnapshot(bool fRestore) { m_fRestoreCurrentSnapshot = fRestore; }
    194 
    195         /** Returns the --no-keyboard-grabbing option value (whether we should restore
    196          *  grab the keyboard or not - for debugging). */
    197         bool shouldNotGrabKeyboard() const { return m_fNoKeyboardGrabbing; }
    198 
    199         /** Returns the --fda option value (whether we have floppy image). */
    200         bool hasFloppyImageToMount() const { return !m_uFloppyImage.isNull(); }
    201         /** Returns the --dvd | --cdrom option value (whether we have DVD image). */
    202         bool hasDvdImageToMount() const { return !m_uDvdImage.isNull(); }
    203         /** Returns floppy image name. */
    204         QUuid getFloppyImage() const { return m_uFloppyImage; }
    205         /** Returns DVD image name. */
    206         QUuid getDvdImage() const { return m_uDvdImage; }
    207 
    208         /** Returns the --execute-all-in-iem option value. */
    209         bool areWeToExecuteAllInIem() const { return m_fExecuteAllInIem; }
    210         /** Returns whether --warp-factor option value is equal to 100. */
    211         bool isDefaultWarpPct() const { return m_uWarpPct == 100; }
    212         /** Returns the --warp-factor option value. */
    213         uint32_t getWarpPct() const { return m_uWarpPct; }
    214 
    215 #ifdef VBOX_WITH_DEBUGGER_GUI
    216         /** Holds whether the debugger should be accessible. */
    217         bool isDebuggerEnabled() const;
    218         /** Holds whether to show the debugger automatically with the console. */
    219         bool isDebuggerAutoShowEnabled() const;
    220         /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
    221         bool isDebuggerAutoShowCommandLineEnabled() const;
    222         /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
    223         bool isDebuggerAutoShowStatisticsEnabled() const;
    224         /** Returns the combined --statistics-expand values. */
    225         QString const getDebuggerStatisticsExpand() const { return m_strDbgStatisticsExpand; }
    226         /** Returns the --statistics-filter value. */
    227         QString const getDebuggerStatisticsFilter() const { return m_strDbgStatisticsFilter; }
    228         /** Returns the --statistics-config value. */
    229         QString const getDebuggerStatisticsConfig() const { return m_strDbgStatisticsConfig; }
    230 
    231         /** VBoxDbg module handle. */
    232         RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
    233 #endif
    234 
    235         /** Returns whether VM should start paused. */
    236         bool shouldStartPaused() const;
    237 
    238 #ifdef VBOX_GUI_WITH_PIDFILE
    239         /** Creates PID file. */
    240         void createPidfile();
    241         /** Deletes PID file. */
    242         void deletePidfile();
    243 #endif
    244     /** @} */
    245 
    246     /** @name COM: Virtual Machine stuff.
    247      * @{ */
    248         /** Switches to certain @a comMachine. */
    249         static bool switchToMachine(CMachine &comMachine);
    250         /** Launches certain @a comMachine in specified @a enmLaunchMode. */
    251         static bool launchMachine(CMachine &comMachine, UILaunchMode enmLaunchMode = UILaunchMode_Default);
    252 
    253         /** Opens session of certain @a enmLockType for VM with certain @a uId. */
    254         CSession openSession(QUuid uId, KLockType enmLockType = KLockType_Write);
    255         /** Opens session of certain @a enmLockType for currently chosen VM. */
    256         CSession openSession(KLockType enmLockType = KLockType_Write);
    257         /** Opens session of KLockType_Shared type for VM with certain @a uId. */
    258         CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
    259         /** Tries to guess if new @a comSession needs to be opened for certain @a comMachine,
    260           * if yes, new session of required type will be opened and machine will be updated,
    261           * otherwise, no session will be created and machine will be left unchanged. */
    262         CSession tryToOpenSessionFor(CMachine &comMachine);
    263     /** @} */
    264 
    265     /** @name COM: Cloud Virtual Machine stuff.
    266      * @{ */
    267         /** Notifies listeners about cloud VM was unregistered.
    268           * @param  strProviderShortName  Brings provider short name.
    269           * @param  strProfileName        Brings profile name.
    270           * @param  uId                   Brings cloud VM id. */
    271         void notifyCloudMachineUnregistered(const QString &strProviderShortName,
    272                                             const QString &strProfileName,
    273                                             const QUuid &uId);
    274         /** Notifies listeners about cloud VM was registered.
    275           * @param  strProviderShortName  Brings provider short name.
    276           * @param  strProfileName        Brings profile name.
    277           * @param  comMachine            Brings cloud VM. */
    278         void notifyCloudMachineRegistered(const QString &strProviderShortName,
    279                                           const QString &strProfileName,
    280                                           const CCloudMachine &comMachine);
    281     /** @} */
    282 
    283     /** @name COM: USB stuff.
    284      * @{ */
    285 #ifdef RT_OS_LINUX
    286         /** Verifies that USB drivers are properly configured on Linux. */
    287         static void checkForWrongUSBMounted();
    288 #endif
    289 
    290         /** Generates details for passed USB @a comDevice. */
    291         static QString usbDetails(const CUSBDevice &comDevice);
    292         /** Generates tool-tip for passed USB @a comDevice. */
    293         static QString usbToolTip(const CUSBDevice &comDevice);
    294         /** Generates tool-tip for passed USB @a comFilter. */
    295         static QString usbToolTip(const CUSBDeviceFilter &comFilter);
    296         /** Generates tool-tip for passed USB @a comWebcam. */
    297         static QString usbToolTip(const CHostVideoInputDevice &comWebcam);
    298     /** @} */
    299 
    300     /** @name COM: Recording stuff.
    301      * @{ */
    302         /** Returns supported recording features flag. */
    303         int supportedRecordingFeatures() const;
    304     /** @} */
    305 
    306     /** @name File-system stuff.
    307      * @{ */
    308         /** Returns full help file name. */
    309         static QString helpFile();
    310 
    311         /** Returns documents path. */
    312         static QString documentsPath();
    313 
    314         /** Returns whether passed @a strFileName ends with one of allowed extension in the @a extensions list. */
    315         static bool hasAllowedExtension(const QString &strFileName, const QStringList &extensions);
    316 
    317         /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts
    318           * searching strBaseFileName and adds suffixes until a unique file name is found. */
    319         static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName);
    320     /** @} */
    321 
    322     /** @name Widget stuff.
    323      * @{ */
    324         /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */
    325         static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
    326     /** @} */
    327 
    328     /** @name Display stuff.
    329      * @{ */
    330 #ifdef VBOX_WITH_3D_ACCELERATION
    331         /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */
    332         static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
    333 #endif
    334         /** Returns the required video memory in bytes for the current desktop
    335           * resolution at maximum possible screen depth in bpp. */
    336         static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
    337         KGraphicsControllerType getRecommendedGraphicsController(const QString &strGuestOSTypeId) const;
    338     /** @} */
    339 
    340     /** @name Thread stuff.
    341      * @{ */
    342         /** Returns the thread-pool instance. */
    343         UIThreadPool *threadPool() const { return m_pThreadPool; }
    344         /** Returns the thread-pool instance for cloud needs. */
    345         UIThreadPool *threadPoolCloud() const { return m_pThreadPoolCloud; }
    346     /** @} */
    347 
    348     /** @name Context sensitive help related functionality
    349      * @{ */
    350         /** Sets the property for help keyword on a QObject
    351           * @param  pObject      The object to set the help keyword property on
    352           * @param  strKeyword   The values of the key word property. */
    353         static void setHelpKeyword(QObject *pObject, const QString &strHelpKeyword);
    354         /** Returns the property for help keyword of a QObject. If no such property exists returns an empty QString.
    355           * @param  pWidget      The object to get the help keyword property from. */
    356         static QString helpKeyword(const QObject *pWidget);
    357     /** @} */
    358 
    359 public slots:
    360 
    361     /** @name Process arguments stuff.
    362      * @{ */
    363         /** Opens the specified URL using OS/Desktop capabilities. */
    364         bool openURL(const QString &strURL) const;
    365     /** @} */
    366 
    367     /** @name Localization stuff.
    368      * @{ */
    369         /** Handles language change to new @a strLanguage. */
    370         void sltGUILanguageChange(QString strLanguage);
    371     /** @} */
    372 
    373     /** @name Machine related stuff.
    374      * @{ */
    375         /** Handles signal about machine was created. */
    376         void sltHandleMachineCreated(const CMachine &comMachine);
    377     /** @} */
    378 
    379     /** @name Cloud Machine related stuff.
    380      * @{ */
    381         /** Handles signal about cloud machine was added. */
    382         void sltHandleCloudMachineAdded(const QString &strProviderShortName,
    383                                         const QString &strProfileName,
    384                                         const CCloudMachine &comMachine);
    385     /** @} */
    386 
    387 protected:
    388 
    389     /** Preprocesses any Qt @a pEvent for passed @a pObject. */
    390     virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
    391 
    392     /** Handles translation event. */
    393     virtual void retranslateUi();
    394 
    395 protected slots:
    396 
    397     /** Calls for cleanup() functionality. */
    398     void sltCleanup() { cleanup(); }
    399 
    400 #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
    401     /** @name Common stuff.
    402      * @{ */
    403         /** Handles @a manager request for emergency session shutdown. */
    404         void sltHandleCommitDataRequest(QSessionManager &manager);
    405     /** @} */
    406 #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    407 
    408     /** @name COM stuff.
    409      * @{ */
    410         /** Handles the VBoxSVC availability change. */
    411         void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
    412     /** @} */
    413 
    414     /* Handle font scale factor change. */
    415     void sltHandleFontScaleFactorChanged(int iFontScaleFactor);
    416 
    417 private:
    418 
    419     /** Construcs global VirtualBox object of passed @a enmType. */
    420     UICommon(UIType enmType);
    421     /** Destrucs global VirtualBox object. */
    422     virtual ~UICommon() RT_OVERRIDE RT_FINAL;
    423 
    424     /** Prepares all. */
    425     void prepare();
    426     /** Cleanups all. */
    427     void cleanup();
    428 
    429     /** @name Process arguments stuff.
    430      * @{ */
    431 #ifdef VBOX_WITH_DEBUGGER_GUI
    432         /** Initializes a debugger config variable.
    433           * @param  piDbgCfgVar       Brings the debugger config variable to init.
    434           * @param  pszEnvVar         Brings the environment variable name relating to this variable.
    435           * @param  pszExtraDataName  Brings the extra data name relating to this variable.
    436           * @param  fDefault          Brings the default value. */
    437         void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
    438         /** Set a debugger config variable according according to start up argument.
    439           * @param  piDbgCfgVar  Brings the debugger config variable to set.
    440           * @param  fState       Brings the value from the command line. */
    441         void setDebuggerVar(int *piDbgCfgVar, bool fState);
    442         /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation.
    443           * @param  piDbgCfgVar       Brings the debugger config variable to consult.
    444           * @param  pszExtraDataName  Brings the extra data name relating to this variable. */
    445         bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const;
    446 #endif
    447     /** @} */
    448 
    449     /** Holds the singleton UICommon instance. */
    450     static UICommon *s_pInstance;
    451 
    452     /** @name General stuff.
    453      * @{ */
    454         /** Holds the UI type. */
    455         UIType  m_enmType;
    456 
    457         /** Holds whether UICommon instance is properly initialized. */
    458         bool  m_fValid;
    459         /** Holds whether UICommon instance cleanup is in progress. */
    460         bool  m_fCleaningUp;
    461 #ifdef VBOX_WS_WIN
    462         /** Holds whether overall GUI data is committed. */
    463         bool  m_fDataCommitted;
    464 #endif
    465     /** @} */
    466 
    467     /** @name Host OS stuff.
    468      * @{ */
    469 #ifdef VBOX_WS_MAC
    470         /** macOS: Holds the #MacOSXRelease determined using <i>uname</i> call. */
    471         MacOSXRelease  m_enmMacOSVersion;
    472 #endif
    473 
    474 #ifdef VBOX_WS_NIX
    475         /** X11: Holds the #X11WMType of the Window Manager we are running under. */
    476         X11WMType             m_enmWindowManagerType;
    477         /** X11: Holds whether the Window Manager we are running at is composition one. */
    478         bool                  m_fCompositingManagerRunning;
    479         /** Unixes: Holds the display server type. */
    480         VBGHDISPLAYSERVERTYPE m_enmDisplayServerType;
    481 #endif
    482 
    483         /** Holds whether host OS is in Dark mode. */
    484         bool  m_fDarkMode;
    485     /** @} */
    486 
    487     /** @name Process arguments stuff.
    488      * @{ */
    489         /** Holds the URL arguments list. */
    490         QList<QUrl>  m_listArgUrls;
    491 
    492         /** Holds the --startvm option value (managed VM id). */
    493         QUuid  m_uManagedVMId;
    494         /** Holds the --separate option value (whether GUI process is separate from VM process). */
    495         bool   m_fSeparateProcess;
    496         /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */
    497         bool   m_fShowStartVMErrors;
    498 
    499         /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */
    500         bool  m_fAgressiveCaching;
    501 
    502         /** Holds the --restore-current option value. */
    503         bool  m_fRestoreCurrentSnapshot;
    504 
    505         /** Holds the --no-keyboard-grabbing option value. */
    506         bool  m_fNoKeyboardGrabbing;
    507 
    508         /** Holds the --fda option value (floppy image). */
    509         QUuid  m_uFloppyImage;
    510         /** Holds the --dvd | --cdrom option value (DVD image). */
    511         QUuid  m_uDvdImage;
    512 
    513         /** Holds the --execute-all-in-iem option value. */
    514         bool      m_fExecuteAllInIem;
    515         /** Holds the --warp-factor option value. */
    516         uint32_t  m_uWarpPct;
    517 
    518 #ifdef VBOX_WITH_DEBUGGER_GUI
    519         /** Holds whether the debugger should be accessible. */
    520         mutable int  m_fDbgEnabled;
    521         /** Holds whether to show the debugger automatically with the console. */
    522         mutable int  m_fDbgAutoShow;
    523         /** Holds whether to show the command line window when m_fDbgAutoShow is set. */
    524         mutable int  m_fDbgAutoShowCommandLine;
    525         /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */
    526         mutable int  m_fDbgAutoShowStatistics;
    527         /** Pattern of statistics to expand when opening the viewer. */
    528         QString      m_strDbgStatisticsExpand;
    529         /** The statistics viewer main filter pattern. */
    530         QString      m_strDbgStatisticsFilter;
    531         /** The statistics viewer advanced filter configuration and possibly more. */
    532         QString      m_strDbgStatisticsConfig;
    533 
    534         /** VBoxDbg module handle. */
    535         RTLDRMOD  m_hVBoxDbg;
    536 
    537         /** Holds whether --start-running, --start-paused or nothing was given. */
    538         LaunchRunning  m_enmLaunchRunning;
    539 #endif
    540 
    541         /** Holds the --settingspw option value or the content of --settingspwfile. */
    542         char  m_astrSettingsPw[256];
    543         /** Holds the --settingspwfile option value. */
    544         bool  m_fSettingsPwSet;
    545 
    546 #ifdef VBOX_GUI_WITH_PIDFILE
    547         /** Holds the --pidfile option value (application PID file path). */
    548         QString m_strPidFile;
    549 #endif
    550     /** @} */
    551 
    552     /** @name Thread stuff.
    553      * @{ */
    554         /** Holds the thread-pool instance. */
    555         UIThreadPool *m_pThreadPool;
    556         /** Holds the thread-pool instance for cloud needs. */
    557         UIThreadPool *m_pThreadPoolCloud;
    558     /** @} */
    559 
    560     /** @name Font scaling related variables.
    561      * @{ */
    562        int iOriginalFontPixelSize;
    563        int iOriginalFontPointSize;
    564     /** @} */
    565 
    566     UITranslationEventListener *m_pTranlationEventListener;
    567     /** Allows for shortcut access. */
    568     friend UICommon &uiCommon();
    569 };
    570 
    571 /** Singleton UICommon 'official' name. */
    572 inline UICommon &uiCommon() { return *UICommon::instance(); }
    573 
    574 #endif /* !FEQT_INCLUDED_SRC_globals_UICommon_h */
     70#endif /* !FEQT_INCLUDED_SRC_globals_UILocalMachineStuff_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.cpp

    r98103 r105081  
    3131/* GUI includes: */
    3232#include "UIBootOrderEditor.h"
    33 #include "UICommon.h"
     33#include "UILocalMachineStuff.h"
    3434#include "UIMachineAttributeSetter.h"
    3535#include "UIMessageCenter.h"
     
    9090    /* Get editable machine & session: */
    9191    CMachine comMachine = comConstMachine;
    92     CSession comSession = uiCommon().tryToOpenSessionFor(comMachine);
     92    CSession comSession = tryToOpenSessionFor(comMachine);
    9393
    9494    /* Main API block: */
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r104586 r105081  
    4747#include "UIGlobalSession.h"
    4848#include "UIIconPool.h"
     49#include "UILocalMachineStuff.h"
    4950#include "UIMessageCenter.h"
    5051#include "UIPathOperations.h"
     
    12451246        return false;
    12461247    }
    1247     m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);
     1248    m_comSession = openSession(m_comMachine.GetId(), KLockType_Shared);
    12481249    if (m_comSession.isNull())
    12491250    {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r104915 r105081  
    6666#include "UIHelpBrowserDialog.h"
    6767#include "UIIconPool.h"
     68#include "UILocalMachineStuff.h"
    6869#include "UILoggingDefs.h"
    6970#include "UIMedium.h"
     
    19321933        /* Open a session to modify VM: */
    19331934        AssertPtrReturnVoid(pItem);
    1934         CSession comSession = uiCommon().openSession(pItem->id());
     1935        CSession comSession = openSession(pItem->id());
    19351936        if (comSession.isNull())
    19361937            return;
     
    19841985
    19851986        /* Open a session to modify VM state: */
    1986         CSession comSession = uiCommon().openExistingSession(pItem->id());
     1987        CSession comSession = openExistingSession(pItem->id());
    19871988        if (comSession.isNull())
    19881989            return;
     
    20392040            {
    20402041                /* Open a session to modify VM state: */
    2041                 CSession comSession = uiCommon().openExistingSession(pItem->id());
     2042                CSession comSession = openExistingSession(pItem->id());
    20422043                if (comSession.isNull())
    20432044                    return;
     
    21772178        {
    21782179            /* Open a session to modify VM state: */
    2179             CSession comSession = uiCommon().openExistingSession(pItem->id());
     2180            CSession comSession = openExistingSession(pItem->id());
    21802181            if (comSession.isNull())
    21812182                return;
     
    29412942        && comMachine.CanShowConsoleWindow())
    29422943    {
    2943         UICommon::switchToMachine(comMachine);
     2944        switchToMachine(comMachine);
    29442945        return;
    29452946    }
     
    39263927        {
    39273928            /* Skip session failures: */
    3928             CSession session = uiCommon().openExistingSession(pItem->id());
     3929            CSession session = openExistingSession(pItem->id());
    39293930            if (session.isNull())
    39303931                continue;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemLocal.cpp

    r104594 r105081  
    3636#include "UIExtraDataManager.h"
    3737#include "UIIconPool.h"
     38#include "UILocalMachineStuff.h"
    3839#include "UITranslationEventListener.h"
    3940#include "UIVirtualMachineItemLocal.h"
     
    229230    {
    230231        /* Open session to determine which frontend VM is started with: */
    231         CSession comSession = uiCommon().openExistingSession(id());
     232        CSession comSession = openExistingSession(id());
    232233        if (!comSession.isNull())
    233234        {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIWelcomePane.cpp

    r104358 r105081  
    4343#include "UITranslationEventListener.h"
    4444#include "UIWelcomePane.h"
     45
     46/* Other VBox includes: */
     47#include "iprt/assert.h"
    4548
    4649
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r104592 r105081  
    4141#include "UIExtraDataManager.h"
    4242#include "UIGlobalSession.h"
     43#include "UILocalMachineStuff.h"
    4344#include "UILoggingDefs.h"
    4445#include "UIMessageCenter.h"
     
    240241        {
    241242            /* 1. Open session: */
    242             comSession = uiCommon().openSession(QUuid(strId));
     243            comSession = openSession(QUuid(strId));
    243244            if (comSession.isNull())
    244245                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetails.cpp

    r98103 r105081  
    3535#include "UIDetailsView.h"
    3636#include "UIExtraDataManager.h"
     37
     38/* Other VBox includes: */
     39#include "iprt/assert.h"
    3740
    3841
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp

    r103771 r105081  
    3333#include "QIFileDialog.h"
    3434#include "QIMessageBox.h"
    35 #include "UICommon.h"
    3635#include "UIExtraDataManager.h"
    3736#include "UIGlobalSession.h"
    3837#include "UIIconPool.h"
     38#include "UILocalMachineStuff.h"
    3939#include "UIMediumItem.h"
    4040#include "UIMessageCenter.h"
     
    315315{
    316316    /* Open session: */
    317     CSession session = uiCommon().openSession(uMachineId);
     317    CSession session = openSession(uMachineId);
    318318    if (session.isNull())
    319319        return false;
     
    346346{
    347347    /* Open session: */
    348     CSession comSession = uiCommon().openSession(attachmentCache.m_uMachineId);
     348    CSession comSession = openSession(attachmentCache.m_uMachineId);
    349349    if (comSession.isNull())
    350350        return false;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumTools.cpp

    r104915 r105081  
    3333/* GUI includes: */
    3434#include "QIFileDialog.h"
    35 #include "UICommon.h"
    3635#include "UIExtraDataManager.h"
    3736#include "UIFDCreationDialog.h"
    3837#include "UIGlobalSession.h"
    3938#include "UIIconPool.h"
     39#include "UILocalMachineStuff.h"
    4040#include "UIMediumEnumerator.h"
    4141#include "UIMediumSelector.h"
     
    247247        {
    248248            filters = HDDBackends(gpGlobalSession->virtualBox());
    249             strTitle = UICommon::tr("Please choose a virtual hard disk file");
    250             allType = UICommon::tr("All virtual hard disk files (%1)");
     249            strTitle = QApplication::translate("UICommon", "Please choose a virtual hard disk file");
     250            allType = QApplication::translate("UICommon", "All virtual hard disk files (%1)");
    251251            break;
    252252        }
     
    254254        {
    255255            filters = DVDBackends(gpGlobalSession->virtualBox());
    256             strTitle = UICommon::tr("Please choose a virtual optical disk file");
    257             allType = UICommon::tr("All virtual optical disk files (%1)");
     256            strTitle = QApplication::translate("UICommon", "Please choose a virtual optical disk file");
     257            allType = QApplication::translate("UICommon", "All virtual optical disk files (%1)");
    258258            break;
    259259        }
     
    261261        {
    262262            filters = FloppyBackends(gpGlobalSession->virtualBox());
    263             strTitle = UICommon::tr("Please choose a virtual floppy disk file");
    264             allType = UICommon::tr("All virtual floppy disk files (%1)");
     263            strTitle = QApplication::translate("UICommon", "Please choose a virtual floppy disk file");
     264            allType = QApplication::translate("UICommon", "All virtual floppy disk files (%1)");
    265265            break;
    266266        }
     
    283283    if (!prefixes.isEmpty())
    284284        backends.insert(0, allType.arg(prefixes.join(" ").trimmed()));
    285     backends << UICommon::tr("All files (*)");
     285    backends << QApplication::translate("UICommon", "All files (*)");
    286286    strFilter = backends.join(";;").trimmed();
    287287
     
    610610    /* Get editable machine & session: */
    611611    CMachine comMachine = comConstMachine;
    612     CSession comSession = uiCommon().tryToOpenSessionFor(comMachine);
     612    CSession comSession = tryToOpenSessionFor(comMachine);
    613613
    614614    /* Remount medium to the predefined port/device: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r104313 r105081  
    3838#include "UIGlobalSession.h"
    3939#include "UIHostComboEditor.h"
     40#include "UILocalMachineStuff.h"
    4041#include "UINotificationCenter.h"
    4142#include "UINotificationObjects.h"
     
    21852186{
    21862187    if (m_comTarget.isNotNull() && !m_comTarget.GetId().isNull())
    2187         emit sigMachineCopied(m_comTarget);
     2188    {
     2189        /* Register created machine: */
     2190        CVirtualBox comVBox = gpGlobalSession->virtualBox();
     2191        comVBox.RegisterMachine(m_comTarget);
     2192        if (!comVBox.isOk())
     2193            UINotificationMessage::cannotRegisterMachine(comVBox, m_comTarget.GetName());
     2194    }
    21882195}
    21892196
     
    23082315{
    23092316    /* Open a session thru which we will modify the machine: */
    2310     m_comSession = uiCommon().openSession(m_uId, KLockType_Write);
     2317    m_comSession = openSession(m_uId, KLockType_Write);
    23112318    if (m_comSession.isNull())
    23122319        return CProgress();
     
    23962403        {
    23972404            /* Open a session thru which we will modify the machine: */
    2398             m_comSession = uiCommon().openExistingSession(uId);
     2405            m_comSession = openExistingSession(uId);
    23992406            if (m_comSession.isNull())
    24002407                return CProgress();
     
    25112518
    25122519            /* Open a session thru which we will modify the machine: */
    2513             m_comSession = uiCommon().openExistingSession(uId);
     2520            m_comSession = openExistingSession(uId);
    25142521            if (m_comSession.isNull())
    25152522                return CProgress();
     
    37343741            /* Open a session thru which we will modify the machine: */
    37353742            if (enmSessionState != KSessionState_Unlocked)
    3736                 m_comSession = uiCommon().openExistingSession(uId);
     3743                m_comSession = openExistingSession(uId);
    37373744            else
    3738                 m_comSession = uiCommon().openSession(uId);
     3745                m_comSession = openSession(uId);
    37393746            if (m_comSession.isNull())
    37403747                return CProgress();
     
    38633870    /* Open a session thru which we will modify the machine: */
    38643871    if (enmSessionState != KSessionState_Unlocked)
    3865         m_comSession = uiCommon().openExistingSession(m_uMachineId);
     3872        m_comSession = openExistingSession(m_uMachineId);
    38663873    else
    3867         m_comSession = uiCommon().openSession(m_uMachineId);
     3874        m_comSession = openSession(m_uMachineId);
    38683875    if (m_comSession.isNull())
    38693876        return CProgress();
     
    39723979    /* Open a session thru which we will modify the machine: */
    39733980    if (enmSessionState != KSessionState_Unlocked)
    3974         m_comSession = uiCommon().openExistingSession(uId);
     3981        m_comSession = openExistingSession(uId);
    39753982    else
    3976         m_comSession = uiCommon().openSession(uId);
     3983        m_comSession = openSession(uId);
    39773984    if (m_comSession.isNull())
    39783985        return CProgress();
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r103982 r105081  
    964964    Q_OBJECT;
    965965
    966 signals:
    967 
    968     /** Notifies listeners about @a comMachine was copied. */
    969     void sigMachineCopied(const CMachine &comMachine);
    970 
    971966public:
    972967
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r104917 r105081  
    4545#include "UIMachine.h"
    4646#include "UITranslationEventListener.h"
     47
     48/* Other VBox includes: */
     49#include "iprt/assert.h"
    4750
    4851
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r104917 r105081  
    3737
    3838/* GUI includes: */
     39#include "UIActionPoolRuntime.h"
    3940#include "UICommon.h"
    4041#include "UIDesktopWidgetWatchdog.h"
     
    4243#include "UIGlobalSession.h"
    4344#include "UIIconPool.h"
     45#include "UILocalMachineStuff.h"
     46#include "UILoggingDefs.h"
    4447#include "UIMachine.h"
    45 #include "UISession.h"
    46 #include "UIActionPoolRuntime.h"
    47 #include "UILoggingDefs.h"
    4848#include "UIMachineLogic.h"
    4949#include "UIMachineWindow.h"
    5050#include "UIMessageCenter.h"
    5151#include "UINotificationCenter.h"
     52#include "UISession.h"
    5253#ifdef VBOX_WS_MAC
    5354# include "UICocoaApplication.h"
     
    125126    {
    126127        /* Create temporary session: */
    127         CSession comSession = uiCommon().openSession(KLockType_VM);
     128        CSession comSession = openSession(KLockType_VM);
    128129        if (comSession.isNull())
    129130            return false;
     
    159160
    160161        /* Try to launch corresponding machine: */
    161         if (!UICommon::launchMachine(machine, UILaunchMode_Separate))
     162        if (!launchMachine(machine, UILaunchMode_Separate))
    162163            return false;
    163164    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r104917 r105081  
    4242#include "UIIconPool.h"
    4343#include "UIGuestOSType.h"
     44#include "UILocalMachineStuff.h"
    4445#include "UILoggingDefs.h"
    4546#include "UIMachine.h"
     
    25102511{
    25112512    /* Open session: */
    2512     m_comSession = uiCommon().openSession(uiCommon().managedVMUuid(),
    2513                                             uiCommon().isSeparateProcess()
    2514                                           ? KLockType_Shared
    2515                                           : KLockType_VM);
     2513    m_comSession = openSession(uiCommon().managedVMUuid(),
     2514                                 uiCommon().isSeparateProcess()
     2515                               ? KLockType_Shared
     2516                               : KLockType_VM);
    25162517    if (m_comSession.isNull())
    25172518        return false;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialogSpecific.cpp

    r104358 r105081  
    3232/* GUI includes: */
    3333#include "UIAdvancedSettingsDialogSpecific.h"
    34 #include "UICommon.h"
    3534#include "UIExtraDataManager.h"
    3635#include "UIGlobalSession.h"
    3736#include "UIIconPool.h"
     37#include "UILocalMachineStuff.h"
    3838#include "UIMessageCenter.h"
    3939#include "UISettingsDefs.h"
     
    403403    /* Prepare session: */
    404404    m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
    405                 configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
    406                                                                               uiCommon().openExistingSession(m_uMachineId);
     405                configurationAccessLevel() == ConfigurationAccessLevel_Full ? openSession(m_uMachineId) :
     406                                                                              openExistingSession(m_uMachineId);
    407407    /* Check that session was created: */
    408408    if (m_session.isNull())
     
    432432    /* Prepare session: */
    433433    m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
    434                 configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
    435                                                                               uiCommon().openExistingSession(m_uMachineId);
     434                configurationAccessLevel() == ConfigurationAccessLevel_Full ? openSession(m_uMachineId) :
     435                                                                              openExistingSession(m_uMachineId);
    436436    /* Check that session was created: */
    437437    if (m_session.isNull())
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIHostComboEditor.cpp

    r104313 r105081  
    5656
    5757/* Other VBox includes: */
     58#include "iprt/assert.h"
    5859#if defined(VBOX_WS_NIX)
    5960# include <VBox/VBoxKeyboard.h>
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMenuBarEditor.cpp

    r104393 r105081  
    5050#include "UIMachineWindow.h"
    5151#include "UIMenuBarEditor.h"
     52
     53/* Other VBox includes: */
     54#include "iprt/assert.h"
    5255
    5356/* Forward declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStatusBarEditor.cpp

    r104313 r105081  
    5151#include "UIStatusBarEditor.h"
    5252#include "UITranslationEventListener.h"
     53
     54/* Other VBox includes: */
     55#include "iprt/assert.h"
    5356
    5457/* Forward declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp

    r104902 r105081  
    5050#include "UIExtraDataManager.h"
    5151#include "UIIconPool.h"
     52#include "UILocalMachineStuff.h"
    5253#include "UILoggingDefs.h"
    5354#include "UIMediumTools.h"
     
    10881089        CSession comSession;
    10891090        if (m_sessionStates.value(pSnapshotItem->machineID()) != KSessionState_Unlocked)
    1090             comSession = uiCommon().openExistingSession(pSnapshotItem->machineID());
     1091            comSession = openExistingSession(pSnapshotItem->machineID());
    10911092        else
    1092             comSession = uiCommon().openSession(pSnapshotItem->machineID());
     1093            comSession = openSession(pSnapshotItem->machineID());
    10931094        if (comSession.isNotNull())
    10941095        {
     
    12221223            {
    12231224                /* We need to open a session when we manipulate the snapshot data of a machine: */
    1224                 CSession comSession = uiCommon().openExistingSession(comSnapshot.GetMachine().GetId());
     1225                CSession comSession = openExistingSession(comSnapshot.GetMachine().GetId());
    12251226                if (!comSession.isNull())
    12261227                {
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r103988 r105081  
    5454# include "UIExtraDataManager.h"
    5555#endif
     56
     57/* Other VBox includes: */
     58#include "iprt/assert.h"
    5659
    5760
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r104295 r105081  
    230230                                                                                             m_enmCloneMode,
    231231                                                                                             options);
    232     connect(pNotification, &UINotificationProgressMachineCopy::sigMachineCopied,
    233             &uiCommon(), &UICommon::sltHandleMachineCreated);
    234232    gpNotificationCenter->append(pNotification);
    235233
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r104891 r105081  
    3434#include "UIGlobalSession.h"
    3535#include "UIGuestOSType.h"
     36#include "UILocalMachineStuff.h"
    3637#include "UIMedium.h"
    3738#include "UIMediumEnumerator.h"
     
    277278    bool success = false;
    278279    QUuid uMachineId = m_machine.GetId();
    279     CSession session = uiCommon().openSession(uMachineId);
     280    CSession session = openSession(uMachineId);
    280281    if (!session.isNull())
    281282    {
Note: See TracChangeset for help on using the changeset viewer.

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