VirtualBox

Ignore:
Timestamp:
Feb 18, 2009 6:27:52 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43063
Message:

NetAdp/win: enabled add/remove tap if UI, make the proper adapters to be displayed in the list

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsNetwork.h

    r16090 r16927  
    106106    bool isWrongInterface() const;
    107107    void setCurrentInterface (const QString &aName);
    108 
     108#if defined (Q_WS_WIN) && defined(VBOX_WITH_NETFLT)
     109    void updateInterfacesList(KNetworkAttachmentType enmAttachmentType);
     110#endif
    109111signals:
    110112
     
    123125
    124126private:
    125 
     127#if defined (Q_WS_WIN) && defined(VBOX_WITH_NETFLT)
     128    void populateInterfacesList(KNetworkAttachmentType enmAttachmentType);
     129#else
    126130    void populateInterfacesList();
    127 
     131#endif
    128132    QILabelSeparator *mLbTitle;
    129133    QTreeWidget      *mList;
    130134
    131 # if defined (Q_WS_WIN) && !defined(VBOX_WITH_NETFLT)
     135# if defined (Q_WS_WIN)
    132136    QAction *mAddAction;
    133137    QAction *mDelAction;
     138#  ifdef VBOX_WITH_NETFLT
     139    KNetworkAttachmentType mEnmAttachmentType;
     140#  endif
    134141# endif
    135142};
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetwork.cpp

    r16854 r16927  
    456456
    457457    /* Prepare actions */
    458 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     458# if defined (Q_WS_WIN)
    459459    mAddAction = new QAction (mList);
    460460    mDelAction = new QAction (mList);
     
    467467    mDelAction->setIcon (VBoxGlobal::iconSet (":/remove_host_iface_16px.png",
    468468                                              ":/remove_host_iface_disabled_16px.png"));
    469 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
    470 
    471 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     469# endif /* Q_WS_WIN */
     470
     471# if defined (Q_WS_WIN)
    472472    /* Prepare toolbar */
    473473    VBoxToolBar *toolBar = new VBoxToolBar (this);
     
    478478    toolBar->addAction (mDelAction);
    479479    layout->addWidget (toolBar);
    480 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
     480# endif /* Q_WS_WIN */
    481481
    482482    /* Setup connections */
    483483    connect (mList, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)),
    484484             this, SLOT (onCurrentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)));
    485 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     485# if defined (Q_WS_WIN)
    486486    connect (mAddAction, SIGNAL (triggered (bool)),
    487487             this, SLOT (addHostInterface()));
    488488    connect (mDelAction, SIGNAL (triggered (bool)),
    489489             this, SLOT (delHostInterface()));
    490 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
    491 
     490# endif /* Q_WS_WIN */
     491
     492#if !defined(Q_WS_WIN) && !defined(VBOX_WITH_NETFLT)
    492493    /* Populating interface list */
    493494    populateInterfacesList();
     495#endif
    494496
    495497    /* Applying language settings */
     
    549551                                       QTreeWidgetItem *)
    550552{
    551 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
    552     VBoxNIListItem *item = aCurrent &&
    553         aCurrent->type() == VBoxNIListItem::typeId ?
    554         static_cast<VBoxNIListItem*> (aCurrent) : 0;
    555     mDelAction->setEnabled (item && !item->isWrong());
     553# if defined (Q_WS_WIN)
     554#  if defined (VBOX_WITH_NETFLT)
     555    if(mEnmAttachmentType == KNetworkAttachmentType_HostOnly)
     556#  endif
     557    {
     558        VBoxNIListItem *item = aCurrent &&
     559            aCurrent->type() == VBoxNIListItem::typeId ?
     560            static_cast<VBoxNIListItem*> (aCurrent) : 0;
     561        mDelAction->setEnabled (item && !item->isWrong());
     562    }
     563#  if defined (VBOX_WITH_NETFLT)
     564    else
     565    {
     566        mDelAction->setEnabled (false);
     567    }
     568#  endif
    556569# else
    557570    NOREF (aCurrent);
     
    564577void VBoxNIList::addHostInterface()
    565578{
    566 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     579# if defined (Q_WS_WIN)
    567580    /* Allow the started helper process to make itself the foreground window */
    568581    AllowSetForegroundWindow (ASFW_ANY);
     
    607620    /* Allow the started helper process to make itself the foreground window */
    608621    AllowSetForegroundWindow (ASFW_ANY);
    609 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
     622# endif /* Q_WS_WIN */
    610623}
    611624
     
    614627    Assert (mList->currentItem());
    615628
    616 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     629# if defined (Q_WS_WIN)
    617630    /* Allow the started helper process to make itself the foreground window */
    618631    AllowSetForegroundWindow (ASFW_ANY);
     
    664677
    665678    emit listChanged();
    666 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
     679# endif /* Q_WS_WIN */
    667680}
    668681
     
    673686    mList->setWhatsThis (tr ("Lists all available host interfaces."));
    674687
    675 # if defined (Q_WS_WIN) && !defined (VBOX_WITH_NETFLT)
     688# if defined (Q_WS_WIN)
    676689    mAddAction->setText (tr ("A&dd New Host Interface"));
    677690    mDelAction->setText (tr ("&Remove Selected Host Interface"));
     
    682695    mDelAction->setToolTip (mDelAction->text().remove ('&') +
    683696        QString (" (%1)").arg (mDelAction->shortcut().toString()));
    684 # endif /* Q_WS_WIN && !VBOX_WITH_NETFLT */
    685 }
    686 
     697# endif /* Q_WS_WIN */
     698}
     699
     700#if defined(Q_WS_WIN) && defined(VBOX_WITH_NETFLT)
     701void VBoxNIList::updateInterfacesList(KNetworkAttachmentType enmAttachmentType)
     702{
     703    bool bHostOnly = enmAttachmentType == KNetworkAttachmentType_HostOnly;
     704    mEnmAttachmentType = enmAttachmentType;
     705    mAddAction->setEnabled(bHostOnly);
     706    mDelAction->setEnabled(bHostOnly);
     707    populateInterfacesList(enmAttachmentType);
     708}
     709
     710void VBoxNIList::populateInterfacesList(KNetworkAttachmentType enmAttachmentType)
     711#else
    687712void VBoxNIList::populateInterfacesList()
     713#endif
    688714{
    689715    /* Load current inner list */
    690716    QList<QTreeWidgetItem*> itemsList;
    691717    CHostNetworkInterfaceVector interfaces =
    692         vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces();
     718#if defined(Q_WS_WIN) && defined(VBOX_WITH_NETFLT)
     719            enmAttachmentType == KNetworkAttachmentType_HostOnly ?
     720                    vboxGlobal().virtualBox().GetHost().GetTapInterfaces()
     721                    :
     722#endif
     723                    vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces();
    693724    for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin();
    694725         it != interfaces.end(); ++it)
     
    897928    VBoxVMSettingsNetwork *page =
    898929        static_cast <VBoxVMSettingsNetwork*> (mTwAdapters->currentWidget());
    899 
    900     bool isHostInterfaceAttached = vboxGlobal().toNetworkAttachmentType (
    901         page->mCbNAType->currentText()) == KNetworkAttachmentType_HostInterface;
     930    KNetworkAttachmentType enmType = vboxGlobal().toNetworkAttachmentType (page->mCbNAType->currentText());
     931
     932    bool isHostInterfaceAttached = enmType == KNetworkAttachmentType_HostInterface;
    902933
    903934    mNIList->setEnabled (isHostInterfaceAttached);
     935# ifdef Q_WS_WIN
     936    if(!isHostInterfaceAttached)
     937    {
     938        mNIList->setEnabled (enmType == KNetworkAttachmentType_HostOnly);
     939    }
     940    mNIList->updateInterfacesList(enmType);
     941# endif
    904942}
    905943#endif
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