- Timestamp:
- Apr 28, 2017 3:49:27 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.cpp
r66725 r66726 26 26 27 27 /* GUI includes: */ 28 # include "QIDialogButtonBox.h"29 28 # include "QILineEdit.h" 30 29 # include "UIGlobalSettingsNetwork.h" … … 35 34 36 35 37 UIHostNetworkDetailsDialog::UIHostNetworkDetailsDialog(QWidget *pParent, UIDataHostNetwork &data) 38 : QIWithRetranslateUI2<QIDialog>(pParent) 39 , m_data(data) 36 UIHostNetworkDetailsDialog::UIHostNetworkDetailsDialog(QWidget *pParent /* = 0 */) 37 : QIWithRetranslateUI2<QWidget>(pParent) 40 38 , m_pTabWidget(0) 41 39 , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pLabelNMv4(0), m_pEditorNMv4(0) … … 48 46 } 49 47 48 void UIHostNetworkDetailsDialog::setData(const UIDataHostNetwork &data) 49 { 50 /* Save old data: */ 51 m_oldData = data; 52 53 /* Invent default old values if current old values are invalid: */ 54 const quint32 uAddr = ipv4FromQStringToQuint32(m_oldData.m_interface.m_strAddress); 55 const quint32 uMask = ipv4FromQStringToQuint32(m_oldData.m_interface.m_strMask); 56 const quint32 uProp = uAddr & uMask; 57 const QString strMask = ipv4FromQuint32ToQString(uMask); 58 const QString strProp = ipv4FromQuint32ToQString(uProp); 59 // printf("Proposal is = %s x %s\n", 60 // strProp.toUtf8().constData(), 61 // strMask.toUtf8().constData()); 62 if ( m_oldData.m_dhcpserver.m_strAddress.isEmpty() 63 || m_oldData.m_dhcpserver.m_strAddress == "0.0.0.0") 64 m_oldData.m_dhcpserver.m_strAddress = strProp; 65 if ( m_oldData.m_dhcpserver.m_strMask.isEmpty() 66 || m_oldData.m_dhcpserver.m_strMask == "0.0.0.0") 67 m_oldData.m_dhcpserver.m_strMask = strMask; 68 if ( m_oldData.m_dhcpserver.m_strLowerAddress.isEmpty() 69 || m_oldData.m_dhcpserver.m_strLowerAddress == "0.0.0.0") 70 m_oldData.m_dhcpserver.m_strLowerAddress = strProp; 71 if ( m_oldData.m_dhcpserver.m_strUpperAddress.isEmpty() 72 || m_oldData.m_dhcpserver.m_strUpperAddress == "0.0.0.0") 73 m_oldData.m_dhcpserver.m_strUpperAddress = strProp; 74 75 /* Copy old data to new one: */ 76 m_newData = m_oldData; 77 78 /* Load 'Interface' data: */ 79 loadDataForInterface(); 80 /* Load 'DHCP server' data: */ 81 loadDataForDHCPServer(); 82 } 83 84 void UIHostNetworkDetailsDialog::clearData() 85 { 86 /* Reset old/new data: */ 87 m_oldData = UIDataHostNetwork(); 88 m_newData = m_oldData; 89 90 /* Load 'Interface' data: */ 91 loadDataForInterface(); 92 /* Load 'DHCP server' data: */ 93 loadDataForDHCPServer(); 94 } 95 50 96 void UIHostNetworkDetailsDialog::retranslateUi() 51 97 { 52 /* Translate this: */53 setWindowTitle(tr("Host Network Details"));54 55 98 /* Translate tab-widget: */ 56 99 m_pTabWidget->setTabText(0, tr("&Adapter")); … … 80 123 } 81 124 82 void UIHostNetworkDetailsDialog::accept()83 {84 /* Save before accept: */85 save();86 87 /* Call to base-class: */88 QIDialog::accept();89 }90 91 125 void UIHostNetworkDetailsDialog::prepare() 92 126 { … … 96 130 /* Apply language settings: */ 97 131 retranslateUi(); 98 99 /* Load: */100 load();101 132 } 102 133 103 134 void UIHostNetworkDetailsDialog::prepareThis() 104 135 { 105 /* Apply window icons: */106 setWindowIcon(UIIconPool::iconSetFull(":/edit_host_iface_22px.png", ":/edit_host_iface_16px.png"));107 108 136 /* Create layout: */ 109 137 QVBoxLayout *pLayout = new QVBoxLayout(this); 110 138 AssertPtrReturnVoid(pLayout); 111 139 { 140 /* Configure layout: */ 141 pLayout->setContentsMargins(0, 0, 0, 0); 112 142 /* Prepare tab-widget: */ 113 143 prepareTabWidget(); 114 /* Prepare button-box: */115 prepareButtonBox();116 144 } 117 145 } … … 161 189 /* Configure editor: */ 162 190 m_pLabelIPv4->setBuddy(m_pEditorIPv4); 191 connect(m_pEditorIPv4, &QLineEdit::textChanged, 192 this, &UIHostNetworkDetailsDialog::sltTextChangedIPv4); 163 193 /* Add into layout: */ 164 194 pLayoutInterface->addWidget(m_pEditorIPv4, 0, 1); … … 179 209 /* Configure editor: */ 180 210 m_pLabelNMv4->setBuddy(m_pEditorNMv4); 211 connect(m_pEditorNMv4, &QLineEdit::textChanged, 212 this, &UIHostNetworkDetailsDialog::sltTextChangedNMv4); 181 213 /* Add into layout: */ 182 214 pLayoutInterface->addWidget(m_pEditorNMv4, 1, 1); … … 197 229 /* Configure editor: */ 198 230 m_pLabelIPv6->setBuddy(m_pEditorIPv6); 199 m_pEditorIPv6->setFixedWidthByText(QString().fill('X', 32) + QString().fill(':', 7)); 231 connect(m_pEditorIPv6, &QLineEdit::textChanged, 232 this, &UIHostNetworkDetailsDialog::sltTextChangedIPv6); 200 233 /* Add into layout: */ 201 234 pLayoutInterface->addWidget(m_pEditorIPv6, 2, 1); … … 216 249 /* Configure editor: */ 217 250 m_pLabelNMv6->setBuddy(m_pEditorNMv6); 251 connect(m_pEditorNMv6, &QLineEdit::textChanged, 252 this, &UIHostNetworkDetailsDialog::sltTextChangedNMv6); 218 253 /* Add into layout: */ 219 254 pLayoutInterface->addWidget(m_pEditorNMv6, 3, 1); … … 252 287 /* Configure check-box: */ 253 288 connect(m_pCheckBoxDHCP, &QCheckBox::stateChanged, 254 this, &UIHostNetworkDetailsDialog::slt DhcpServerStatusChanged);289 this, &UIHostNetworkDetailsDialog::sltStatusChangedServer); 255 290 /* Add into layout: */ 256 291 pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2); … … 271 306 /* Configure editor: */ 272 307 m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress); 308 connect(m_pEditorDHCPAddress, &QLineEdit::textChanged, 309 this, &UIHostNetworkDetailsDialog::sltTextChangedAddress); 273 310 /* Add into layout: */ 274 311 pLayoutDHCPServer->addWidget(m_pEditorDHCPAddress, 1, 2); … … 289 326 /* Configure editor: */ 290 327 m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask); 328 connect(m_pEditorDHCPMask, &QLineEdit::textChanged, 329 this, &UIHostNetworkDetailsDialog::sltTextChangedMask); 291 330 /* Add into layout: */ 292 331 pLayoutDHCPServer->addWidget(m_pEditorDHCPMask, 2, 2); … … 307 346 /* Configure editor: */ 308 347 m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress); 348 connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged, 349 this, &UIHostNetworkDetailsDialog::sltTextChangedLowerAddress); 309 350 /* Add into layout: */ 310 351 pLayoutDHCPServer->addWidget(m_pEditorDHCPLowerAddress, 3, 2); … … 325 366 /* Configure editor: */ 326 367 m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress); 368 connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged, 369 this, &UIHostNetworkDetailsDialog::sltTextChangedUpperAddress); 327 370 /* Add into layout: */ 328 371 pLayoutDHCPServer->addWidget(m_pEditorDHCPUpperAddress, 4, 2); … … 353 396 } 354 397 355 void UIHostNetworkDetailsDialog::prepareButtonBox()356 {357 /* Create dialog button-box: */358 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;359 AssertPtrReturnVoid(pButtonBox);360 {361 /* Configure button-box: */362 pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);363 connect(pButtonBox, &QIDialogButtonBox::accepted,364 this, &UIHostNetworkDetailsDialog::accept);365 connect(pButtonBox, &QIDialogButtonBox::rejected,366 this, &UIHostNetworkDetailsDialog::reject);367 /* Add button-box into layout: */368 layout()->addWidget(pButtonBox);369 }370 }371 372 void UIHostNetworkDetailsDialog::load()373 {374 /* Load 'Interface' data: */375 loadDataForInterface();376 377 /* Load 'DHCP server' data: */378 m_pCheckBoxDHCP->setChecked(m_data.m_dhcpserver.m_fEnabled);379 loadDataForDHCPServer();380 }381 382 398 void UIHostNetworkDetailsDialog::loadDataForInterface() 383 399 { 384 400 /* Load IPv4 interface fields: */ 385 m_pEditorIPv4->setText(m_ data.m_interface.m_strAddress);386 m_pEditorNMv4->setText(m_ data.m_interface.m_strMask);401 m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress); 402 m_pEditorNMv4->setText(m_newData.m_interface.m_strMask); 387 403 388 404 /* Toggle IPv6 interface fields availability: */ 389 const bool fIsIpv6Supported = m_ data.m_interface.m_fSupportedIPv6;405 const bool fIsIpv6Supported = m_newData.m_interface.m_fSupportedIPv6; 390 406 m_pLabelIPv6->setEnabled(fIsIpv6Supported); 391 407 m_pLabelNMv6->setEnabled(fIsIpv6Supported); … … 394 410 395 411 /* Load IPv6 interface fields: */ 396 m_pEditorIPv6->setText(m_ data.m_interface.m_strAddress6);397 m_pEditorNMv6->setText(m_ data.m_interface.m_strMaskLength6);412 m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6); 413 m_pEditorNMv6->setText(m_newData.m_interface.m_strMaskLength6); 398 414 } 399 415 … … 401 417 { 402 418 /* Toggle DHCP server fields availability: */ 403 const bool fIsDHCPServerEnabled = m_ data.m_dhcpserver.m_fEnabled;419 const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled; 404 420 m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled); 405 421 m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled); … … 412 428 413 429 /* Load DHCP server fields: */ 414 m_pEditorDHCPAddress->setText(m_data.m_dhcpserver.m_strAddress); 415 m_pEditorDHCPMask->setText(m_data.m_dhcpserver.m_strMask); 416 m_pEditorDHCPLowerAddress->setText(m_data.m_dhcpserver.m_strLowerAddress); 417 m_pEditorDHCPUpperAddress->setText(m_data.m_dhcpserver.m_strUpperAddress); 418 419 /* Invent default values where necessary: */ 420 const quint32 uAddr = ipv4FromQStringToQuint32(m_data.m_interface.m_strAddress); 421 const quint32 uMask = ipv4FromQStringToQuint32(m_data.m_interface.m_strMask); 422 const quint32 uProp = uAddr & uMask; 423 const QString strMask = ipv4FromQuint32ToQString(uMask); 424 const QString strProp = ipv4FromQuint32ToQString(uProp); 425 //printf("Proposal is = %s x %s\n", 426 // strProp.toUtf8().constData(), 427 // strMask.toUtf8().constData()); 428 if ( m_data.m_dhcpserver.m_strAddress.isEmpty() 429 || m_data.m_dhcpserver.m_strAddress == "0.0.0.0") 430 m_pEditorDHCPAddress->setText(strProp); 431 if ( m_data.m_dhcpserver.m_strMask.isEmpty() 432 || m_data.m_dhcpserver.m_strMask == "0.0.0.0") 433 m_pEditorDHCPMask->setText(strMask); 434 if ( m_data.m_dhcpserver.m_strLowerAddress.isEmpty() 435 || m_data.m_dhcpserver.m_strLowerAddress == "0.0.0.0") 436 m_pEditorDHCPLowerAddress->setText(strProp); 437 if ( m_data.m_dhcpserver.m_strUpperAddress.isEmpty() 438 || m_data.m_dhcpserver.m_strUpperAddress == "0.0.0.0") 439 m_pEditorDHCPUpperAddress->setText(strProp); 440 } 441 442 void UIHostNetworkDetailsDialog::save() 443 { 444 /* Save interface data: */ 445 m_data.m_interface.m_strAddress = m_pEditorIPv4->text(); 446 m_data.m_interface.m_strMask = m_pEditorNMv4->text(); 447 if (m_data.m_interface.m_fSupportedIPv6) 448 { 449 m_data.m_interface.m_strAddress6 = m_pEditorIPv6->text(); 450 m_data.m_interface.m_strMaskLength6 = m_pEditorNMv6->text(); 451 } 452 453 /* Save DHCP server data: */ 454 m_data.m_dhcpserver.m_fEnabled = m_pCheckBoxDHCP->isChecked(); 455 if (m_data.m_dhcpserver.m_fEnabled) 456 { 457 m_data.m_dhcpserver.m_strAddress = m_pEditorDHCPAddress->text(); 458 m_data.m_dhcpserver.m_strMask = m_pEditorDHCPMask->text(); 459 m_data.m_dhcpserver.m_strLowerAddress = m_pEditorDHCPLowerAddress->text(); 460 m_data.m_dhcpserver.m_strUpperAddress = m_pEditorDHCPUpperAddress->text(); 461 } 430 m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled); 431 m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress); 432 m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask); 433 m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress); 434 m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress); 435 } 436 437 void UIHostNetworkDetailsDialog::notify() 438 { 439 // if (m_oldData != m_newData) 440 // printf("Interface: %s, %s, %s, %s; DHCP server: %d, %s, %s, %s, %s\n", 441 // m_newData.m_interface.m_strAddress.toUtf8().constData(), 442 // m_newData.m_interface.m_strMask.toUtf8().constData(), 443 // m_newData.m_interface.m_strAddress6.toUtf8().constData(), 444 // m_newData.m_interface.m_strMaskLength6.toUtf8().constData(), 445 // (int)m_newData.m_dhcpserver.m_fEnabled, 446 // m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(), 447 // m_newData.m_dhcpserver.m_strMask.toUtf8().constData(), 448 // m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(), 449 // m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()); 450 451 emit sigDataChanged(m_oldData != m_newData); 462 452 } 463 453 -
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.h
r66723 r66726 19 19 #define __UIHostNetworkDetailsDialog_h__ 20 20 21 /* Qt includes: */ 22 #include <QWidget> 23 21 24 /* GUI includes: */ 22 #include "QIDialog.h"23 25 #include "QIWithRetranslateUI.h" 24 26 … … 148 150 149 151 150 /** Host Network Manager: Host network details dialog. */151 class UIHostNetworkDetailsDialog : public QIWithRetranslateUI2<Q IDialog>152 /** Host Network Manager: Host network details widget. */ 153 class UIHostNetworkDetailsDialog : public QIWithRetranslateUI2<QWidget> 152 154 { 153 155 Q_OBJECT; 154 156 157 signals: 158 159 /** Notifies listeners about data changed and whether it @a fDiffers. */ 160 void sigDataChanged(bool fDiffers); 161 155 162 public: 156 163 157 164 /** Constructs host network details dialog for the passed @a pParent and @a data. */ 158 UIHostNetworkDetailsDialog(QWidget *pParent, UIDataHostNetwork &data); 165 UIHostNetworkDetailsDialog(QWidget *pParent = 0); 166 167 /** Returns the host network data. */ 168 const UIDataHostNetwork &data() const { return m_newData; } 169 /** Defines the host network @a data. */ 170 void setData(const UIDataHostNetwork &data); 171 /** Clears the host network data. */ 172 void clearData(); 159 173 160 174 protected: … … 165 179 private slots: 166 180 167 /** Handles DHCP server status change. */ 168 void sltDhcpServerStatusChanged() { loadDataForDHCPServer(); } 169 170 /** Accepts dialog changes. */ 171 void accept(); 181 /** @name Change handling stuff. 182 * @{ */ 183 /** Handles interface IPv4 text change. */ 184 void sltTextChangedIPv4(const QString &strText) { m_newData.m_interface.m_strAddress = strText; notify(); } 185 /** Handles interface NMv4 text change. */ 186 void sltTextChangedNMv4(const QString &strText) { m_newData.m_interface.m_strMask = strText; notify(); } 187 /** Handles interface IPv6 text change. */ 188 void sltTextChangedIPv6(const QString &strText) { m_newData.m_interface.m_strAddress6 = strText; notify(); } 189 /** Handles interface NMv6 text change. */ 190 void sltTextChangedNMv6(const QString &strText) { m_newData.m_interface.m_strMaskLength6 = strText; notify(); } 191 192 /** Handles DHCP server status change. */ 193 void sltStatusChangedServer(int iChecked) { m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked; loadDataForDHCPServer(); notify(); } 194 /** Handles DHCP server address text change. */ 195 void sltTextChangedAddress(const QString &strText) { m_newData.m_dhcpserver.m_strAddress = strText; notify(); } 196 /** Handles DHCP server mask text change. */ 197 void sltTextChangedMask(const QString &strText) { m_newData.m_dhcpserver.m_strMask = strText; notify(); } 198 /** Handles DHCP server lower address text change. */ 199 void sltTextChangedLowerAddress(const QString &strText) { m_newData.m_dhcpserver.m_strLowerAddress = strText; notify(); } 200 /** Handles DHCP server upper address text change. */ 201 void sltTextChangedUpperAddress(const QString &strText) { m_newData.m_dhcpserver.m_strUpperAddress = strText; notify(); } 202 /** @} */ 172 203 173 204 private: … … 185 216 /** Prepares 'DHCP server' tab. */ 186 217 void prepareTabDHCPServer(); 187 /** Prepares button-box. */ 188 void prepareButtonBox(); 189 /** @} */ 190 191 /** @name Loading/saving stuff. 192 * @{ */ 193 /** Loads data. */ 194 void load(); 218 /** @} */ 219 220 /** @name Loading stuff. 221 * @{ */ 195 222 /** Loads interface data. */ 196 223 void loadDataForInterface(); 197 224 /** Loads server data. */ 198 225 void loadDataForDHCPServer(); 199 /** Saves data. */ 200 void save(); 226 /** @} */ 227 228 /** @name Change handling stuff. 229 * @{ */ 230 /** Notifies listeners about data changed or not. */ 231 void notify(); 201 232 /** @} */ 202 233 … … 211 242 /** @name General variables. 212 243 * @{ */ 213 /** Holds the external data reference. */ 214 UIDataHostNetwork &m_data; 244 /** Holds the old data copy. */ 245 UIDataHostNetwork m_oldData; 246 /** Holds the new data copy. */ 247 UIDataHostNetwork m_newData; 215 248 /** Holds the tab-widget. */ 216 249 QITabWidget *m_pTabWidget; -
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp
r66723 r66726 24 24 # include <QMenuBar> 25 25 # include <QPushButton> 26 # include <QSplitter> 26 27 27 28 /* GUI includes: */ … … 198 199 , m_pActionRemove(0) 199 200 , m_pActionEdit(0) 201 , m_pSplitter(0) 200 202 , m_pTreeWidget(0) 203 , m_pDetailsWidget(0) 201 204 , m_pButtonBox(0) 202 205 { … … 433 436 void UIHostNetworkManager::sltEditHostNetwork() 434 437 { 438 /* Open details area: */ 439 const QList<int> sizes = m_pSplitter->sizes(); 440 AssertReturnVoid(sizes.size() >= 2); 441 if (sizes.at(1) == 0) 442 { 443 m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 1); 444 m_pButtonBox->button(QDialogButtonBox::Apply)->show(); 445 } 446 else 447 /* Close details area: */ 448 if (sizes.at(1) > 0) 449 { 450 m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0); 451 m_pButtonBox->button(QDialogButtonBox::Apply)->hide(); 452 } 453 } 454 455 void UIHostNetworkManager::sltHandleButtonClicked(QAbstractButton *pButton) 456 { 457 /* Handle known button (Apply) only: */ 458 if (pButton != m_pButtonBox->button(QDialogButtonBox::Apply)) 459 return; 460 461 /* Disable button first of all: */ 462 m_pButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false); 463 435 464 /* Get network item: */ 436 465 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); … … 439 468 /* Get item data: */ 440 469 UIDataHostNetwork oldData = *pItem; 441 UIDataHostNetwork newData = oldData; 442 443 /* Show details dialog: */ 444 UIHostNetworkDetailsDialog details(this, newData); 445 if (details.exec() != QDialog::Accepted) 446 return; 470 UIDataHostNetwork newData = m_pDetailsWidget->data(); 447 471 448 472 /* Get host for further activities: */ … … 633 657 m_pActionRemove->setEnabled(pItem); 634 658 m_pActionEdit->setEnabled(pItem); 659 660 /* If there is an item => update details data: */ 661 if (pItem) 662 m_pDetailsWidget->setData(*pItem); 663 else 664 { 665 /* Otherwise => clear details and close the area: */ 666 m_pDetailsWidget->clearData(); 667 m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0); 668 m_pButtonBox->button(QDialogButtonBox::Apply)->hide(); 669 } 635 670 } 636 671 … … 765 800 /* Prepare tool-bar: */ 766 801 prepareToolBar(); 767 /* Prepare tree-widget: */768 prepare TreeWidget();802 /* Prepare splitter: */ 803 prepareSplitter(); 769 804 /* Prepare button-box: */ 770 805 prepareButtonBox(); … … 810 845 } 811 846 847 void UIHostNetworkManager::prepareSplitter() 848 { 849 /* Create splitter: */ 850 m_pSplitter = new QSplitter; 851 AssertPtrReturnVoid(m_pSplitter); 852 { 853 /* Prepare tree-widget: */ 854 prepareTreeWidget(); 855 /* Prepare details-widget: */ 856 prepareDetailsWidget(); 857 /* Configure splitter: */ 858 m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0); 859 m_pSplitter->setOrientation(Qt::Vertical); 860 m_pSplitter->setCollapsible(0, false); 861 /* Add splitter into layout: */ 862 QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout()); 863 pMainLayout->addWidget(m_pSplitter); 864 } 865 } 866 812 867 void UIHostNetworkManager::prepareTreeWidget() 813 868 { … … 832 887 connect(m_pTreeWidget, &QITreeWidget::itemChanged, 833 888 this, &UIHostNetworkManager::sltHandleItemChange); 834 /* Add tree-widget into layout: */ 835 QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout()); 836 pMainLayout->addWidget(m_pTreeWidget); 889 /* Add tree-widget into splitter: */ 890 m_pSplitter->addWidget(m_pTreeWidget); 891 } 892 } 893 894 void UIHostNetworkManager::prepareDetailsWidget() 895 { 896 /* Create details-widget: */ 897 m_pDetailsWidget = new UIHostNetworkDetailsDialog; 898 AssertPtrReturnVoid(m_pDetailsWidget); 899 { 900 /* Add details-widget into splitter: */ 901 m_pSplitter->addWidget(m_pDetailsWidget); 837 902 } 838 903 } … … 845 910 { 846 911 /* Configure button-box: */ 847 m_pButtonBox->setStandardButtons(QDialogButtonBox:: Help | QDialogButtonBox::Close);912 m_pButtonBox->setStandardButtons(QDialogButtonBox::Close | QDialogButtonBox::Apply); 848 913 m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 849 connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);914 m_pButtonBox->button(QDialogButtonBox::Apply)->hide(); 850 915 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIHostNetworkManager::close); 916 connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UIHostNetworkManager::sltHandleButtonClicked); 917 connect(m_pDetailsWidget, &UIHostNetworkDetailsDialog::sigDataChanged, 918 m_pButtonBox->button(QDialogButtonBox::Apply), &QWidget::setEnabled); 851 919 /* Add button-box into layout: */ 852 920 QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout()); -
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h
r66720 r66726 27 27 /* Forward declarations: */ 28 28 class CHostNetworkInterface; 29 class QAbstractButton; 30 class QSplitter; 29 31 class QTreeWidgetItem; 30 32 class QIDialogButtonBox; 31 33 class QITreeWidget; 34 class UIHostNetworkDetailsDialog; 32 35 class UIItemHostNetwork; 33 36 class UIToolBar; … … 79 82 /** @} */ 80 83 84 /** @name Button-box stuff. 85 * @{ */ 86 /** Handles button-box @a pButton click. */ 87 void sltHandleButtonClicked(QAbstractButton *pButton); 88 /** @} */ 89 81 90 /** @name Tree-widget stuff. 82 91 * @{ */ … … 108 117 /** Prepares tool-bar. */ 109 118 void prepareToolBar(); 119 /** Prepares splitter. */ 120 void prepareSplitter(); 110 121 /** Prepares tree-widget. */ 111 122 void prepareTreeWidget(); 123 /** Prepares details-widget. */ 124 void prepareDetailsWidget(); 112 125 /** Prepares button-box. */ 113 126 void prepareButtonBox(); … … 158 171 /** @} */ 159 172 160 /** @name Tree-widgetvariables.173 /** @name Splitter variables. 161 174 * @{ */ 175 /** Holds the splitter instance. */ 176 QSplitter *m_pSplitter; 162 177 /** Holds the tree-widget instance. */ 163 178 QITreeWidget *m_pTreeWidget; 179 /** Holds the details-widget instance. */ 180 UIHostNetworkDetailsDialog *m_pDetailsWidget; 164 181 /** @} */ 165 182
Note:
See TracChangeset
for help on using the changeset viewer.