VirtualBox

Changeset 98485 in vbox


Ignore:
Timestamp:
Feb 7, 2023 10:45:42 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155751
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking UIIndicatorsPool media related 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

    r98103 r98485  
    3737#include "UIDetailsGenerator.h"
    3838#include "UIErrorString.h"
     39#include "UIMedium.h"
    3940#include "UITranslator.h"
    4041
     
    7374
    7475
     76const QString UIDetailsGenerator::e_strTableRow1 = QString("<tr><td colspan='2'><nobr><b>%1</b></nobr></td></tr>");
     77const QString UIDetailsGenerator::e_strTableRow2 = QString("<tr><td><nobr>%1:</nobr></td><td><nobr>%2</nobr></td></tr>");
     78const QString UIDetailsGenerator::e_strTableRow3 = QString("<tr><td><nobr>&nbsp;%1:</nobr></td><td><nobr>%2</nobr></td></tr>");
     79
     80
    7581UITextTable UIDetailsGenerator::generateMachineInformationGeneral(CMachine &comMachine,
    7682                                                                  const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions)
     
    11661172    return table;
    11671173}
     1174
     1175void UIDetailsGenerator::acquireHardDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     1176                                                   bool &fAttachmentsPresent)
     1177{
     1178    /* Enumerate all the controllers: */
     1179    foreach (const CStorageController &comController, comMachine.GetStorageControllers())
     1180    {
     1181        /* Enumerate all the attachments: */
     1182        QString strAttData;
     1183        foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
     1184        {
     1185            /* Skip unrelated attachments: */
     1186            if (comAttachment.GetType() != KDeviceType_HardDisk)
     1187                continue;
     1188            /* Append attachment data: */
     1189            strAttData += e_strTableRow3
     1190                .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
     1191                .arg(UIMedium(comAttachment.GetMedium(), UIMediumDeviceType_HardDisk).location());
     1192            fAttachmentsPresent = true;
     1193        }
     1194        /* Append controller data: */
     1195        if (!strAttData.isNull())
     1196            strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
     1197    }
     1198}
     1199
     1200void UIDetailsGenerator::acquireOpticalDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     1201                                                      bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     1202{
     1203    /* Enumerate all the controllers: */
     1204    foreach (const CStorageController &comController, comMachine.GetStorageControllers())
     1205    {
     1206        QString strAttData;
     1207        /* Enumerate all the attachments: */
     1208        foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
     1209        {
     1210            /* Skip unrelated attachments: */
     1211            if (comAttachment.GetType() != KDeviceType_DVD)
     1212                continue;
     1213            /* Append attachment data: */
     1214            UIMedium vboxMedium(comAttachment.GetMedium(), UIMediumDeviceType_DVD);
     1215            strAttData += e_strTableRow3
     1216                .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
     1217                .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
     1218            fAttachmentsPresent = true;
     1219            if (!vboxMedium.isNull())
     1220                fAttachmentsMounted = true;
     1221        }
     1222        /* Append controller data: */
     1223        if (!strAttData.isNull())
     1224            strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
     1225    }
     1226}
     1227
     1228void UIDetailsGenerator::acquireFloppyDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     1229                                                     bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     1230{
     1231    /* Enumerate all the controllers: */
     1232    foreach (const CStorageController &comController, comMachine.GetStorageControllers())
     1233    {
     1234        QString strAttData;
     1235        /* Enumerate all the attachments: */
     1236        foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
     1237        {
     1238            /* Skip unrelated attachments: */
     1239            if (comAttachment.GetType() != KDeviceType_Floppy)
     1240                continue;
     1241            /* Append attachment data: */
     1242            UIMedium vboxMedium(comAttachment.GetMedium(), UIMediumDeviceType_Floppy);
     1243            strAttData += e_strTableRow3
     1244                .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
     1245                .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
     1246            fAttachmentsPresent = true;
     1247            if (!vboxMedium.isNull())
     1248                fAttachmentsMounted = true;
     1249        }
     1250        /* Append controller data: */
     1251        if (!strAttData.isNull())
     1252            strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
     1253    }
     1254}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.h

    r98103 r98485  
    8181    SHARED_LIBRARY_STUFF UITextTable generateMachineInformationDescription(CMachine &comMachine,
    8282                                                                           const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription &fOptions);
     83
     84    SHARED_LIBRARY_STUFF void acquireHardDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     85                                                        bool &fAttachmentsPresent);
     86
     87    SHARED_LIBRARY_STUFF void acquireOpticalDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     88                                                           bool &fAttachmentsPresent, bool &fAttachmentsMounted);
     89
     90    SHARED_LIBRARY_STUFF void acquireFloppyDiskStatusInfo(CMachine &comMachine, QString &strInfo,
     91                                                          bool &fAttachmentsPresent, bool &fAttachmentsMounted);
     92
     93    /** Holds the table row format 1. */
     94    extern const QString e_strTableRow1;
     95    /** Holds the table row format 2. */
     96    extern const QString e_strTableRow2;
     97    /** Holds the table row format 3. */
     98    extern const QString e_strTableRow3;
    8399}
    84100
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r98482 r98485  
    4444#include "UIIndicatorsPool.h"
    4545#include "UIMachine.h"
    46 #include "UIMedium.h"
    4746#include "UISession.h"
    4847
     
    5857#include "CMachineDebugger.h"
    5958#include "CGuest.h"
    60 #include "CStorageController.h"
    61 #include "CMediumAttachment.h"
    6259#include "CNetworkAdapter.h"
    6360#include "CUSBController.h"
     
    195192public:
    196193
    197     /** Constructor, passes @a pSession to the UISessionStateStatusBarIndicator constructor. */
     194    /** Constructs indicator passing @a pMachine to the base-class. */
    198195    UIIndicatorHardDrive(UIMachine *pMachine, UISession *pSession)
    199196        : UISessionStateStatusBarIndicator(IndicatorType_HardDisks, pMachine, pSession)
     
    205202        setStateIcon(KDeviceActivity_Null,    UIIconPool::iconSet(":/hd_disabled_16px.png"));
    206203        /* Configure connection: */
    207         connect(pSession, &UISession::sigStorageDeviceChange,
     204        connect(pMachine, &UIMachine::sigStorageDeviceChange,
    208205                this, &UIIndicatorHardDrive::sltStorageDeviceChange);
    209206        /* Translate finally: */
     
    213210private slots:
    214211
    215     /** Refresh the tooltip if the device config changes at runtime (hotplugging,
    216      *  USB storage). */
    217     void sltStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent)
    218     {
    219         RT_NOREF(attachment, fRemoved, fSilent);
     212    /** Refreshes the tooltip if the device config changes at runtime (hotplugging, USB storage). */
     213    void sltStorageDeviceChange()
     214    {
    220215        updateAppearance();
    221216    }
     
    226221    void updateAppearance()
    227222    {
    228         /* Get machine: */
    229         const CMachine machine = m_pSession->machine();
    230 
    231         /* Prepare tool-tip: */
     223        /* Acquire data: */
    232224        QString strFullData;
    233 
    234         /* Enumerate all the controllers: */
    235225        bool fAttachmentsPresent = false;
    236         foreach (const CStorageController &controller, machine.GetStorageControllers())
    237         {
    238             QString strAttData;
    239             /* Enumerate all the attachments: */
    240             foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName()))
    241             {
    242                 /* Skip unrelated attachments: */
    243                 if (attachment.GetType() != KDeviceType_HardDisk)
    244                     continue;
    245                 /* Append attachment data: */
    246                 strAttData += s_strTableRow4
    247                     .arg(gpConverter->toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
    248                     .arg(UIMedium(attachment.GetMedium(), UIMediumDeviceType_HardDisk).location());
    249                 fAttachmentsPresent = true;
    250             }
    251             /* Append controller data: */
    252             if (!strAttData.isNull())
    253                 strFullData += s_strTableRow1.arg(controller.GetName()) + strAttData;
    254         }
     226        m_pMachine->acquireHardDiskStatusInfo(strFullData, fAttachmentsPresent);
    255227
    256228        /* Hide indicator if there are no attachments: */
     
    272244public:
    273245
    274     /** Constructor, passes @a pSession to the UISessionStateStatusBarIndicator constructor. */
     246    /** Constructs indicator passing @a pMachine to the base-class. */
    275247    UIIndicatorOpticalDisks(UIMachine *pMachine, UISession *pSession)
    276248        : UISessionStateStatusBarIndicator(IndicatorType_OpticalDisks, pMachine, pSession)
     
    290262    void updateAppearance()
    291263    {
    292         /* Get machine: */
    293         const CMachine machine = m_pSession->machine();
    294 
    295         /* Prepare tool-tip: */
    296264        QString strFullData;
    297 
    298         /* Enumerate all the controllers: */
    299265        bool fAttachmentsPresent = false;
    300266        bool fAttachmentsMounted = false;
    301         foreach (const CStorageController &controller, machine.GetStorageControllers())
    302         {
    303             QString strAttData;
    304             /* Enumerate all the attachments: */
    305             foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName()))
    306             {
    307                 /* Skip unrelated attachments: */
    308                 if (attachment.GetType() != KDeviceType_DVD)
    309                     continue;
    310                 /* Append attachment data: */
    311                 UIMedium vboxMedium(attachment.GetMedium(), UIMediumDeviceType_DVD);
    312                 strAttData += s_strTableRow4
    313                     .arg(gpConverter->toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
    314                     .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
    315                 fAttachmentsPresent = true;
    316                 if (!vboxMedium.isNull())
    317                     fAttachmentsMounted = true;
    318             }
    319             /* Append controller data: */
    320             if (!strAttData.isNull())
    321                 strFullData += s_strTableRow1.arg(controller.GetName()) + strAttData;
    322         }
     267        m_pMachine->acquireOpticalDiskStatusInfo(strFullData, fAttachmentsPresent, fAttachmentsMounted);
    323268
    324269        /* Hide indicator if there are no attachments: */
    325         if (!fAttachmentsPresent)
    326             hide();
     270        setVisible(fAttachmentsPresent);
    327271
    328272        /* Update tool-tip: */
     
    341285public:
    342286
    343     /** Constructor, passes @a pSession to the UISessionStateStatusBarIndicator constructor. */
     287    /** Constructs indicator passing @a pMachine to the base-class. */
    344288    UIIndicatorFloppyDisks(UIMachine *pMachine, UISession *pSession)
    345289        : UISessionStateStatusBarIndicator(IndicatorType_FloppyDisks, pMachine, pSession)
     
    359303    void updateAppearance()
    360304    {
    361         /* Get machine: */
    362         const CMachine machine = m_pSession->machine();
    363 
    364         /* Prepare tool-tip: */
    365305        QString strFullData;
    366 
    367         /* Enumerate all the controllers: */
    368306        bool fAttachmentsPresent = false;
    369307        bool fAttachmentsMounted = false;
    370         foreach (const CStorageController &controller, machine.GetStorageControllers())
    371         {
    372             QString strAttData;
    373             /* Enumerate all the attachments: */
    374             foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName()))
    375             {
    376                 /* Skip unrelated attachments: */
    377                 if (attachment.GetType() != KDeviceType_Floppy)
    378                     continue;
    379                 /* Append attachment data: */
    380                 UIMedium vboxMedium(attachment.GetMedium(), UIMediumDeviceType_Floppy);
    381                 strAttData += s_strTableRow4
    382                     .arg(gpConverter->toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
    383                     .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
    384                 fAttachmentsPresent = true;
    385                 if (!vboxMedium.isNull())
    386                     fAttachmentsMounted = true;
    387             }
    388             /* Append controller data: */
    389             if (!strAttData.isNull())
    390                 strFullData += s_strTableRow1.arg(controller.GetName()) + strAttData;
    391         }
     308        m_pMachine->acquireFloppyDiskStatusInfo(strFullData, fAttachmentsPresent, fAttachmentsMounted);
    392309
    393310        /* Hide indicator if there are no attachments: */
    394         if (!fAttachmentsPresent)
    395             hide();
     311        setVisible(fAttachmentsPresent);
    396312
    397313        /* Update tool-tip: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98482 r98485  
    446446{
    447447    uisession()->acquireDeviceActivity(deviceTypes, states);
     448}
     449
     450void UIMachine::acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent)
     451{
     452    uisession()->acquireHardDiskStatusInfo(strInfo, fAttachmentsPresent);
     453}
     454
     455void UIMachine::acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     456{
     457    uisession()->acquireOpticalDiskStatusInfo(strInfo, fAttachmentsPresent, fAttachmentsMounted);
     458}
     459
     460void UIMachine::acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     461{
     462    uisession()->acquireFloppyDiskStatusInfo(strInfo, fAttachmentsPresent, fAttachmentsMounted);
    448463}
    449464
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98482 r98485  
    378378        /** Acquires device activity composing a vector of current @a states for device with @a deviceTypes specified. */
    379379        void acquireDeviceActivity(const QVector<KDeviceType> &deviceTypes, QVector<KDeviceActivity> &states);
     380
     381        /** Acquires status info for hard disk indicator. */
     382        void acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent);
     383        /** Acquires status info for optical disk indicator. */
     384        void acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted);
     385        /** Acquires status info for floppy disk indicator. */
     386        void acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted);
    380387    /** @} */
    381388
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98482 r98485  
    3838#include "UICommon.h"
    3939#include "UIConsoleEventHandler.h"
     40#include "UIDetailsGenerator.h"
    4041#include "UIExtraDataManager.h"
    4142#include "UIFrameBuffer.h"
     
    313314    if (!comConsole.isOk())
    314315        UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
     316}
     317
     318void UISession::acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent)
     319{
     320    CMachine comMachine = machine();
     321    UIDetailsGenerator::acquireHardDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent);
     322}
     323
     324void UISession::acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     325{
     326    CMachine comMachine = machine();
     327    UIDetailsGenerator::acquireOpticalDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent, fAttachmentsMounted);
     328}
     329
     330void UISession::acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
     331{
     332    CMachine comMachine = machine();
     333    UIDetailsGenerator::acquireFloppyDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent, fAttachmentsMounted);
    315334}
    316335
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98482 r98485  
    264264        /** Acquires device activity composing a vector of current @a states for device with @a deviceTypes specified. */
    265265        void acquireDeviceActivity(const QVector<KDeviceType> &deviceTypes, QVector<KDeviceActivity> &states);
     266
     267        /** Acquires status info for hard disk indicator. */
     268        void acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent);
     269        /** Acquires status info for optical disk indicator. */
     270        void acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted);
     271        /** Acquires status info for floppy disk indicator. */
     272        void acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted);
    266273    /** @} */
    267274
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