Changeset 1628 in vbox
- Timestamp:
- Mar 22, 2007 4:38:51 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19755
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile
r1459 r1628 81 81 ui/VBoxVMSettingsDlg.ui.h \ 82 82 ui/VBoxSharedFoldersSettings.ui.h 83 ifeq ($(BUILD_TARGET),win) 84 VirtualBox_QT_MOCUIHDRS += ui/VBoxVMNetworkSettings.ui.h 85 endif 83 86 84 87 VirtualBox_GENSRCS = \ -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui
r1517 r1628 27 27 <x>0</x> 28 28 <y>0</y> 29 <width>3 07</width>30 <height>3 12</height>29 <width>361</width> 30 <height>368</height> 31 31 </rect> 32 32 </property> … … 34 34 <string>VBoxVMNetworkSettings</string> 35 35 </property> 36 < grid>36 <vbox> 37 37 <property name="name"> 38 38 <cstring>unnamed</cstring> … … 41 41 <number>10</number> 42 42 </property> 43 <widget class="QGroupBox" row="0" column="0">43 <widget class="QGroupBox"> 44 44 <property name="name"> 45 45 <cstring>grbEnabled</cstring> … … 219 219 </property> 220 220 <property name="flat"> 221 <bool> true</bool>221 <bool>false</bool> 222 222 </property> 223 223 <vbox> … … 225 225 <cstring>unnamed</cstring> 226 226 </property> 227 <property name="margin">228 <number>0</number>229 </property>230 227 <widget class="QLayoutWidget"> 231 228 <property name="name"> 232 <cstring>layout3 4</cstring>229 <cstring>layout33</cstring> 233 230 </property> 234 231 <hbox> … … 236 233 <cstring>unnamed</cstring> 237 234 </property> 235 <property name="spacing"> 236 <number>0</number> 237 </property> 238 238 <widget class="QFrame"> 239 239 <property name="name"> … … 246 246 <enum>Raised</enum> 247 247 </property> 248 < vbox>248 <grid> 249 249 <property name="name"> 250 250 <cstring>unnamed</cstring> … … 253 253 <number>0</number> 254 254 </property> 255 <widget class="QLayoutWidget"> 256 <property name="name"> 257 <cstring>layout14</cstring> 255 <property name="spacing"> 256 <number>6</number> 257 </property> 258 <widget class="QLayoutWidget" row="0" column="0"> 259 <property name="name"> 260 <cstring>layout31</cstring> 258 261 </property> 259 262 <hbox> … … 284 287 <cstring>leHostInterfaceName</cstring> 285 288 </property> 289 <property name="focusPolicy"> 290 <enum>NoFocus</enum> 291 </property> 292 <property name="readOnly"> 293 <bool>true</bool> 294 </property> 286 295 <property name="whatsThis" stdset="0"> 287 <string>Enter name for the new interface here</string> 288 </property> 289 </widget> 290 <widget class="QToolButton"> 291 <property name="name"> 292 <cstring>pbHostAdd</cstring> 293 </property> 294 <property name="text"> 295 <string>...</string> 296 </property> 297 <property name="toolTip" stdset="0"> 298 <string></string> 299 </property> 300 <property name="whatsThis" stdset="0"> 301 <string>Add a new host interface</string> 302 </property> 303 </widget> 304 <widget class="QToolButton"> 305 <property name="name"> 306 <cstring>pbHostRemove</cstring> 307 </property> 308 <property name="text"> 309 <string>...</string> 310 </property> 311 <property name="toolTip" stdset="0"> 312 <string></string> 313 </property> 314 <property name="whatsThis" stdset="0"> 315 <string>Remove 316 the selected host interface</string> 296 <string>The name of the interface selected for the current adapter</string> 317 297 </property> 318 298 </widget> 319 299 </hbox> 320 300 </widget> 321 <widget class="QListBox" >301 <widget class="QListBox" row="1" column="0"> 322 302 <property name="name"> 323 303 <cstring>lbHostInterface</cstring> … … 335 315 </property> 336 316 </widget> 337 </vbox> 317 <widget class="QLayoutWidget" row="1" column="1"> 318 <property name="name"> 319 <cstring>layout27</cstring> 320 </property> 321 <vbox> 322 <property name="name"> 323 <cstring>unnamed</cstring> 324 </property> 325 <property name="margin"> 326 <number>0</number> 327 </property> 328 <property name="spacing"> 329 <number>0</number> 330 </property> 331 <widget class="QToolButton"> 332 <property name="name"> 333 <cstring>pbHostAdd</cstring> 334 </property> 335 <property name="focusPolicy"> 336 <enum>StrongFocus</enum> 337 </property> 338 <property name="text"> 339 <string>...</string> 340 </property> 341 <property name="autoRaise"> 342 <bool>true</bool> 343 </property> 344 <property name="toolTip" stdset="0"> 345 <string></string> 346 </property> 347 <property name="whatsThis" stdset="0"> 348 <string>Add a new host interface</string> 349 </property> 350 </widget> 351 <widget class="QToolButton"> 352 <property name="name"> 353 <cstring>pbHostRemove</cstring> 354 </property> 355 <property name="focusPolicy"> 356 <enum>StrongFocus</enum> 357 </property> 358 <property name="text"> 359 <string>...</string> 360 </property> 361 <property name="autoRaise"> 362 <bool>true</bool> 363 </property> 364 <property name="toolTip" stdset="0"> 365 <string></string> 366 </property> 367 <property name="whatsThis" stdset="0"> 368 <string>Remove 369 the selected host interface</string> 370 </property> 371 </widget> 372 <spacer> 373 <property name="name"> 374 <cstring>spacer7</cstring> 375 </property> 376 <property name="orientation"> 377 <enum>Vertical</enum> 378 </property> 379 <property name="sizeType"> 380 <enum>Expanding</enum> 381 </property> 382 <property name="sizeHint"> 383 <size> 384 <width>10</width> 385 <height>10</height> 386 </size> 387 </property> 388 </spacer> 389 </vbox> 390 </widget> 391 <spacer row="0" column="1"> 392 <property name="name"> 393 <cstring>spacer11</cstring> 394 </property> 395 <property name="orientation"> 396 <enum>Horizontal</enum> 397 </property> 398 <property name="sizeType"> 399 <enum>Minimum</enum> 400 </property> 401 <property name="sizeHint"> 402 <size> 403 <width>20</width> 404 <height>20</height> 405 </size> 406 </property> 407 </spacer> 408 </grid> 338 409 </widget> 339 410 <widget class="QLayoutWidget"> … … 639 710 </vbox> 640 711 </widget> 641 </ grid>712 </vbox> 642 713 </widget> 643 714 <connections> … … 690 761 <include location="global" impldecl="in implementation">qfiledialog.h</include> 691 762 <include location="local" impldecl="in declaration">COMDefs.h</include> 763 <include location="local" impldecl="in declaration">QIWidgetValidator.h</include> 692 764 <include location="local" impldecl="in implementation">VBoxGlobal.h</include> 693 765 <include location="local" impldecl="in implementation">VBoxProblemReporter.h</include> 694 766 </includes> 695 767 <variables> 696 <variable access="private">QStringList networkInterfaceList;</variable>697 768 <variable access="private">CNetworkAdapter cadapter;</variable> 698 <variable access="private">QString NoSuitableIfaces;</variable> 769 <variable access="private">int mInterfaceNumber;</variable> 770 <variable access="private">QIWidgetValidator *mWalidator;</variable> 771 <variable access="private">QString mNoInterfaces;</variable> 699 772 </variables> 773 <signals> 774 <signal>listChanged( QWidget* )</signal> 775 </signals> 700 776 <slots> 701 777 <slot>cbNetworkAttachment_activated( const QString & string )</slot> … … 703 779 <slot>pbTAPSetup_clicked()</slot> 704 780 <slot>pbTAPTerminate_clicked()</slot> 705 781 <slot access="protected">hostInterfaceAdd()</slot> 706 782 <slot access="protected">hostInterfaceRemove()</slot> 707 783 <slot access="protected">lbHostInterface_highlighted( QListBoxItem* item )</slot> 784 <slot access="protected">grbEnabledToggled( bool )</slot> 708 785 </slots> 709 786 <functions> 710 787 <function access="private" specifier="non virtual">init()</function> 711 <function>getFromAdapter( const CNetworkAdapter & adapter )</function> 788 <function>loadList( const QStringList & )</function> 789 <function>getFromAdapter( const CNetworkAdapter & )</function> 712 790 <function>putBackToAdapter()</function> 713 <function access="private">updateInterfaceList()</function> 714 <function returnType="bool">checkNetworkInterface( QString input )</function> 791 <function>setValidator( QIWidgetValidator* )</function> 792 <function>revalidate()</function> 793 <function returnType="bool">isPageValid( const QStringList & )</function> 794 <function access="private">selectListItem( const QString & )</function> 795 <function access="private" returnType="bool">isInterfaceInvalid( const QStringList &, const QString & )</function> 715 796 </functions> 716 797 <pixmapinproject/> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui.h
r1521 r1628 30 30 *****************************************************************************/ 31 31 32 /** 33 * QDialog class reimplementation to use for adding network interface. 34 * It has one line-edit field for entering network interface's name and 35 * common dialog's ok/cancel buttons. 36 */ 37 #if defined Q_WS_WIN 38 class VBoxAddNIDialog : public QDialog 39 { 40 Q_OBJECT 41 42 public: 43 44 VBoxAddNIDialog (QWidget *aParent, const QString &aIfaceName) : 45 QDialog (aParent, "VBoxAddNIDialog", true /* modal */), 46 mLeName (0) 47 { 48 setCaption (tr ("Add Host Interface")); 49 QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10, "mainLayout"); 50 51 /* Setup Input layout */ 52 QHBoxLayout *inputLayout = new QHBoxLayout (mainLayout, 10, "inputLayout"); 53 QLabel *lbName = new QLabel ("Interface Name", this); 54 mLeName = new QLineEdit (aIfaceName, this); 55 QWhatsThis::add (mLeName, tr ("Enter name for the interface to be created")); 56 inputLayout->addWidget (lbName); 57 inputLayout->addWidget (mLeName); 58 connect (mLeName, SIGNAL (textChanged (const QString &)), 59 this, SLOT (validate())); 60 61 /* Setup Button layout */ 62 QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout"); 63 mBtOk = new QPushButton ("OK", this, "btOk"); 64 QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 65 QPushButton *btCancel = new QPushButton ("Cancel", this, "btCancel"); 66 connect (mBtOk, SIGNAL (clicked()), this, SLOT (accept())); 67 connect (btCancel, SIGNAL (clicked()), this, SLOT (reject())); 68 buttonLayout->addWidget (mBtOk); 69 buttonLayout->addItem (spacer); 70 buttonLayout->addWidget (btCancel); 71 72 /* Validate interface name field */ 73 validate(); 74 } 75 76 ~VBoxAddNIDialog() {} 77 78 QString getName() { return mLeName->text(); } 79 80 private slots: 81 82 void validate() 83 { 84 mBtOk->setEnabled (!mLeName->text().isEmpty()); 85 } 86 87 private: 88 89 void showEvent (QShowEvent *aEvent) 90 { 91 setFixedHeight (height()); 92 QDialog::showEvent (aEvent); 93 } 94 95 QPushButton *mBtOk; 96 QLineEdit *mLeName; 97 }; 98 #endif 99 100 101 /** 102 * VBoxVMNetworkSettings class to use as network interface setup page. 103 */ 32 104 void VBoxVMNetworkSettings::init() 33 105 { 34 /* set initial values35 * -------------------------------------------------------------------- */106 mInterfaceNumber = 0; 107 mNoInterfaces = tr ("<No suitable interfaces>"); 36 108 37 109 leMACAddress->setValidator (new QRegExpValidator (QRegExp ("[0-9,A-F]{12,12}"), this)); 38 110 39 #if defined Q_WS_X1140 leTAPDescriptor->setValidator (new QIntValidator (-1, std::numeric_limits <LONG>::max(), this));41 #endif42 43 /* set initial values44 * -------------------------------------------------------------------- */45 46 NoSuitableIfaces = tr ("<No suitable interfaces>");47 48 #if defined Q_WS_WIN49 updateInterfaceList();50 #endif51 52 111 cbNetworkAttachment->insertItem (vboxGlobal().toString (CEnums::NoNetworkAttachment)); 53 112 cbNetworkAttachment->insertItem (vboxGlobal().toString (CEnums::NATNetworkAttachment)); … … 55 114 cbNetworkAttachment->insertItem (vboxGlobal().toString (CEnums::InternalNetworkAttachment)); 56 115 57 grbTAP->setEnabled (false); /* initially disabled */ 116 #if defined Q_WS_X11 117 leTAPDescriptor->setValidator (new QIntValidator (-1, std::numeric_limits <LONG>::max(), this)); 118 #else 119 /* hide unavailable settings (TAP setup and terminate apps) */ 120 frmTAPSetupTerminate->setHidden (true); 121 #endif 58 122 59 123 #if defined Q_WS_WIN 60 124 /* disable unused interface name UI */ 61 125 frmHostInterface_X11->setHidden (true); 62 /* setup iconsets -- qdesigner is not capable...*/126 /* setup iconsets */ 63 127 pbHostAdd->setIconSet (VBoxGlobal::iconSet ("add_host_iface_16px.png", 64 128 "add_host_iface_disabled_16px.png")); 65 129 pbHostRemove->setIconSet (VBoxGlobal::iconSet ("remove_host_iface_16px.png", 66 130 "remove_host_iface_disabled_16px.png")); 131 connect (grbEnabled, SIGNAL (toggled (bool)), 132 this, SLOT (grbEnabledToggled (bool))); 67 133 #else 68 134 /* disable unused interface name UI */ 69 135 frmHostInterface_WIN->setHidden (true); 70 /* setup iconsets -- qdesigner is not capable...*/136 /* setup iconsets */ 71 137 pbTAPSetup->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png", 72 138 "select_file_dis_16px.png")); … … 75 141 #endif 76 142 77 #if !defined Q_WS_X1178 /* hide unavailable settings (TAP setup and terminate apps) */79 frmTAPSetupTerminate->setHidden (true);80 #endif81 82 143 /* the TAP file descriptor setting is always invisible -- currently not used 83 144 * (remove the relative code at all? -- just leave for some time...) */ … … 85 146 } 86 147 87 void VBoxVMNetworkSettings::updateInterfaceList() 88 { 89 #if defined Q_WS_WIN 90 /* clear lists */ 91 networkInterfaceList.clear(); 148 bool VBoxVMNetworkSettings::isPageValid (const QStringList &aList) 149 { 150 #if defined Q_WS_WIN 151 CEnums::NetworkAttachmentType type = 152 vboxGlobal().toNetworkAttachmentType (cbNetworkAttachment->currentText()); 153 154 return !(type == CEnums::HostInterfaceNetworkAttachment && 155 isInterfaceInvalid (aList, leHostInterfaceName->text())); 156 #else 157 NOREF (aList); 158 return true; 159 #endif 160 } 161 162 void VBoxVMNetworkSettings::loadList (const QStringList &aList) 163 { 164 #if defined Q_WS_WIN 165 /* save current list item name */ 166 QString currentListItemName = leHostInterfaceName->text(); 167 /* load current list items */ 168 lbHostInterface->clearFocus(); 92 169 lbHostInterface->clear(); 93 /* read a QStringList of interface names */ 94 CHostNetworkInterfaceEnumerator en = 95 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces().Enumerate(); 96 while (en.HasMore()) 97 networkInterfaceList += en.GetNext().GetName(); 98 /* setup a list of interface names */ 99 if (networkInterfaceList.count()) 100 lbHostInterface->insertStringList (networkInterfaceList); 170 if (aList.count()) 171 lbHostInterface->insertStringList (aList); 101 172 else 102 lbHostInterface->insertItem (NoSuitableIfaces); 173 lbHostInterface->insertItem (mNoInterfaces); 174 selectListItem (currentListItemName); 103 175 /* disable interface delete button */ 104 pbHostRemove->setEnabled (!networkInterfaceList.isEmpty()); 176 pbHostRemove->setEnabled (!aList.isEmpty()); 177 #else 178 NOREF (aList); 105 179 #endif 106 180 } … … 127 201 128 202 #if defined Q_WS_WIN 129 if (adapter.GetHostInterface().isEmpty()) 130 lbHostInterface->setCurrentItem (0); 131 else 132 { 133 QListBoxItem* adapterNode = lbHostInterface->findItem(adapter.GetHostInterface()); 134 if (adapterNode) 135 lbHostInterface->setCurrentItem(adapterNode); 136 } 203 selectListItem (adapter.GetHostInterface()); 137 204 #else 138 205 leHostInterface->setText (adapter.GetHostInterface()); … … 140 207 141 208 #if defined Q_WS_X11 142 leTAPDescriptor->setText (QString::number (adapter.GetTAPFileDescriptor()));209 leTAPDescriptor->setText (QString::number (adapter.GetTAPFileDescriptor())); 143 210 leTAPSetup->setText (adapter.GetTAPSetupApplication()); 144 211 leTAPTerminate->setText (adapter.GetTAPTerminateApplication()); … … 194 261 } 195 262 196 void VBoxVMNetworkSettings::cbNetworkAttachment_activated (const QString &string) 197 { 198 grbTAP->setEnabled (vboxGlobal().toNetworkAttachmentType (string) == 199 CEnums::HostInterfaceNetworkAttachment); 200 } 201 202 void VBoxVMNetworkSettings::lbHostInterface_highlighted(QListBoxItem* /*item*/) 203 { 204 leHostInterfaceName->clear(); 205 } 206 207 bool VBoxVMNetworkSettings::checkNetworkInterface (QString ni) 208 { 209 #if defined Q_WS_WIN 210 return networkInterfaceList.find (ni) != networkInterfaceList.end() ? 1 : 0; 211 #else 212 NOREF(ni); 213 return true; 263 void VBoxVMNetworkSettings::setValidator (QIWidgetValidator *aWalidator) 264 { 265 mWalidator = aWalidator; 266 } 267 268 void VBoxVMNetworkSettings::revalidate() 269 { 270 mWalidator->revalidate(); 271 } 272 273 void VBoxVMNetworkSettings::grbEnabledToggled (bool aOn) 274 { 275 #if defined Q_WS_WIN 276 if (!aOn) 277 { 278 lbHostInterface->clearFocus(); 279 cbNetworkAttachment->setCurrentItem (0); 280 cbNetworkAttachment_activated (cbNetworkAttachment->currentText()); 281 if (lbHostInterface->selectedItem()) 282 lbHostInterface->setSelected (lbHostInterface->selectedItem(), false); 283 } 284 if (lbHostInterface->currentItem() != -1) 285 lbHostInterface->setSelected (lbHostInterface->currentItem(), aOn); 286 #else 287 NOREF (aOn); 288 #endif 289 } 290 291 void VBoxVMNetworkSettings::selectListItem (const QString &aItemName) 292 { 293 if (!aItemName.isEmpty()) 294 { 295 #if defined Q_WS_WIN 296 leHostInterfaceName->setText (aItemName); 297 QListBoxItem* adapterNode = lbHostInterface->findItem (aItemName); 298 if (adapterNode) 299 { 300 lbHostInterface->setCurrentItem (adapterNode); 301 lbHostInterface->setSelected (adapterNode, true); 302 } 303 #endif 304 } 305 } 306 307 void VBoxVMNetworkSettings::cbNetworkAttachment_activated (const QString &aString) 308 { 309 #if defined Q_WS_WIN 310 bool enableHostIf = vboxGlobal().toNetworkAttachmentType (aString) == 311 CEnums::HostInterfaceNetworkAttachment; 312 txHostInterface_WIN->setEnabled (enableHostIf); 313 leHostInterfaceName->setEnabled (enableHostIf); 314 lbHostInterface_highlighted (lbHostInterface->selectedItem()); 315 #else 316 NOREF (aString); 317 #endif 318 } 319 320 void VBoxVMNetworkSettings::lbHostInterface_highlighted (QListBoxItem *aItem) 321 { 322 if (!aItem) return; 323 #if defined Q_WS_WIN 324 leHostInterfaceName->setText (leHostInterfaceName->isEnabled() ? 325 aItem->text() : QString::null); 326 if (!lbHostInterface->isSelected (aItem)) 327 lbHostInterface->setSelected (aItem, true); 328 #endif 329 } 330 331 bool VBoxVMNetworkSettings::isInterfaceInvalid (const QStringList &aList, 332 const QString &aIface) 333 { 334 #if defined Q_WS_WIN 335 return aList.find (aIface) == aList.end(); 336 #else 337 NOREF (aList); 338 NOREF (aIface); 339 return false; 214 340 #endif 215 341 } … … 223 349 void VBoxVMNetworkSettings::pbTAPSetup_clicked() 224 350 { 225 // QFileDialog dlg ("/", QString::null, this);226 // dlg.setMode (QFileDialog::ExistingFile);227 // dlg.setViewMode (QFileDialog::List);228 // dlg.setCaption (tr ("Select TAP setup application"));229 // if (dlg.exec() == QDialog::Accepted)230 // leTAPSetup->setText (dlg.selectedFile());231 232 351 QString selected = QFileDialog::getOpenFileName ( 233 352 "/", … … 243 362 void VBoxVMNetworkSettings::pbTAPTerminate_clicked() 244 363 { 245 // QFileDialog dlg ("/", QString::null, this);246 // dlg.setMode (QFileDialog::ExistingFile);247 // dlg.setViewMode (QFileDialog::List);248 // dlg.setCaption (tr ("Select TAP terminate application"));249 // if (dlg.exec() == QDialog::Accepted)250 // leTAPTerminate->setText (dlg.selectedFile());251 252 364 QString selected = QFileDialog::getOpenFileName ( 253 365 "/", … … 268 380 AllowSetForegroundWindow (ASFW_ANY); 269 381 270 /* check interface name */ 271 QString iName = leHostInterfaceName->text(); 272 if (iName.isEmpty() || iName == NoSuitableIfaces) 273 { 274 vboxProblem().message (this, VBoxProblemReporter::Error, 275 tr ("Host network interface name cannot be empty")); 382 /* creating add host interface dialog */ 383 VBoxAddNIDialog dlg (this, lbHostInterface->currentItem() != -1 ? 384 tr ("Host Interface %1").arg (++mInterfaceNumber) : 385 leHostInterfaceName->text()); 386 if (dlg.exec() != QDialog::Accepted) 276 387 return; 277 }388 QString iName = dlg.getName(); 278 389 279 390 /* create interface */ … … 286 397 if (progress.GetResultCode() == 0) 287 398 { 288 updateInterfaceList(); 289 /* move the selection to the new created item */ 290 QListBoxItem *createdNode = 291 lbHostInterface->findItem (leHostInterfaceName->text()); 292 if (createdNode) 293 lbHostInterface->setCurrentItem (createdNode); 294 else 295 lbHostInterface->setCurrentItem (0); 399 /* add&select newly created created interface */ 400 delete lbHostInterface->findItem (mNoInterfaces); 401 lbHostInterface->insertItem (iName); 402 selectListItem (iName); 403 emit listChanged (this); 296 404 } 297 405 else 298 406 vboxProblem().cannotCreateHostInterface (progress, iName, this); 299 300 407 } 301 408 else … … 320 427 return; 321 428 429 /* asking user about deleting selected network interface */ 430 int delNetIface = vboxProblem().message (this, VBoxProblemReporter::Question, 431 tr ("<p>Do you want to remove selected network interface " 432 "<nobr><b>%1</b>?</nobr></p>" 433 "<p>If this interface is currently selected you should " 434 "apply VM settings changes to avoid VM using of non-existing " 435 "interface</p>").arg (iName), 436 0, /* autoConfirmId */ 437 QIMessageBox::Ok | QIMessageBox::Default, 438 QIMessageBox::Cancel | QIMessageBox::Escape); 439 if (delNetIface == QIMessageBox::Cancel) 440 return; 441 322 442 CHost host = vboxGlobal().virtualBox().GetHost(); 323 443 CHostNetworkInterface iFace = host.GetNetworkInterfaces().FindByName (iName); … … 325 445 { 326 446 /* delete interface */ 327 447 CProgress progress = host.RemoveHostNetworkInterface (iFace.GetId(), iFace); 328 448 if (host.isOk()) 329 449 { … … 331 451 if (progress.GetResultCode() == 0) 332 452 { 333 updateInterfaceList();334 /* move the selection to the start of the list */335 lbHostInterface->setCurrentItem(0);336 lbHostInterface->setSelected(0, true);453 if (lbHostInterface->count() == 1) 454 lbHostInterface->insertItem (mNoInterfaces); 455 delete lbHostInterface->findItem (iName); 456 emit listChanged (this); 337 457 } 338 458 else … … 345 465 #endif 346 466 } 467 468 #if defined Q_WS_WIN 469 #include "VBoxVMNetworkSettings.ui.moc" 470 #endif -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r1455 r1628 2663 2663 <variable access="private">QValueVector < CHostFloppyDrive > hostFloppies;</variable> 2664 2664 <variable access="private">CMachine cmachine;</variable> 2665 <variable access="private">QStringList bootDevicesInUse;</variable>2665 <variable access="private">QStringList mInterfaceList;</variable> 2666 2666 <variable access="private">QWidgetStack *wstUSBFilters;</variable> 2667 2667 <variable access="private">ulong mLastUSBFilterNum;</variable> … … 2690 2690 <slot>showImageManagerISOFloppy()</slot> 2691 2691 <slot>showVDImageManager( QUuid *id, VBoxMediaComboBox *le, QLabel *tx = NULL )</slot> 2692 <slot>addNetworkAdapter( const CNetworkAdapter & adapter , bool select)</slot>2692 <slot>addNetworkAdapter( const CNetworkAdapter & adapter )</slot> 2693 2693 <slot>slRAM_valueChanged( int val )</slot> 2694 2694 <slot>leRAM_textChanged( const QString & text )</slot> … … 2713 2713 <slot>fdMediaChanged()</slot> 2714 2714 <slot>processAdjustSize()</slot> 2715 <slot>updateInterfaces( QWidget* )</slot> 2716 <slot>networkPageUpdate( QWidget* )</slot> 2715 2717 </slots> 2716 2718 <functions> … … 2718 2720 <function>setup( const QString &, const QString & )</function> 2719 2721 <function>getFromMachine( const CMachine & machine )</function> 2722 <function returnType="bool">eventFilter( QObject * watched, QEvent * e )</function> 2720 2723 <function returnType="COMResult">putBackToMachine()</function> 2721 <function access="protected">setWarning( const QString & )</function> 2722 <function access="protected">showEvent( QShowEvent * )</function> 2723 <function returnType="bool">eventFilter( QObject * watched, QEvent * e )</function> 2724 <function access="protected">updateShortcuts()</function> 2725 <function access="protected" returnType="QString">getHdInfo( QGroupBox*, QUuid )</function> 2724 <function access="private">setWarning( const QString & )</function> 2725 <function access="private">showEvent( QShowEvent * )</function> 2726 <function access="private">updateShortcuts()</function> 2727 <function access="private" returnType="QString">getHdInfo( QGroupBox*, QUuid )</function> 2726 2728 </functions> 2727 2729 <pixmapinproject/> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r1557 r1628 721 721 /* Network Page */ 722 722 723 updateInterfaces (0); 724 723 725 /* 724 726 * update the Ok button state for pages with validation … … 822 824 cbISOFloppy->refresh(); 823 825 } 826 } 827 828 829 void VBoxVMSettingsDlg::updateInterfaces (QWidget *aWidget) 830 { 831 #if defined Q_WS_WIN 832 /* clear list */ 833 mInterfaceList.clear(); 834 /* write a QStringList of interface names */ 835 CHostNetworkInterfaceEnumerator en = 836 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces().Enumerate(); 837 while (en.HasMore()) 838 mInterfaceList += en.GetNext().GetName(); 839 if (aWidget) 840 { 841 VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget); 842 set->revalidate(); 843 } 844 #else 845 NOREF (aWidget); 846 #endif 847 } 848 849 void VBoxVMSettingsDlg::networkPageUpdate (QWidget *aWidget) 850 { 851 if (!aWidget) return; 852 #if defined Q_WS_WIN 853 updateInterfaces (0); 854 VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget); 855 set->loadList (mInterfaceList); 856 set->revalidate(); 857 #endif 824 858 } 825 859 … … 1131 1165 else if (pg == pageNetwork) 1132 1166 { 1133 int slot = -1; 1134 for (int index = 0; index < tbwNetwork->count(); index++) 1135 { 1136 QWidget* pTab = tbwNetwork->page (index); 1137 Assert(pTab); 1138 VBoxVMNetworkSettings* pNetSet = static_cast <VBoxVMNetworkSettings*>(pTab); 1139 if (!pNetSet->grbEnabled->isChecked()) 1140 { 1141 pNetSet->cbNetworkAttachment->setCurrentItem (0); 1142 pNetSet->cbNetworkAttachment_activated (pNetSet->cbNetworkAttachment->currentText()); 1143 } 1144 1145 CEnums::NetworkAttachmentType type = 1146 vboxGlobal().toNetworkAttachmentType (pNetSet->cbNetworkAttachment->currentText()); 1147 valid = (slot == -1) && 1148 !(type == CEnums::HostInterfaceNetworkAttachment && 1149 !pNetSet->checkNetworkInterface (pNetSet->lbHostInterface->currentText())); 1150 if (slot == -1 && !valid) 1151 slot = index; 1167 int index = 0; 1168 for (; index < tbwNetwork->count(); ++index) 1169 { 1170 QWidget *tab = tbwNetwork->page (index); 1171 VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (tab); 1172 valid = set->isPageValid (mInterfaceList); 1173 if (!valid) break; 1152 1174 } 1153 1175 if (!valid) 1154 setWarning (tr ("Incorrect host network interface is selected for Adapter %1.")1155 .arg (slot));1176 setWarning (tr ("Incorrect host network interface is selected " 1177 "for Adapter %1.").arg (index)); 1156 1178 } 1157 1179 else if (pg == pageVRDP) … … 1397 1419 { 1398 1420 ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount(); 1399 for (ulong slot = 0; slot < count; slot ++)1421 for (ulong slot = 0; slot < count; ++ slot) 1400 1422 { 1401 1423 CNetworkAdapter adapter = machine.GetNetworkAdapter (slot); 1402 addNetworkAdapter (adapter , false);1424 addNetworkAdapter (adapter); 1403 1425 } 1404 1426 } … … 1744 1766 } 1745 1767 1746 void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &a dapter,1747 bool /* select */) 1748 { 1749 VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings ();1750 page->getFromAdapter (a dapter);1751 tbwNetwork->addTab (page, QString("Adapter %1").arg(adapter.GetSlot()));1768 void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &aAdapter) 1769 { 1770 VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings(); 1771 page->loadList (mInterfaceList); 1772 page->getFromAdapter (aAdapter); 1773 tbwNetwork->addTab (page, QString ("Adapter %1").arg (aAdapter.GetSlot())); 1752 1774 1753 1775 /* fix the tab order so that main dialog's buttons are always the last */ … … 1758 1780 /* setup validation */ 1759 1781 QIWidgetValidator *wval = new QIWidgetValidator (pageNetwork, this); 1782 connect (page->grbEnabled, SIGNAL (toggled (bool)), wval, SLOT (revalidate())); 1760 1783 connect (page->cbNetworkAttachment, SIGNAL (activated (const QString &)), 1761 1784 wval, SLOT (revalidate())); 1762 1785 1763 connect (page->lbHostInterface, SIGNAL ( selectionChanged () ), 1786 #if defined Q_WS_WIN 1787 connect (page->lbHostInterface, SIGNAL (highlighted (QListBoxItem*)), 1764 1788 wval, SLOT (revalidate())); 1765 connect (page->lbHostInterface, SIGNAL ( currentChanged ( QListBoxItem * ) ), 1766 wval, SLOT (revalidate())); 1767 connect (page->lbHostInterface, SIGNAL ( highlighted ( QListBoxItem * ) ), 1768 wval, SLOT (revalidate())); 1769 connect (page->grbEnabled, SIGNAL (toggled (bool)), 1770 wval, SLOT (revalidate())); 1789 connect (tbwNetwork, SIGNAL (currentChanged (QWidget*)), 1790 this, SLOT (networkPageUpdate (QWidget*))); 1791 connect (page, SIGNAL (listChanged (QWidget*)), 1792 this, SLOT (updateInterfaces (QWidget*))); 1793 #endif 1771 1794 1772 1795 connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)), … … 1775 1798 this, SLOT (revalidate( QIWidgetValidator *))); 1776 1799 1777 wval->revalidate(); 1800 page->setValidator (wval); 1801 page->revalidate(); 1778 1802 } 1779 1803
Note:
See TracChangeset
for help on using the changeset viewer.