Changeset 87220 in vbox for trunk/src/VBox
- Timestamp:
- Jan 12, 2021 7:56:08 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/networkmanager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp
r87219 r87220 48 48 49 49 50 /** Tree-widget column tags. */51 enum 52 { 53 Column_Name,54 Column_IPv4,55 Column_IPv6,56 Column_DHCP,57 Column_Max,50 /** Host network tree-widget column indexes. */ 51 enum HostNetworkColumn 52 { 53 HostNetworkColumn_Name, 54 HostNetworkColumn_IPv4, 55 HostNetworkColumn_IPv6, 56 HostNetworkColumn_DHCP, 57 HostNetworkColumn_Max, 58 58 }; 59 59 … … 86 86 { 87 87 /* Compose item fields: */ 88 setText( Column_Name, m_interface.m_strName);89 setText( Column_IPv4, m_interface.m_strAddress.isEmpty() ? QString() :90 QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask)));91 setText( Column_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() :92 QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt()));93 setText( Column_DHCP, tr("Enable", "DHCP Server"));94 setCheckState( Column_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked);88 setText(HostNetworkColumn_Name, m_interface.m_strName); 89 setText(HostNetworkColumn_IPv4, m_interface.m_strAddress.isEmpty() ? QString() : 90 QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask))); 91 setText(HostNetworkColumn_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() : 92 QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt())); 93 setText(HostNetworkColumn_DHCP, tr("Enable", "DHCP Server")); 94 setCheckState(HostNetworkColumn_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked); 95 95 96 96 /* Compose item tool-tip: */ … … 151 151 152 152 /* Assign tool-tip finally: */ 153 setToolTip( Column_Name, strTable.arg(strToolTip));153 setToolTip(HostNetworkColumn_Name, strTable.arg(strToolTip)); 154 154 } 155 155 … … 302 302 /* Create interface: */ 303 303 CHostNetworkInterface comInterface; 304 CProgress progress = comHost.CreateHostOnlyNetworkInterface(comInterface);304 CProgress comProgress = comHost.CreateHostOnlyNetworkInterface(comInterface); 305 305 306 306 /* Show error message if necessary: */ 307 if (!comHost.isOk() || progress.isNull())307 if (!comHost.isOk() || comProgress.isNull()) 308 308 msgCenter().cannotCreateHostNetworkInterface(comHost, this); 309 309 else 310 310 { 311 311 /* Show interface creation progress: */ 312 msgCenter().showModalProgressDialog( progress, UINetworkManager::tr("Adding network ..."), ":/progress_network_interface_90px.png", this, 0);312 msgCenter().showModalProgressDialog(comProgress, UINetworkManager::tr("Adding network ..."), ":/progress_network_interface_90px.png", this, 0); 313 313 314 314 /* Show error message if necessary: */ 315 if (! progress.isOk() || progress.GetResultCode() != 0)316 msgCenter().cannotCreateHostNetworkInterface( progress, this);315 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 316 msgCenter().cannotCreateHostNetworkInterface(comProgress, this); 317 317 else 318 318 { … … 406 406 407 407 /* Remove interface finally: */ 408 CProgress progress = comHost.RemoveHostOnlyNetworkInterface(uInterfaceId);408 CProgress comProgress = comHost.RemoveHostOnlyNetworkInterface(uInterfaceId); 409 409 410 410 /* Show error message if necessary: */ 411 if (!comHost.isOk() || progress.isNull())411 if (!comHost.isOk() || comProgress.isNull()) 412 412 msgCenter().cannotRemoveHostNetworkInterface(comHost, strInterfaceName, this); 413 413 else 414 414 { 415 415 /* Show interface removal progress: */ 416 msgCenter().showModalProgressDialog( progress, UINetworkManager::tr("Removing network ..."), ":/progress_network_interface_90px.png", this, 0);416 msgCenter().showModalProgressDialog(comProgress, UINetworkManager::tr("Removing network ..."), ":/progress_network_interface_90px.png", this, 0); 417 417 418 418 /* Show error message if necessary: */ 419 if (! progress.isOk() || progress.GetResultCode() != 0)420 return msgCenter().cannotRemoveHostNetworkInterface( progress, strInterfaceName, this);419 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 420 return msgCenter().cannotRemoveHostNetworkInterface(comProgress, strInterfaceName, this); 421 421 else 422 422 { … … 432 432 } 433 433 434 void UINetworkManagerWidget::sltToggleDetailsVisibility HostNetwork(bool fVisible)434 void UINetworkManagerWidget::sltToggleDetailsVisibility(bool fVisible) 435 435 { 436 436 /* Save the setting: */ … … 440 440 m_pDetailsWidgetHostNetwork->setVisible(fVisible); 441 441 /* Notify external listeners: */ 442 emit sigDetailsVisibilityChangedHostNetwork(fVisible); 443 } 444 445 void UINetworkManagerWidget::sltRefreshHostNetworks() 446 { 447 // Not implemented. 448 AssertMsgFailed(("Not implemented!")); 442 emit sigDetailsVisibilityChanged(fVisible); 449 443 } 450 444 … … 462 456 const int iTotal = m_pTreeWidgetHostNetwork->viewport()->width(); 463 457 /* Look for a minimum width hints for non-important columns: */ 464 const int iMinWidth1 = qMax(pItemView->sizeHintForColumn( Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4));465 const int iMinWidth2 = qMax(pItemView->sizeHintForColumn( Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6));466 const int iMinWidth3 = qMax(pItemView->sizeHintForColumn( Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP));458 const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_IPv4), pItemHeader->sectionSizeHint(HostNetworkColumn_IPv4)); 459 const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_IPv6), pItemHeader->sectionSizeHint(HostNetworkColumn_IPv6)); 460 const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_DHCP), pItemHeader->sectionSizeHint(HostNetworkColumn_DHCP)); 467 461 /* Propose suitable width hints for non-important columns: */ 468 const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal /Column_Max;469 const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal /Column_Max;470 const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal /Column_Max;462 const int iWidth1 = iMinWidth1 < iTotal / HostNetworkColumn_Max ? iMinWidth1 : iTotal / HostNetworkColumn_Max; 463 const int iWidth2 = iMinWidth2 < iTotal / HostNetworkColumn_Max ? iMinWidth2 : iTotal / HostNetworkColumn_Max; 464 const int iWidth3 = iMinWidth3 < iTotal / HostNetworkColumn_Max ? iMinWidth3 : iTotal / HostNetworkColumn_Max; 471 465 /* Apply the proposal: */ 472 m_pTreeWidgetHostNetwork->setColumnWidth( Column_IPv4, iWidth1);473 m_pTreeWidgetHostNetwork->setColumnWidth( Column_IPv6, iWidth2);474 m_pTreeWidgetHostNetwork->setColumnWidth( Column_DHCP, iWidth3);475 m_pTreeWidgetHostNetwork->setColumnWidth( Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3);466 m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_IPv4, iWidth1); 467 m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_IPv6, iWidth2); 468 m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_DHCP, iWidth3); 469 m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_Name, iTotal - iWidth1 - iWidth2 - iWidth3); 476 470 } 477 471 } … … 488 482 /* Make sure dhcp server status changed: */ 489 483 if ( ( oldData.m_dhcpserver.m_fEnabled 490 && pChangedItem->checkState( Column_DHCP) == Qt::Checked)484 && pChangedItem->checkState(HostNetworkColumn_DHCP) == Qt::Checked) 491 485 || ( !oldData.m_dhcpserver.m_fEnabled 492 && pChangedItem->checkState( Column_DHCP) == Qt::Unchecked))486 && pChangedItem->checkState(HostNetworkColumn_DHCP) == Qt::Unchecked)) 493 487 return; 494 488 … … 583 577 /* Otherwise => clear details and close the area: */ 584 578 m_pDetailsWidgetHostNetwork->setData(UIDataHostNetwork()); 585 sltToggleDetailsVisibility HostNetwork(false);579 sltToggleDetailsVisibility(false); 586 580 } 587 581 } … … 767 761 this, &UINetworkManagerWidget::sltRemoveHostNetwork); 768 762 connect(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details), &QAction::toggled, 769 this, &UINetworkManagerWidget::sltToggleDetailsVisibilityHostNetwork); 770 connect(m_pActionPool->action(UIActionIndexMN_M_Network_S_Refresh), &QAction::triggered, 771 this, &UINetworkManagerWidget::sltRefreshHostNetworks); 763 this, &UINetworkManagerWidget::sltToggleDetailsVisibility); 772 764 } 773 765 … … 810 802 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_S_Remove)); 811 803 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)); 812 // m_pToolBar->addSeparator();813 // m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_S_Refresh));814 804 815 805 #ifdef VBOX_WS_MAC … … 869 859 m_pTreeWidgetHostNetwork->setContextMenuPolicy(Qt::CustomContextMenu); 870 860 m_pTreeWidgetHostNetwork->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 871 m_pTreeWidgetHostNetwork->setColumnCount( Column_Max);861 m_pTreeWidgetHostNetwork->setColumnCount(HostNetworkColumn_Max); 872 862 m_pTreeWidgetHostNetwork->setSortingEnabled(true); 873 m_pTreeWidgetHostNetwork->sortByColumn( Column_Name, Qt::AscendingOrder);863 m_pTreeWidgetHostNetwork->sortByColumn(HostNetworkColumn_Name, Qt::AscendingOrder); 874 864 m_pTreeWidgetHostNetwork->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); 875 865 connect(m_pTreeWidgetHostNetwork, &QITreeWidget::currentItemChanged, … … 913 903 { 914 904 m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded()); 915 sltToggleDetailsVisibility HostNetwork(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked());905 sltToggleDetailsVisibility(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked()); 916 906 } 917 907 } … … 1138 1128 { 1139 1129 /* Configure button-box: */ 1140 connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged HostNetwork,1130 connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged, 1141 1131 button(ButtonType_Apply), &QPushButton::setVisible); 1142 connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged HostNetwork,1132 connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged, 1143 1133 button(ButtonType_Reset), &QPushButton::setVisible); 1144 1134 connect(widget(), &UINetworkManagerWidget::sigDetailsDataChangedHostNetwork, -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h
r87219 r87220 51 51 signals: 52 52 53 /** Notifies listeners about host network details-widget @a fVisible. */ 54 void sigDetailsVisibilityChangedHostNetwork(bool fVisible); 53 /** Notifies listeners about details-widget @a fVisible. */ 54 void sigDetailsVisibilityChanged(bool fVisible); 55 55 56 /** Notifies listeners about host network details data @a fDiffers. */ 56 57 void sigDetailsDataChangedHostNetwork(bool fDiffers); … … 105 106 /** Handles command to remove host network. */ 106 107 void sltRemoveHostNetwork(); 107 /** Handles command to make host network details @a fVisible. */ 108 void sltToggleDetailsVisibilityHostNetwork(bool fVisible); 109 /** Handles command to refresh host networks. */ 110 void sltRefreshHostNetworks(); 108 109 /** Handles command to make details @a fVisible. */ 110 void sltToggleDetailsVisibility(bool fVisible); 111 111 /** @} */ 112 112
Note:
See TracChangeset
for help on using the changeset viewer.