VirtualBox

Changeset 98488 in vbox


Ignore:
Timestamp:
Feb 7, 2023 11:33:52 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155754
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking UIIndicatorsPool USB and shared folders indicators to move COM related logic to UISession.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp

    r98487 r98488  
    4747#include "CChoiceFormValue.h"
    4848#include "CCloudMachine.h"
     49#include "CConsole.h"
    4950#include "CForm.h"
    5051#include "CFormValue.h"
    5152#include "CGraphicsAdapter.h"
     53#include "CGuest.h"
    5254#include "CMachine.h"
    5355#include "CMediumAttachment.h"
     
    6668#include "CUefiVariableStore.h"
    6769#include "CUSBController.h"
     70#include "CUSBDevice.h"
    6871#include "CUSBDeviceFilter.h"
    6972#include "CUSBDeviceFilters.h"
     
    13391342}
    13401343
     1344void UIDetailsGenerator::acquireUsbStatusInfo(CMachine &comMachine, CConsole &comConsole,
     1345                                              QString &strInfo, bool &fUsbEnabled)
     1346{
     1347    /* Check whether there is at least one USB controller with an available proxy: */
     1348    fUsbEnabled =    !comMachine.GetUSBDeviceFilters().isNull()
     1349                  && !comMachine.GetUSBControllers().isEmpty()
     1350                  && comMachine.GetUSBProxyAvailable();
     1351    if (fUsbEnabled)
     1352    {
     1353        /* Enumerate all the USB devices: */
     1354        foreach (const CUSBDevice &comUsbDevice, comConsole.GetUSBDevices())
     1355            strInfo += e_strTableRow1.arg(uiCommon().usbDetails(comUsbDevice));
     1356        /* Handle 'no-usb-devices' case: */
     1357        if (strInfo.isNull())
     1358            strInfo = e_strTableRow1
     1359                .arg(QApplication::translate("UIIndicatorsPool", "No USB devices attached", "USB tooltip"));
     1360    }
     1361}
     1362
     1363void UIDetailsGenerator::acquireSharedFoldersStatusInfo(CMachine &comMachine, CConsole &comConsole, CGuest &comGuest,
     1364                                                        QString &strInfo, bool &fFoldersPresent)
     1365{
     1366    /* Enumerate all the folders: */
     1367    QMap<QString, QString> folders;
     1368    foreach (const CSharedFolder &comPermanentFolder, comMachine.GetSharedFolders())
     1369        folders.insert(comPermanentFolder.GetName(), comPermanentFolder.GetHostPath());
     1370    foreach (const CSharedFolder &comTemporaryFolder, comConsole.GetSharedFolders())
     1371        folders.insert(comTemporaryFolder.GetName(), comTemporaryFolder.GetHostPath());
     1372    fFoldersPresent = !folders.isEmpty();
     1373
     1374    /* Append attachment data: */
     1375    for (QMap<QString, QString>::const_iterator it = folders.constBegin(); it != folders.constEnd(); ++it)
     1376    {
     1377        /* Select slashes depending on the OS type: */
     1378        if (UICommon::isDOSType(comGuest.GetOSTypeId()))
     1379            strInfo += e_strTableRow2.arg(QString("<b>\\\\vboxsvr\\%1</b>").arg(it.key()), it.value());
     1380        else
     1381            strInfo += e_strTableRow2.arg(QString("<b>%1</b>").arg(it.key()), it.value());
     1382    }
     1383
     1384    /* Handle 'no-folders' case: */
     1385    if (!fFoldersPresent)
     1386        strInfo = e_strTableRow1
     1387            .arg(QApplication::translate("UIIndicatorsPool", "No shared folders", "Shared folders tooltip"));
     1388}
     1389
    13411390void UIDetailsGenerator::acquireDisplayStatusInfo(CMachine &comMachine, QString &strInfo,
    13421391                                                  bool &fAcceleration3D)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.h

    r98487 r98488  
    3838/* Forward declarations: */
    3939class CCloudMachine;
     40class CConsole;
    4041class CFormValue;
     42class CGuest;
    4143class CMachine;
    4244
     
    9799                                                       bool &fAdaptersPresent, bool &fCablesDisconnected);
    98100
     101    SHARED_LIBRARY_STUFF void acquireUsbStatusInfo(CMachine &comMachine, CConsole &comConsole,
     102                                                   QString &strInfo, bool &fUsbEnableds);
     103
     104    SHARED_LIBRARY_STUFF void acquireSharedFoldersStatusInfo(CMachine &comMachine, CConsole &comConsole, CGuest &comGuest,
     105                                                             QString &strInfo, bool &fFoldersPresent);
     106
    99107    SHARED_LIBRARY_STUFF void acquireDisplayStatusInfo(CMachine &comMachine, QString &strInfo,
    100108                                                       bool &fAcceleration3D);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r98487 r98488  
    3030#include <QHBoxLayout>
    3131#include <QPainter>
    32 #include <QStyle>
    3332#include <QTimer>
    3433
     
    4948#include "CRecordingSettings.h"
    5049#include "CRecordingScreenSettings.h"
    51 #include "CConsole.h"
    5250#include "CMachine.h"
    5351#include "CMachineDebugger.h"
    54 #include "CGuest.h"
    55 #include "CUSBController.h"
    56 #include "CUSBDeviceFilters.h"
    57 #include "CUSBDevice.h"
    58 #include "CSharedFolder.h"
    5952
    6053
     
    452445public:
    453446
    454     /** Constructor, passes @a pSession to the UISessionStateStatusBarIndicator constructor. */
     447    /** Constructs indicator passing @a pMachine to the base-class. */
    455448    UIIndicatorUSB(UIMachine *pMachine, UISession *pSession)
    456449        : UISessionStateStatusBarIndicator(IndicatorType_USB, pMachine, pSession)
     
    470463    void updateAppearance()
    471464    {
    472         /* Get machine: */
    473         const CMachine machine = m_pSession->machine();
    474 
    475         /* Prepare tool-tip: */
    476465        QString strFullData;
    477 
    478         /* Check whether there is at least one USB controller with an available proxy. */
    479         bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
    480                            && !machine.GetUSBControllers().isEmpty()
    481                            && machine.GetUSBProxyAvailable();
    482         if (fUSBEnabled)
    483         {
    484             /* Enumerate all the USB devices: */
    485             const CConsole console = m_pSession->console();
    486             foreach (const CUSBDevice &usbDevice, console.GetUSBDevices())
    487                 strFullData += s_strTableRow1.arg(uiCommon().usbDetails(usbDevice));
    488             /* Handle 'no-usb-devices' case: */
    489             if (strFullData.isNull())
    490                 strFullData = s_strTableRow1
    491                     .arg(QApplication::translate("UIIndicatorsPool", "No USB devices attached", "USB tooltip"));
    492         }
    493 
    494         /* Hide indicator if there are USB controllers: */
    495         if (!fUSBEnabled)
    496             hide();
     466        bool fUsbEnabled = false;
     467        m_pMachine->acquireUsbStatusInfo(strFullData, fUsbEnabled);
     468
     469        /* Hide indicator if no USB enabled: */
     470        setVisible(fUsbEnabled);
    497471
    498472        /* Update tool-tip: */
    499473        setToolTip(s_strTable.arg(strFullData));
    500474        /* Update indicator state: */
    501         setState(fUSBEnabled ? KDeviceActivity_Idle : KDeviceActivity_Null);
     475        setState(fUsbEnabled ? KDeviceActivity_Idle : KDeviceActivity_Null);
    502476    }
    503477};
     
    511485public:
    512486
    513     /** Constructor, passes @a pSession to the UISessionStateStatusBarIndicator constructor. */
     487    /** Constructs indicator passing @a pMachine to the base-class. */
    514488    UIIndicatorSharedFolders(UIMachine *pMachine, UISession *pSession)
    515489        : UISessionStateStatusBarIndicator(IndicatorType_SharedFolders, pMachine, pSession)
     
    529503    void updateAppearance()
    530504    {
    531         /* Get objects: */
    532         const CMachine machine = m_pSession->machine();
    533         const CConsole console = m_pSession->console();
    534         const CGuest guest = m_pSession->guest();
    535 
    536         /* Prepare tool-tip: */
    537505        QString strFullData;
    538 
    539         /* Enumerate all the folders: */
    540         QMap<QString, QString> sfs;
    541         foreach (const CSharedFolder &sf, machine.GetSharedFolders())
    542             sfs.insert(sf.GetName(), sf.GetHostPath());
    543         foreach (const CSharedFolder &sf, console.GetSharedFolders())
    544             sfs.insert(sf.GetName(), sf.GetHostPath());
    545 
    546         /* Append attachment data: */
    547         for (QMap<QString, QString>::const_iterator it = sfs.constBegin(); it != sfs.constEnd(); ++it)
    548         {
    549             /* Select slashes depending on the OS type: */
    550             if (UICommon::isDOSType(guest.GetOSTypeId()))
    551                 strFullData += s_strTableRow2.arg(QString("<b>\\\\vboxsvr\\%1</b>").arg(it.key()), it.value());
    552             else
    553                 strFullData += s_strTableRow2.arg(QString("<b>%1</b>").arg(it.key()), it.value());
    554         }
    555         /* Handle 'no-folders' case: */
    556         if (sfs.isEmpty())
    557             strFullData = s_strTableRow1
    558                 .arg(QApplication::translate("UIIndicatorsPool", "No shared folders", "Shared folders tooltip"));
     506        bool fFoldersPresent = false;
     507        m_pMachine->acquireSharedFoldersStatusInfo(strFullData, fFoldersPresent);
    559508
    560509        /* Update tool-tip: */
    561510        setToolTip(s_strTable.arg(strFullData));
    562511        /* Update indicator state: */
    563         setState(!sfs.isEmpty() ? KDeviceActivity_Idle : KDeviceActivity_Null);
     512        setState(fFoldersPresent ? KDeviceActivity_Idle : KDeviceActivity_Null);
    564513    }
    565514};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98487 r98488  
    471471{
    472472    uisession()->acquireNetworkStatusInfo(strInfo, fAdaptersPresent, fCablesDisconnected);
     473}
     474
     475void UIMachine::acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds)
     476{
     477    uisession()->acquireUsbStatusInfo(strInfo, fUsbEnableds);
     478}
     479
     480void UIMachine::acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent)
     481{
     482    uisession()->acquireSharedFoldersStatusInfo(strInfo, fFoldersPresent);
    473483}
    474484
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98487 r98488  
    389389        /** Acquires status info for network indicator. */
    390390        void acquireNetworkStatusInfo(QString &strInfo, bool &fAdaptersPresent, bool &fCablesDisconnected);
     391        /** Acquires status info for USB indicator. */
     392        void acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds);
     393        /** Acquires status info for Shared Folders indicator. */
     394        void acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent);
    391395        /** Acquires status info for Display indicator. */
    392396        void acquireDisplayStatusInfo(QString &strInfo, bool &fAcceleration3D);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98487 r98488  
    344344    CMachine comMachine = machine();
    345345    UIDetailsGenerator::acquireNetworkStatusInfo(comMachine, strInfo, fAdaptersPresent, fCablesDisconnected);
     346}
     347
     348void UISession::acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds)
     349{
     350    CMachine comMachine = machine();
     351    CConsole comConsole = console();
     352    UIDetailsGenerator::acquireUsbStatusInfo(comMachine, comConsole, strInfo, fUsbEnableds);
     353}
     354
     355void UISession::acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent)
     356{
     357    CMachine comMachine = machine();
     358    CConsole comConsole = console();
     359    CGuest comGuest = guest();
     360    UIDetailsGenerator::acquireSharedFoldersStatusInfo(comMachine, comConsole, comGuest, strInfo, fFoldersPresent);
    346361}
    347362
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98487 r98488  
    275275        /** Acquires status info for network indicator. */
    276276        void acquireNetworkStatusInfo(QString &strInfo, bool &fAdaptersPresent, bool &fCablesDisconnected);
     277        /** Acquires status info for USB indicator. */
     278        void acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds);
     279        /** Acquires status info for Shared Folders indicator. */
     280        void acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent);
    277281        /** Acquires status info for Display indicator. */
    278282        void acquireDisplayStatusInfo(QString &strInfo, bool &fAcceleration3D);
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