Changeset 9951 in vbox
- Timestamp:
- Jun 26, 2008 12:17:43 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsNetwork.h
r9751 r9951 28 28 #include "COMDefs.h" 29 29 30 class QIWidgetValidator; 30 31 class VBoxVMSettingsDlg; 31 class QIWidgetValidator; 32 #ifdef Q_WS_WIN 33 class QTreeWidget; 34 class QTreeWidgetItem; 35 #endif 32 36 37 /* 38 * QWidget sub-class which represents one tab-page per each network adapter. 39 * It has generated UI part. 40 */ 33 41 class VBoxVMSettingsNetwork : public QIWithRetranslateUI<QWidget>, 34 42 public Ui::VBoxVMSettingsNetwork … … 38 46 public: 39 47 40 VBoxVMSettingsNetwork (QWidget *aParent = NULL); 41 42 static void getFromMachine (const CMachine &aMachine, 43 QWidget *aPage, 44 VBoxVMSettingsDlg *aDlg, 45 const QString &aPath); 46 static void putBackToMachine(); 47 static bool revalidate (QString &aWarning, QString &aTitle); 48 49 void loadListNetworks (const QStringList &aList); 48 VBoxVMSettingsNetwork(); 50 49 51 50 void getFromAdapter (const CNetworkAdapter &aAdapter); 52 51 void putBackToAdapter(); 53 52 53 QString pageTitle() const; 54 54 55 void setValidator (QIWidgetValidator *aValidator); 56 void setNetworksList (const QStringList &aList); 57 58 #ifdef Q_WS_WIN 59 void setInterfaceName (const QString &); 60 QString interfaceName() const; 61 #endif 55 62 56 63 protected: … … 59 66 60 67 private slots: 61 62 static void updateListNetworks();63 // #ifdef Q_WS_WIN64 // static void addHostInterface();65 // static void delHostInterface();66 // #endif67 68 68 69 void adapterToggled (bool aOn); … … 76 77 private: 77 78 78 QString pageTitle() const;79 79 void prepareComboboxes(); 80 80 81 static void prepareListNetworks(); 82 // #ifdef Q_WS_WIN 83 // static void prepareListInterfaces(); 84 // #endif 81 CNetworkAdapter mAdapter; 82 QIWidgetValidator *mValidator; 83 84 #ifdef Q_WS_WIN 85 QString mInterfaceName; 86 #endif 87 }; 88 89 90 #ifdef Q_WS_WIN 91 /* 92 * QGroupBox sub-class which represents network interface list. 93 */ 94 class VBoxNIList : public QIWithRetranslateUI<QGroupBox> 95 { 96 Q_OBJECT; 97 98 public: 99 100 VBoxNIList (QWidget *aParent); 101 102 bool isWrongInterface() const; 103 void setCurrentInterface (const QString &aName); 104 105 signals: 106 107 void listChanged(); 108 void currentInterfaceChanged (const QString &); 109 110 private slots: 111 112 void onCurrentItemChanged (QTreeWidgetItem *aCurrent, QTreeWidgetItem *aPrev = 0); 113 void addHostInterface(); 114 void delHostInterface(); 115 116 protected: 117 118 void retranslateUi(); 119 120 private: 121 122 void populateInterfacesList(); 123 124 QTreeWidget *mList; 125 126 QAction *mAddAction; 127 QAction *mDelAction; 128 }; 129 #endif 130 131 132 /* 133 * QWidget sub-class which represents network settings page itself. 134 */ 135 class VBoxVMSettingsNetworkPage : public QIWithRetranslateUI<QWidget> 136 { 137 Q_OBJECT; 138 139 public: 140 141 static void getFromMachine (const CMachine &aMachine, 142 QWidget *aPage, 143 VBoxVMSettingsDlg *aDlg, 144 const QString &aPath); 145 static void putBackToMachine(); 146 static bool revalidate (QString &aWarning, QString &aTitle); 147 148 protected slots: 149 150 void updateNetworksList(); 151 #ifdef Q_WS_WIN 152 void onCurrentPageChanged (int); 153 void onCurrentInterfaceChanged (const QString &); 154 #endif 155 156 protected: 157 158 VBoxVMSettingsNetworkPage (QWidget *aParent); 159 160 void getFrom (const CMachine &aMachine, 161 VBoxVMSettingsDlg *aDlg, 162 const QString &aPath); 163 void putBackTo(); 164 bool validate (QString &aWarning, QString &aTitle); 165 166 void retranslateUi(); 167 168 void populateNetworksList(); 169 170 static VBoxVMSettingsNetworkPage *mSettings; 85 171 86 172 /* Widgets */ 87 static QTabWidget *mTwAdapters; 88 // #ifdef Q_WS_WIN 89 // static QGroupBox *mGbInterfaces; 90 // static QListWidget *mLwInterfaces; 91 // #endif 173 QTabWidget *mTwAdapters; 174 #ifdef Q_WS_WIN 175 VBoxNIList *mNIList; 176 #endif 92 177 93 /* Actions */ 94 // #ifdef Q_WS_WIN 95 // static QAction *mAddAction; 96 // static QAction *mDelAction; 97 // #endif 178 /* Lists */ 179 QStringList mListNetworks; 98 180 99 181 /* Flags */ 100 static bool mLockNetworkListUpdate; 101 102 /* Lists */ 103 static QStringList mListNetworks; 104 // #ifdef Q_WS_WIN 105 // static QStringList mListInterface; 106 // static QString mNoInterfaces; 107 // #endif 108 109 QIWidgetValidator *mValidator; 110 CNetworkAdapter mAdapter; 111 // #ifdef Q_WS_WIN 112 // QString mInterface_win; 113 // #endif 182 bool mLockNetworkListUpdate; 114 183 }; 115 184 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsUtils.h
r9782 r9951 26 26 #include <VBoxGlobal.h> 27 27 28 //#include <QDialog> 29 //#include <QLineEdit> 30 //#include <QPushButton> 28 #ifdef Q_WS_WIN 29 #include <QDialog> 30 #include <QLineEdit> 31 #include <QPushButton> 32 #endif 31 33 #include <QHBoxLayout> 32 34 #include <QLabel> … … 101 103 }; 102 104 103 //#ifdef Q_WS_WIN104 / / /**105 //* QDialog class reimplementation to use for adding network interface.106 //* It has one line-edit field for entering network interface's name and107 //* common dialog's ok/cancel buttons.108 //*/109 //class VBoxAddNIDialog : public QDialog110 //{111 //Q_OBJECT112 // 113 //public:114 // 115 //VBoxAddNIDialog (QWidget *aParent, const QString &aIfaceName) :116 //QDialog (aParent),117 //mLeName (0)118 //{119 //setWindowTitle (tr ("Add Host Interface"));120 //QVBoxLayout *mainLayout = new QVBoxLayout (this);121 // 122 ///* Setup Input layout */123 //QHBoxLayout *inputLayout = new QHBoxLayout();124 //QLabel *lbName = new QLabel (tr ("Interface Name"), this);125 //mLeName = new QLineEdit (aIfaceName, this);126 //mLeName->setWhatsThis (tr ("Descriptive name of the new "127 //"network interface"));128 //inputLayout->addWidget (lbName);129 //inputLayout->addWidget (mLeName);130 //connect (mLeName, SIGNAL (textChanged (const QString &)),131 //this, SLOT (validate()));132 //mainLayout->addLayout (inputLayout);133 // 134 ///* Setup Button layout */135 //QHBoxLayout *buttonLayout = new QHBoxLayout();136 //mBtOk = new QPushButton (tr ("&OK"), this);137 //QPushButton *btCancel = new QPushButton (tr ("Cancel"), this);138 //connect (mBtOk, SIGNAL (clicked()), this, SLOT (accept()));139 //connect (btCancel, SIGNAL (clicked()), this, SLOT (reject()));140 //buttonLayout->addWidget (mBtOk);141 //buttonLayout->addStretch();142 //buttonLayout->addWidget (btCancel);143 //mainLayout->addLayout (buttonLayout);144 // 145 // /* resize to fit the aIfaceName in one string */146 //int requiredWidth = mLeName->fontMetrics().width (aIfaceName) +147 //inputLayout->spacing() +148 //lbName->fontMetrics().width (lbName->text()) +149 //lbName->frameWidth() * 2 +150 //lbName->lineWidth() * 2 +151 //mainLayout->margin() * 2;152 //resize (requiredWidth, minimumHeight());153 // 154 ///* Validate interface name field */155 //validate();156 //}157 // 158 //~VBoxAddNIDialog() {}159 // 160 //QString getName() { return mLeName->text(); }161 // 162 //private slots:163 // 164 //void validate()165 //{166 //mBtOk->setEnabled (!mLeName->text().isEmpty());167 //}168 // 169 //private:170 // 171 //void showEvent (QShowEvent *aEvent)172 //{173 //setFixedHeight (height());174 //QDialog::showEvent (aEvent);175 //}176 // 177 //QPushButton *mBtOk;178 //QLineEdit *mLeName;179 //};180 //#endif105 #ifdef Q_WS_WIN 106 /** 107 * QDialog class reimplementation to use for adding network interface. 108 * It has one line-edit field for entering network interface's name and 109 * common dialog's ok/cancel buttons. 110 */ 111 class VBoxAddNIDialog : public QDialog 112 { 113 Q_OBJECT 114 115 public: 116 117 VBoxAddNIDialog (QWidget *aParent, const QString &aIfaceName) : 118 QDialog (aParent), 119 mLeName (0) 120 { 121 setWindowTitle (tr ("Add Host Interface")); 122 QVBoxLayout *mainLayout = new QVBoxLayout (this); 123 124 /* Setup Input layout */ 125 QHBoxLayout *inputLayout = new QHBoxLayout(); 126 QLabel *lbName = new QLabel (tr ("Interface Name"), this); 127 mLeName = new QLineEdit (aIfaceName, this); 128 mLeName->setWhatsThis (tr ("Descriptive name of the new " 129 "network interface")); 130 inputLayout->addWidget (lbName); 131 inputLayout->addWidget (mLeName); 132 connect (mLeName, SIGNAL (textChanged (const QString &)), 133 this, SLOT (validate())); 134 mainLayout->addLayout (inputLayout); 135 136 /* Setup Button layout */ 137 QHBoxLayout *buttonLayout = new QHBoxLayout(); 138 mBtOk = new QPushButton (tr ("&OK"), this); 139 QPushButton *btCancel = new QPushButton (tr ("Cancel"), this); 140 connect (mBtOk, SIGNAL (clicked()), this, SLOT (accept())); 141 connect (btCancel, SIGNAL (clicked()), this, SLOT (reject())); 142 buttonLayout->addWidget (mBtOk); 143 buttonLayout->addStretch(); 144 buttonLayout->addWidget (btCancel); 145 mainLayout->addLayout (buttonLayout); 146 147 /* Resize to fit the aIfaceName in one string */ 148 int requiredWidth = mLeName->fontMetrics().width (aIfaceName) + 149 inputLayout->spacing() + 150 lbName->fontMetrics().width (lbName->text()) + 151 lbName->frameWidth() * 2 + 152 lbName->lineWidth() * 2 + 153 mainLayout->margin() * 2; 154 resize (requiredWidth, minimumHeight()); 155 156 /* Validate interface name field */ 157 validate(); 158 } 159 160 ~VBoxAddNIDialog() {} 161 162 QString getName() { return mLeName->text(); } 163 164 private slots: 165 166 void validate() 167 { 168 mBtOk->setEnabled (!mLeName->text().isEmpty()); 169 } 170 171 private: 172 173 void showEvent (QShowEvent *aEvent) 174 { 175 setFixedHeight (height()); 176 QDialog::showEvent (aEvent); 177 } 178 179 QPushButton *mBtOk; 180 QLineEdit *mLeName; 181 }; 182 #endif 181 183 182 184 class USBListItem : public QTreeWidgetItem -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsDlg.cpp
r9889 r9951 202 202 203 203 /* Network */ 204 VBoxVMSettingsNetwork ::getFromMachine (aMachine, mPageNetwork,205 this, pagePath (mPageNetwork));204 VBoxVMSettingsNetworkPage::getFromMachine (aMachine, mPageNetwork, 205 this, pagePath (mPageNetwork)); 206 206 207 207 /* Serial Ports */ … … 258 258 259 259 /* Network */ 260 VBoxVMSettingsNetwork ::putBackToMachine();260 VBoxVMSettingsNetworkPage::putBackToMachine(); 261 261 262 262 /* Serial ports */ … … 371 371 valid = VBoxVMSettingsFD::revalidate (warningText); 372 372 else if (pg == mPageNetwork) 373 valid = VBoxVMSettingsNetwork ::revalidate (warningText, pageTitle);373 valid = VBoxVMSettingsNetworkPage::revalidate (warningText, pageTitle); 374 374 else if (pg == mPageSerial) 375 375 valid = VBoxVMSettingsSerial::revalidate (warningText, pageTitle); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsNetwork.cpp
r9751 r9951 21 21 */ 22 22 23 /* Common Includes */ 23 24 #include "VBoxVMSettingsNetwork.h" 24 25 #include "VBoxVMSettingsDlg.h" 25 26 #include "QIWidgetValidator.h" 26 27 #include "VBoxGlobal.h" 27 28 /* Qt includes */ 28 #ifdef Q_WS_WIN 29 #include "VBoxToolBar.h" 30 #include "VBoxVMSettingsUtils.h" 31 #include "VBoxProblemReporter.h" 32 #endif 33 34 /* Qt Includes */ 35 #ifdef Q_WS_X11 29 36 #include <QFileDialog> 30 31 // #ifdef Q_WS_WIN 32 // static QListWidgetItem* findItem (QListWidget *aList, 33 // const QString &aMatch) 34 // { 35 // QList<QListWidgetItem*> list = 36 // aList->findItems (aMatch, Qt::MatchExactly); 37 // 38 // return list.count() ? list [0] : 0; 39 // } 40 //#endif 41 42 /* Initialization of variables common for all pages */ 43 QTabWidget* VBoxVMSettingsNetwork::mTwAdapters = 0; 44 // #ifdef Q_WS_WIN 45 // QGroupBox* VBoxVMSettingsNetwork::mGbInterfaces = 0; 46 // QListWidget* VBoxVMSettingsNetwork::mLwInterfaces = 0; 47 // QAction* VBoxVMSettingsNetwork::mAddAction = 0; 48 // QAction* VBoxVMSettingsNetwork::mDelAction = 0; 49 // #endif 50 bool VBoxVMSettingsNetwork::mLockNetworkListUpdate = true; 51 QStringList VBoxVMSettingsNetwork::mListNetworks = QStringList(); 52 // #ifdef Q_WS_WIN 53 // QStringList VBoxVMSettingsNetwork::mListInterface = QStringList(); 54 // QString VBoxVMSettingsNetwork::mNoInterfaces = tr ("<No suitable interfaces>"); 55 // #endif 56 57 VBoxVMSettingsNetwork::VBoxVMSettingsNetwork(QWidget *aParent /* = NULL */) 58 : QIWithRetranslateUI<QWidget> (aParent) 37 #endif 38 #ifdef Q_WS_WIN 39 #include <QTreeWidget> 40 #endif 41 42 /* Common Stuff */ 43 #ifdef Q_WS_WIN 44 static QTreeWidgetItem* findItem (QTreeWidget *aList, 45 const QString &aMatch) 46 { 47 QList<QTreeWidgetItem*> list = 48 aList->findItems (aMatch, Qt::MatchExactly, 0); 49 return list.count() ? list [0] : 0; 50 } 51 #endif 52 53 54 /* VBoxVMSettingsNetwork Stuff */ 55 VBoxVMSettingsNetwork::VBoxVMSettingsNetwork() 56 : QIWithRetranslateUI<QWidget> (0) 59 57 , mValidator (0) 60 58 { … … 67 65 68 66 /* Setup dialog for current platform */ 69 70 67 #ifndef Q_WS_X11 71 68 mGbTAP->setHidden (true); 72 69 #endif 73 74 70 #ifdef Q_WS_MAC 75 71 /* No Host Interface Networking on the Mac yet */ 76 72 mGbTAP->setHidden (true); 77 73 #endif 78 79 74 #ifdef Q_WS_X11 80 75 /* Setup iconsets */ … … 89 84 } 90 85 91 void VBoxVMSettingsNetwork::getFromMachine (const CMachine &aMachine,92 QWidget *aPage,93 VBoxVMSettingsDlg *aDlg,94 const QString &aPath)95 {96 /* Creating Page Layout */97 QVBoxLayout *layout = new QVBoxLayout (aPage);98 layout->setContentsMargins (0, 5, 0, 0);99 100 /* Creating Tab Widget */101 mTwAdapters = new QTabWidget (aPage);102 layout->addWidget (mTwAdapters);103 104 /* Prepare networks & interfaces lists */105 prepareListNetworks();106 // #ifdef Q_WS_WIN107 // prepareListInterfaces();108 // #endif109 110 // #ifdef Q_WS_WIN111 // /* Creating Tree Widget */112 // mGbInterfaces = new QGroupBox (aPage);113 // layout->addWidget (mGbInterfaces);114 // QHBoxLayout *iLayout = new QHBoxLayout (mGbInterfaces);115 // mLwInterfaces = new QListWidget (mGbInterfaces);116 // mLwInterfaces->setContextMenuPolicy (Qt::ActionsContextMenu);117 // iLayout->addWidget (mLwInterfaces);118 //119 // /* Prepare actions */120 // mAddAction = new QAction (mLwInterfaces);121 // mDelAction = new QAction (mLwInterfaces);122 // mAddAction->setText (tr ("A&dd New Host Interface"));123 // mDelAction->setText (tr ("&Remove Selected Host Interface"));124 // mAddAction->setShortcut (QKeySequence ("Ins"));125 // mDelAction->setShortcut (QKeySequence ("Del"));126 // mAddAction->setToolTip (mAddAction->text().remove ('&') +127 // QString (" (%1)").arg (mAddAction->shortcut().toString()));128 // mDelAction->setToolTip (mDelAction->text().remove ('&') +129 // QString (" (%1)").arg (mDelAction->shortcut().toString()));130 // mAddAction->setWhatsThis (tr ("Adds a new host interface."));131 // mDelAction->setWhatsThis (tr ("Removes the selected host interface."));132 // mAddAction->setIcon (VBoxGlobal::iconSet (":/add_host_iface_16px.png",133 // ":/add_host_iface_disabled_16px.png"));134 // mDelAction->setIcon (VBoxGlobal::iconSet (":/remove_host_iface_16px.png",135 // ":/remove_host_iface_disabled_16px.png"));136 // connect (mAddAction, SIGNAL (clicked()), this, SLOT (addHostInterface()));137 // connect (mDelAction, SIGNAL (clicked()), this, SLOT (delHostInterface()));138 //139 // /* Prepare toolbar */140 // VBoxToolBar *toolBar = new VBoxToolBar (mGbInterfaces);141 // toolBar->setUsesTextLabel (false);142 // toolBar->setUsesBigPixmaps (false);143 // toolBar->setOrientation (Qt::Vertical);144 // toolBar->addAction (mAddAction);145 // toolBar->addAction (mDelAction);146 // iLayout->addWidget (toolBar);147 // #endif148 149 /* Creating Tab Pages */150 CVirtualBox vbox = vboxGlobal().virtualBox();151 ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount();152 for (ulong slot = 0; slot < count; ++ slot)153 {154 /* Get Adapter */155 CNetworkAdapter adapter = aMachine.GetNetworkAdapter (slot);156 157 /* Creating Adapter's page */158 VBoxVMSettingsNetwork *page = new VBoxVMSettingsNetwork();159 160 /* Set the mAdapter member which is necessary for next pageTitle call. */161 page->mAdapter = adapter;162 /* Setup validation */163 QIWidgetValidator *wval =164 new QIWidgetValidator (QString ("%1: %2").arg (aPath, page->pageTitle()),165 aPage, aDlg);166 connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),167 aDlg, SLOT (enableOk (const QIWidgetValidator*)));168 connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)),169 aDlg, SLOT (revalidate (QIWidgetValidator*)));170 171 page->setValidator (wval);172 173 /* Loading Adapter's data into page */174 page->loadListNetworks (mListNetworks);175 page->getFromAdapter (adapter);176 177 /* Attach Adapter's page to Tab Widget */178 mTwAdapters->addTab (page, page->pageTitle());179 }180 181 layout->addStretch();182 }183 184 void VBoxVMSettingsNetwork::putBackToMachine()185 {186 for (int index = 0; index < mTwAdapters->count(); ++ index)187 {188 VBoxVMSettingsNetwork *page =189 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index));190 if (page)191 page->putBackToAdapter();192 }193 }194 195 bool VBoxVMSettingsNetwork::revalidate (QString &aWarning, QString &aTitle)196 {197 bool valid = true;198 199 for (int index = 0; index < mTwAdapters->count(); ++ index)200 {201 VBoxVMSettingsNetwork *page =202 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index));203 Assert (page);204 205 KNetworkAttachmentType type =206 vboxGlobal().toNetworkAttachmentType (page->mCbNAType->currentText());207 208 // #ifdef Q_WS_WIN209 // if (type == KNetworkAttachmentType_HostInterface &&210 // mListInterface.indexOf (mLwInterfaces->currentItem()->text()) == -1)211 // {212 // valid = false;213 // aWarning = tr ("Incorrect host network interface is selected");214 // }215 // else216 // #endif217 if (type == KNetworkAttachmentType_Internal &&218 page->mCbNetwork->currentText().isEmpty())219 {220 valid = false;221 aWarning = tr ("Internal network name is not set");222 }223 224 if (!valid)225 {226 aTitle += ": " +227 mTwAdapters->tabText (mTwAdapters->indexOf (page));228 break;229 }230 }231 232 return valid;233 }234 235 void VBoxVMSettingsNetwork::loadListNetworks (const QStringList &aList)236 {237 QString curText = mCbNetwork->currentText();238 mCbNetwork->clear();239 mCbNetwork->clearEditText();240 mCbNetwork->insertItems (0, aList);241 mCbNetwork->setCurrentIndex (mCbNetwork->findText (curText));242 mValidator->revalidate();243 }244 245 86 void VBoxVMSettingsNetwork::getFromAdapter (const CNetworkAdapter &aAdapter) 246 87 { … … 265 106 mCbNetwork->setCurrentIndex (inPos == -1 ? 0 : inPos); 266 107 267 // #ifdef Q_WS_WIN 268 // mInterface_win = aAdapter.GetHostInterface(); 269 // #endif 108 #ifdef Q_WS_WIN 109 mInterfaceName = aAdapter.GetHostInterface().isEmpty() ? 110 QString::null : aAdapter.GetHostInterface(); 111 #endif 270 112 #ifdef Q_WS_X11 271 113 mLeInterface_x11->setText (aAdapter.GetHostInterface()); … … 309 151 if (type == KNetworkAttachmentType_HostInterface) 310 152 { 311 //#ifdef Q_WS_WIN312 // mAdapter.SetHostInterface (mInterface_win);313 //#endif153 #ifdef Q_WS_WIN 154 mAdapter.SetHostInterface (mInterfaceName); 155 #endif 314 156 #ifdef Q_WS_X11 315 157 QString iface = mLeInterface_x11->text(); … … 325 167 } 326 168 169 QString VBoxVMSettingsNetwork::pageTitle() const 170 { 171 QString pageTitle; 172 if (!mAdapter.isNull()) 173 { 174 pageTitle = VBoxGlobal::tr ("Adapter %1", "network") 175 .arg (mAdapter.GetSlot()); 176 } 177 return pageTitle; 178 } 179 327 180 void VBoxVMSettingsNetwork::setValidator (QIWidgetValidator *aValidator) 328 181 { … … 335 188 connect (mCbNetwork, SIGNAL (activated (const QString&)), 336 189 mValidator, SLOT (revalidate())); 337 connect (mCbNetwork, SIGNAL (editTextChanged (const QString&)),338 this, SLOT (updateListNetworks()));339 190 connect (mPbMAC, SIGNAL (clicked()), this, SLOT (genMACClicked())); 340 191 #ifdef Q_WS_X11 … … 346 197 } 347 198 199 void VBoxVMSettingsNetwork::setNetworksList (const QStringList &aList) 200 { 201 QString curText = mCbNetwork->currentText(); 202 mCbNetwork->clear(); 203 mCbNetwork->clearEditText(); 204 mCbNetwork->insertItems (0, aList); 205 mCbNetwork->setCurrentIndex (mCbNetwork->findText (curText)); 206 if (mValidator) 207 mValidator->revalidate(); 208 } 209 210 #ifdef Q_WS_WIN 211 void VBoxVMSettingsNetwork::setInterfaceName (const QString &aName) 212 { 213 mInterfaceName = aName; 214 if (mValidator) 215 mValidator->revalidate(); 216 } 217 218 QString VBoxVMSettingsNetwork::interfaceName() const 219 { 220 return mInterfaceName; 221 } 222 #endif 348 223 349 224 void VBoxVMSettingsNetwork::retranslateUi() … … 352 227 Ui::VBoxVMSettingsNetwork::retranslateUi (this); 353 228 354 mTwAdapters->setTabText (mTwAdapters->indexOf (this), pageTitle());355 356 229 prepareComboboxes(); 357 230 } 358 231 232 void VBoxVMSettingsNetwork::adapterToggled (bool aOn) 233 { 234 if (!aOn) 235 { 236 mCbNAType->setCurrentIndex (0); 237 naTypeChanged (mCbNAType->currentText()); 238 } 239 if (mValidator) 240 mValidator->revalidate(); 241 } 359 242 360 243 void VBoxVMSettingsNetwork::naTypeChanged (const QString &aString) … … 369 252 mGbTAP->setEnabled (enableHostIf); 370 253 #endif 371 mValidator->revalidate(); 254 if (mValidator) 255 mValidator->revalidate(); 372 256 } 373 257 … … 397 281 } 398 282 #endif 399 400 void VBoxVMSettingsNetwork::adapterToggled (bool aOn)401 {402 if (!aOn)403 {404 mCbNAType->setCurrentIndex (0);405 naTypeChanged (mCbNAType->currentText());406 }407 mValidator->revalidate();408 }409 410 void VBoxVMSettingsNetwork::updateListNetworks()411 {412 if (mLockNetworkListUpdate)413 return;414 mLockNetworkListUpdate = true;415 416 QStringList curList (mListNetworks);417 for (int index = 0; index < mTwAdapters->count(); ++ index)418 {419 VBoxVMSettingsNetwork *page =420 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index));421 if (page)422 {423 QString curText = page->mCbNetwork->currentText();424 if (!curText.isEmpty() && !curList.contains (curText))425 curList << curText;426 }427 }428 429 for (int index = 0; index < mTwAdapters->count(); ++ index)430 {431 VBoxVMSettingsNetwork *page =432 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index));433 if (page)434 page->loadListNetworks (curList);435 }436 437 mLockNetworkListUpdate = false;438 }439 440 // #ifdef Q_WS_WIN441 // void VBoxVMSettingsNetwork::addHostInterface()442 // {443 // /* Allow the started helper process to make itself the foreground window */444 // AllowSetForegroundWindow (ASFW_ANY);445 //446 // /* Search for the max available interface index */447 // int ifaceNumber = 0;448 // QString ifaceName = tr ("VirtualBox Host Interface %1");449 // QRegExp regExp (QString ("^") + ifaceName.arg ("([0-9]+)") + QString ("$"));450 // for (int index = 0; index < mLwInterfaces->count(); ++ index)451 // {452 // QString iface = mLwInterfaces->item (index)->text();453 // int pos = regExp.indexIn (iface);454 // if (pos != -1)455 // ifaceNumber = regExp.cap (1).toInt() > ifaceNumber ?456 // regExp.cap (1).toInt() : ifaceNumber;457 // }458 //459 // /* Creating add host interface dialog */460 // VBoxAddNIDialog dlg (this, ifaceName.arg (++ ifaceNumber));461 // if (dlg.exec() != QDialog::Accepted)462 // return;463 // QString iName = dlg.getName();464 //465 // /* Create interface */466 // CHost host = vboxGlobal().virtualBox().GetHost();467 // CHostNetworkInterface iFace;468 // CProgress progress = host.CreateHostNetworkInterface (iName, iFace);469 // if (host.isOk())470 // {471 // vboxProblem().showModalProgressDialog (progress, iName, this);472 // if (progress.GetResultCode() == 0)473 // {474 // /* Add&Select newly created interface */475 // delete findItem (mLwInterfaces, mNoInterfaces);476 // mLwInterfaces->addItem (iName);477 // mListInterface += iName;478 // mLwInterfaces->setCurrentItem (mLwInterfaces->count() - 1);479 // /* Enable interface delete button */480 // mTbRemInterface->setEnabled (true);481 // }482 // else483 // vboxProblem().cannotCreateHostInterface (progress, iName, this);484 // }485 // else486 // vboxProblem().cannotCreateHostInterface (host, iName, this);487 //488 // /* Allow the started helper process to make itself the foreground window */489 // AllowSetForegroundWindow (ASFW_ANY);490 // }491 //492 // void VBoxVMSettingsNetwork::delHostInterface()493 // {494 // /* Allow the started helper process to make itself the foreground window */495 // AllowSetForegroundWindow (ASFW_ANY);496 //497 // /* Check interface name */498 // QString iName = mLwInterfaces->currentItem()->text();499 // if (iName.isEmpty())500 // return;501 //502 // /* Asking user about deleting selected network interface */503 // int delNetIface = vboxProblem().message (this, VBoxProblemReporter::Question,504 // tr ("<p>Do you want to remove the selected host network interface "505 // "<nobr><b>%1</b>?</nobr></p>"506 // "<p><b>Note:</b> This interface may be in use by one or more "507 // "network adapters of this or another VM. After it is removed, these "508 // "adapters will no longer work until you correct their settings by "509 // "either choosing a different interface name or a different adapter "510 // "attachment type.</p>").arg (iName),511 // 0, /* autoConfirmId */512 // QIMessageBox::Ok | QIMessageBox::Default,513 // QIMessageBox::Cancel | QIMessageBox::Escape);514 // if (delNetIface == QIMessageBox::Cancel)515 // return;516 //517 // CHost host = vboxGlobal().virtualBox().GetHost();518 // CHostNetworkInterface iFace = host.GetNetworkInterfaces().FindByName (iName);519 // if (host.isOk())520 // {521 // /* Delete interface */522 // CProgress progress = host.RemoveHostNetworkInterface (iFace.GetId(), iFace);523 // if (host.isOk())524 // {525 // vboxProblem().showModalProgressDialog (progress, iName, this);526 // if (progress.GetResultCode() == 0)527 // {528 // if (mLwInterfaces->count() == 1)529 // {530 // mLwInterfaces->addItem (mNoInterfaces);531 // /* Disable interface delete button */532 // mTbRemInterface->setEnabled (false);533 // }534 // delete findItem (mLwInterfaces, iName);535 // mLwInterfaces->currentItem()->setSelected (true);536 // mListInterface.erase (mListInterface.find (iName));537 // }538 // else539 // vboxProblem().cannotRemoveHostInterface (progress, iFace, this);540 // }541 // }542 //543 // if (!host.isOk())544 // vboxProblem().cannotRemoveHostInterface (host, iFace, this);545 // }546 // #endif547 548 QString VBoxVMSettingsNetwork::pageTitle() const549 {550 QString pageTitle;551 if (!mAdapter.isNull())552 {553 pageTitle = QString (tr ("Adapter %1", "network"))554 .arg (mAdapter.GetSlot());555 }556 return pageTitle;557 }558 283 559 284 void VBoxVMSettingsNetwork::prepareComboboxes() … … 596 321 } 597 322 598 void VBoxVMSettingsNetwork::prepareListNetworks() 323 324 /* VBoxNIList Stuff */ 325 #ifdef Q_WS_WIN 326 class VBoxNIListItem : public QTreeWidgetItem 327 { 328 public: 329 330 enum { typeId = QTreeWidgetItem::UserType + 1 }; 331 332 VBoxNIListItem (QTreeWidget *aParent, const QString &aName, bool aWrong = false) 333 : QTreeWidgetItem (aParent, QStringList (aName), typeId) 334 , mWrong (aWrong) 335 { 336 init(); 337 } 338 339 VBoxNIListItem (const QString &aName, bool aWrong = false) 340 : QTreeWidgetItem (QStringList (aName), typeId) 341 , mWrong (aWrong) 342 { 343 init(); 344 } 345 346 void init() 347 { 348 /* Force the fake item's font to italic */ 349 if (mWrong) 350 { 351 QFont fnt = font (0); 352 fnt.setItalic (true); 353 setFont (0, fnt); 354 } 355 } 356 357 bool isWrong() { return mWrong; } 358 359 private: 360 361 bool mWrong; 362 }; 363 364 VBoxNIList::VBoxNIList (QWidget *aParent) 365 : QIWithRetranslateUI<QGroupBox> (aParent) 366 { 367 /* Creating List Widget */ 368 QHBoxLayout *layout = new QHBoxLayout (this); 369 mList = new QTreeWidget (this); 370 mList->setColumnCount (1); 371 mList->header()->hide(); 372 mList->setContextMenuPolicy (Qt::ActionsContextMenu); 373 mList->setRootIsDecorated (false); 374 layout->addWidget (mList); 375 376 /* Prepare actions */ 377 mAddAction = new QAction (mList); 378 mDelAction = new QAction (mList); 379 mList->addAction (mAddAction); 380 mList->addAction (mDelAction); 381 mAddAction->setShortcut (QKeySequence ("Ins")); 382 mDelAction->setShortcut (QKeySequence ("Del")); 383 mAddAction->setIcon (VBoxGlobal::iconSet (":/add_host_iface_16px.png", 384 ":/add_host_iface_disabled_16px.png")); 385 mDelAction->setIcon (VBoxGlobal::iconSet (":/remove_host_iface_16px.png", 386 ":/remove_host_iface_disabled_16px.png")); 387 388 /* Prepare toolbar */ 389 VBoxToolBar *toolBar = new VBoxToolBar (this); 390 toolBar->setUsesTextLabel (false); 391 toolBar->setUsesBigPixmaps (false); 392 toolBar->setOrientation (Qt::Vertical); 393 toolBar->addAction (mAddAction); 394 toolBar->addAction (mDelAction); 395 layout->addWidget (toolBar); 396 397 /* Setup connections */ 398 connect (mList, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), 399 this, SLOT (onCurrentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *))); 400 connect (mAddAction, SIGNAL (triggered (bool)), 401 this, SLOT (addHostInterface())); 402 connect (mDelAction, SIGNAL (triggered (bool)), 403 this, SLOT (delHostInterface())); 404 405 /* Populating interface list */ 406 populateInterfacesList(); 407 408 /* Applying language settings */ 409 retranslateUi(); 410 } 411 412 bool VBoxNIList::isWrongInterface() const 413 { 414 return !mList->currentItem(); 415 } 416 417 void VBoxNIList::setCurrentInterface (const QString &aName) 418 { 419 /* Remove wrong item if present */ 420 for (int i = 0; i < mList->topLevelItemCount(); ++ i) 421 { 422 VBoxNIListItem *item = 423 mList->topLevelItem (i)->type() == VBoxNIListItem::typeId ? 424 static_cast<VBoxNIListItem*> (mList->topLevelItem (i)) : 0; 425 Assert (item); 426 if (item && item->isWrong()) 427 delete item; 428 } 429 430 if (aName.isEmpty()) 431 { 432 /* Make sure no one of items selected in the list currently */ 433 mList->setCurrentItem (0); 434 mList->clearSelection(); 435 } 436 else 437 { 438 /* Search for the required item */ 439 QTreeWidgetItem *querryItem = findItem (mList, aName); 440 441 /* Create fake required item if real is not present */ 442 if (!querryItem) 443 querryItem = new VBoxNIListItem (mList, aName, true); 444 445 /* Set the required item to be the current */ 446 mList->setCurrentItem (querryItem); 447 } 448 } 449 450 void VBoxNIList::onCurrentItemChanged (QTreeWidgetItem *aCurrent, 451 QTreeWidgetItem *) 452 { 453 VBoxNIListItem *item = aCurrent && 454 aCurrent->type() == VBoxNIListItem::typeId ? 455 static_cast<VBoxNIListItem*> (aCurrent) : 0; 456 mDelAction->setEnabled (item && !item->isWrong()); 457 458 emit currentInterfaceChanged (mList->currentItem() ? 459 mList->currentItem()->text (0) : QString::null); 460 } 461 462 void VBoxNIList::addHostInterface() 463 { 464 /* Allow the started helper process to make itself the foreground window */ 465 AllowSetForegroundWindow (ASFW_ANY); 466 467 /* Search for the max available interface index */ 468 int ifaceNumber = 0; 469 QString ifaceName = tr ("VirtualBox Host Interface %1"); 470 QRegExp regExp (QString ("^") + ifaceName.arg ("([0-9]+)") + QString ("$")); 471 for (int index = 0; index < mList->topLevelItemCount(); ++ index) 472 { 473 QString iface = mList->topLevelItem (index)->text (0); 474 int pos = regExp.indexIn (iface); 475 if (pos != -1) 476 ifaceNumber = regExp.cap (1).toInt() > ifaceNumber ? 477 regExp.cap (1).toInt() : ifaceNumber; 478 } 479 480 /* Creating add host interface dialog */ 481 VBoxAddNIDialog dlg (this, ifaceName.arg (++ ifaceNumber)); 482 if (dlg.exec() != QDialog::Accepted) 483 return; 484 QString iName = dlg.getName(); 485 486 /* Create interface */ 487 CHost host = vboxGlobal().virtualBox().GetHost(); 488 CHostNetworkInterface iFace; 489 CProgress progress = host.CreateHostNetworkInterface (iName, iFace); 490 if (host.isOk()) 491 { 492 vboxProblem().showModalProgressDialog (progress, iName, this); 493 /* Add&Select newly created interface */ 494 if (progress.GetResultCode() == 0) 495 new VBoxNIListItem (mList, iName); 496 else 497 vboxProblem().cannotCreateHostInterface (progress, iName, this); 498 } 499 else 500 vboxProblem().cannotCreateHostInterface (host, iName, this); 501 502 emit listChanged(); 503 504 /* Allow the started helper process to make itself the foreground window */ 505 AllowSetForegroundWindow (ASFW_ANY); 506 } 507 508 void VBoxNIList::delHostInterface() 509 { 510 Assert (mList->currentItem()); 511 512 /* Allow the started helper process to make itself the foreground window */ 513 AllowSetForegroundWindow (ASFW_ANY); 514 515 /* Check interface name */ 516 QString iName = mList->currentItem()->text (0); 517 if (iName.isEmpty()) 518 return; 519 520 /* Asking user about deleting selected network interface */ 521 int delNetIface = vboxProblem().message (this, VBoxProblemReporter::Question, 522 tr ("<p>Do you want to remove the selected host network interface " 523 "<nobr><b>%1</b>?</nobr></p>" 524 "<p><b>Note:</b> This interface may be in use by one or more " 525 "network adapters of this or another VM. After it is removed, these " 526 "adapters will no longer work until you correct their settings by " 527 "either choosing a different interface name or a different adapter " 528 "attachment type.</p>").arg (iName), 529 0, /* autoConfirmId */ 530 QIMessageBox::Ok | QIMessageBox::Default, 531 QIMessageBox::Cancel | QIMessageBox::Escape); 532 if (delNetIface == QIMessageBox::Cancel) 533 return; 534 535 CHost host = vboxGlobal().virtualBox().GetHost(); 536 CHostNetworkInterface iFace = host.GetNetworkInterfaces().FindByName (iName); 537 if (host.isOk()) 538 { 539 /* Delete interface */ 540 CProgress progress = host.RemoveHostNetworkInterface (iFace.GetId(), iFace); 541 if (host.isOk()) 542 { 543 vboxProblem().showModalProgressDialog (progress, iName, this); 544 if (progress.GetResultCode() == 0) 545 delete findItem (mList, iName); 546 else 547 vboxProblem().cannotRemoveHostInterface (progress, iFace, this); 548 } 549 } 550 551 if (!host.isOk()) 552 vboxProblem().cannotRemoveHostInterface (host, iFace, this); 553 554 emit listChanged(); 555 } 556 557 void VBoxNIList::retranslateUi() 558 { 559 setTitle (tr ("Host &Interfaces")); 560 561 mList->setWhatsThis (tr ("Lists all available host interfaces.")); 562 563 mAddAction->setText (tr ("A&dd New Host Interface")); 564 mDelAction->setText (tr ("&Remove Selected Host Interface")); 565 mAddAction->setWhatsThis (tr ("Adds a new host interface.")); 566 mDelAction->setWhatsThis (tr ("Removes the selected host interface.")); 567 mAddAction->setToolTip (mAddAction->text().remove ('&') + 568 QString (" (%1)").arg (mAddAction->shortcut().toString())); 569 mDelAction->setToolTip (mDelAction->text().remove ('&') + 570 QString (" (%1)").arg (mDelAction->shortcut().toString())); 571 } 572 573 void VBoxNIList::populateInterfacesList() 574 { 575 /* Load current inner list */ 576 QList<QTreeWidgetItem*> itemsList; 577 CHostNetworkInterfaceEnumerator en = 578 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces().Enumerate(); 579 while (en.HasMore()) 580 itemsList << new VBoxNIListItem (en.GetNext().GetName()); 581 582 /* Save current list item name */ 583 QString currentListItemName = mList->currentItem() ? 584 mList->currentItem()->text (0) : QString::null; 585 586 /* Load current list items */ 587 mList->clear(); 588 if (!itemsList.isEmpty()) 589 mList->insertTopLevelItems (0, itemsList); 590 591 /* Select current list item */ 592 QTreeWidgetItem *item = findItem (mList, currentListItemName); 593 mList->setCurrentItem (item ? item : mList->topLevelItem (0)); 594 595 /* Update item's state */ 596 onCurrentItemChanged (mList->currentItem()); 597 } 598 #endif 599 600 601 /* VBoxVMSettingsNetworkPage Stuff */ 602 VBoxVMSettingsNetworkPage* VBoxVMSettingsNetworkPage::mSettings = 0; 603 604 void VBoxVMSettingsNetworkPage::getFromMachine (const CMachine &aMachine, 605 QWidget *aPage, 606 VBoxVMSettingsDlg *aDlg, 607 const QString &aPath) 608 { 609 mSettings = new VBoxVMSettingsNetworkPage (aPage); 610 QVBoxLayout *layout = new QVBoxLayout (aPage); 611 layout->setContentsMargins (0, 5, 0, 0); 612 layout->addWidget (mSettings); 613 mSettings->getFrom (aMachine, aDlg, aPath); 614 } 615 616 void VBoxVMSettingsNetworkPage::putBackToMachine() 617 { 618 mSettings->putBackTo(); 619 } 620 621 bool VBoxVMSettingsNetworkPage::revalidate (QString &aWarning, 622 QString &aTitle) 623 { 624 return mSettings->validate (aWarning, aTitle); 625 } 626 627 VBoxVMSettingsNetworkPage::VBoxVMSettingsNetworkPage (QWidget *aParent) 628 : QIWithRetranslateUI<QWidget> (aParent) 629 , mLockNetworkListUpdate (true) 630 { 631 QVBoxLayout *layout = new QVBoxLayout (this); 632 layout->setContentsMargins (0, 0, 0, 0); 633 634 /* Creating Tab Widget */ 635 mTwAdapters = new QTabWidget (aParent); 636 layout->addWidget (mTwAdapters); 637 /* Prepare Networks Lists */ 638 populateNetworksList(); 639 640 #ifdef Q_WS_WIN 641 /* Creating Interfaces List */ 642 mNIList = new VBoxNIList (aParent); 643 layout->addWidget (mNIList); 644 #else 645 layout->addStretch(); 646 #endif 647 } 648 649 void VBoxVMSettingsNetworkPage::getFrom (const CMachine &aMachine, 650 VBoxVMSettingsDlg *aDlg, 651 const QString &aPath) 652 { 653 /* Creating Tab Pages */ 654 CVirtualBox vbox = vboxGlobal().virtualBox(); 655 ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount(); 656 for (ulong slot = 0; slot < count; ++ slot) 657 { 658 /* Get Adapter */ 659 CNetworkAdapter adapter = aMachine.GetNetworkAdapter (slot); 660 661 /* Creating Adapter's page */ 662 VBoxVMSettingsNetwork *page = new VBoxVMSettingsNetwork(); 663 664 /* Loading Adapter's data into page */ 665 page->setNetworksList (mListNetworks); 666 page->getFromAdapter (adapter); 667 668 /* Attach Adapter's page to Tab Widget */ 669 mTwAdapters->addTab (page, page->pageTitle()); 670 671 /* Setup validation */ 672 QIWidgetValidator *wval = 673 new QIWidgetValidator (QString ("%1: %2").arg (aPath, page->pageTitle()), 674 (QWidget*)parent(), aDlg); 675 connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)), 676 aDlg, SLOT (enableOk (const QIWidgetValidator*))); 677 connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)), 678 aDlg, SLOT (revalidate (QIWidgetValidator*))); 679 connect (page->mCbNetwork, SIGNAL (editTextChanged (const QString&)), 680 this, SLOT (updateNetworksList())); 681 #ifdef Q_WS_WIN 682 connect (mNIList, SIGNAL (listChanged()), wval, SLOT (revalidate())); 683 #endif 684 page->setValidator (wval); 685 } 686 687 #ifdef Q_WS_WIN 688 connect (mTwAdapters, SIGNAL (currentChanged (int)), 689 this, SLOT (onCurrentPageChanged (int))); 690 connect (mNIList, SIGNAL (currentInterfaceChanged (const QString &)), 691 this, SLOT (onCurrentInterfaceChanged (const QString &))); 692 onCurrentPageChanged (mTwAdapters->currentIndex()); 693 #endif 694 695 /* Applying language settings */ 696 retranslateUi(); 697 } 698 699 void VBoxVMSettingsNetworkPage::putBackTo() 700 { 701 for (int i = 0; i < mTwAdapters->count(); ++ i) 702 { 703 VBoxVMSettingsNetwork *page = static_cast<VBoxVMSettingsNetwork*> 704 (mTwAdapters->widget (i)); 705 if (page) 706 page->putBackToAdapter(); 707 } 708 } 709 710 bool VBoxVMSettingsNetworkPage::validate (QString &aWarning, 711 QString &aTitle) 712 { 713 bool valid = true; 714 715 for (int i = 0; i < mTwAdapters->count(); ++ i) 716 { 717 VBoxVMSettingsNetwork *page = static_cast<VBoxVMSettingsNetwork*> 718 (mTwAdapters->widget (i)); 719 Assert (page); 720 721 KNetworkAttachmentType type = 722 vboxGlobal().toNetworkAttachmentType (page->mCbNAType->currentText()); 723 724 #ifdef Q_WS_WIN 725 if (type == KNetworkAttachmentType_HostInterface && 726 page->interfaceName().isNull()) 727 { 728 valid = false; 729 aWarning = tr ("No host network interface is selected"); 730 } else 731 #endif 732 if (type == KNetworkAttachmentType_Internal && 733 page->mCbNetwork->currentText().isEmpty()) 734 { 735 valid = false; 736 aWarning = tr ("Internal network name is not set"); 737 } 738 739 if (!valid) 740 { 741 aTitle += ": " + page->pageTitle(); 742 break; 743 } 744 } 745 746 return valid; 747 } 748 749 void VBoxVMSettingsNetworkPage::retranslateUi() 750 { 751 for (int i = 0; i < mTwAdapters->count(); ++ i) 752 { 753 VBoxVMSettingsNetwork *page = 754 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (i)); 755 mTwAdapters->setTabText (i, page->pageTitle()); 756 } 757 } 758 759 void VBoxVMSettingsNetworkPage::updateNetworksList() 760 { 761 /* Lock to prevent few simultaneously update */ 762 if (mLockNetworkListUpdate) 763 return; 764 mLockNetworkListUpdate = true; 765 766 /* Compose latest list from current + new on all pages */ 767 QStringList curList (mListNetworks); 768 for (int index = 0; index < mTwAdapters->count(); ++ index) 769 { 770 VBoxVMSettingsNetwork *page = 771 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index)); 772 if (page) 773 { 774 QString curText = page->mCbNetwork->currentText(); 775 if (!curText.isEmpty() && !curList.contains (curText)) 776 curList << curText; 777 } 778 } 779 780 /* Load latest list to all pages */ 781 for (int index = 0; index < mTwAdapters->count(); ++ index) 782 { 783 VBoxVMSettingsNetwork *page = 784 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (index)); 785 if (page) 786 page->setNetworksList (curList); 787 } 788 789 /* Allow further Network List update */ 790 mLockNetworkListUpdate = false; 791 } 792 793 #ifdef Q_WS_WIN 794 void VBoxVMSettingsNetworkPage::onCurrentPageChanged (int aIndex) 795 { 796 VBoxVMSettingsNetwork *page = 797 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->widget (aIndex)); 798 Assert (page); 799 mNIList->setCurrentInterface (page->interfaceName()); 800 } 801 802 void VBoxVMSettingsNetworkPage::onCurrentInterfaceChanged (const QString &aName) 803 { 804 VBoxVMSettingsNetwork *page = 805 static_cast<VBoxVMSettingsNetwork*> (mTwAdapters->currentWidget()); 806 Assert (page); 807 page->setInterfaceName (aName); 808 } 809 #endif 810 811 void VBoxVMSettingsNetworkPage::populateNetworksList() 599 812 { 600 813 /* Clear inner list */ … … 624 837 } 625 838 626 // #ifdef Q_WS_WIN627 // void VBoxVMSettingsNetwork::prepareListInterfaces()628 // {629 // /* Clear inner list */630 // mListInterface.clear();631 //632 // /* Load current inner list */633 // CHostNetworkInterfaceEnumerator en =634 // vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces().Enumerate();635 // while (en.HasMore())636 // mListInterface += en.GetNext().GetName();637 //638 // /* Save current list item name */639 // QString currentListItemName = mLwInterfaces->currentText();640 //641 // /* Load current list items */642 // mLwInterfaces->clear();643 // if (mListInterface.count())644 // mLwInterfaces->insertItems (0, mListInterface);645 // else646 // mLwInterfaces->insertItem (0, mNoInterfaces);647 //648 // /* Select current list item */649 // QListWidgetItem *item = findItem (mLwInterfaces, currentListItemName);650 // mLwInterfaces->setCurrentItem (item ? item : mLwInterfaces->item (0));651 //652 // /* Enable/Disable interface delete button */653 // mDelAction->setEnabled (!mListInterface.isEmpty());654 // }655 // #endif656
Note:
See TracChangeset
for help on using the changeset viewer.