VirtualBox

Changeset 105150 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 4, 2024 3:53:45 PM (7 months ago)
Author:
vboxsync
Message:

FE/Qt: Moving USB COM stuff from UICommon to new UIUSBTools namespace.

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

Legend:

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

    r105081 r105150  
    328328        ./src/softkeyboard \
    329329        ./src/snapshots \
     330        ./src/usb \
    330331        ./src/widgets \
    331332        ./src/widgets/graphics \
     
    15441545        src/settings/machine/UIMachineSettingsSystem.cpp \
    15451546        src/settings/machine/UIMachineSettingsUSB.cpp \
     1547        src/usb/UIUSBTools.cpp \
    15461548        src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \
    15471549        src/widgets/UIFilePathSelector.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r105122 r105150  
    8484/* COM includes: */
    8585#include "CCloudMachine.h"
    86 #include "CHostUSBDevice.h"
    87 #include "CHostVideoInputDevice.h"
    8886#include "CMachine.h"
    89 #include "CUSBDevice.h"
    90 #include "CUSBDeviceFilter.h"
    9187
    9288/* Other VBox includes: */
     
    10197# include <VBox/sup.h> /* for SUPR3HardenedLdrLoadAppPriv */
    10298#endif
    103 
    104 /* VirtualBox interface declarations: */
    105 #include <VBox/com/VirtualBox.h>
    10699
    107100/* External includes: */
     
    11611154
    11621155/* static */
    1163 QString UICommon::usbDetails(const CUSBDevice &comDevice)
    1164 {
    1165     QString strDetails;
    1166     if (comDevice.isNull())
    1167         strDetails = tr("Unknown device", "USB device details");
    1168     else
    1169     {
    1170         QVector<QString> devInfoVector = comDevice.GetDeviceInfo();
    1171         QString strManufacturer;
    1172         QString strProduct;
    1173 
    1174         if (devInfoVector.size() >= 1)
    1175             strManufacturer = devInfoVector[0].trimmed();
    1176         if (devInfoVector.size() >= 2)
    1177             strProduct = devInfoVector[1].trimmed();
    1178 
    1179         if (strManufacturer.isEmpty() && strProduct.isEmpty())
    1180         {
    1181             strDetails =
    1182                 tr("Unknown device %1:%2", "USB device details")
    1183                    .arg(QString::number(comDevice.GetVendorId(),  16).toUpper().rightJustified(4, '0'))
    1184                    .arg(QString::number(comDevice.GetProductId(), 16).toUpper().rightJustified(4, '0'));
    1185         }
    1186         else
    1187         {
    1188             if (strProduct.toUpper().startsWith(strManufacturer.toUpper()))
    1189                 strDetails = strProduct;
    1190             else
    1191                 strDetails = strManufacturer + " " + strProduct;
    1192         }
    1193         ushort iRev = comDevice.GetRevision();
    1194         if (iRev != 0)
    1195         {
    1196             strDetails += " [";
    1197             strDetails += QString::number(iRev, 16).toUpper().rightJustified(4, '0');
    1198             strDetails += "]";
    1199         }
    1200     }
    1201 
    1202     return strDetails.trimmed();
    1203 }
    1204 
    1205 /* static */
    1206 QString UICommon::usbToolTip(const CUSBDevice &comDevice)
    1207 {
    1208     QString strTip =
    1209         tr("<nobr>Vendor ID: %1</nobr><br>"
    1210            "<nobr>Product ID: %2</nobr><br>"
    1211            "<nobr>Revision: %3</nobr>", "USB device tooltip")
    1212            .arg(QString::number(comDevice.GetVendorId(),  16).toUpper().rightJustified(4, '0'))
    1213            .arg(QString::number(comDevice.GetProductId(), 16).toUpper().rightJustified(4, '0'))
    1214            .arg(QString::number(comDevice.GetRevision(),  16).toUpper().rightJustified(4, '0'));
    1215 
    1216     const QString strSerial = comDevice.GetSerialNumber();
    1217     if (!strSerial.isEmpty())
    1218         strTip += QString(tr("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))
    1219                              .arg(strSerial);
    1220 
    1221     /* Add the state field if it's a host USB device: */
    1222     CHostUSBDevice hostDev(comDevice);
    1223     if (!hostDev.isNull())
    1224     {
    1225         strTip += QString(tr("<br><nobr>State: %1</nobr>", "USB device tooltip"))
    1226                              .arg(gpConverter->toString(hostDev.GetState()));
    1227     }
    1228 
    1229     return strTip;
    1230 }
    1231 
    1232 /* static */
    1233 QString UICommon::usbToolTip(const CUSBDeviceFilter &comFilter)
    1234 {
    1235     QString strTip;
    1236 
    1237     const QString strVendorId = comFilter.GetVendorId();
    1238     if (!strVendorId.isEmpty())
    1239         strTip += tr("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip")
    1240                      .arg(strVendorId);
    1241 
    1242     const QString strProductId = comFilter.GetProductId();
    1243     if (!strProductId.isEmpty())
    1244         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product ID: %2</nobr>", "USB filter tooltip")
    1245                                                      .arg(strProductId);
    1246 
    1247     const QString strRevision = comFilter.GetRevision();
    1248     if (!strRevision.isEmpty())
    1249         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Revision: %3</nobr>", "USB filter tooltip")
    1250                                                      .arg(strRevision);
    1251 
    1252     const QString strProduct = comFilter.GetProduct();
    1253     if (!strProduct.isEmpty())
    1254         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product: %4</nobr>", "USB filter tooltip")
    1255                                                      .arg(strProduct);
    1256 
    1257     const QString strManufacturer = comFilter.GetManufacturer();
    1258     if (!strManufacturer.isEmpty())
    1259         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip")
    1260                                                      .arg(strManufacturer);
    1261 
    1262     const QString strSerial = comFilter.GetSerialNumber();
    1263     if (!strSerial.isEmpty())
    1264         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Serial No.: %1</nobr>", "USB filter tooltip")
    1265                                                      .arg(strSerial);
    1266 
    1267     const QString strPort = comFilter.GetPort();
    1268     if (!strPort.isEmpty())
    1269         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Port: %1</nobr>", "USB filter tooltip")
    1270                                                      .arg(strPort);
    1271 
    1272     /* Add the state field if it's a host USB device: */
    1273     CHostUSBDevice hostDev(comFilter);
    1274     if (!hostDev.isNull())
    1275     {
    1276         strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>State: %1</nobr>", "USB filter tooltip")
    1277                                                      .arg(gpConverter->toString(hostDev.GetState()));
    1278     }
    1279 
    1280     return strTip;
    1281 }
    1282 
    1283 /* static */
    1284 QString UICommon::usbToolTip(const CHostVideoInputDevice &comWebcam)
    1285 {
    1286     QStringList records;
    1287 
    1288     const QString strName = comWebcam.GetName();
    1289     if (!strName.isEmpty())
    1290         records << strName;
    1291 
    1292     const QString strPath = comWebcam.GetPath();
    1293     if (!strPath.isEmpty())
    1294         records << strPath;
    1295 
    1296     return records.join("<br>");
    1297 }
    1298 
    1299 /* static */
    13001156QString UICommon::helpFile()
    13011157{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r105128 r105150  
    5252class QSpinBox;
    5353class CCloudMachine;
    54 class CHostVideoInputDevice;
    55 class CUSBDevice;
    56 class CUSBDeviceFilter;
    5754class UIThreadPool;
    5855
     
    265262    /** @} */
    266263
    267     /** @name COM: USB stuff.
    268      * @{ */
    269         /** Generates details for passed USB @a comDevice. */
    270         static QString usbDetails(const CUSBDevice &comDevice);
    271         /** Generates tool-tip for passed USB @a comDevice. */
    272         static QString usbToolTip(const CUSBDevice &comDevice);
    273         /** Generates tool-tip for passed USB @a comFilter. */
    274         static QString usbToolTip(const CUSBDeviceFilter &comFilter);
    275         /** Generates tool-tip for passed USB @a comWebcam. */
    276         static QString usbToolTip(const CHostVideoInputDevice &comWebcam);
    277     /** @} */
    278 
    279264    /** @name File-system stuff.
    280265     * @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp

    r104917 r105150  
    3333/* GUI includes: */
    3434#include "UIBootOrderEditor.h"
    35 #include "UICommon.h"
    3635#include "UIConverter.h"
    3736#include "UIDetailsGenerator.h"
     
    4241#include "UIMediumTools.h"
    4342#include "UITranslator.h"
     43#include "UIUSBTools.h"
    4444
    4545/* COM includes: */
     
    607607            /* That hack makes sure 'Inaccessible' word is always bold: */
    608608            { // hack
    609                 const QString strInaccessibleString(UICommon::tr("Inaccessible", "medium"));
     609                const QString strInaccessibleString(QApplication::translate("UICommon", "Inaccessible", "medium"));
    610610                const QString strBoldInaccessibleString(QString("<b>%1</b>").arg(strInaccessibleString));
    611611                strAttachmentInfo.replace(strInaccessibleString, strBoldInaccessibleString);
     
    13861386        /* Enumerate all the USB devices: */
    13871387        foreach (const CUSBDevice &comUsbDevice, comConsole.GetUSBDevices())
    1388             strInfo += e_strTableRow1.arg(uiCommon().usbDetails(comUsbDevice));
     1388            strInfo += e_strTableRow1.arg(usbDetails(comUsbDevice));
    13891389        /* Handle 'no-usb-devices' case: */
    13901390        if (strInfo.isNull())
     
    14291429    /* Video Memory: */
    14301430    const ULONG uVRAMSize = comGraphics.GetVRAMSize();
    1431     const QString strVRAMSize = UICommon::tr("<nobr>%1 MB</nobr>", "details report").arg(uVRAMSize);
     1431    const QString strVRAMSize = QApplication::translate("UICommon", "<nobr>%1 MB</nobr>", "details report").arg(uVRAMSize);
    14321432    strInfo += e_strTableRow2
    14331433        .arg(QApplication::translate("UIIndicatorsPool", "Video memory", "Display tooltip"), strVRAMSize);
     
    14471447    {
    14481448        const QString strAcceleration3D = fAcceleration3D
    1449             ? UICommon::tr("Enabled", "details report (3D Acceleration)")
    1450             : UICommon::tr("Disabled", "details report (3D Acceleration)");
     1449            ? QApplication::translate("UICommon", "Enabled", "details report (3D Acceleration)")
     1450            : QApplication::translate("UICommon", "Disabled", "details report (3D Acceleration)");
    14511451        strInfo += e_strTableRow2
    14521452            .arg(QApplication::translate("UIIndicatorsPool", "3D acceleration", "Display tooltip"), strAcceleration3D);
     
    15131513            RT_FALL_THRU();
    15141514        case KVMExecutionEngine_NotSet:
    1515             strExecutionEngine = UICommon::tr("not set", "details report (execution engine)");
     1515            strExecutionEngine = QApplication::translate("UICommon", "not set", "details report (execution engine)");
    15161516            break;
    15171517    }
     
    15191519    /* Nested Paging feature: */
    15201520    const QString strNestedPaging = fNestedPagingEnabled
    1521                                   ? UICommon::tr("Active", "details report (Nested Paging)")
    1522                                   : UICommon::tr("Inactive", "details report (Nested Paging)");
     1521                                  ? QApplication::translate("UICommon", "Active", "details report (Nested Paging)")
     1522                                  : QApplication::translate("UICommon", "Inactive", "details report (Nested Paging)");
    15231523
    15241524    /* Unrestricted Execution feature: */
    15251525    const QString strUnrestrictExec = fUxEnabled
    1526                                     ? UICommon::tr("Active", "details report (Unrestricted Execution)")
    1527                                     : UICommon::tr("Inactive", "details report (Unrestricted Execution)");
     1526                                    ? QApplication::translate("UICommon", "Active", "details report (Unrestricted Execution)")
     1527                                    : QApplication::translate("UICommon", "Inactive", "details report (Unrestricted Execution)");
    15281528
    15291529    /* CPU Execution Cap feature: */
     
    15341534
    15351535    /* Compose tool-tip: */
    1536     strInfo += e_strTableRow2.arg(UICommon::tr("Execution engine", "details report"),             strExecutionEngine);
    1537     strInfo += e_strTableRow2.arg(UICommon::tr("Nested Paging"),                                  strNestedPaging);
    1538     strInfo += e_strTableRow2.arg(UICommon::tr("Unrestricted Execution"),                         strUnrestrictExec);
    1539     strInfo += e_strTableRow2.arg(UICommon::tr("Execution Cap", "details report"),                strCPUExecCap);
    1540     strInfo += e_strTableRow2.arg(UICommon::tr("Paravirtualization Interface", "details report"), strParavirt);
     1536    strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Execution engine", "details report"),             strExecutionEngine);
     1537    strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Nested Paging"),                                  strNestedPaging);
     1538    strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Unrestricted Execution"),                         strUnrestrictExec);
     1539    strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Execution Cap", "details report"),                strCPUExecCap);
     1540    strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Paravirtualization Interface", "details report"), strParavirt);
    15411541
    15421542    /* Add CPU count optional info: */
    15431543    const int cCpuCount = comMachine.GetCPUCount();
    15441544    if (cCpuCount > 1)
    1545         strInfo += e_strTableRow2.arg(UICommon::tr("Processors", "details report"), QString::number(cCpuCount));
     1545        strInfo += e_strTableRow2.arg(QApplication::translate("UICommon", "Processors", "details report"), QString::number(cCpuCount));
    15461546}
    15471547
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r104901 r105150  
    7676#include "UITranslationEventListener.h"
    7777#include "UITakeSnapshotDialog.h"
     78#include "UIUSBTools.h"
    7879#include "UIVersion.h"
    7980#include "UIVirtualBoxEventHandler.h"
     
    633634    {
    634635        if (fIsAttached)
    635             UINotificationMessage::cannotAttachUSBDevice(error, uiCommon().usbDetails(device), machineName());
     636            UINotificationMessage::cannotAttachUSBDevice(error, usbDetails(device), machineName());
    636637        else
    637             UINotificationMessage::cannotDetachUSBDevice(error, uiCommon().usbDetails(device), machineName());
     638            UINotificationMessage::cannotDetachUSBDevice(error, usbDetails(device), machineName());
    638639    }
    639640}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r105081 r105150  
    5757#include "UISession.h"
    5858#include "UITextTable.h"
     59#include "UIUSBTools.h"
    5960#include "UIVersion.h"
    6061#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
     
    11001101            if (fSuccess)
    11011102            {
    1102                 /// @todo make sure UICommon::usbDetails is checked for errors as well
    1103                 guiUSBDevice.m_strName = uiCommon().usbDetails(comUSBDevice);
     1103                /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
     1104                guiUSBDevice.m_strName = usbDetails(comUSBDevice);
    11041105                fSuccess = comUSBDevice.isOk();
    11051106            }
    11061107            if (fSuccess)
    11071108            {
    1108                 /// @todo make sure UICommon::usbToolTip is checked for errors as well
    1109                 guiUSBDevice.m_strToolTip = uiCommon().usbToolTip(comUSBDevice);
     1109                /// @todo make sure UIUSBTools::usbToolTip is checked for errors as well
     1110                guiUSBDevice.m_strToolTip = usbToolTip(comUSBDevice);
    11101111                fSuccess = comUSBDevice.isOk();
    11111112            }
     
    11461147         * this stuff requires #include <VBox/com/VirtualBox.h> */
    11471148        CUSBDevice comUSBDevice(comHostUSBDevice);
    1148         UINotificationMessage::cannotAttachUSBDevice(comConsole, uiCommon().usbDetails(comUSBDevice));
    1149         /// @todo make sure UICommon::usbDetails is checked for errors as well
     1149        UINotificationMessage::cannotAttachUSBDevice(comConsole, usbDetails(comUSBDevice));
     1150        /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
    11501151    }
    11511152    return fSuccess;
     
    11601161    {
    11611162        CUSBDevice comUSBDevice = CConsole(comConsole).FindUSBDeviceById(uId);
    1162         UINotificationMessage::cannotDetachUSBDevice(comConsole, uiCommon().usbDetails(comUSBDevice));
    1163         /// @todo make sure UICommon::usbDetails is checked for errors as well
     1163        UINotificationMessage::cannotDetachUSBDevice(comConsole, usbDetails(comUSBDevice));
     1164        /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
    11641165    }
    11651166    return fSuccess;
     
    12041205                    if (fSuccess)
    12051206                    {
    1206                         /// @todo make sure UICommon::usbToolTip is checked for errors as well
    1207                         guiWebcamDevice.m_strToolTip = uiCommon().usbToolTip(comHostVideoInputDevice);
     1207                        /// @todo make sure UIUSBTools::usbToolTip is checked for errors as well
     1208                        guiWebcamDevice.m_strToolTip = usbToolTip(comHostVideoInputDevice);
    12081209                        fSuccess = comHostVideoInputDevice.isOk();
    12091210                    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUSBFiltersEditor.cpp

    r104313 r105150  
    3939#include "QIToolBar.h"
    4040#include "QITreeWidget.h"
    41 #include "UICommon.h"
    4241#include "UIGlobalSession.h"
    4342#include "UIIconPool.h"
    4443#include "UIUSBFilterDetailsEditor.h"
    4544#include "UIUSBFiltersEditor.h"
     45#include "UIUSBTools.h"
    4646
    4747/* COM includes: */
     
    163163            if (!usb.isNull())
    164164            {
    165                 QToolTip::showText(pHelpEvent->globalPos(), uiCommon().usbToolTip(usb));
     165                QToolTip::showText(pHelpEvent->globalPos(), usbToolTip(usb));
    166166                return true;
    167167            }
     
    196196        {
    197197            CUSBDevice comUsb(comHostUsb);
    198             QAction *pAction = addAction(uiCommon().usbDetails(comUsb));
     198            QAction *pAction = addAction(usbDetails(comUsb));
    199199            pAction->setCheckable(true);
    200200            m_usbDeviceMap[pAction] = comUsb;
     
    401401    UIDataUSBFilter newFilterData;
    402402    newFilterData.m_fActive = true;
    403     newFilterData.m_strName = uiCommon().usbDetails(comUsb);
     403    newFilterData.m_strName = usbDetails(comUsb);
    404404    newFilterData.m_strVendorId  = QString::number(comUsb.GetVendorId(),  16).toUpper().rightJustified(4, '0');
    405405    newFilterData.m_strProductId = QString::number(comUsb.GetProductId(), 16).toUpper().rightJustified(4, '0');
Note: See TracChangeset for help on using the changeset viewer.

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