Changeset 85886 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 25, 2020 8:58:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp
r85791 r85886 207 207 private: 208 208 209 /* Helper: Prepare stuff: */ 210 void prepareValidation(); 211 212 /* Prepares widgets: */ 209 /** Prepares all. */ 210 void prepare(); 211 /** Prepares widgets. */ 213 212 void prepareWidgets(); 213 /** Prepares connections. */ 214 void prepareConnections(); 214 215 215 216 /* Helping stuff: */ … … 233 234 /** @name Widgets 234 235 * @{ */ 235 QLabel *m_pAttachmentTypeLabel; 236 QLabel *m_pAdapterNameLabel; 237 QLabel *m_pAdapterTypeLabel; 238 QLabel *m_pPromiscuousModeLabel; 239 QLabel *m_pMACLabel; 240 QLabel *m_pGenericPropertiesLabel; 241 UINetworkAttachmentEditor *m_pAttachmentTypeEditor; 242 QILineEdit *m_pMACEditor; 243 QIToolButton *m_pMACButton; 244 QIArrowButtonSwitch *m_pAdvancedArrow; 245 QCheckBox *m_pEnableAdapterCheckBox; 246 QCheckBox *m_pCableConnectedCheckBox; 247 QPushButton *m_pPortForwardingButton; 248 QComboBox *m_pPromiscuousModeCombo; 249 QComboBox *m_pAdapterTypeCombo; 250 QTextEdit *m_pGenericPropertiesTextEdit; 251 QWidget *m_pAdapterOptionsContainer; 236 /** Holds the adapter check-box instance. */ 237 QCheckBox *m_pCheckBoxAdapter; 238 /** Holds the adapter settings widget instance. */ 239 QWidget *m_pWidgetAdapterSettings; 240 /** Holds the attachment type label instance. */ 241 QLabel *m_pLabelAttachmentType; 242 /** Holds the adapter name label instance. */ 243 QLabel *m_pLabelAdapterName; 244 /** Holds the attachment type editor instance. */ 245 UINetworkAttachmentEditor *m_pEditorAttachmentType; 246 /** Holds the advanced button instance. */ 247 QIArrowButtonSwitch *m_pButtonAdvanced; 248 /** Holds the adapter type label instance. */ 249 QLabel *m_pLabelAdapterType; 250 /** Holds the adapter type editor instance. */ 251 QComboBox *m_pComboAdapterType; 252 /** Holds the promiscuous mode label instance. */ 253 QLabel *m_pLabelPromiscuousMode; 254 /** Holds the promiscuous mode combo instance. */ 255 QComboBox *m_pComboPromiscuousMode; 256 /** Holds the MAC label instance. */ 257 QLabel *m_pLabelMAC; 258 /** Holds the MAC editor instance. */ 259 QILineEdit *m_pEditorMAC; 260 /** Holds the MAC button instance. */ 261 QIToolButton *m_pButtonMAC; 262 /** Holds the generic properties label instance. */ 263 QLabel *m_pLabelGenericProperties; 264 /** Holds the generic properties editor instance. */ 265 QTextEdit *m_pEditorGenericProperties; 266 /** Holds the cable connected check-box instance. */ 267 QCheckBox *m_pCheckBoxCableConnected; 268 /** Holds the port forwarding button instance. */ 269 QPushButton *m_pButtonPortForwarding; 252 270 /** @} */ 253 271 }; … … 263 281 , m_iSlot(-1) 264 282 , m_enmAdapterType(KNetworkAdapterType_Null) 265 , m_pAttachmentTypeLabel(0) 266 , m_pAdapterNameLabel(0) 267 , m_pAdapterTypeLabel(0) 268 , m_pPromiscuousModeLabel(0) 269 , m_pMACLabel(0) 270 , m_pGenericPropertiesLabel(0) 271 , m_pAttachmentTypeEditor(0) 272 , m_pMACEditor(0) 273 , m_pMACButton(0) 274 , m_pAdvancedArrow(0) 275 , m_pEnableAdapterCheckBox(0) 276 , m_pCableConnectedCheckBox(0) 277 , m_pPortForwardingButton(0) 278 , m_pPromiscuousModeCombo(0) 279 , m_pAdapterTypeCombo(0) 280 , m_pGenericPropertiesTextEdit(0) 281 , m_pAdapterOptionsContainer(0) 282 { 283 prepareWidgets(); 284 285 /* Determine icon metric: */ 286 const QStyle *pStyle = QApplication::style(); 287 const int iIconMetric = (int)(pStyle->pixelMetric(QStyle::PM_SmallIconSize) * .625); 288 289 /* Setup widgets: */ 290 m_pAttachmentTypeLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy1()); 291 m_pAdapterNameLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy2()); 292 m_pMACEditor->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this)); 293 m_pMACEditor->setMinimumWidthByText(QString().fill('0', 12)); 294 m_pMACButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 295 m_pAdvancedArrow->setIconSize(QSize(iIconMetric, iIconMetric)); 296 m_pAdvancedArrow->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"), 297 UIIconPool::iconSet(":/arrow_down_10px.png")); 298 299 /* Setup connections: */ 300 connect(m_pEnableAdapterCheckBox, &QCheckBox::toggled, this, &UIMachineSettingsNetwork::sltHandleAdapterActivityChange); 301 connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueTypeChanged, 302 this, &UIMachineSettingsNetwork::sltHandleAttachmentTypeChange); 303 connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueNameChanged, 304 this, &UIMachineSettingsNetwork::sltHandleAlternativeNameChange); 305 connect(m_pAdvancedArrow, &QIArrowButtonSwitch::sigClicked, this, &UIMachineSettingsNetwork::sltHandleAdvancedButtonStateChange); 306 connect(m_pMACButton, &QIToolButton::clicked, this, &UIMachineSettingsNetwork::sltGenerateMac); 307 connect(m_pPortForwardingButton, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg); 308 connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate); 309 310 /* Prepare validation: */ 311 prepareValidation(); 312 313 /* Apply language settings: */ 314 retranslateUi(); 283 , m_pCheckBoxAdapter(0) 284 , m_pWidgetAdapterSettings(0) 285 , m_pLabelAttachmentType(0) 286 , m_pLabelAdapterName(0) 287 , m_pEditorAttachmentType(0) 288 , m_pButtonAdvanced(0) 289 , m_pLabelAdapterType(0) 290 , m_pComboAdapterType(0) 291 , m_pLabelPromiscuousMode(0) 292 , m_pComboPromiscuousMode(0) 293 , m_pLabelMAC(0) 294 , m_pEditorMAC(0) 295 , m_pButtonMAC(0) 296 , m_pLabelGenericProperties(0) 297 , m_pEditorGenericProperties(0) 298 , m_pCheckBoxCableConnected(0) 299 , m_pButtonPortForwarding(0) 300 { 301 prepare(); 315 302 } 316 303 … … 324 311 325 312 /* Load adapter activity state: */ 326 m_p EnableAdapterCheckBox->setChecked(oldAdapterData.m_fAdapterEnabled);313 m_pCheckBoxAdapter->setChecked(oldAdapterData.m_fAdapterEnabled); 327 314 /* Handle adapter activity change: */ 328 315 sltHandleAdapterActivityChange(); 329 316 330 317 /* Load attachment type: */ 331 m_p AttachmentTypeEditor->setValueType(oldAdapterData.m_attachmentType);318 m_pEditorAttachmentType->setValueType(oldAdapterData.m_attachmentType); 332 319 /* Load alternative names: */ 333 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_Bridged, wipedOutString(oldAdapterData.m_strBridgedAdapterName));334 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_Internal, wipedOutString(oldAdapterData.m_strInternalNetworkName));335 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_HostOnly, wipedOutString(oldAdapterData.m_strHostInterfaceName));336 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_Generic, wipedOutString(oldAdapterData.m_strGenericDriverName));337 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_NATNetwork, wipedOutString(oldAdapterData.m_strNATNetworkName));320 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Bridged, wipedOutString(oldAdapterData.m_strBridgedAdapterName)); 321 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Internal, wipedOutString(oldAdapterData.m_strInternalNetworkName)); 322 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_HostOnly, wipedOutString(oldAdapterData.m_strHostInterfaceName)); 323 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Generic, wipedOutString(oldAdapterData.m_strGenericDriverName)); 324 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_NATNetwork, wipedOutString(oldAdapterData.m_strNATNetworkName)); 338 325 #ifdef VBOX_WITH_CLOUD_NET 339 m_p AttachmentTypeEditor->setValueName(KNetworkAttachmentType_Cloud, wipedOutString(oldAdapterData.m_strCloudNetworkName));326 m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Cloud, wipedOutString(oldAdapterData.m_strCloudNetworkName)); 340 327 #endif /* VBOX_WITH_CLOUD_NET */ 341 328 /* Handle attachment type change: */ … … 346 333 347 334 /* Load promiscuous mode type: */ 348 m_p PromiscuousModeCombo->setCurrentIndex(position(m_pPromiscuousModeCombo, oldAdapterData.m_promiscuousMode));335 m_pComboPromiscuousMode->setCurrentIndex(position(m_pComboPromiscuousMode, oldAdapterData.m_promiscuousMode)); 349 336 350 337 /* Other options: */ 351 m_p MACEditor->setText(oldAdapterData.m_strMACAddress);352 m_p GenericPropertiesTextEdit->setText(oldAdapterData.m_strGenericProperties);353 m_pC ableConnectedCheckBox->setChecked(oldAdapterData.m_fCableConnected);338 m_pEditorMAC->setText(oldAdapterData.m_strMACAddress); 339 m_pEditorGenericProperties->setText(oldAdapterData.m_strGenericProperties); 340 m_pCheckBoxCableConnected->setChecked(oldAdapterData.m_fCableConnected); 354 341 355 342 /* Load port forwarding rules: */ … … 370 357 371 358 /* Save adapter activity state: */ 372 newAdapterData.m_fAdapterEnabled = m_p EnableAdapterCheckBox->isChecked();359 newAdapterData.m_fAdapterEnabled = m_pCheckBoxAdapter->isChecked(); 373 360 374 361 /* Save attachment type & alternative name: */ … … 384 371 break; 385 372 case KNetworkAttachmentType_Internal: 386 newAdapterData.m_strInternalNetworkName = m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal);373 newAdapterData.m_strInternalNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Internal); 387 374 break; 388 375 case KNetworkAttachmentType_HostOnly: 389 newAdapterData.m_strHostInterfaceName = m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_HostOnly);376 newAdapterData.m_strHostInterfaceName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_HostOnly); 390 377 break; 391 378 case KNetworkAttachmentType_Generic: 392 newAdapterData.m_strGenericDriverName = m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic);393 newAdapterData.m_strGenericProperties = m_p GenericPropertiesTextEdit->toPlainText();379 newAdapterData.m_strGenericDriverName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Generic); 380 newAdapterData.m_strGenericProperties = m_pEditorGenericProperties->toPlainText(); 394 381 break; 395 382 case KNetworkAttachmentType_NATNetwork: 396 newAdapterData.m_strNATNetworkName = m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_NATNetwork);383 newAdapterData.m_strNATNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_NATNetwork); 397 384 break; 398 385 #ifdef VBOX_WITH_CLOUD_NET 399 386 case KNetworkAttachmentType_Cloud: 400 newAdapterData.m_strCloudNetworkName = m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_Cloud);387 newAdapterData.m_strCloudNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Cloud); 401 388 break; 402 389 #endif /* VBOX_WITH_CLOUD_NET */ … … 406 393 407 394 /* Save adapter type: */ 408 newAdapterData.m_adapterType = m_p AdapterTypeCombo->currentData().value<KNetworkAdapterType>();395 newAdapterData.m_adapterType = m_pComboAdapterType->currentData().value<KNetworkAdapterType>(); 409 396 410 397 /* Save promiscuous mode type: */ 411 newAdapterData.m_promiscuousMode = (KNetworkAdapterPromiscModePolicy)m_p PromiscuousModeCombo->itemData(m_pPromiscuousModeCombo->currentIndex()).toInt();398 newAdapterData.m_promiscuousMode = (KNetworkAdapterPromiscModePolicy)m_pComboPromiscuousMode->itemData(m_pComboPromiscuousMode->currentIndex()).toInt(); 412 399 413 400 /* Other options: */ 414 newAdapterData.m_strMACAddress = m_p MACEditor->text().isEmpty() ? QString() : m_pMACEditor->text();415 newAdapterData.m_fCableConnected = m_pC ableConnectedCheckBox->isChecked();401 newAdapterData.m_strMACAddress = m_pEditorMAC->text().isEmpty() ? QString() : m_pEditorMAC->text(); 402 newAdapterData.m_fCableConnected = m_pCheckBoxCableConnected->isChecked(); 416 403 417 404 /* Save port forwarding rules: */ … … 426 413 { 427 414 /* Pass if adapter is disabled: */ 428 if (!m_p EnableAdapterCheckBox->isChecked())415 if (!m_pCheckBoxAdapter->isChecked()) 429 416 return true; 430 417 … … 500 487 501 488 /* Validate MAC-address length: */ 502 if (m_p MACEditor->text().size() < 12)489 if (m_pEditorMAC->text().size() < 12) 503 490 { 504 491 message.second << tr("The MAC address must be 12 hexadecimal digits long."); … … 507 494 508 495 /* Make sure MAC-address is unicast: */ 509 if (m_p MACEditor->text().size() >= 2)496 if (m_pEditorMAC->text().size() >= 2) 510 497 { 511 498 QRegExp validator("^[0-9A-Fa-f][02468ACEace]"); 512 if (validator.indexIn(m_p MACEditor->text()) != 0)499 if (validator.indexIn(m_pEditorMAC->text()) != 0) 513 500 { 514 501 message.second << tr("The second digit in the MAC address may not be odd as only unicast addresses are allowed."); … … 527 514 QWidget *UIMachineSettingsNetwork::setOrderAfter(QWidget *pAfter) 528 515 { 529 setTabOrder(pAfter, m_p EnableAdapterCheckBox);530 setTabOrder(m_p EnableAdapterCheckBox, m_pAttachmentTypeEditor);531 setTabOrder(m_p AttachmentTypeEditor, m_pAdvancedArrow);532 setTabOrder(m_p AdvancedArrow, m_pAdapterTypeCombo);533 setTabOrder(m_p AdapterTypeCombo, m_pPromiscuousModeCombo);534 setTabOrder(m_p PromiscuousModeCombo, m_pMACEditor);535 setTabOrder(m_p MACEditor, m_pMACButton);536 setTabOrder(m_p MACButton, m_pGenericPropertiesTextEdit);537 setTabOrder(m_p GenericPropertiesTextEdit, m_pCableConnectedCheckBox);538 setTabOrder(m_pC ableConnectedCheckBox, m_pPortForwardingButton);539 return m_p PortForwardingButton;516 setTabOrder(pAfter, m_pCheckBoxAdapter); 517 setTabOrder(m_pCheckBoxAdapter, m_pEditorAttachmentType); 518 setTabOrder(m_pEditorAttachmentType, m_pButtonAdvanced); 519 setTabOrder(m_pButtonAdvanced, m_pComboAdapterType); 520 setTabOrder(m_pComboAdapterType, m_pComboPromiscuousMode); 521 setTabOrder(m_pComboPromiscuousMode, m_pEditorMAC); 522 setTabOrder(m_pEditorMAC, m_pButtonMAC); 523 setTabOrder(m_pButtonMAC, m_pEditorGenericProperties); 524 setTabOrder(m_pEditorGenericProperties, m_pCheckBoxCableConnected); 525 setTabOrder(m_pCheckBoxCableConnected, m_pButtonPortForwarding); 526 return m_pButtonPortForwarding; 540 527 } 541 528 … … 547 534 KNetworkAttachmentType UIMachineSettingsNetwork::attachmentType() const 548 535 { 549 return m_p AttachmentTypeEditor->valueType();536 return m_pEditorAttachmentType->valueType(); 550 537 } 551 538 … … 554 541 if (enmType == KNetworkAttachmentType_Null) 555 542 enmType = attachmentType(); 556 return m_p AttachmentTypeEditor->valueName(enmType);543 return m_pEditorAttachmentType->valueName(enmType); 557 544 } 558 545 … … 560 547 { 561 548 /* Basic attributes: */ 562 m_p EnableAdapterCheckBox->setEnabled(m_pParent->isMachineOffline());563 m_p AttachmentTypeLabel->setEnabled(m_pParent->isMachineInValidMode());564 m_p AttachmentTypeEditor->setEnabled(m_pParent->isMachineInValidMode());565 m_p AdapterNameLabel->setEnabled(m_pParent->isMachineInValidMode() &&549 m_pCheckBoxAdapter->setEnabled(m_pParent->isMachineOffline()); 550 m_pLabelAttachmentType->setEnabled(m_pParent->isMachineInValidMode()); 551 m_pEditorAttachmentType->setEnabled(m_pParent->isMachineInValidMode()); 552 m_pLabelAdapterName->setEnabled(m_pParent->isMachineInValidMode() && 566 553 attachmentType() != KNetworkAttachmentType_Null && 567 554 attachmentType() != KNetworkAttachmentType_NAT); 568 m_p AdvancedArrow->setEnabled(m_pParent->isMachineInValidMode());555 m_pButtonAdvanced->setEnabled(m_pParent->isMachineInValidMode()); 569 556 570 557 /* Advanced attributes: */ 571 m_p AdapterTypeLabel->setEnabled(m_pParent->isMachineOffline());572 m_p AdapterTypeCombo->setEnabled(m_pParent->isMachineOffline());573 m_p PromiscuousModeLabel->setEnabled(m_pParent->isMachineInValidMode() &&558 m_pLabelAdapterType->setEnabled(m_pParent->isMachineOffline()); 559 m_pComboAdapterType->setEnabled(m_pParent->isMachineOffline()); 560 m_pLabelPromiscuousMode->setEnabled(m_pParent->isMachineInValidMode() && 574 561 attachmentType() != KNetworkAttachmentType_Null && 575 562 attachmentType() != KNetworkAttachmentType_Generic && 576 563 attachmentType() != KNetworkAttachmentType_NAT); 577 m_p PromiscuousModeCombo->setEnabled(m_pParent->isMachineInValidMode() &&564 m_pComboPromiscuousMode->setEnabled(m_pParent->isMachineInValidMode() && 578 565 attachmentType() != KNetworkAttachmentType_Null && 579 566 attachmentType() != KNetworkAttachmentType_Generic && 580 567 attachmentType() != KNetworkAttachmentType_NAT); 581 m_p MACLabel->setEnabled(m_pParent->isMachineOffline());582 m_p MACEditor->setEnabled(m_pParent->isMachineOffline());583 m_p MACButton->setEnabled(m_pParent->isMachineOffline());584 m_p GenericPropertiesLabel->setEnabled(m_pParent->isMachineInValidMode());585 m_p GenericPropertiesTextEdit->setEnabled(m_pParent->isMachineInValidMode());586 m_pC ableConnectedCheckBox->setEnabled(m_pParent->isMachineInValidMode());587 m_p PortForwardingButton->setEnabled(m_pParent->isMachineInValidMode() &&568 m_pLabelMAC->setEnabled(m_pParent->isMachineOffline()); 569 m_pEditorMAC->setEnabled(m_pParent->isMachineOffline()); 570 m_pButtonMAC->setEnabled(m_pParent->isMachineOffline()); 571 m_pLabelGenericProperties->setEnabled(m_pParent->isMachineInValidMode()); 572 m_pEditorGenericProperties->setEnabled(m_pParent->isMachineInValidMode()); 573 m_pCheckBoxCableConnected->setEnabled(m_pParent->isMachineInValidMode()); 574 m_pButtonPortForwarding->setEnabled(m_pParent->isMachineInValidMode() && 588 575 attachmentType() == KNetworkAttachmentType_NAT); 589 576 … … 594 581 void UIMachineSettingsNetwork::reloadAlternatives() 595 582 { 596 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Bridged, m_pParent->bridgedAdapterList());597 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Internal, m_pParent->internalNetworkList());598 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_HostOnly, m_pParent->hostInterfaceList());599 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Generic, m_pParent->genericDriverList());600 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_NATNetwork, m_pParent->natNetworkList());583 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Bridged, m_pParent->bridgedAdapterList()); 584 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Internal, m_pParent->internalNetworkList()); 585 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_HostOnly, m_pParent->hostInterfaceList()); 586 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Generic, m_pParent->genericDriverList()); 587 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_NATNetwork, m_pParent->natNetworkList()); 601 588 #ifdef VBOX_WITH_CLOUD_NET 602 m_p AttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Cloud, m_pParent->cloudNetworkList());589 m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Cloud, m_pParent->cloudNetworkList()); 603 590 #endif /* VBOX_WITH_CLOUD_NET */ 604 591 } … … 607 594 { 608 595 /* Check whether the button state really changed: */ 609 if (m_p AdvancedArrow->isExpanded() == fExpanded)596 if (m_pButtonAdvanced->isExpanded() == fExpanded) 610 597 return; 611 598 612 599 /* Push the state to button and handle the state change: */ 613 m_p AdvancedArrow->setExpanded(fExpanded);600 m_pButtonAdvanced->setExpanded(fExpanded); 614 601 handleAdvancedButtonStateChange(); 615 602 } … … 617 604 void UIMachineSettingsNetwork::retranslateUi() 618 605 { 619 m_p EnableAdapterCheckBox->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual "606 m_pCheckBoxAdapter->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual " 620 607 "network adapter into the virtual machine.")); 621 m_p EnableAdapterCheckBox->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter"));622 m_p AttachmentTypeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:"));623 m_p AttachmentTypeEditor->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter "608 m_pCheckBoxAdapter->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter")); 609 m_pLabelAttachmentType->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:")); 610 m_pEditorAttachmentType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter " 624 611 "is attached to the real network of the Host OS.")); 625 m_p AdapterNameLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:"));626 m_p AdvancedArrow->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced"));627 m_p AdvancedArrow->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options."));628 m_p AdapterTypeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:"));629 m_p AdapterTypeCombo->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network "612 m_pLabelAdapterName->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:")); 613 m_pButtonAdvanced->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced")); 614 m_pButtonAdvanced->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options.")); 615 m_pLabelAdapterType->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:")); 616 m_pComboAdapterType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network " 630 617 "adapter. Depending on this value, VirtualBox will provide different " 631 618 "network hardware to the virtual machine.")); 632 m_p PromiscuousModeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:"));633 m_p PromiscuousModeCombo->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy "619 m_pLabelPromiscuousMode->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:")); 620 m_pComboPromiscuousMode->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy " 634 621 "of the network adapter when attached to an internal network, " 635 622 "host only network or a bridge.")); 636 m_p MACLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:"));637 m_p MACEditor->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains "623 m_pLabelMAC->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:")); 624 m_pEditorMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains " 638 625 "exactly 12 characters chosen from {0-9,A-F}. Note that the second character " 639 626 "must be an even digit.")); 640 m_p MACButton->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Generates a new random MAC address."));641 m_p GenericPropertiesLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "Generic Properties:"));642 m_p GenericPropertiesTextEdit->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the configuration settings "627 m_pButtonMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Generates a new random MAC address.")); 628 m_pLabelGenericProperties->setText(QApplication::translate("UIMachineSettingsNetwork", "Generic Properties:")); 629 m_pEditorGenericProperties->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the configuration settings " 643 630 "for the network attachment driver. The settings should be of " 644 631 "the form <b>name=value</b> and will depend on the driver. " 645 632 "Use <b>shift-enter</b> to add a new entry.")); 646 m_pC ableConnectedCheckBox->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, the virtual network "633 m_pCheckBoxCableConnected->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, the virtual network " 647 634 "cable is plugged in.")); 648 m_pC ableConnectedCheckBox->setText(QApplication::translate("UIMachineSettingsNetwork", "&Cable Connected"));649 m_p PortForwardingButton->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Displays a window to configure port "635 m_pCheckBoxCableConnected->setText(QApplication::translate("UIMachineSettingsNetwork", "&Cable Connected")); 636 m_pButtonPortForwarding->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Displays a window to configure port " 650 637 "forwarding rules.")); 651 m_p PortForwardingButton->setText(QApplication::translate("UIMachineSettingsNetwork", "&Port Forwarding"));638 m_pButtonPortForwarding->setText(QApplication::translate("UIMachineSettingsNetwork", "&Port Forwarding")); 652 639 653 640 /* Translate combo-boxes content: */ … … 661 648 { 662 649 /* Update availability: */ 663 m_p AdapterOptionsContainer->setEnabled(m_pEnableAdapterCheckBox->isChecked());650 m_pWidgetAdapterSettings->setEnabled(m_pCheckBoxAdapter->isChecked()); 664 651 665 652 /* Generate a new MAC address in case this adapter was never enabled before: */ 666 if ( m_p EnableAdapterCheckBox->isChecked()667 && m_p MACEditor->text().isEmpty())653 if ( m_pCheckBoxAdapter->isChecked() 654 && m_pEditorMAC->text().isEmpty()) 668 655 sltGenerateMac(); 669 656 … … 675 662 { 676 663 /* Update alternative-name combo-box availability: */ 677 m_p AdapterNameLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&664 m_pLabelAdapterName->setEnabled(attachmentType() != KNetworkAttachmentType_Null && 678 665 attachmentType() != KNetworkAttachmentType_NAT); 679 666 /* Update promiscuous-mode combo-box availability: */ 680 m_p PromiscuousModeLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&667 m_pLabelPromiscuousMode->setEnabled(attachmentType() != KNetworkAttachmentType_Null && 681 668 attachmentType() != KNetworkAttachmentType_Generic && 682 669 attachmentType() != KNetworkAttachmentType_NAT); 683 m_p PromiscuousModeCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&670 m_pComboPromiscuousMode->setEnabled(attachmentType() != KNetworkAttachmentType_Null && 684 671 attachmentType() != KNetworkAttachmentType_Generic && 685 672 attachmentType() != KNetworkAttachmentType_NAT); 686 673 /* Update generic-properties editor visibility: */ 687 m_p GenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&688 m_p AdvancedArrow->isExpanded());689 m_p GenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&690 m_p AdvancedArrow->isExpanded());674 m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 675 m_pButtonAdvanced->isExpanded()); 676 m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 677 m_pButtonAdvanced->isExpanded()); 691 678 /* Update forwarding rules button availability: */ 692 m_p PortForwardingButton->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);679 m_pButtonPortForwarding->setEnabled(attachmentType() == KNetworkAttachmentType_NAT); 693 680 694 681 /* Revalidate: */ … … 704 691 case KNetworkAttachmentType_Internal: 705 692 { 706 if (!m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal).isNull())693 if (!m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Internal).isNull()) 707 694 emit sigTabUpdated(); 708 695 break; … … 710 697 case KNetworkAttachmentType_Generic: 711 698 { 712 if (!m_p AttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic).isNull())699 if (!m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Generic).isNull()) 713 700 emit sigTabUpdated(); 714 701 break; … … 728 715 729 716 /* Notify listeners about the button state change: */ 730 emit sigNotifyAdvancedButtonStateChange(m_p AdvancedArrow->isExpanded());717 emit sigNotifyAdvancedButtonStateChange(m_pButtonAdvanced->isExpanded()); 731 718 } 732 719 733 720 void UIMachineSettingsNetwork::sltGenerateMac() 734 721 { 735 m_p MACEditor->setText(uiCommon().host().GenerateMACAddress());722 m_pEditorMAC->setText(uiCommon().host().GenerateMACAddress()); 736 723 } 737 724 … … 743 730 } 744 731 745 void UIMachineSettingsNetwork::prepareValidation() 746 { 747 /* Configure validation: */ 748 connect(m_pMACEditor, &QILineEdit::textChanged, m_pParent, &UIMachineSettingsNetworkPage::revalidate); 732 void UIMachineSettingsNetwork::prepare() 733 { 734 /* Prepare everything: */ 735 prepareWidgets(); 736 prepareConnections(); 737 738 /* Apply language settings: */ 739 retranslateUi(); 749 740 } 750 741 751 742 void UIMachineSettingsNetwork::prepareWidgets() 752 743 { 753 if (objectName().isEmpty()) 754 setObjectName(QStringLiteral("UIMachineSettingsNetwork")); 755 resize(430, 250); 744 /* Prepare main layout: */ 756 745 QGridLayout *pMainLayout = new QGridLayout(this); 757 pMainLayout->setObjectName(QStringLiteral("pMainLayout")); 758 m_pEnableAdapterCheckBox = new QCheckBox(this); 759 m_pEnableAdapterCheckBox->setObjectName(QStringLiteral("m_pEnableAdapterCheckBox")); 760 761 pMainLayout->addWidget(m_pEnableAdapterCheckBox, 0, 0, 1, 2); 762 QSpacerItem *pHorizontalSpacer1 = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 763 pMainLayout->addItem(pHorizontalSpacer1, 1, 0, 1, 1); 764 765 m_pAdapterOptionsContainer = new QWidget(); 766 m_pAdapterOptionsContainer->setObjectName(QStringLiteral("m_pAdapterOptionsContainer")); 767 QGridLayout *pAdapterOptionsLayout = new QGridLayout(m_pAdapterOptionsContainer); 768 pAdapterOptionsLayout->setContentsMargins(0, 0, 0, 0); 769 pAdapterOptionsLayout->setObjectName(QStringLiteral("pAdapterOptionsLayout")); 770 m_pAttachmentTypeLabel = new QLabel(m_pAdapterOptionsContainer); 771 m_pAttachmentTypeLabel->setObjectName(QStringLiteral("m_pAttachmentTypeLabel")); 772 m_pAttachmentTypeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 773 pAdapterOptionsLayout->addWidget(m_pAttachmentTypeLabel, 0, 0, 1, 1); 774 775 m_pAttachmentTypeEditor = new UINetworkAttachmentEditor(m_pAdapterOptionsContainer); 776 m_pAttachmentTypeEditor->setObjectName(QStringLiteral("m_pAttachmentTypeEditor")); 777 pAdapterOptionsLayout->addWidget(m_pAttachmentTypeEditor, 0, 1, 2, 3); 778 779 m_pAdapterNameLabel = new QLabel(m_pAdapterOptionsContainer); 780 m_pAdapterNameLabel->setObjectName(QStringLiteral("m_pAdapterNameLabel")); 781 m_pAdapterNameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 782 pAdapterOptionsLayout->addWidget(m_pAdapterNameLabel, 1, 0, 1, 1); 783 784 QHBoxLayout *pAdvancedButtonLayout = new QHBoxLayout(); 785 pAdvancedButtonLayout->setContentsMargins(0, 0, 0, 0); 786 pAdvancedButtonLayout->setObjectName(QStringLiteral("pAdvancedButtonLayout")); 787 QSpacerItem *pHorizontalSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 788 pAdvancedButtonLayout->addItem(pHorizontalSpacer2); 789 790 m_pAdvancedArrow = new QIArrowButtonSwitch(m_pAdapterOptionsContainer); 791 m_pAdvancedArrow->setObjectName(QStringLiteral("m_pAdvancedArrow")); 792 pAdvancedButtonLayout->addWidget(m_pAdvancedArrow); 793 pAdapterOptionsLayout->addLayout(pAdvancedButtonLayout, 2, 0, 1, 1); 794 795 m_pAdapterTypeLabel = new QLabel(m_pAdapterOptionsContainer); 796 m_pAdapterTypeLabel->setObjectName(QStringLiteral("m_pAdapterTypeLabel")); 797 m_pAdapterTypeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 798 pAdapterOptionsLayout->addWidget(m_pAdapterTypeLabel, 3, 0, 1, 1); 799 800 m_pAdapterTypeCombo = new QComboBox(m_pAdapterOptionsContainer); 801 m_pAdapterTypeCombo->setObjectName(QStringLiteral("m_pAdapterTypeCombo")); 802 QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 803 sizePolicy.setHorizontalStretch(1); 804 sizePolicy.setVerticalStretch(0); 805 sizePolicy.setHeightForWidth(m_pAdapterTypeCombo->sizePolicy().hasHeightForWidth()); 806 m_pAdapterTypeCombo->setSizePolicy(sizePolicy); 807 pAdapterOptionsLayout->addWidget(m_pAdapterTypeCombo, 3, 1, 1, 3); 808 809 m_pPromiscuousModeLabel = new QLabel(m_pAdapterOptionsContainer); 810 m_pPromiscuousModeLabel->setObjectName(QStringLiteral("m_pPromiscuousModeLabel")); 811 m_pPromiscuousModeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 812 pAdapterOptionsLayout->addWidget(m_pPromiscuousModeLabel, 4, 0, 1, 1); 813 814 m_pPromiscuousModeCombo = new QComboBox(m_pAdapterOptionsContainer); 815 m_pPromiscuousModeCombo->setObjectName(QStringLiteral("m_pPromiscuousModeCombo")); 816 sizePolicy.setHeightForWidth(m_pPromiscuousModeCombo->sizePolicy().hasHeightForWidth()); 817 m_pPromiscuousModeCombo->setSizePolicy(sizePolicy); 818 pAdapterOptionsLayout->addWidget(m_pPromiscuousModeCombo, 4, 1, 1, 3); 819 820 m_pMACLabel = new QLabel(m_pAdapterOptionsContainer); 821 m_pMACLabel->setObjectName(QStringLiteral("m_pMACLabel")); 822 m_pMACLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 823 pAdapterOptionsLayout->addWidget(m_pMACLabel, 5, 0, 1, 1); 824 825 m_pMACEditor = new QILineEdit(m_pAdapterOptionsContainer); 826 m_pMACEditor->setObjectName(QStringLiteral("m_pMACEditor")); 827 sizePolicy.setHeightForWidth(m_pMACEditor->sizePolicy().hasHeightForWidth()); 828 m_pMACEditor->setSizePolicy(sizePolicy); 829 pAdapterOptionsLayout->addWidget(m_pMACEditor, 5, 1, 1, 2); 830 831 m_pMACButton = new QIToolButton(m_pAdapterOptionsContainer); 832 m_pMACButton->setObjectName(QStringLiteral("m_pMACButton")); 833 pAdapterOptionsLayout->addWidget(m_pMACButton, 5, 3, 1, 1); 834 835 m_pGenericPropertiesLabel = new QLabel(m_pAdapterOptionsContainer); 836 m_pGenericPropertiesLabel->setObjectName(QStringLiteral("m_pGenericPropertiesLabel")); 837 m_pGenericPropertiesLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignTop); 838 pAdapterOptionsLayout->addWidget(m_pGenericPropertiesLabel, 6, 0, 1, 1); 839 840 m_pGenericPropertiesTextEdit = new QTextEdit(m_pAdapterOptionsContainer); 841 m_pGenericPropertiesTextEdit->setObjectName(QStringLiteral("m_pGenericPropertiesTextEdit")); 842 pAdapterOptionsLayout->addWidget(m_pGenericPropertiesTextEdit, 6, 1, 1, 3); 843 844 m_pCableConnectedCheckBox = new QCheckBox(m_pAdapterOptionsContainer); 845 m_pCableConnectedCheckBox->setObjectName(QStringLiteral("m_pCableConnectedCheckBox")); 846 pAdapterOptionsLayout->addWidget(m_pCableConnectedCheckBox, 7, 1, 1, 3); 847 848 m_pPortForwardingButton = new QPushButton(m_pAdapterOptionsContainer); 849 m_pPortForwardingButton->setObjectName(QStringLiteral("m_pPortForwardingButton")); 850 pAdapterOptionsLayout->addWidget(m_pPortForwardingButton, 8, 1, 1, 1); 851 852 QSpacerItem *pVerticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); 853 pAdapterOptionsLayout->addItem(pVerticalSpacer, 9, 0, 1, 4); 854 pMainLayout->addWidget(m_pAdapterOptionsContainer, 1, 1, 1, 1); 855 856 m_pAdapterTypeLabel->setBuddy(m_pAdapterTypeCombo); 857 m_pPromiscuousModeLabel->setBuddy(m_pPromiscuousModeCombo); 858 m_pMACLabel->setBuddy(m_pMACEditor); 746 if (pMainLayout) 747 { 748 pMainLayout->setRowStretch(2, 1); 749 750 /* Prepare adapter check-box: */ 751 m_pCheckBoxAdapter = new QCheckBox(this); 752 if (m_pCheckBoxAdapter) 753 pMainLayout->addWidget(m_pCheckBoxAdapter, 0, 0, 1, 2); 754 755 /* Prepare 20-px shifting spacer: */ 756 QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 757 if (pSpacerItem) 758 pMainLayout->addItem(pSpacerItem, 1, 0); 759 760 /* Prepare adapter settings widget: */ 761 m_pWidgetAdapterSettings = new QWidget(this); 762 if (m_pWidgetAdapterSettings) 763 { 764 /* Prepare adapter settings widget layout: */ 765 QGridLayout *pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings); 766 if (pLayoutAdapterSettings) 767 { 768 pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0); 769 pLayoutAdapterSettings->setColumnStretch(2, 1); 770 771 /* Prepare attachment type label: */ 772 m_pLabelAttachmentType = new QLabel(m_pWidgetAdapterSettings); 773 if (m_pLabelAttachmentType) 774 { 775 m_pLabelAttachmentType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 776 pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0); 777 } 778 /* Prepare adapter name label: */ 779 m_pLabelAdapterName = new QLabel(m_pWidgetAdapterSettings); 780 if (m_pLabelAdapterName) 781 { 782 m_pLabelAdapterName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 783 pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0); 784 } 785 /* Prepare attachment type editor: */ 786 m_pEditorAttachmentType = new UINetworkAttachmentEditor(m_pWidgetAdapterSettings); 787 if (m_pEditorAttachmentType) 788 { 789 m_pLabelAttachmentType->setBuddy(m_pEditorAttachmentType->focusProxy1()); 790 m_pLabelAdapterName->setBuddy(m_pEditorAttachmentType->focusProxy2()); 791 pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3); 792 } 793 794 /* Prepare advanced arraow button: */ 795 m_pButtonAdvanced = new QIArrowButtonSwitch(m_pWidgetAdapterSettings); 796 if (m_pButtonAdvanced) 797 { 798 const QStyle *pStyle = QApplication::style(); 799 const int iIconMetric = (int)(pStyle->pixelMetric(QStyle::PM_SmallIconSize) * .625); 800 m_pButtonAdvanced->setIconSize(QSize(iIconMetric, iIconMetric)); 801 m_pButtonAdvanced->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"), 802 UIIconPool::iconSet(":/arrow_down_10px.png")); 803 804 pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0); 805 } 806 807 /* Prepare adapter type label: */ 808 m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings); 809 if (m_pLabelAdapterType) 810 { 811 m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 812 pLayoutAdapterSettings->addWidget(m_pLabelAdapterType, 3, 0); 813 } 814 /* Prepare adapter type combo: */ 815 m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings); 816 if (m_pComboAdapterType) 817 { 818 m_pLabelAdapterType->setBuddy(m_pComboAdapterType); 819 pLayoutAdapterSettings->addWidget(m_pComboAdapterType, 3, 1, 1, 3); 820 } 821 822 /* Prepare promiscuous mode label: */ 823 m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings); 824 if (m_pLabelPromiscuousMode) 825 { 826 m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 827 pLayoutAdapterSettings->addWidget(m_pLabelPromiscuousMode, 4, 0); 828 } 829 /* Prepare promiscuous mode combo: */ 830 m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings); 831 if (m_pComboPromiscuousMode) 832 { 833 m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode); 834 pLayoutAdapterSettings->addWidget(m_pComboPromiscuousMode, 4, 1, 1, 3); 835 } 836 837 /* Prepare MAC label: */ 838 m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings); 839 if (m_pLabelMAC) 840 { 841 m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 842 pLayoutAdapterSettings->addWidget(m_pLabelMAC, 5, 0); 843 } 844 /* Prepare MAC editor: */ 845 m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings); 846 if (m_pEditorMAC) 847 { 848 m_pLabelMAC->setBuddy(m_pEditorMAC); 849 m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this)); 850 m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12)); 851 852 pLayoutAdapterSettings->addWidget(m_pEditorMAC, 5, 1, 1, 2); 853 } 854 /* Prepare MAC button: */ 855 m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings); 856 if (m_pButtonMAC) 857 { 858 m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 859 pLayoutAdapterSettings->addWidget(m_pButtonMAC, 5, 3); 860 } 861 862 /* Prepare MAC label: */ 863 m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings); 864 if (m_pLabelGenericProperties) 865 { 866 m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop); 867 pLayoutAdapterSettings->addWidget(m_pLabelGenericProperties, 6, 0); 868 } 869 /* Prepare MAC editor: */ 870 m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings); 871 if (m_pEditorGenericProperties) 872 pLayoutAdapterSettings->addWidget(m_pEditorGenericProperties, 6, 1, 1, 3); 873 874 /* Prepare cable connected check-box: */ 875 m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings); 876 if (m_pCheckBoxCableConnected) 877 pLayoutAdapterSettings->addWidget(m_pCheckBoxCableConnected, 7, 1, 1, 3); 878 879 /* Prepare port forwarding button: */ 880 m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings); 881 if (m_pButtonPortForwarding) 882 pLayoutAdapterSettings->addWidget(m_pButtonPortForwarding, 8, 1); 883 } 884 885 pMainLayout->addWidget(m_pWidgetAdapterSettings, 1, 1); 886 } 887 } 888 } 889 890 void UIMachineSettingsNetwork::prepareConnections() 891 { 892 connect(m_pCheckBoxAdapter, &QCheckBox::toggled, this, &UIMachineSettingsNetwork::sltHandleAdapterActivityChange); 893 connect(m_pEditorAttachmentType, &UINetworkAttachmentEditor::sigValueTypeChanged, 894 this, &UIMachineSettingsNetwork::sltHandleAttachmentTypeChange); 895 connect(m_pEditorAttachmentType, &UINetworkAttachmentEditor::sigValueNameChanged, 896 this, &UIMachineSettingsNetwork::sltHandleAlternativeNameChange); 897 connect(m_pButtonAdvanced, &QIArrowButtonSwitch::sigClicked, this, &UIMachineSettingsNetwork::sltHandleAdvancedButtonStateChange); 898 connect(m_pEditorMAC, &QILineEdit::textChanged, m_pParent, &UIMachineSettingsNetworkPage::revalidate); 899 connect(m_pButtonMAC, &QIToolButton::clicked, this, &UIMachineSettingsNetwork::sltGenerateMac); 900 connect(m_pButtonPortForwarding, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg); 901 connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate); 859 902 } 860 903 … … 869 912 { 870 913 /* Clear the adapter type combo-box: */ 871 m_p AdapterTypeCombo->clear();914 m_pComboAdapterType->clear(); 872 915 873 916 /* Load currently supported network adapter types: */ … … 882 925 foreach (const KNetworkAdapterType &enmType, supportedTypes) 883 926 { 884 m_p AdapterTypeCombo->insertItem(iAdapterTypeIndex, gpConverter->toString(enmType));885 m_p AdapterTypeCombo->setItemData(iAdapterTypeIndex, QVariant::fromValue(enmType));886 m_p AdapterTypeCombo->setItemData(iAdapterTypeIndex, m_pAdapterTypeCombo->itemText(iAdapterTypeIndex), Qt::ToolTipRole);927 m_pComboAdapterType->insertItem(iAdapterTypeIndex, gpConverter->toString(enmType)); 928 m_pComboAdapterType->setItemData(iAdapterTypeIndex, QVariant::fromValue(enmType)); 929 m_pComboAdapterType->setItemData(iAdapterTypeIndex, m_pComboAdapterType->itemText(iAdapterTypeIndex), Qt::ToolTipRole); 887 930 ++iAdapterTypeIndex; 888 931 } 889 932 890 933 /* Choose requested adapter type: */ 891 const int iIndex = m_p AdapterTypeCombo->findData(m_enmAdapterType);892 m_p AdapterTypeCombo->setCurrentIndex(iIndex != -1 ? iIndex : 0);934 const int iIndex = m_pComboAdapterType->findData(m_enmAdapterType); 935 m_pComboAdapterType->setCurrentIndex(iIndex != -1 ? iIndex : 0); 893 936 } 894 937 … … 896 939 { 897 940 /* Remember the currently selected promiscuous mode type: */ 898 int iCurrentPromiscuousMode = m_p PromiscuousModeCombo->currentIndex();941 int iCurrentPromiscuousMode = m_pComboPromiscuousMode->currentIndex(); 899 942 900 943 /* Clear the promiscuous mode combo-box: */ 901 m_p PromiscuousModeCombo->clear();944 m_pComboPromiscuousMode->clear(); 902 945 903 946 /* Populate promiscuous modes: */ 904 947 int iPromiscuousModeIndex = 0; 905 m_p PromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_Deny));906 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_Deny);907 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);948 m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_Deny)); 949 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_Deny); 950 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole); 908 951 ++iPromiscuousModeIndex; 909 m_p PromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowNetwork));910 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowNetwork);911 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);952 m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowNetwork)); 953 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowNetwork); 954 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole); 912 955 ++iPromiscuousModeIndex; 913 m_p PromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowAll));914 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowAll);915 m_p PromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);956 m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowAll)); 957 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowAll); 958 m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole); 916 959 ++iPromiscuousModeIndex; 917 960 918 961 /* Restore the previously selected promiscuous mode type: */ 919 m_p PromiscuousModeCombo->setCurrentIndex(iCurrentPromiscuousMode == -1 ? 0 : iCurrentPromiscuousMode);962 m_pComboPromiscuousMode->setCurrentIndex(iCurrentPromiscuousMode == -1 ? 0 : iCurrentPromiscuousMode); 920 963 } 921 964 } … … 924 967 { 925 968 /* Update visibility of advanced options: */ 926 m_p AdapterTypeLabel->setVisible(m_pAdvancedArrow->isExpanded());927 m_p AdapterTypeCombo->setVisible(m_pAdvancedArrow->isExpanded());928 m_p PromiscuousModeLabel->setVisible(m_pAdvancedArrow->isExpanded());929 m_p PromiscuousModeCombo->setVisible(m_pAdvancedArrow->isExpanded());930 m_p GenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&931 m_p AdvancedArrow->isExpanded());932 m_p GenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&933 m_p AdvancedArrow->isExpanded());934 m_p MACLabel->setVisible(m_pAdvancedArrow->isExpanded());935 m_p MACEditor->setVisible(m_pAdvancedArrow->isExpanded());936 m_p MACButton->setVisible(m_pAdvancedArrow->isExpanded());937 m_pC ableConnectedCheckBox->setVisible(m_pAdvancedArrow->isExpanded());938 m_p PortForwardingButton->setVisible(m_pAdvancedArrow->isExpanded());969 m_pLabelAdapterType->setVisible(m_pButtonAdvanced->isExpanded()); 970 m_pComboAdapterType->setVisible(m_pButtonAdvanced->isExpanded()); 971 m_pLabelPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded()); 972 m_pComboPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded()); 973 m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 974 m_pButtonAdvanced->isExpanded()); 975 m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 976 m_pButtonAdvanced->isExpanded()); 977 m_pLabelMAC->setVisible(m_pButtonAdvanced->isExpanded()); 978 m_pEditorMAC->setVisible(m_pButtonAdvanced->isExpanded()); 979 m_pButtonMAC->setVisible(m_pButtonAdvanced->isExpanded()); 980 m_pCheckBoxCableConnected->setVisible(m_pButtonAdvanced->isExpanded()); 981 m_pButtonPortForwarding->setVisible(m_pButtonAdvanced->isExpanded()); 939 982 } 940 983
Note:
See TracChangeset
for help on using the changeset viewer.