VirtualBox

Changeset 18832 in vbox


Ignore:
Timestamp:
Apr 7, 2009 3:59:10 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45838
Message:

FE/Qt4: 3808: Network settings not intuitive: default values set for three alternatives (bridged-interface, internal network, host-only interface) - this will allow the user to avoid entering network details at all "by default".

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

Legend:

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

    r17901 r18832  
    8181    VBoxVMSettingsNetworkPage();
    8282
    83     QStringList netList() const;
    84     QStringList intList (KHostNetworkInterfaceType aType) const;
     83    QStringList intList (bool aRefresh = false);
     84    QStringList brgList (bool aRefresh = false);
     85    QStringList hoiList (bool aRefresh = false);
    8586
    8687protected:
     
    9899    QIWidgetValidator *mValidator;
    99100    QTabWidget *mTwAdapters;
     101
     102    QStringList mIntList;
     103    QStringList mBrgList;
     104    QStringList mHoiList;
    100105};
    101106
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsNetworkDetails.h

    r18733 r18832  
    6161
    6262    void populateComboboxes();
     63    void saveAlternative();
    6364    QComboBox* comboBox() const;
    6465
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetwork.cpp

    r18591 r18832  
    177177void VBoxVMSettingsNetwork::updateAttachmentInfo()
    178178{
     179    KNetworkAttachmentType type = attachmentType();
     180
     181    /* Reload alternate list */
     182    switch (type)
     183    {
     184        case KNetworkAttachmentType_Bridged:
     185            mDetails->loadList (type, mParent->brgList());
     186            break;
     187        case KNetworkAttachmentType_Internal:
     188            mDetails->loadList (type, mParent->intList());
     189            break;
     190        case KNetworkAttachmentType_HostOnly:
     191            mDetails->loadList (type, mParent->hoiList());
     192            break;
     193        default:
     194            break;
     195    }
     196
     197    /* Update information */
    179198    QString line ("<tr><td><i><b><nobr><font color=grey>%1:&nbsp;</font></nobr></b></i></td>"
    180199                  "<td><i><font color=grey>%2</font></i></td></tr>");
     
    182201
    183202    /* Append alternative information */
    184     KNetworkAttachmentType type = attachmentType();
    185203    switch (type)
    186204    {
     
    234252    /* Lock the button to avoid double-click bug */
    235253    mTbDetails->setEnabled (false);
    236     /* Reload alternate list */
    237     KNetworkAttachmentType type = attachmentType();
    238     QStringList list;
    239     switch (type)
    240     {
    241         case KNetworkAttachmentType_Bridged:
    242             list = mParent->intList (KHostNetworkInterfaceType_Bridged);
    243             break;
    244         case KNetworkAttachmentType_Internal:
    245             list = mParent->netList();
    246             break;
    247         case KNetworkAttachmentType_HostOnly:
    248             list = mParent->intList (KHostNetworkInterfaceType_HostOnly);
    249             break;
    250         default:
    251             break;
    252     }
    253     mDetails->loadList (type, list);
     254
     255    /* Show details sub-dialog */
    254256    mDetails->activateWindow();
    255257    mDetails->exec();
    256258    updateAttachmentInfo();
     259
    257260    /* Unlock the previously locked button */
    258261    mTbDetails->setEnabled (true);
     
    367370}
    368371
    369 QStringList VBoxVMSettingsNetworkPage::netList() const
    370 {
    371     QStringList list;
    372 
    373     /* Load total network list of all VMs */
    374     CVirtualBox vbox = vboxGlobal().virtualBox();
    375     ulong count = qMin ((ULONG) 4, vbox.GetSystemProperties().GetNetworkAdapterCount());
    376     CMachineVector vec =  vbox.GetMachines();
    377     for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m)
    378     {
    379         if (m->GetAccessible())
    380         {
    381             for (ulong slot = 0; slot < count; ++ slot)
     372QStringList VBoxVMSettingsNetworkPage::intList (bool aRefresh)
     373{
     374    if (aRefresh)
     375    {
     376        /* Load total network list of all VMs */
     377        mIntList.clear();
     378        CVirtualBox vbox = vboxGlobal().virtualBox();
     379        ulong count = qMin ((ULONG) 4, vbox.GetSystemProperties().GetNetworkAdapterCount());
     380        CMachineVector vec = vbox.GetMachines();
     381        for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m)
     382        {
     383            if (m->GetAccessible())
    382384            {
    383                 QString name = m->GetNetworkAdapter (slot).GetInternalNetwork();
    384                 if (!name.isEmpty() && !list.contains (name))
    385                     list << name;
     385                for (ulong slot = 0; slot < count; ++ slot)
     386                {
     387                    QString name = m->GetNetworkAdapter (slot).GetInternalNetwork();
     388                    if (!name.isEmpty() && !mIntList.contains (name))
     389                        mIntList << name;
     390                }
    386391            }
    387392        }
     
    389394
    390395    /* Append network list with names from all the pages */
     396    QStringList list (mIntList);
    391397    for (int index = 0; index < mTwAdapters->count(); ++ index)
    392398    {
     
    404410}
    405411
    406 QStringList VBoxVMSettingsNetworkPage::intList (KHostNetworkInterfaceType aType) const
    407 {
    408     QStringList list;
    409 
    410     /* Load total interfaces list */
    411     CHostNetworkInterfaceVector interfaces =
    412         vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces();
    413     for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin();
    414          it != interfaces.end(); ++ it)
    415     {
    416         if (it->GetInterfaceType() == aType)
    417             list << it->GetName();
    418     }
    419 
    420     return list;
     412QStringList VBoxVMSettingsNetworkPage::brgList (bool aRefresh)
     413{
     414    if (aRefresh)
     415    {
     416        mBrgList.clear();
     417        CHostNetworkInterfaceVector interfaces =
     418            vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces();
     419        for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin();
     420             it != interfaces.end(); ++ it)
     421        {
     422            if (it->GetInterfaceType() == KHostNetworkInterfaceType_Bridged)
     423                mBrgList << it->GetName();
     424        }
     425    }
     426
     427    return mBrgList;
     428}
     429
     430QStringList VBoxVMSettingsNetworkPage::hoiList (bool aRefresh)
     431{
     432    if (aRefresh)
     433    {
     434        mHoiList.clear();
     435        CHostNetworkInterfaceVector interfaces =
     436            vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces();
     437        for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin();
     438             it != interfaces.end(); ++ it)
     439        {
     440            if (it->GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
     441                mHoiList << it->GetName();
     442        }
     443    }
     444
     445    return mHoiList;
    421446}
    422447
     
    427452    setTabOrder (mFirstWidget, mTwAdapters->focusProxy());
    428453    QWidget *lastFocusWidget = mTwAdapters->focusProxy();
     454
     455    /* Cache data */
     456    intList (true);
     457    brgList (true);
     458    hoiList (true);
    429459
    430460    /* Creating Tab Pages */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetworkDetails.cpp

    r18829 r18832  
    133133    {
    134134        comboBox()->clear();
     135        comboBox()->insertItems (comboBox()->count(), aList);
    135136        populateComboboxes();
    136         comboBox()->insertItems (comboBox()->count(), aList);
    137137        int pos = comboBox()->findText (currentName());
    138138        comboBox()->setCurrentIndex (pos == -1 ? 0 : pos);
     139        saveAlternative();
    139140    }
    140141
     
    253254{
    254255    /* Save temporary attributes as dynamic properties */
    255     switch (mType)
    256     {
    257         case KNetworkAttachmentType_Bridged:
    258             setProperty ("BRG_Name",
    259                          QVariant (mCbBRG->itemData (mCbBRG->currentIndex()).toString() == QString (emptyItemCode) ?
    260                                    QString::null : mCbBRG->currentText()));
    261             break;
    262         case KNetworkAttachmentType_Internal:
    263             setProperty ("INT_Name",
    264                          QVariant (mCbINT->itemData (mCbINT->currentIndex()).toString() == QString (emptyItemCode) &&
    265                                    mCbINT->currentText() == mCbINT->itemText (mCbINT->currentIndex()) ?
    266                                    QString::null : mCbINT->currentText()));
    267             break;
    268         case KNetworkAttachmentType_HostOnly:
    269             setProperty ("HOI_Name",
    270                          QVariant (mCbHOI->itemData (mCbHOI->currentIndex()).toString() == QString (emptyItemCode) ?
    271                                    QString::null : mCbHOI->currentText()));
    272             break;
    273         default:
    274             break;
    275     }
     256    saveAlternative();
    276257    setProperty ("MAC_Address", QVariant (mLeMAC->text()));
    277258    setProperty ("Cable_Connected", QVariant (mCbCable->isChecked()));
     
    288269void VBoxVMSettingsNetworkDetails::populateComboboxes()
    289270{
    290     {   /* Bridged adapters combo-box */
     271    if (mCbBRG->count() == 0)
     272    {
     273        /* Bridged adapters combo-box */
    291274        int pos = mCbBRG->findData (emptyItemCode);
    292275        if (pos == -1)
     
    297280            mCbBRG->setItemText (pos,
    298281                VBoxVMSettingsNetwork::tr ("Not selected", "adapter"));
    299     }   /* Bridged adapters combo-box */
    300 
    301     {   /* Internal networks combo-box */
    302         int pos = mCbINT->findData (emptyItemCode);
    303         if (pos == -1)
    304             mCbINT->insertItem (0,
    305                 VBoxVMSettingsNetwork::tr ("Not selected", "network"),
    306                 emptyItemCode);
    307         else
    308             mCbINT->setItemText (pos,
    309                 VBoxVMSettingsNetwork::tr ("Not selected", "network"));
    310     }   /* Internal networks combo-box */
    311 
    312     {   /* Host-only adapters combo-box */
     282    }
     283
     284    if (mCbINT->count() == 0)
     285    {
     286        /* Internal networks combo-box default value */
     287        if (mCbINT->findText ("intnet") == -1)
     288            mCbINT->insertItem (0, "intnet");
     289    }
     290
     291    if (mCbHOI->count() == 0)
     292    {
     293        /* Host-only adapters combo-box */
    313294        int pos = mCbHOI->findData (emptyItemCode);
    314295        if (pos == -1)
     
    319300            mCbHOI->setItemText (pos,
    320301                VBoxVMSettingsNetwork::tr ("Not selected", "adapter"));
    321     }   /* Host-only adapters combo-box */
     302    }
     303}
     304
     305void VBoxVMSettingsNetworkDetails::saveAlternative()
     306{
     307    /* Save alternative attributes as temporary dynamic properties */
     308    switch (mType)
     309    {
     310        case KNetworkAttachmentType_Bridged:
     311            setProperty ("BRG_Name",
     312                         QVariant (mCbBRG->itemData (mCbBRG->currentIndex()).toString() == QString (emptyItemCode) ?
     313                                   QString::null : mCbBRG->currentText()));
     314            break;
     315        case KNetworkAttachmentType_Internal:
     316            setProperty ("INT_Name",
     317                         QVariant (mCbINT->itemData (mCbINT->currentIndex()).toString() == QString (emptyItemCode) &&
     318                                   mCbINT->currentText() == mCbINT->itemText (mCbINT->currentIndex()) ?
     319                                   QString::null : mCbINT->currentText()));
     320            break;
     321        case KNetworkAttachmentType_HostOnly:
     322            setProperty ("HOI_Name",
     323                         QVariant (mCbHOI->itemData (mCbHOI->currentIndex()).toString() == QString (emptyItemCode) ?
     324                                   QString::null : mCbHOI->currentText()));
     325            break;
     326        default:
     327            break;
     328    }
    322329}
    323330
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