VirtualBox

Changeset 9827 in vbox


Ignore:
Timestamp:
Jun 19, 2008 4:25:58 PM (17 years ago)
Author:
vboxsync
Message:

Fe/Qt4: GlobalUSBSettings ported to qt4. Hidden for now by #ifdef ENABLE_GLOBAL_USB (in VBoxVMSettingsUSB.cpp file).

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsUSB.h

    r9751 r9827  
    2828#include "COMDefs.h"
    2929
     30class VBoxGlobalSettingsDlg;
    3031class VBoxVMSettingsDlg;
    3132class QIWidgetValidator;
     
    4647    };
    4748
    48     VBoxVMSettingsUSB (QWidget *aParent,
    49                        FilterType aType,
    50                        VBoxVMSettingsDlg *aDlg,
    51                        const QString &aPath);
    52 
    53     static void getFromMachine (const CMachine &aMachine,
    54                                 QWidget *aPage,
    55                                 VBoxVMSettingsDlg *aDlg,
    56                                 const QString &aPath);
    57     static void putBackToMachine();
    58 
    59     void getFrom (const CMachine &aMachine);
    60     void putBackTo();
     49    static void getFrom (QWidget *aPage,
     50                         VBoxGlobalSettingsDlg *aDlg,
     51                         const QString &aPath);
     52    static void getFrom (const CMachine &aMachine,
     53                         QWidget *aPage,
     54                         VBoxVMSettingsDlg *aDlg,
     55                         const QString &aPath);
     56    static void putBackTo();
    6157
    6258protected:
    6359
     60    VBoxVMSettingsUSB (QWidget *aParent,
     61                       FilterType aType,
     62                       QWidget *aDlg,
     63                       const QString &aPath);
     64
     65    void getFromHost();
     66    void putBackToHost();
     67
     68    void getFromMachine (const CMachine &aMachine);
     69    void putBackToMachine();
     70
    6471    void retranslateUi();
     72
     73    FilterType mType;
    6574
    6675private slots:
     
    8594
    8695    CMachine mMachine;
    87     FilterType mType;
    8896    QIWidgetValidator *mValidator;
    8997    QAction *mNewAction;
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobalSettingsDlg.cpp

    r9820 r9827  
    3535#include "VBoxGlobalSettingsGeneral.h"
    3636#include "VBoxGlobalSettingsInput.h"
    37 //#include "VBoxGlobalSettingsUSB.h"
     37#include "VBoxVMSettingsUSB.h"
    3838//#include "VBoxGlobalSettingsLanguage.h"
    3939
     
    370370                                     const VBoxGlobalSettings &aGs)
    371371{
    372 //     /* USB Page */
    373 // #ifdef DEBUG_dmik
    374 //     CHost host = vboxGlobal().virtualBox().GetHost();
    375 //     CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters();
    376 //
    377 //     /* Show an error message (if there is any).
    378 //      * This message box may be suppressed if the user wishes so. */
    379 //     if (!host.isReallyOk())
    380 //         vboxProblem().cannotAccessUSB (host);
    381 //
    382 //     if (coll.isNull())
    383 //     {
    384 // #endif
    385 //         /* disable the USB host filters category if the USB is
    386 //          * not available (i.e. in VirtualBox OSE) */
    387 //
    388 //         Q3ListViewItem *usbItem = listView->findItem ("#usb", listView_Link);
    389 //         Assert (usbItem);
    390 //         usbItem->setVisible (false);
    391 //
    392 //         /* disable validators if any */
    393 //         pageUSB->setEnabled (false);
    394 //
    395 // #ifdef DEBUG_dmik
    396 //     }
    397 //     else
    398 //     {
    399 //         CHostUSBDeviceFilterEnumerator en = coll.Enumerate();
    400 //         while (en.HasMore())
    401 //         {
    402 //             CHostUSBDeviceFilter hostFilter = en.GetNext();
    403 //             CUSBDeviceFilter filter = CUnknown (hostFilter);
    404 //             addUSBFilter (filter, false);
    405 //         }
    406 //         lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
    407 //         lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
    408 //     }
    409 // #endif
    410 
    411372//     /* Language page */
    412373//     QString langId = gs.languageId();
     
    432393
    433394    /* USB Page */
    434     //VBoxVMSettingsUSB::getFrom (aProps, aGs, mPageUSB,
    435     //                            this, pagePath (mPageUSB));
     395    VBoxVMSettingsUSB::getFrom (mPageUSB, this, pagePath (mPageUSB));
    436396
    437397    /* Language Page */
     
    446406                                            VBoxGlobalSettings &aGs)
    447407{
    448 //     /* USB Page */
    449 //     /*
    450 //      *  first, remove all old filters (only if the list is changed,
    451 //      *  not only individual properties of filters)
    452 //      */
    453 //     CHost host = vboxGlobal().virtualBox().GetHost();
    454 //     if (mUSBFilterListModified)
    455 //         for (ulong cnt = host.GetUSBDeviceFilters().GetCount(); cnt; -- cnt)
    456 //             host.RemoveUSBDeviceFilter (0);
    457 //
    458 //     /* then add all new filters */
    459 //     for (Q3ListViewItem *item = lvUSBFilters->firstChild(); item;
    460 //          item = item->nextSibling())
    461 //     {
    462 //         USBListItem *uli = static_cast<USBListItem*> (item);
    463 //         /*
    464 //         VBoxUSBFilterSettings *settings =
    465 //             static_cast <VBoxUSBFilterSettings *>
    466 //                 (wstUSBFilters->widget (uli->mId));
    467 //         Assert (settings);
    468 //
    469 //         COMResult res = settings->putBackToFilter();
    470 //         if (!res.isOk())
    471 //             return;
    472 //
    473 //         CUSBDeviceFilter filter = settings->filter();
    474 //         filter.SetActive (uli->isOn());
    475 //
    476 //         CHostUSBDeviceFilter insertedFilter = CUnknown (filter);
    477 //         if (mUSBFilterListModified)
    478 //             host.InsertUSBDeviceFilter (host.GetUSBDeviceFilters().GetCount(),
    479 //                                         insertedFilter);
    480 //         */
    481 //     }
    482 //     mUSBFilterListModified = false;
    483 
    484408//     /* Language Page */
    485409//     Q3ListViewItem *selItem = lvLanguages->selectedItem();
     
    498422
    499423    /* USB Page */
    500     //VBoxVMSettingsUSB::putBackTo (aProps, aGs);
     424    VBoxVMSettingsUSB::putBackTo();
    501425
    502426    /* Language Page */
     
    762686//     */
    763687// }
    764 //
    765 // void VBoxGlobalSettingsDlg::lvUSBFilters_currentChanged (Q3ListViewItem *item)
    766 // {
    767 //     if (item && lvUSBFilters->selectedItem() != item)
    768 //         lvUSBFilters->setSelected (item, true);
    769 //
    770 //     tbRemoveUSBFilter->setEnabled (!!item);
    771 //
    772 //     tbUSBFilterUp->setEnabled (!!item && item->itemAbove());
    773 //     tbUSBFilterDown->setEnabled (!!item && item->itemBelow());
    774 //
    775 //     if (item)
    776 //     {
    777 //         USBListItem *uli = static_cast <USBListItem *> (item);
    778 //         wstUSBFilters->raiseWidget (uli->mId);
    779 //     }
    780 //     else
    781 //     {
    782 //         /* raise the disabled widget */
    783 //         wstUSBFilters->raiseWidget (0);
    784 //     }
    785 // }
    786 //
    787 // void VBoxGlobalSettingsDlg::lvUSBFilters_setCurrentText (const QString &aText)
    788 // {
    789 //     Q3ListViewItem *item = lvUSBFilters->currentItem();
    790 //     Assert (item);
    791 //
    792 //     item->setText (lvUSBFilters_Name, aText);
    793 // }
    794 //
    795 // void VBoxGlobalSettingsDlg::tbAddUSBFilter_clicked()
    796 // {
    797 //     /* search for the max available filter index */
    798 //     int maxFilterIndex = 0;
    799 //     QString usbFilterName = tr ("New Filter %1", "usb");
    800 //     QRegExp regExp (QString ("^") + usbFilterName.arg ("([0-9]+)") + QString ("$"));
    801 //     Q3ListViewItemIterator iterator (lvUSBFilters);
    802 //     while (*iterator)
    803 //     {
    804 //         QString filterName = (*iterator)->text (lvUSBFilters_Name);
    805 //         int pos = regExp.search (filterName);
    806 //         if (pos != -1)
    807 //             maxFilterIndex = regExp.cap (1).toInt() > maxFilterIndex ?
    808 //                              regExp.cap (1).toInt() : maxFilterIndex;
    809 //         ++ iterator;
    810 //     }
    811 //
    812 //     /* create a new usb filter */
    813 //     CHost host = vboxGlobal().virtualBox().GetHost();
    814 //     CHostUSBDeviceFilter hostFilter = host
    815 //         .CreateUSBDeviceFilter (usbFilterName.arg (maxFilterIndex + 1));
    816 //     hostFilter.SetAction (KUSBDeviceFilterAction_Hold);
    817 //
    818 //     CUSBDeviceFilter filter = CUnknown (hostFilter);
    819 //     filter.SetActive (true);
    820 //     addUSBFilter (filter, true);
    821 //
    822 //     mUSBFilterListModified = true;
    823 // }
    824 //
    825 // void VBoxGlobalSettingsDlg::tbAddUSBFilterFrom_clicked()
    826 // {
    827 //     usbDevicesMenu->exec (QCursor::pos());
    828 // }
    829 //
    830 // void VBoxGlobalSettingsDlg::menuAddUSBFilterFrom_activated (QAction *aAction)
    831 // {
    832 //     CUSBDevice usb = usbDevicesMenu->getUSB (aAction);
    833 //
    834 //     // if null then some other item but a USB device is selected
    835 //     if (usb.isNull())
    836 //         return;
    837 //
    838 //     CHost host = vboxGlobal().virtualBox().GetHost();
    839 //     CHostUSBDeviceFilter hostFilter = host
    840 //         .CreateUSBDeviceFilter (vboxGlobal().details (usb));
    841 //     hostFilter.SetAction (KUSBDeviceFilterAction_Hold);
    842 //
    843 //     CUSBDeviceFilter filter = CUnknown (hostFilter);
    844 //     filter.SetVendorId (QString().sprintf ("%04hX", usb.GetVendorId()));
    845 //     filter.SetProductId (QString().sprintf ("%04hX", usb.GetProductId()));
    846 //     filter.SetRevision (QString().sprintf ("%04hX", usb.GetRevision()));
    847 //     /* The port property depends on the host computer rather than on the USB
    848 //      * device itself; for this reason only a few people will want to use it in
    849 //      * the filter since the same device plugged into a different socket will
    850 //      * not match the filter in this case.  */
    851 // #if 0
    852 //     /// @todo set it anyway if Alt is currently pressed
    853 //     filter.SetPort (QString().sprintf ("%04hX", usb.GetPort()));
    854 // #endif
    855 //     filter.SetManufacturer (usb.GetManufacturer());
    856 //     filter.SetProduct (usb.GetProduct());
    857 //     filter.SetSerialNumber (usb.GetSerialNumber());
    858 //     filter.SetRemote (usb.GetRemote() ? "yes" : "no");
    859 //
    860 //     filter.SetActive (true);
    861 //     addUSBFilter (filter, true);
    862 //
    863 //     mUSBFilterListModified = true;
    864 // }
    865 //
    866 // void VBoxGlobalSettingsDlg::tbRemoveUSBFilter_clicked()
    867 // {
    868 //     Q3ListViewItem *item = lvUSBFilters->currentItem();
    869 //     Assert (item);
    870 //
    871 //     USBListItem *uli = static_cast <USBListItem *> (item);
    872 //     QWidget *settings = wstUSBFilters->widget (uli->mId);
    873 //     Assert (settings);
    874 //     wstUSBFilters->removeWidget (settings);
    875 //     delete settings;
    876 //
    877 //     delete item;
    878 //
    879 //     lvUSBFilters->setSelected (lvUSBFilters->currentItem(), true);
    880 //     mUSBFilterListModified = true;
    881 // }
    882 //
    883 // void VBoxGlobalSettingsDlg::tbUSBFilterUp_clicked()
    884 // {
    885 //     Q3ListViewItem *item = lvUSBFilters->currentItem();
    886 //     Assert (item);
    887 //
    888 //     Q3ListViewItem *itemAbove = item->itemAbove();
    889 //     Assert (itemAbove);
    890 //     itemAbove = itemAbove->itemAbove();
    891 //
    892 //     if (!itemAbove)
    893 //         item->itemAbove()->moveItem (item);
    894 //     else
    895 //         item->moveItem (itemAbove);
    896 //
    897 //     lvUSBFilters_currentChanged (item);
    898 //     mUSBFilterListModified = true;
    899 // }
    900 //
    901 // void VBoxGlobalSettingsDlg::tbUSBFilterDown_clicked()
    902 // {
    903 //     Q3ListViewItem *item = lvUSBFilters->currentItem();
    904 //     Assert (item);
    905 //
    906 //     Q3ListViewItem *itemBelow = item->itemBelow();
    907 //     Assert (itemBelow);
    908 //
    909 //     item->moveItem (itemBelow);
    910 //
    911 //     lvUSBFilters_currentChanged (item);
    912 //     mUSBFilterListModified = true;
    913 // }
    914688
    915689// /* Language Page */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsDlg.cpp

    r9784 r9827  
    217217
    218218    /* USB */
    219     VBoxVMSettingsUSB::getFromMachine (aMachine, mPageUSB,
    220                                        this, pagePath (mPageUSB));
     219    VBoxVMSettingsUSB::getFrom (aMachine, mPageUSB,
     220                                this, pagePath (mPageUSB));
    221221
    222222    /* Shared Folders */
     
    267267
    268268    /* USB */
    269     VBoxVMSettingsUSB::putBackToMachine();
     269    VBoxVMSettingsUSB::putBackTo();
    270270
    271271    /* Shared folders */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsUSB.cpp

    r9751 r9827  
    2222
    2323#include "VBoxVMSettingsUSB.h"
     24#include "VBoxGlobalSettingsDlg.h"
    2425#include "VBoxVMSettingsDlg.h"
    2526#include "VBoxVMSettingsUtils.h"
     
    2930#include "VBoxProblemReporter.h"
    3031
     32//#define ENABLE_GLOBAL_USB
     33
    3134inline static QString emptyToNull (const QString &str)
    3235{
     
    3538
    3639VBoxVMSettingsUSB* VBoxVMSettingsUSB::mSettings = 0;
     40
     41void VBoxVMSettingsUSB::getFrom (QWidget *aPage,
     42                                 VBoxGlobalSettingsDlg *aDlg,
     43                                 const QString &aPath)
     44{
     45    /* USB Page */
     46#ifdef ENABLE_GLOBAL_USB
     47    CHost host = vboxGlobal().virtualBox().GetHost();
     48    CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters();
     49
     50    /* Show an error message (if there is any).
     51     * This message box may be suppressed if the user wishes so. */
     52    if (!host.isReallyOk())
     53        vboxProblem().cannotAccessUSB (host);
     54
     55    if (coll.isNull())
     56    {
     57#else
     58    NOREF (aPage);
     59    NOREF (aPath);
     60#endif
     61        /* Disable the USB controller category if the USB controller is
     62         * not available (i.e. in VirtualBox OSE) */
     63        QList<QTreeWidgetItem*> items = aDlg->mTwSelector->findItems (
     64            "#usb", Qt::MatchExactly, listView_Link);
     65        QTreeWidgetItem *usbItem = items.count() ? items [0] : 0;
     66        Assert (usbItem);
     67        if (usbItem)
     68            usbItem->setHidden (true);
     69        return;
     70#ifdef ENABLE_GLOBAL_USB
     71    }
     72
     73    mSettings = new VBoxVMSettingsUSB (aPage, HostType, aDlg, aPath);
     74    QVBoxLayout *layout = new QVBoxLayout (aPage);
     75    layout->setContentsMargins (0, 0, 0, 0);
     76    layout->addWidget (mSettings);
     77
     78    mSettings->getFromHost();
     79
     80    /* Fixing tab-order */
     81    setTabOrder (aDlg->mTwSelector, mSettings->mTwFilters);
     82    setTabOrder (mSettings->mTwFilters, mSettings->mLeName);
     83    setTabOrder (mSettings->mLeName, mSettings->mLeVendorID);
     84    setTabOrder (mSettings->mLeVendorID, mSettings->mLeManufacturer);
     85    setTabOrder (mSettings->mLeManufacturer, mSettings->mLeProductID);
     86    setTabOrder (mSettings->mLeProductID, mSettings->mLeProduct);
     87    setTabOrder (mSettings->mLeProduct, mSettings->mLeRevision);
     88    setTabOrder (mSettings->mLeRevision, mSettings->mLeSerialNo);
     89    setTabOrder (mSettings->mLeSerialNo, mSettings->mLePort);
     90    setTabOrder (mSettings->mLePort, mSettings->mCbAction);
     91#endif
     92}
     93
     94void VBoxVMSettingsUSB::getFrom (const CMachine &aMachine,
     95                                 QWidget *aPage,
     96                                 VBoxVMSettingsDlg *aDlg,
     97                                 const QString &aPath)
     98{
     99    CUSBController ctl = aMachine.GetUSBController();
     100
     101    /* Show an error message (if there is any).
     102     * Note that we don't use the generic cannotLoadMachineSettings()
     103     * call here because we want this message to be suppressable. */
     104    if (!aMachine.isReallyOk())
     105        vboxProblem().cannotAccessUSB (aMachine);
     106
     107    if (ctl.isNull())
     108    {
     109        /* Disable the USB controller category if the USB controller is
     110         * not available (i.e. in VirtualBox OSE) */
     111        QList<QTreeWidgetItem*> items = aDlg->mTwSelector->findItems (
     112            "#usb", Qt::MatchExactly, listView_Link);
     113        QTreeWidgetItem *usbItem = items.count() ? items [0] : 0;
     114        Assert (usbItem);
     115        if (usbItem)
     116            usbItem->setHidden (true);
     117        return;
     118    }
     119
     120    mSettings = new VBoxVMSettingsUSB (aPage, MachineType, aDlg, aPath);
     121    QVBoxLayout *layout = new QVBoxLayout (aPage);
     122    layout->setContentsMargins (0, 0, 0, 0);
     123    layout->addWidget (mSettings);
     124
     125    mSettings->getFromMachine (aMachine);
     126
     127    /* Fixing tab-order */
     128    setTabOrder (aDlg->mTwSelector, mSettings->mGbUSB);
     129    setTabOrder (mSettings->mGbUSB, mSettings->mCbUSB2);
     130    setTabOrder (mSettings->mCbUSB2, mSettings->mTwFilters);
     131    setTabOrder (mSettings->mTwFilters, mSettings->mLeName);
     132    setTabOrder (mSettings->mLeName, mSettings->mLeVendorID);
     133    setTabOrder (mSettings->mLeVendorID, mSettings->mLeManufacturer);
     134    setTabOrder (mSettings->mLeManufacturer, mSettings->mLeProductID);
     135    setTabOrder (mSettings->mLeProductID, mSettings->mLeProduct);
     136    setTabOrder (mSettings->mLeProduct, mSettings->mLeRevision);
     137    setTabOrder (mSettings->mLeRevision, mSettings->mLeSerialNo);
     138    setTabOrder (mSettings->mLeSerialNo, mSettings->mLePort);
     139    setTabOrder (mSettings->mLePort, mSettings->mCbRemote);
     140}
     141
     142void VBoxVMSettingsUSB::putBackTo()
     143{
     144    if (mSettings)
     145        mSettings->mType == MachineType ? mSettings->putBackToMachine() :
     146                                          mSettings->putBackToHost();
     147}
     148
    37149
    38150VBoxVMSettingsUSB::VBoxVMSettingsUSB (QWidget *aParent,
    39151                                      FilterType aType,
    40                                       VBoxVMSettingsDlg *aDlg,
     152                                      QWidget *aDlg,
    41153                                      const QString &aPath)
    42154    : QIWithRetranslateUI<QWidget> (aParent)
     
    95207    toolBar->addAction (mMupAction);
    96208    toolBar->addAction (mMdnAction);
     209    toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
    97210    mGbUSBFilters->layout()->addWidget (toolBar);
    98211
     
    154267    mCbAction->setHidden (mType != HostType);
    155268
    156     /* Fixing tab-order */
    157     setTabOrder (aDlg->mTwSelector, mGbUSB);
    158     setTabOrder (mGbUSB, mCbUSB2);
    159     setTabOrder (mCbUSB2, mTwFilters);
    160     setTabOrder (mTwFilters, mLeName);
    161     setTabOrder (mLeName, mLeVendorID);
    162     setTabOrder (mLeVendorID, mLeManufacturer);
    163     setTabOrder (mLeManufacturer, mLeProductID);
    164     setTabOrder (mLeProductID, mLeProduct);
    165     setTabOrder (mLeProduct, mLeRevision);
    166     setTabOrder (mLeRevision, mLeSerialNo);
    167     setTabOrder (mLeSerialNo, mLePort);
    168     setTabOrder (mLePort, mCbRemote);
    169     setTabOrder (mCbRemote, mCbAction);
    170269    /* Applying language settings */
    171270    retranslateUi();
    172271}
    173272
    174 void VBoxVMSettingsUSB::getFromMachine (const CMachine &aMachine,
    175                                         QWidget *aPage,
    176                                         VBoxVMSettingsDlg *aDlg,
    177                                         const QString &aPath)
    178 {
    179     CUSBController ctl = aMachine.GetUSBController();
    180 
    181     /* Show an error message (if there is any).
    182      * Note that we don't use the generic cannotLoadMachineSettings()
    183      * call here because we want this message to be suppressable. */
    184     if (!aMachine.isReallyOk())
    185         vboxProblem().cannotAccessUSB (aMachine);
    186 
    187     if (ctl.isNull())
    188     {
    189         /* Disable the USB controller category if the USB controller is
    190          * not available (i.e. in VirtualBox OSE) */
    191         QList<QTreeWidgetItem*> items = aDlg->mTwSelector->findItems (
    192             "#usb", Qt::MatchExactly, listView_Link);
    193         QTreeWidgetItem *usbItem = items.count() ? items [0] : 0;
    194         Assert (usbItem);
    195         if (usbItem)
    196             usbItem->setHidden (true);
    197         return;
    198     }
    199 
    200     mSettings = new VBoxVMSettingsUSB (aPage, MachineType, aDlg, aPath);
    201     QVBoxLayout *layout = new QVBoxLayout (aPage);
    202     layout->setContentsMargins (0, 0, 0, 0);
    203     layout->addWidget (mSettings);
    204 
    205     mSettings->getFrom (aMachine);
    206 }
    207 
    208 void VBoxVMSettingsUSB::putBackToMachine()
    209 {
    210     if (mSettings)
    211         mSettings->putBackTo();
    212 }
    213 
    214 void VBoxVMSettingsUSB::getFrom (const CMachine &aMachine)
     273void VBoxVMSettingsUSB::getFromHost()
     274{
     275    mGbUSB->setVisible (false);
     276
     277    CHostUSBDeviceFilterEnumerator en = vboxGlobal().virtualBox().GetHost()
     278                                        .GetUSBDeviceFilters().Enumerate();
     279    while (en.HasMore())
     280    {
     281        CHostUSBDeviceFilter hostFilter = en.GetNext();
     282        CUSBDeviceFilter filter = CUnknown (hostFilter);
     283        addUSBFilter (filter, false /* isNew */);
     284    }
     285
     286    mTwFilters->setCurrentItem (mTwFilters->topLevelItem (0));
     287    currentChanged (mTwFilters->currentItem());
     288}
     289
     290void VBoxVMSettingsUSB::putBackToHost()
     291{
     292    CHost host = vboxGlobal().virtualBox().GetHost();
     293
     294    if (mUSBFilterListModified)
     295    {
     296        /* First, remove all old filters */
     297        for (ulong count = host.GetUSBDeviceFilters().GetCount(); count; -- count)
     298            host.RemoveUSBDeviceFilter (0);
     299
     300        /* Then add all new filters */
     301        for (int i = 0; i < mFilters.size(); ++ i)
     302        {
     303            CUSBDeviceFilter filter = mFilters [i];
     304            filter.SetActive (mTwFilters->topLevelItem (i)->
     305                checkState (0) == Qt::Checked);
     306            CHostUSBDeviceFilter insertedFilter = CUnknown (filter);
     307            host.InsertUSBDeviceFilter (host.GetUSBDeviceFilters().GetCount(),
     308                                        insertedFilter);
     309        }
     310    }
     311
     312    mUSBFilterListModified = false;
     313}
     314
     315void VBoxVMSettingsUSB::getFromMachine (const CMachine &aMachine)
    215316{
    216317    mMachine = aMachine;
     
    229330}
    230331
    231 void VBoxVMSettingsUSB::putBackTo()
     332void VBoxVMSettingsUSB::putBackToMachine()
    232333{
    233334    CUSBController ctl = mMachine.GetUSBController();
     
    448549
    449550    /* Creating new usb filter */
    450     CUSBDeviceFilter filter = mMachine.GetUSBController()
    451         .CreateDeviceFilter (mUSBFilterName.arg (maxFilterIndex + 1));
     551    CUSBDeviceFilter filter;
     552
     553    if (mType == HostType)
     554    {
     555        CHost host = vboxGlobal().virtualBox().GetHost();
     556        CHostUSBDeviceFilter hostFilter = host
     557            .CreateUSBDeviceFilter (mUSBFilterName.arg (maxFilterIndex + 1));
     558        hostFilter.SetAction (KUSBDeviceFilterAction_Hold);
     559        filter = CUnknown (hostFilter);
     560    }
     561    else if (mType == MachineType)
     562    {
     563        filter = mMachine.GetUSBController()
     564            .CreateDeviceFilter (mUSBFilterName.arg (maxFilterIndex + 1));
     565    }
     566    else
     567    {
     568        AssertMsgFailed (("Invalid VBoxVMSettingsUSB type"));
     569    }
    452570
    453571    filter.SetActive (true);
     
    469587        return;
    470588
    471     CUSBDeviceFilter filter = mMachine.GetUSBController()
    472         .CreateDeviceFilter (vboxGlobal().details (usb));
     589    /* Creating new usb filter */
     590    CUSBDeviceFilter filter;
     591
     592    if (mType == HostType)
     593    {
     594        CHost host = vboxGlobal().virtualBox().GetHost();
     595        CHostUSBDeviceFilter hostFilter = host
     596            .CreateUSBDeviceFilter (vboxGlobal().details (usb));
     597        hostFilter.SetAction (KUSBDeviceFilterAction_Hold);
     598        filter = CUnknown (hostFilter);
     599    }
     600    else if (mType == MachineType)
     601    {
     602        filter = mMachine.GetUSBController()
     603            .CreateDeviceFilter (vboxGlobal().details (usb));
     604    }
     605    else
     606    {
     607        AssertMsgFailed (("Invalid VBoxVMSettingsUSB type"));
     608    }
    473609
    474610    filter.SetVendorId (QString().sprintf ("%04hX", usb.GetVendorId()));
  • trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMSettingsUSB.ui

    r9654 r9827  
    259259        </item>
    260260        <item row="3" column="2" >
    261          <widget class="QLabel" name="mLbRemote" >
    262           <property name="text" >
    263            <string>R&amp;emote</string>
    264           </property>
    265           <property name="buddy" >
    266            <cstring>mCbRemote</cstring>
    267           </property>
    268          </widget>
     261         <layout class="QVBoxLayout" >
     262          <item>
     263           <widget class="QLabel" name="mLbRemote" >
     264            <property name="text" >
     265             <string>R&amp;emote</string>
     266            </property>
     267            <property name="buddy" >
     268             <cstring>mCbRemote</cstring>
     269            </property>
     270           </widget>
     271          </item>
     272          <item>
     273           <widget class="QLabel" name="mLbAction" >
     274            <property name="text" >
     275             <string>&amp;Action</string>
     276            </property>
     277            <property name="buddy" >
     278             <cstring>mCbAction</cstring>
     279            </property>
     280           </widget>
     281          </item>
     282         </layout>
    269283        </item>
    270284        <item row="3" column="3" >
    271          <widget class="QComboBox" name="mCbRemote" >
    272           <property name="sizePolicy" >
    273            <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
    274             <horstretch>0</horstretch>
    275             <verstretch>0</verstretch>
    276            </sizepolicy>
    277           </property>
    278           <property name="whatsThis" >
    279            <string>Defines whether this filter applies to USB devices attached locally to the host computer (&lt;i>No&lt;/i>), to a VRDP client's computer (&lt;i>Yes&lt;/i>), or both (&lt;i>Any&lt;/i>).</string>
    280           </property>
    281          </widget>
    282         </item>
    283         <item row="4" column="2" >
    284          <widget class="QLabel" name="mLbAction" >
    285           <property name="text" >
    286            <string>&amp;Action</string>
    287           </property>
    288           <property name="buddy" >
    289            <cstring>mCbAction</cstring>
    290           </property>
    291          </widget>
    292         </item>
    293         <item row="4" column="3" >
    294          <widget class="QComboBox" name="mCbAction" >
    295           <property name="sizePolicy" >
    296            <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
    297             <horstretch>0</horstretch>
    298             <verstretch>0</verstretch>
    299            </sizepolicy>
    300           </property>
    301           <property name="whatsThis" >
    302            <string>Defines an action performed by the host computer when a matching device is attached: give it up to the host OS (&lt;i>Ignore&lt;/i>) or grab it for later usage by virtual machines (&lt;i>Hold&lt;/i>).</string>
    303           </property>
    304          </widget>
     285         <layout class="QVBoxLayout" >
     286          <item>
     287           <widget class="QComboBox" name="mCbRemote" >
     288            <property name="sizePolicy" >
     289             <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
     290              <horstretch>0</horstretch>
     291              <verstretch>0</verstretch>
     292             </sizepolicy>
     293            </property>
     294            <property name="whatsThis" >
     295             <string>Defines whether this filter applies to USB devices attached locally to the host computer (&lt;i>No&lt;/i>), to a VRDP client's computer (&lt;i>Yes&lt;/i>), or both (&lt;i>Any&lt;/i>).</string>
     296            </property>
     297           </widget>
     298          </item>
     299          <item>
     300           <widget class="QComboBox" name="mCbAction" >
     301            <property name="sizePolicy" >
     302             <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
     303              <horstretch>0</horstretch>
     304              <verstretch>0</verstretch>
     305             </sizepolicy>
     306            </property>
     307            <property name="whatsThis" >
     308             <string>Defines an action performed by the host computer when a matching device is attached: give it up to the host OS (&lt;i>Ignore&lt;/i>) or grab it for later usage by virtual machines (&lt;i>Hold&lt;/i>).</string>
     309            </property>
     310           </widget>
     311          </item>
     312         </layout>
    305313        </item>
    306314       </layout>
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