- Timestamp:
- Oct 15, 2018 6:36:00 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 deleted
- 1 edited
- 5 copied
-
Makefile.kmk (modified) (3 diffs)
-
src/cloud (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork )
-
src/cloud/UICloudProfileDetailsWidget.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsWidget.cpp ) (8 diffs)
-
src/cloud/UICloudProfileDetailsWidget.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsWidget.h ) (8 diffs)
-
src/cloud/UICloudProfileManager.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp ) (28 diffs)
-
src/cloud/UICloudProfileManager.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h ) (13 diffs)
-
src/cloud/UIHostNetworkDetailsWidget.cpp (deleted)
-
src/cloud/UIHostNetworkDetailsWidget.h (deleted)
-
src/cloud/UIHostNetworkManager.cpp (deleted)
-
src/cloud/UIHostNetworkManager.h (deleted)
-
src/cloud/UIHostNetworkUtils.cpp (deleted)
-
src/cloud/UIHostNetworkUtils.h (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r74740 r74853 339 339 VBOX_GUI_INC_DIRS = \ 340 340 ./src \ 341 ./src/cloud \ 341 342 ./src/converter \ 342 343 ./src/extensions \ … … 680 681 # 681 682 VirtualBox_QT_MOCHDRS = \ 683 src/cloud/UICloudProfileDetailsWidget.h \ 684 src/cloud/UICloudProfileManager.h \ 682 685 src/globals/UIStarter.h \ 683 686 src/hostnetwork/UIHostNetworkDetailsWidget.h \ … … 1371 1374 VirtualBox_SOURCES = \ 1372 1375 src/main.cpp \ 1376 src/cloud/UICloudProfileDetailsWidget.cpp \ 1377 src/cloud/UICloudProfileManager.cpp \ 1373 1378 src/globals/UIStarter.cpp \ 1374 1379 src/hostnetwork/UIHostNetworkDetailsWidget.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.cpp
r74811 r74853 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI HostNetworkDetailsWidget class implementation.3 * VBox Qt GUI - UICloudProfileDetailsWidget class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QCheckBox>24 # include <QLabel>25 23 # include <QPushButton> 26 # include <QRadioButton> 27 # include <QRegExpValidator> 28 # include <QStyleOption> 24 # include <QTableWidget> 29 25 # include <QVBoxLayout> 30 26 31 27 /* GUI includes: */ 32 28 # include "QIDialogButtonBox.h" 33 # include "QILineEdit.h" 34 # include "QITabWidget.h" 35 # include "UIHostNetworkDetailsWidget.h" 36 # include "UIHostNetworkUtils.h" 37 # include "UIIconPool.h" 29 # include "UICloudProfileDetailsWidget.h" 38 30 39 31 /* Other VBox includes: */ 40 32 # include "iprt/assert.h" 41 # include "iprt/cidr.h"42 33 43 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 44 35 45 36 46 UI HostNetworkDetailsWidget::UIHostNetworkDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)37 UICloudProfileDetailsWidget::UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */) 47 38 : QIWithRetranslateUI<QWidget>(pParent) 48 39 , m_enmEmbedding(enmEmbedding) 49 , m_pTabWidget(0) 50 , m_pButtonAutomatic(0), m_pErrorPaneAutomatic(0) 51 , m_pButtonManual(0), m_pErrorPaneManual(0) 52 , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pErrorPaneIPv4(0) 53 , m_pLabelNMv4(0), m_pEditorNMv4(0), m_pErrorPaneNMv4(0) 54 , m_pLabelIPv6(0), m_pEditorIPv6(0), m_pErrorPaneIPv6(0) 55 , m_pLabelNMv6(0), m_pEditorNMv6(0), m_pErrorPaneNMv6(0) 56 , m_pButtonBoxInterface(0) 57 , m_pCheckBoxDHCP(0) 58 , m_pLabelDHCPAddress(0), m_pEditorDHCPAddress(0), m_pErrorPaneDHCPAddress(0) 59 , m_pLabelDHCPMask(0), m_pEditorDHCPMask(0), m_pErrorPaneDHCPMask(0) 60 , m_pLabelDHCPLowerAddress(0), m_pEditorDHCPLowerAddress(0), m_pErrorPaneDHCPLowerAddress(0) 61 , m_pLabelDHCPUpperAddress(0), m_pEditorDHCPUpperAddress(0), m_pErrorPaneDHCPUpperAddress(0) 62 , m_pButtonBoxServer(0) 40 , m_pTableWidget(0) 41 , m_pButtonBox(0) 63 42 { 64 43 /* Prepare: */ … … 66 45 } 67 46 68 void UI HostNetworkDetailsWidget::setData(const UIDataHostNetwork&data)47 void UICloudProfileDetailsWidget::setData(const UIDataCloudProfile &data) 69 48 { 70 49 /* Cache old/new data: */ … … 72 51 m_newData = m_oldData; 73 52 74 /* Load 'Interface' data: */ 75 loadDataForInterface(); 76 /* Load 'DHCP server' data: */ 77 loadDataForDHCPServer(); 53 /* Load data: */ 54 loadData(); 78 55 } 79 56 80 void UI HostNetworkDetailsWidget::retranslateUi()57 void UICloudProfileDetailsWidget::retranslateUi() 81 58 { 82 /* Translate tab-widget: */ 83 m_pTabWidget->setTabText(0, tr("&Adapter")); 84 m_pTabWidget->setTabText(1, tr("&DHCP Server")); 85 86 /* Translate 'Interface' tab content: */ 87 m_pButtonAutomatic->setText(tr("Configure Adapter &Automatically")); 88 m_pButtonManual->setText(tr("Configure Adapter &Manually")); 89 m_pLabelIPv4->setText(tr("&IPv4 Address:")); 90 m_pEditorIPv4->setToolTip(tr("Holds the host IPv4 address for this adapter.")); 91 m_pLabelNMv4->setText(tr("IPv4 Network &Mask:")); 92 m_pEditorNMv4->setToolTip(tr("Holds the host IPv4 network mask for this adapter.")); 93 m_pLabelIPv6->setText(tr("I&Pv6 Address:")); 94 m_pEditorIPv6->setToolTip(tr("Holds the host IPv6 address for this adapter if IPv6 is supported.")); 95 m_pLabelNMv6->setText(tr("IPv6 Prefix &Length:")); 96 m_pEditorNMv6->setToolTip(tr("Holds the host IPv6 prefix length for this adapter if IPv6 is supported.")); 97 if (m_pButtonBoxInterface) 98 { 99 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setText(tr("Reset")); 100 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 101 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 102 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 103 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current interface details")); 104 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current interface details")); 105 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)-> 106 setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->shortcut().toString())); 107 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)-> 108 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->shortcut().toString())); 109 } 110 111 /* Translate 'DHCP server' tab content: */ 112 m_pCheckBoxDHCP->setText(tr("&Enable Server")); 113 m_pCheckBoxDHCP->setToolTip(tr("When checked, the DHCP Server will be enabled for this network on machine start-up.")); 114 m_pLabelDHCPAddress->setText(tr("Server Add&ress:")); 115 m_pEditorDHCPAddress->setToolTip(tr("Holds the address of the DHCP server servicing the network associated with this host-only adapter.")); 116 m_pLabelDHCPMask->setText(tr("Server &Mask:")); 117 m_pEditorDHCPMask->setToolTip(tr("Holds the network mask of the DHCP server servicing the network associated with this host-only adapter.")); 118 m_pLabelDHCPLowerAddress->setText(tr("&Lower Address Bound:")); 119 m_pEditorDHCPLowerAddress->setToolTip(tr("Holds the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter.")); 120 m_pLabelDHCPUpperAddress->setText(tr("&Upper Address Bound:")); 121 m_pEditorDHCPUpperAddress->setToolTip(tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter.")); 122 if (m_pButtonBoxServer) 123 { 124 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setText(tr("Reset")); 125 m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 126 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 127 m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 128 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current DHCP server details")); 129 m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current DHCP server details")); 130 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)-> 131 setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->shortcut().toString())); 132 m_pButtonBoxServer->button(QDialogButtonBox::Ok)-> 133 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Ok)->shortcut().toString())); 134 } 59 /* Translate table-widget: */ 60 m_pTableWidget->setToolTip(tr("Contains cloud profile settings")); 135 61 136 62 /* Retranslate validation: */ … … 138 64 } 139 65 140 void UI HostNetworkDetailsWidget::sltToggledButtonAutomatic(bool fChecked)66 void UICloudProfileDetailsWidget::sltTableChanged() 141 67 { 142 m_newData.m_interface.m_fDHCPEnabled = fChecked; 143 loadDataForInterface(); 144 revalidate(); 145 updateButtonStates(); 68 /// @todo handle profile settings table change! 146 69 } 147 70 148 void UIHostNetworkDetailsWidget::sltToggledButtonManual(bool fChecked) 149 { 150 m_newData.m_interface.m_fDHCPEnabled = !fChecked; 151 loadDataForInterface(); 152 revalidate(); 153 updateButtonStates(); 154 } 155 156 void UIHostNetworkDetailsWidget::sltTextChangedIPv4(const QString &strText) 157 { 158 m_newData.m_interface.m_strAddress = strText; 159 revalidate(m_pErrorPaneIPv4); 160 updateButtonStates(); 161 } 162 163 void UIHostNetworkDetailsWidget::sltTextChangedNMv4(const QString &strText) 164 { 165 m_newData.m_interface.m_strMask = strText; 166 revalidate(m_pErrorPaneNMv4); 167 updateButtonStates(); 168 } 169 170 void UIHostNetworkDetailsWidget::sltTextChangedIPv6(const QString &strText) 171 { 172 m_newData.m_interface.m_strAddress6 = strText; 173 revalidate(m_pErrorPaneIPv6); 174 updateButtonStates(); 175 } 176 177 void UIHostNetworkDetailsWidget::sltTextChangedNMv6(const QString &strText) 178 { 179 m_newData.m_interface.m_strPrefixLength6 = strText; 180 revalidate(m_pErrorPaneNMv6); 181 updateButtonStates(); 182 } 183 184 void UIHostNetworkDetailsWidget::sltStatusChangedServer(int iChecked) 185 { 186 m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked; 187 loadDataForDHCPServer(); 188 revalidate(); 189 updateButtonStates(); 190 } 191 192 void UIHostNetworkDetailsWidget::sltTextChangedAddress(const QString &strText) 193 { 194 m_newData.m_dhcpserver.m_strAddress = strText; 195 revalidate(m_pErrorPaneDHCPAddress); 196 updateButtonStates(); 197 } 198 199 void UIHostNetworkDetailsWidget::sltTextChangedMask(const QString &strText) 200 { 201 m_newData.m_dhcpserver.m_strMask = strText; 202 revalidate(m_pErrorPaneDHCPMask); 203 updateButtonStates(); 204 } 205 206 void UIHostNetworkDetailsWidget::sltTextChangedLowerAddress(const QString &strText) 207 { 208 m_newData.m_dhcpserver.m_strLowerAddress = strText; 209 revalidate(m_pErrorPaneDHCPLowerAddress); 210 updateButtonStates(); 211 } 212 213 void UIHostNetworkDetailsWidget::sltTextChangedUpperAddress(const QString &strText) 214 { 215 m_newData.m_dhcpserver.m_strUpperAddress = strText; 216 revalidate(m_pErrorPaneDHCPUpperAddress); 217 updateButtonStates(); 218 } 219 220 void UIHostNetworkDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton) 71 void UICloudProfileDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton) 221 72 { 222 73 /* Make sure button-box exists: */ 223 AssertPtrReturnVoid(m_pButtonBoxInterface); 224 AssertPtrReturnVoid(m_pButtonBoxServer); 74 AssertPtrReturnVoid(m_pButtonBox); 225 75 226 76 /* Disable buttons first of all: */ 227 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(false); 228 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(false); 229 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(false); 230 m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(false); 77 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); 78 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 231 79 232 80 /* Compare with known buttons: */ 233 if ( pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Cancel) 234 || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Cancel)) 81 if (pButton == m_pButtonBox->button(QDialogButtonBox::Cancel)) 235 82 emit sigDataChangeRejected(); 236 83 else 237 if ( pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Ok) 238 || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Ok)) 84 if (pButton == m_pButtonBox->button(QDialogButtonBox::Ok)) 239 85 emit sigDataChangeAccepted(); 240 86 } 241 87 242 void UI HostNetworkDetailsWidget::prepare()88 void UICloudProfileDetailsWidget::prepare() 243 89 { 244 /* Prepare this: */245 prepare This();90 /* Prepare widgets: */ 91 prepareWidgets(); 246 92 247 93 /* Apply language settings: */ … … 252 98 } 253 99 254 void UI HostNetworkDetailsWidget::prepareThis()100 void UICloudProfileDetailsWidget::prepareWidgets() 255 101 { 256 102 /* Create layout: */ 257 103 QVBoxLayout *pLayout = new QVBoxLayout(this); 258 AssertPtrReturnVoid(pLayout);104 if (pLayout) 259 105 { 260 106 /* Configure layout: */ 261 107 pLayout->setContentsMargins(0, 0, 0, 0); 262 108 263 /* Prepare tab-widget: */ 264 prepareTabWidget(); 109 /* Create tab-widget: */ 110 m_pTableWidget = new QTableWidget; 111 if (m_pTableWidget) 112 { 113 /* Add into layout: */ 114 pLayout->addWidget(m_pTableWidget); 115 } 265 116 } 266 117 } 267 118 268 void UI HostNetworkDetailsWidget::prepareTabWidget()119 void UICloudProfileDetailsWidget::loadData() 269 120 { 270 /* Create tab-widget: */ 271 m_pTabWidget = new QITabWidget; 272 AssertPtrReturnVoid(m_pTabWidget); 273 { 274 /* Prepare 'Interface' tab: */ 275 prepareTabInterface(); 276 /* Prepare 'DHCP server' tab: */ 277 prepareTabDHCPServer(); 278 279 /* Add into layout: */ 280 layout()->addWidget(m_pTabWidget); 281 } 121 /// @todo load profile settings table data! 282 122 } 283 123 284 void UI HostNetworkDetailsWidget::prepareTabInterface()124 void UICloudProfileDetailsWidget::revalidate(QWidget *pWidget /* = 0 */) 285 125 { 286 /* Create 'Interface' tab: */ 287 QWidget *pTabInterface = new QWidget; 288 AssertPtrReturnVoid(pTabInterface); 289 { 290 /* Create 'Interface' layout: */ 291 QGridLayout *pLayoutInterface = new QGridLayout(pTabInterface); 292 AssertPtrReturnVoid(pLayoutInterface); 293 { 294 #ifdef VBOX_WS_MAC 295 /* Configure layout: */ 296 pLayoutInterface->setSpacing(10); 297 pLayoutInterface->setContentsMargins(10, 10, 10, 10); 298 #endif 299 300 /* Get the required icon metric: */ 301 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 302 303 /* Create automatic interface configuration layout: */ 304 QHBoxLayout *pLayoutAutomatic = new QHBoxLayout; 305 AssertPtrReturnVoid(pLayoutAutomatic); 306 { 307 /* Configure layout: */ 308 pLayoutAutomatic->setContentsMargins(0, 0, 0, 0); 309 310 /* Create automatic interface configuration radio-button: */ 311 m_pButtonAutomatic = new QRadioButton; 312 AssertPtrReturnVoid(m_pButtonAutomatic); 313 { 314 /* Configure radio-button: */ 315 connect(m_pButtonAutomatic, &QRadioButton::toggled, 316 this, &UIHostNetworkDetailsWidget::sltToggledButtonAutomatic); 317 /* Add into layout: */ 318 pLayoutAutomatic->addWidget(m_pButtonAutomatic); 319 } 320 /* Create automatic interface configuration error pane: */ 321 m_pErrorPaneAutomatic = new QLabel; 322 AssertPtrReturnVoid(m_pErrorPaneAutomatic); 323 { 324 /* Configure label: */ 325 m_pErrorPaneAutomatic->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); 326 m_pErrorPaneAutomatic->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); 327 m_pErrorPaneAutomatic->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 328 .pixmap(QSize(iIconMetric, iIconMetric))); 329 /* Add into layout: */ 330 pLayoutAutomatic->addWidget(m_pErrorPaneAutomatic); 331 } 332 /* Add into layout: */ 333 pLayoutInterface->addLayout(pLayoutAutomatic, 0, 0, 1, 3); 334 #ifdef VBOX_WS_MAC 335 pLayoutInterface->setRowMinimumHeight(0, 22); 336 #endif 337 } 338 339 /* Create manual interface configuration layout: */ 340 QHBoxLayout *pLayoutManual = new QHBoxLayout; 341 AssertPtrReturnVoid(pLayoutManual); 342 { 343 /* Configure layout: */ 344 pLayoutManual->setContentsMargins(0, 0, 0, 0); 345 /* Create manual interface configuration radio-button: */ 346 m_pButtonManual = new QRadioButton; 347 AssertPtrReturnVoid(m_pButtonManual); 348 { 349 /* Configure radio-button: */ 350 connect(m_pButtonManual, &QRadioButton::toggled, 351 this, &UIHostNetworkDetailsWidget::sltToggledButtonManual); 352 /* Add into layout: */ 353 pLayoutManual->addWidget(m_pButtonManual); 354 } 355 /* Create manual interface configuration error pane: */ 356 m_pErrorPaneManual = new QLabel; 357 AssertPtrReturnVoid(m_pErrorPaneManual); 358 { 359 /* Configure label: */ 360 m_pErrorPaneManual->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); 361 m_pErrorPaneManual->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); 362 m_pErrorPaneManual->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 363 .pixmap(QSize(iIconMetric, iIconMetric))); 364 /* Add into layout: */ 365 pLayoutManual->addWidget(m_pErrorPaneManual); 366 } 367 /* Add into layout: */ 368 pLayoutInterface->addLayout(pLayoutManual, 1, 0, 1, 3); 369 #ifdef VBOX_WS_MAC 370 pLayoutInterface->setRowMinimumHeight(1, 22); 371 #endif 372 } 373 374 /* Create IPv4 address label: */ 375 m_pLabelIPv4 = new QLabel; 376 AssertPtrReturnVoid(m_pLabelIPv4); 377 { 378 /* Configure label: */ 379 m_pLabelIPv4->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 380 /* Add into layout: */ 381 pLayoutInterface->addWidget(m_pLabelIPv4, 2, 1); 382 } 383 /* Create IPv4 layout: */ 384 QHBoxLayout *pLayoutIPv4 = new QHBoxLayout; 385 AssertPtrReturnVoid(pLayoutIPv4); 386 { 387 /* Configure layout: */ 388 pLayoutIPv4->setContentsMargins(0, 0, 0, 0); 389 /* Create IPv4 address editor: */ 390 m_pEditorIPv4 = new QILineEdit; 391 AssertPtrReturnVoid(m_pEditorIPv4); 392 { 393 /* Configure editor: */ 394 m_pLabelIPv4->setBuddy(m_pEditorIPv4); 395 connect(m_pEditorIPv4, &QLineEdit::textChanged, 396 this, &UIHostNetworkDetailsWidget::sltTextChangedIPv4); 397 /* Add into layout: */ 398 pLayoutIPv4->addWidget(m_pEditorIPv4); 399 } 400 /* Create IPv4 error pane: */ 401 m_pErrorPaneIPv4 = new QLabel; 402 AssertPtrReturnVoid(m_pErrorPaneIPv4); 403 { 404 /* Configure label: */ 405 m_pErrorPaneIPv4->setAlignment(Qt::AlignCenter); 406 m_pErrorPaneIPv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 407 .pixmap(QSize(iIconMetric, iIconMetric))); 408 /* Add into layout: */ 409 pLayoutIPv4->addWidget(m_pErrorPaneIPv4); 410 } 411 /* Add into layout: */ 412 pLayoutInterface->addLayout(pLayoutIPv4, 2, 2); 413 } 414 415 /* Create NMv4 network mask label: */ 416 m_pLabelNMv4 = new QLabel; 417 AssertPtrReturnVoid(m_pLabelNMv4); 418 { 419 /* Configure label: */ 420 m_pLabelNMv4->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 421 /* Add into layout: */ 422 pLayoutInterface->addWidget(m_pLabelNMv4, 3, 1); 423 } 424 /* Create NMv4 layout: */ 425 QHBoxLayout *pLayoutNMv4 = new QHBoxLayout; 426 AssertPtrReturnVoid(pLayoutNMv4); 427 { 428 /* Configure layout: */ 429 pLayoutNMv4->setContentsMargins(0, 0, 0, 0); 430 /* Create NMv4 network mask editor: */ 431 m_pEditorNMv4 = new QILineEdit; 432 AssertPtrReturnVoid(m_pEditorNMv4); 433 { 434 /* Configure editor: */ 435 m_pLabelNMv4->setBuddy(m_pEditorNMv4); 436 connect(m_pEditorNMv4, &QLineEdit::textChanged, 437 this, &UIHostNetworkDetailsWidget::sltTextChangedNMv4); 438 /* Add into layout: */ 439 pLayoutNMv4->addWidget(m_pEditorNMv4); 440 } 441 /* Create NMv4 error pane: */ 442 m_pErrorPaneNMv4 = new QLabel; 443 AssertPtrReturnVoid(m_pErrorPaneNMv4); 444 { 445 /* Configure label: */ 446 m_pErrorPaneNMv4->setAlignment(Qt::AlignCenter); 447 m_pErrorPaneNMv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 448 .pixmap(QSize(iIconMetric, iIconMetric))); 449 /* Add into layout: */ 450 pLayoutNMv4->addWidget(m_pErrorPaneNMv4); 451 } 452 /* Add into layout: */ 453 pLayoutInterface->addLayout(pLayoutNMv4, 3, 2); 454 } 455 456 /* Create IPv6 address label: */ 457 m_pLabelIPv6 = new QLabel; 458 AssertPtrReturnVoid(m_pLabelIPv6); 459 { 460 /* Configure label: */ 461 m_pLabelIPv6->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 462 /* Add into layout: */ 463 pLayoutInterface->addWidget(m_pLabelIPv6, 4, 1); 464 } 465 /* Create IPv6 layout: */ 466 QHBoxLayout *pLayoutIPv6 = new QHBoxLayout; 467 AssertPtrReturnVoid(pLayoutIPv6); 468 { 469 /* Configure layout: */ 470 pLayoutIPv6->setContentsMargins(0, 0, 0, 0); 471 /* Create IPv6 address editor: */ 472 m_pEditorIPv6 = new QILineEdit; 473 AssertPtrReturnVoid(m_pEditorIPv6); 474 { 475 /* Configure editor: */ 476 m_pLabelIPv6->setBuddy(m_pEditorIPv6); 477 connect(m_pEditorIPv6, &QLineEdit::textChanged, 478 this, &UIHostNetworkDetailsWidget::sltTextChangedIPv6); 479 /* Add into layout: */ 480 pLayoutIPv6->addWidget(m_pEditorIPv6); 481 } 482 /* Create IPv4 error pane: */ 483 m_pErrorPaneIPv6 = new QLabel; 484 AssertPtrReturnVoid(m_pErrorPaneIPv6); 485 { 486 /* Configure label: */ 487 m_pErrorPaneIPv6->setAlignment(Qt::AlignCenter); 488 m_pErrorPaneIPv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 489 .pixmap(QSize(iIconMetric, iIconMetric))); 490 /* Add into layout: */ 491 pLayoutIPv6->addWidget(m_pErrorPaneIPv6); 492 } 493 /* Add into layout: */ 494 pLayoutInterface->addLayout(pLayoutIPv6, 4, 2); 495 } 496 497 /* Create NMv6 network mask label: */ 498 m_pLabelNMv6 = new QLabel; 499 AssertPtrReturnVoid(m_pLabelNMv6); 500 { 501 /* Configure label: */ 502 m_pLabelNMv6->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 503 /* Add into layout: */ 504 pLayoutInterface->addWidget(m_pLabelNMv6, 5, 1); 505 } 506 /* Create NMv6 layout: */ 507 QHBoxLayout *pLayoutNMv6 = new QHBoxLayout; 508 AssertPtrReturnVoid(pLayoutNMv6); 509 { 510 /* Configure layout: */ 511 pLayoutNMv6->setContentsMargins(0, 0, 0, 0); 512 /* Create NMv6 network mask editor: */ 513 m_pEditorNMv6 = new QILineEdit; 514 AssertPtrReturnVoid(m_pEditorNMv6); 515 { 516 /* Configure editor: */ 517 m_pLabelNMv6->setBuddy(m_pEditorNMv6); 518 connect(m_pEditorNMv6, &QLineEdit::textChanged, 519 this, &UIHostNetworkDetailsWidget::sltTextChangedNMv6); 520 /* Add into layout: */ 521 pLayoutNMv6->addWidget(m_pEditorNMv6); 522 } 523 /* Create NMv6 error pane: */ 524 m_pErrorPaneNMv6 = new QLabel; 525 AssertPtrReturnVoid(m_pErrorPaneNMv6); 526 { 527 /* Configure label: */ 528 m_pErrorPaneNMv6->setAlignment(Qt::AlignCenter); 529 m_pErrorPaneNMv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 530 .pixmap(QSize(iIconMetric, iIconMetric))); 531 /* Add into layout: */ 532 pLayoutNMv6->addWidget(m_pErrorPaneNMv6); 533 } 534 /* Add into layout: */ 535 pLayoutInterface->addLayout(pLayoutNMv6, 5, 2); 536 } 537 538 /* Create indent: */ 539 QStyleOption options; 540 options.initFrom(m_pButtonManual); 541 const int iWidth = m_pButtonManual->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pButtonManual) + 542 m_pButtonManual->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pButtonManual) - 543 pLayoutInterface->spacing() - 1; 544 QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 545 AssertPtrReturnVoid(pSpacer1); 546 { 547 /* Add into layout: */ 548 pLayoutInterface->addItem(pSpacer1, 2, 0, 4); 549 } 550 /* Create stretch: */ 551 QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); 552 AssertPtrReturnVoid(pSpacer2); 553 { 554 /* Add into layout: */ 555 pLayoutInterface->addItem(pSpacer2, 6, 0, 1, 3); 556 } 557 558 /* If parent embedded into stack: */ 559 if (m_enmEmbedding == EmbedTo_Stack) 560 { 561 /* Create button-box: */ 562 m_pButtonBoxInterface = new QIDialogButtonBox; 563 AssertPtrReturnVoid(m_pButtonBoxInterface); 564 /* Configure button-box: */ 565 m_pButtonBoxInterface->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 566 connect(m_pButtonBoxInterface, &QIDialogButtonBox::clicked, this, &UIHostNetworkDetailsWidget::sltHandleButtonBoxClick); 567 568 /* Add into layout: */ 569 pLayoutInterface->addWidget(m_pButtonBoxInterface, 7, 0, 1, 3); 570 } 571 } 572 /* Add to tab-widget: */ 573 m_pTabWidget->addTab(pTabInterface, QString()); 574 } 575 } 576 577 void UIHostNetworkDetailsWidget::prepareTabDHCPServer() 578 { 579 /* Create 'DHCP server' tab: */ 580 QWidget *pTabDHCPServer = new QWidget; 581 AssertPtrReturnVoid(pTabDHCPServer); 582 { 583 /* Create 'DHCP server' layout: */ 584 QGridLayout *pLayoutDHCPServer = new QGridLayout(pTabDHCPServer); 585 AssertPtrReturnVoid(pLayoutDHCPServer); 586 { 587 #ifdef VBOX_WS_MAC 588 /* Configure layout: */ 589 pLayoutDHCPServer->setSpacing(10); 590 pLayoutDHCPServer->setContentsMargins(10, 10, 10, 10); 591 #endif 592 593 /* Get the required icon metric: */ 594 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 595 596 /* Create DHCP server status check-box: */ 597 m_pCheckBoxDHCP = new QCheckBox; 598 AssertPtrReturnVoid(m_pCheckBoxDHCP); 599 { 600 /* Configure check-box: */ 601 connect(m_pCheckBoxDHCP, &QCheckBox::stateChanged, 602 this, &UIHostNetworkDetailsWidget::sltStatusChangedServer); 603 /* Add into layout: */ 604 pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2); 605 #ifdef VBOX_WS_MAC 606 pLayoutDHCPServer->setRowMinimumHeight(0, 22); 607 #endif 608 } 609 610 /* Create DHCP address label: */ 611 m_pLabelDHCPAddress = new QLabel; 612 AssertPtrReturnVoid(m_pLabelDHCPAddress); 613 { 614 /* Configure label: */ 615 m_pLabelDHCPAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 616 /* Add into layout: */ 617 pLayoutDHCPServer->addWidget(m_pLabelDHCPAddress, 1, 1); 618 } 619 /* Create DHCP address layout: */ 620 QHBoxLayout *pLayoutDHCPAddress = new QHBoxLayout; 621 AssertPtrReturnVoid(pLayoutDHCPAddress); 622 { 623 /* Configure layout: */ 624 pLayoutDHCPAddress->setContentsMargins(0, 0, 0, 0); 625 /* Create DHCP address editor: */ 626 m_pEditorDHCPAddress = new QILineEdit; 627 AssertPtrReturnVoid(m_pEditorDHCPAddress); 628 { 629 /* Configure editor: */ 630 m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress); 631 connect(m_pEditorDHCPAddress, &QLineEdit::textChanged, 632 this, &UIHostNetworkDetailsWidget::sltTextChangedAddress); 633 /* Add into layout: */ 634 pLayoutDHCPAddress->addWidget(m_pEditorDHCPAddress); 635 } 636 /* Create DHCP address error pane: */ 637 m_pErrorPaneDHCPAddress = new QLabel; 638 AssertPtrReturnVoid(m_pErrorPaneDHCPAddress); 639 { 640 /* Configure label: */ 641 m_pErrorPaneDHCPAddress->setAlignment(Qt::AlignCenter); 642 m_pErrorPaneDHCPAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 643 .pixmap(QSize(iIconMetric, iIconMetric))); 644 /* Add into layout: */ 645 pLayoutDHCPAddress->addWidget(m_pErrorPaneDHCPAddress); 646 } 647 /* Add into layout: */ 648 pLayoutDHCPServer->addLayout(pLayoutDHCPAddress, 1, 2); 649 } 650 651 /* Create DHCP network mask label: */ 652 m_pLabelDHCPMask = new QLabel; 653 AssertPtrReturnVoid(m_pLabelDHCPMask); 654 { 655 /* Configure label: */ 656 m_pLabelDHCPMask->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 657 /* Add into layout: */ 658 pLayoutDHCPServer->addWidget(m_pLabelDHCPMask, 2, 1); 659 } 660 /* Create DHCP mask layout: */ 661 QHBoxLayout *pLayoutDHCPMask = new QHBoxLayout; 662 AssertPtrReturnVoid(pLayoutDHCPMask); 663 { 664 /* Configure layout: */ 665 pLayoutDHCPMask->setContentsMargins(0, 0, 0, 0); 666 /* Create DHCP network mask editor: */ 667 m_pEditorDHCPMask = new QILineEdit; 668 AssertPtrReturnVoid(m_pEditorDHCPMask); 669 { 670 /* Configure editor: */ 671 m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask); 672 connect(m_pEditorDHCPMask, &QLineEdit::textChanged, 673 this, &UIHostNetworkDetailsWidget::sltTextChangedMask); 674 /* Add into layout: */ 675 pLayoutDHCPMask->addWidget(m_pEditorDHCPMask); 676 } 677 /* Create DHCP mask error pane: */ 678 m_pErrorPaneDHCPMask = new QLabel; 679 AssertPtrReturnVoid(m_pErrorPaneDHCPMask); 680 { 681 /* Configure label: */ 682 m_pErrorPaneDHCPMask->setAlignment(Qt::AlignCenter); 683 m_pErrorPaneDHCPMask->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 684 .pixmap(QSize(iIconMetric, iIconMetric))); 685 /* Add into layout: */ 686 pLayoutDHCPMask->addWidget(m_pErrorPaneDHCPMask); 687 } 688 /* Add into layout: */ 689 pLayoutDHCPServer->addLayout(pLayoutDHCPMask, 2, 2); 690 } 691 692 /* Create DHCP lower address label: */ 693 m_pLabelDHCPLowerAddress = new QLabel; 694 AssertPtrReturnVoid(m_pLabelDHCPLowerAddress); 695 { 696 /* Configure label: */ 697 m_pLabelDHCPLowerAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 698 /* Add into layout: */ 699 pLayoutDHCPServer->addWidget(m_pLabelDHCPLowerAddress, 3, 1); 700 } 701 /* Create DHCP lower address layout: */ 702 QHBoxLayout *pLayoutDHCPLowerAddress = new QHBoxLayout; 703 AssertPtrReturnVoid(pLayoutDHCPLowerAddress); 704 { 705 /* Configure layout: */ 706 pLayoutDHCPLowerAddress->setContentsMargins(0, 0, 0, 0); 707 /* Create DHCP lower address editor: */ 708 m_pEditorDHCPLowerAddress = new QILineEdit; 709 AssertPtrReturnVoid(m_pEditorDHCPLowerAddress); 710 { 711 /* Configure editor: */ 712 m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress); 713 connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged, 714 this, &UIHostNetworkDetailsWidget::sltTextChangedLowerAddress); 715 /* Add into layout: */ 716 pLayoutDHCPLowerAddress->addWidget(m_pEditorDHCPLowerAddress); 717 } 718 /* Create DHCP lower address error pane: */ 719 m_pErrorPaneDHCPLowerAddress = new QLabel; 720 AssertPtrReturnVoid(m_pErrorPaneDHCPLowerAddress); 721 { 722 /* Configure label: */ 723 m_pErrorPaneDHCPLowerAddress->setAlignment(Qt::AlignCenter); 724 m_pErrorPaneDHCPLowerAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 725 .pixmap(QSize(iIconMetric, iIconMetric))); 726 /* Add into layout: */ 727 pLayoutDHCPLowerAddress->addWidget(m_pErrorPaneDHCPLowerAddress); 728 } 729 /* Add into layout: */ 730 pLayoutDHCPServer->addLayout(pLayoutDHCPLowerAddress, 3, 2); 731 } 732 733 /* Create DHCP upper address label: */ 734 m_pLabelDHCPUpperAddress = new QLabel; 735 AssertPtrReturnVoid(m_pLabelDHCPUpperAddress); 736 { 737 /* Configure label: */ 738 m_pLabelDHCPUpperAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 739 /* Add into layout: */ 740 pLayoutDHCPServer->addWidget(m_pLabelDHCPUpperAddress, 4, 1); 741 } 742 /* Create DHCP upper address layout: */ 743 QHBoxLayout *pLayoutDHCPUpperAddress = new QHBoxLayout; 744 AssertPtrReturnVoid(pLayoutDHCPUpperAddress); 745 { 746 /* Configure layout: */ 747 pLayoutDHCPUpperAddress->setContentsMargins(0, 0, 0, 0); 748 /* Create DHCP upper address editor: */ 749 m_pEditorDHCPUpperAddress = new QILineEdit; 750 AssertPtrReturnVoid(m_pEditorDHCPUpperAddress); 751 { 752 /* Configure editor: */ 753 m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress); 754 connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged, 755 this, &UIHostNetworkDetailsWidget::sltTextChangedUpperAddress); 756 /* Add into layout: */ 757 pLayoutDHCPUpperAddress->addWidget(m_pEditorDHCPUpperAddress); 758 } 759 /* Create DHCP upper address error pane: */ 760 m_pErrorPaneDHCPUpperAddress = new QLabel; 761 AssertPtrReturnVoid(m_pErrorPaneDHCPUpperAddress); 762 { 763 /* Configure label: */ 764 m_pErrorPaneDHCPUpperAddress->setAlignment(Qt::AlignCenter); 765 m_pErrorPaneDHCPUpperAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 766 .pixmap(QSize(iIconMetric, iIconMetric))); 767 /* Add into layout: */ 768 pLayoutDHCPUpperAddress->addWidget(m_pErrorPaneDHCPUpperAddress); 769 } 770 /* Add into layout: */ 771 pLayoutDHCPServer->addLayout(pLayoutDHCPUpperAddress, 4, 2); 772 } 773 774 /* Create indent: */ 775 QStyleOption options; 776 options.initFrom(m_pCheckBoxDHCP); 777 const int iWidth = m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_IndicatorWidth, &options, m_pCheckBoxDHCP) + 778 m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &options, m_pCheckBoxDHCP) - 779 pLayoutDHCPServer->spacing() - 1; 780 QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 781 AssertPtrReturnVoid(pSpacer1); 782 { 783 /* Add into layout: */ 784 pLayoutDHCPServer->addItem(pSpacer1, 1, 0, 4); 785 } 786 /* Create stretch: */ 787 QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); 788 AssertPtrReturnVoid(pSpacer2); 789 { 790 /* Add into layout: */ 791 pLayoutDHCPServer->addItem(pSpacer2, 5, 0, 1, 3); 792 } 793 794 /* If parent embedded into stack: */ 795 if (m_enmEmbedding == EmbedTo_Stack) 796 { 797 /* Create button-box: */ 798 m_pButtonBoxServer = new QIDialogButtonBox; 799 AssertPtrReturnVoid(m_pButtonBoxServer); 800 /* Configure button-box: */ 801 m_pButtonBoxServer->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 802 connect(m_pButtonBoxServer, &QIDialogButtonBox::clicked, this, &UIHostNetworkDetailsWidget::sltHandleButtonBoxClick); 803 804 /* Add into layout: */ 805 pLayoutDHCPServer->addWidget(m_pButtonBoxServer, 6, 0, 1, 3); 806 } 807 } 808 /* Add to tab-widget: */ 809 m_pTabWidget->addTab(pTabDHCPServer, QString()); 810 } 811 } 812 813 void UIHostNetworkDetailsWidget::loadDataForInterface() 814 { 815 /* Toggle IPv4 & IPv6 interface fields availability: */ 816 const bool fIsInterfaceConfigurable = !m_newData.m_interface.m_fDHCPEnabled; 817 m_pLabelIPv4->setEnabled(fIsInterfaceConfigurable); 818 m_pLabelNMv4->setEnabled(fIsInterfaceConfigurable); 819 m_pEditorIPv4->setEnabled(fIsInterfaceConfigurable); 820 m_pEditorNMv4->setEnabled(fIsInterfaceConfigurable); 821 822 /* Load IPv4 interface fields: */ 823 m_pButtonAutomatic->setChecked(!fIsInterfaceConfigurable); 824 m_pButtonManual->setChecked(fIsInterfaceConfigurable); 825 m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress); 826 m_pEditorNMv4->setText(m_newData.m_interface.m_strMask); 827 828 /* Toggle IPv6 interface fields availability: */ 829 const bool fIsIpv6Configurable = fIsInterfaceConfigurable && m_newData.m_interface.m_fSupportedIPv6; 830 m_pLabelIPv6->setEnabled(fIsIpv6Configurable); 831 m_pLabelNMv6->setEnabled(fIsIpv6Configurable); 832 m_pEditorIPv6->setEnabled(fIsIpv6Configurable); 833 m_pEditorNMv6->setEnabled(fIsIpv6Configurable); 834 835 /* Load IPv6 interface fields: */ 836 m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6); 837 m_pEditorNMv6->setText(m_newData.m_interface.m_strPrefixLength6); 838 } 839 840 void UIHostNetworkDetailsWidget::loadDataForDHCPServer() 841 { 842 /* Toggle DHCP server fields availability: */ 843 const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled; 844 m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled); 845 m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled); 846 m_pLabelDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled); 847 m_pLabelDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled); 848 m_pEditorDHCPAddress->setEnabled(fIsDHCPServerEnabled); 849 m_pEditorDHCPMask->setEnabled(fIsDHCPServerEnabled); 850 m_pEditorDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled); 851 m_pEditorDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled); 852 853 /* Load DHCP server fields: */ 854 m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled); 855 m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress); 856 m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask); 857 m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress); 858 m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress); 859 860 /* Invent default values if server was enabled 861 * but at least one current value is invalid: */ 862 if ( fIsDHCPServerEnabled 863 && ( m_pEditorDHCPAddress->text().isEmpty() 864 || m_pEditorDHCPAddress->text() == "0.0.0.0" 865 || m_pEditorDHCPMask->text().isEmpty() 866 || m_pEditorDHCPMask->text() == "0.0.0.0" 867 || m_pEditorDHCPLowerAddress->text().isEmpty() 868 || m_pEditorDHCPLowerAddress->text() == "0.0.0.0" 869 || m_pEditorDHCPUpperAddress->text().isEmpty() 870 || m_pEditorDHCPUpperAddress->text() == "0.0.0.0")) 871 { 872 const QStringList &proposal = makeDhcpServerProposal(m_oldData.m_interface.m_strAddress, 873 m_oldData.m_interface.m_strMask); 874 m_pEditorDHCPAddress->setText(proposal.at(0)); 875 m_pEditorDHCPMask->setText(proposal.at(1)); 876 m_pEditorDHCPLowerAddress->setText(proposal.at(2)); 877 m_pEditorDHCPUpperAddress->setText(proposal.at(3)); 878 } 879 } 880 881 void UIHostNetworkDetailsWidget::revalidate(QWidget *pWidget /* = 0 */) 882 { 883 /* Validate 'Interface' tab content: */ 884 if (!pWidget || pWidget == m_pErrorPaneAutomatic) 885 { 886 const bool fError = m_newData.m_interface.m_fDHCPEnabled 887 && !m_newData.m_dhcpserver.m_fEnabled; 888 m_pErrorPaneAutomatic->setVisible(fError); 889 } 890 if (!pWidget || pWidget == m_pErrorPaneManual) 891 { 892 const bool fError = false; 893 m_pErrorPaneManual->setVisible(fError); 894 } 895 if (!pWidget || pWidget == m_pErrorPaneIPv4) 896 { 897 const bool fError = !m_newData.m_interface.m_fDHCPEnabled 898 && !m_newData.m_interface.m_strAddress.trimmed().isEmpty() 899 && ( !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strAddress.toUtf8().constData()) 900 || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strAddress.toUtf8().constData())); 901 m_pErrorPaneIPv4->setVisible(fError); 902 } 903 if (!pWidget || pWidget == m_pErrorPaneNMv4) 904 { 905 const bool fError = !m_newData.m_interface.m_fDHCPEnabled 906 && !m_newData.m_interface.m_strMask.trimmed().isEmpty() 907 && ( !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strMask.toUtf8().constData()) 908 || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strMask.toUtf8().constData())); 909 m_pErrorPaneNMv4->setVisible(fError); 910 } 911 if (!pWidget || pWidget == m_pErrorPaneIPv6) 912 { 913 const bool fError = !m_newData.m_interface.m_fDHCPEnabled 914 && m_newData.m_interface.m_fSupportedIPv6 915 && !m_newData.m_interface.m_strAddress6.trimmed().isEmpty() 916 && ( !RTNetIsIPv6AddrStr(m_newData.m_interface.m_strAddress6.toUtf8().constData()) 917 || RTNetStrIsIPv6AddrAny(m_newData.m_interface.m_strAddress6.toUtf8().constData())); 918 m_pErrorPaneIPv6->setVisible(fError); 919 } 920 if (!pWidget || pWidget == m_pErrorPaneNMv6) 921 { 922 bool fIsMaskPrefixLengthNumber = false; 923 const int iMaskPrefixLength = m_newData.m_interface.m_strPrefixLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber); 924 const bool fError = !m_newData.m_interface.m_fDHCPEnabled 925 && m_newData.m_interface.m_fSupportedIPv6 926 && ( !fIsMaskPrefixLengthNumber 927 || iMaskPrefixLength < 0 928 || iMaskPrefixLength > 128); 929 m_pErrorPaneNMv6->setVisible(fError); 930 } 931 932 /* Validate 'DHCP server' tab content: */ 933 if (!pWidget || pWidget == m_pErrorPaneDHCPAddress) 934 { 935 const bool fError = m_newData.m_dhcpserver.m_fEnabled 936 && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData()) 937 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData())); 938 m_pErrorPaneDHCPAddress->setVisible(fError); 939 } 940 if (!pWidget || pWidget == m_pErrorPaneDHCPMask) 941 { 942 const bool fError = m_newData.m_dhcpserver.m_fEnabled 943 && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strMask.toUtf8().constData()) 944 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strMask.toUtf8().constData())); 945 m_pErrorPaneDHCPMask->setVisible(fError); 946 } 947 if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress) 948 { 949 const bool fError = m_newData.m_dhcpserver.m_fEnabled 950 && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData()) 951 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData())); 952 m_pErrorPaneDHCPLowerAddress->setVisible(fError); 953 } 954 if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress) 955 { 956 const bool fError = m_newData.m_dhcpserver.m_fEnabled 957 && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()) 958 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData())); 959 m_pErrorPaneDHCPUpperAddress->setVisible(fError); 960 } 126 /// @todo validate profile settings table! 961 127 962 128 /* Retranslate validation: */ … … 964 130 } 965 131 966 void UI HostNetworkDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */)132 void UICloudProfileDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */) 967 133 { 968 /* Translate 'Interface' tab content: */ 969 if (!pWidget || pWidget == m_pErrorPaneAutomatic) 970 m_pErrorPaneAutomatic->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> is set to obtain the address automatically " 971 "but the corresponding DHCP server is not enabled.").arg(m_newData.m_interface.m_strName)); 972 if (!pWidget || pWidget == m_pErrorPaneIPv4) 973 m_pErrorPaneIPv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 974 "IPv4 address.").arg(m_newData.m_interface.m_strName)); 975 if (!pWidget || pWidget == m_pErrorPaneNMv4) 976 m_pErrorPaneNMv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 977 "IPv4 network mask.").arg(m_newData.m_interface.m_strName)); 978 if (!pWidget || pWidget == m_pErrorPaneIPv6) 979 m_pErrorPaneIPv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 980 "IPv6 address.").arg(m_newData.m_interface.m_strName)); 981 if (!pWidget || pWidget == m_pErrorPaneNMv6) 982 m_pErrorPaneNMv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 983 "IPv6 prefix length.").arg(m_newData.m_interface.m_strName)); 134 Q_UNUSED(pWidget); 984 135 985 /* Translate 'DHCP server' tab content: */ 986 if (!pWidget || pWidget == m_pErrorPaneDHCPAddress) 987 m_pErrorPaneDHCPAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 988 "DHCP server address.").arg(m_newData.m_interface.m_strName)); 989 if (!pWidget || pWidget == m_pErrorPaneDHCPMask) 990 m_pErrorPaneDHCPMask->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 991 "DHCP server mask.").arg(m_newData.m_interface.m_strName)); 992 if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress) 993 m_pErrorPaneDHCPLowerAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 994 "DHCP server lower address bound.").arg(m_newData.m_interface.m_strName)); 995 if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress) 996 m_pErrorPaneDHCPUpperAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid " 997 "DHCP server upper address bound.").arg(m_newData.m_interface.m_strName)); 136 /// @todo retranslate profile settings vaidation! 998 137 } 999 138 1000 void UI HostNetworkDetailsWidget::updateButtonStates()139 void UICloudProfileDetailsWidget::updateButtonStates() 1001 140 { 1002 // if (m_oldData != m_newData) 1003 // printf("Interface: %s, %s, %s, %s; DHCP server: %d, %s, %s, %s, %s\n", 1004 // m_newData.m_interface.m_strAddress.toUtf8().constData(), 1005 // m_newData.m_interface.m_strMask.toUtf8().constData(), 1006 // m_newData.m_interface.m_strAddress6.toUtf8().constData(), 1007 // m_newData.m_interface.m_strPrefixLength6.toUtf8().constData(), 1008 // (int)m_newData.m_dhcpserver.m_fEnabled, 1009 // m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(), 1010 // m_newData.m_dhcpserver.m_strMask.toUtf8().constData(), 1011 // m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(), 1012 // m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()); 141 /// @todo update that printf as well! 142 #if 0 143 if (m_oldData != m_newData) 144 printf("Interface: %s, %s, %s, %s; DHCP server: %d, %s, %s, %s, %s\n", 145 m_newData.m_interface.m_strAddress.toUtf8().constData(), 146 m_newData.m_interface.m_strMask.toUtf8().constData(), 147 m_newData.m_interface.m_strAddress6.toUtf8().constData(), 148 m_newData.m_interface.m_strPrefixLength6.toUtf8().constData(), 149 (int)m_newData.m_dhcpserver.m_fEnabled, 150 m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(), 151 m_newData.m_dhcpserver.m_strMask.toUtf8().constData(), 152 m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(), 153 m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()); 154 #endif 1013 155 1014 156 /* Update 'Apply' / 'Reset' button states: */ 1015 if (m_pButtonBox Interface)157 if (m_pButtonBox) 1016 158 { 1017 m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 1018 m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 1019 } 1020 if (m_pButtonBoxServer) 1021 { 1022 m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 1023 m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 159 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 160 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 1024 161 } 1025 162 … … 1027 164 emit sigDataChanged(m_oldData != m_newData); 1028 165 } 1029 -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.h
r74811 r74853 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI HostNetworkDetailsWidget class declaration.3 * VBox Qt GUI - UICloudProfileDetailsWidget class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef ___UI HostNetworkDetailsWidget_h___19 #define ___UI HostNetworkDetailsWidget_h___18 #ifndef ___UICloudProfileDetailsWidget_h___ 19 #define ___UICloudProfileDetailsWidget_h___ 20 20 21 21 /* Qt includes: */ … … 28 28 /* Forward declarations: */ 29 29 class QAbstractButton; 30 class QCheckBox; 31 class QLabel; 32 class QRadioButton; 30 class QTableWidget; 33 31 class QIDialogButtonBox; 34 class QILineEdit;35 class QITabWidget;36 32 37 33 38 /** Host Network Manager: Host Network Interface data structure. */39 struct UIData HostNetworkInterface34 /** Cloud Profile data structure. */ 35 struct UIDataCloudProfile 40 36 { 41 37 /** Constructs data. */ 42 UIData HostNetworkInterface()38 UIDataCloudProfile() 43 39 : m_strName(QString()) 44 , m_fDHCPEnabled(false)45 , m_strAddress(QString())46 , m_strMask(QString())47 , m_fSupportedIPv6(false)48 , m_strAddress6(QString())49 , m_strPrefixLength6(QString())50 40 {} 51 41 52 42 /** Returns whether the @a other passed data is equal to this one. */ 53 bool equal(const UIData HostNetworkInterface &other) const43 bool equal(const UIDataCloudProfile &other) const 54 44 { 55 45 return true 56 46 && (m_strName == other.m_strName) 57 && (m_fDHCPEnabled == other.m_fDHCPEnabled)58 && (m_strAddress == other.m_strAddress)59 && (m_strMask == other.m_strMask)60 && (m_fSupportedIPv6 == other.m_fSupportedIPv6)61 && (m_strAddress6 == other.m_strAddress6)62 && (m_strPrefixLength6 == other.m_strPrefixLength6)63 47 ; 64 48 } 65 49 66 50 /** Returns whether the @a other passed data is equal to this one. */ 67 bool operator==(const UIData HostNetworkInterface &other) const { return equal(other); }51 bool operator==(const UIDataCloudProfile &other) const { return equal(other); } 68 52 /** Returns whether the @a other passed data is different from this one. */ 69 bool operator!=(const UIData HostNetworkInterface &other) const { return !equal(other); }53 bool operator!=(const UIDataCloudProfile &other) const { return !equal(other); } 70 54 71 /** Holds interface name. */ 72 QString m_strName; 73 /** Holds whether DHCP is enabled for that interface. */ 74 bool m_fDHCPEnabled; 75 /** Holds IPv4 interface address. */ 76 QString m_strAddress; 77 /** Holds IPv4 interface mask. */ 78 QString m_strMask; 79 /** Holds whether IPv6 protocol supported. */ 80 bool m_fSupportedIPv6; 81 /** Holds IPv6 interface address. */ 82 QString m_strAddress6; 83 /** Holds IPv6 interface prefix length. */ 84 QString m_strPrefixLength6; 55 /** Holds the snapshot name. */ 56 QString m_strName; 85 57 }; 86 58 87 59 88 /** Host Network Manager: DHCP Server data structure. */ 89 struct UIDataDHCPServer 90 { 91 /** Constructs data. */ 92 UIDataDHCPServer() 93 : m_fEnabled(false) 94 , m_strAddress(QString()) 95 , m_strMask(QString()) 96 , m_strLowerAddress(QString()) 97 , m_strUpperAddress(QString()) 98 {} 99 100 /** Returns whether the @a other passed data is equal to this one. */ 101 bool equal(const UIDataDHCPServer &other) const 102 { 103 return true 104 && (m_fEnabled == other.m_fEnabled) 105 && (m_strAddress == other.m_strAddress) 106 && (m_strMask == other.m_strMask) 107 && (m_strLowerAddress == other.m_strLowerAddress) 108 && (m_strUpperAddress == other.m_strUpperAddress) 109 ; 110 } 111 112 /** Returns whether the @a other passed data is equal to this one. */ 113 bool operator==(const UIDataDHCPServer &other) const { return equal(other); } 114 /** Returns whether the @a other passed data is different from this one. */ 115 bool operator!=(const UIDataDHCPServer &other) const { return !equal(other); } 116 117 /** Holds whether DHCP server enabled. */ 118 bool m_fEnabled; 119 /** Holds DHCP server address. */ 120 QString m_strAddress; 121 /** Holds DHCP server mask. */ 122 QString m_strMask; 123 /** Holds DHCP server lower address. */ 124 QString m_strLowerAddress; 125 /** Holds DHCP server upper address. */ 126 QString m_strUpperAddress; 127 }; 128 129 130 /** Host Network Manager: Host network data structure. */ 131 struct UIDataHostNetwork 132 { 133 /** Constructs data. */ 134 UIDataHostNetwork() 135 : m_interface(UIDataHostNetworkInterface()) 136 , m_dhcpserver(UIDataDHCPServer()) 137 {} 138 139 /** Returns whether the @a other passed data is equal to this one. */ 140 bool equal(const UIDataHostNetwork &other) const 141 { 142 return true 143 && (m_interface == other.m_interface) 144 && (m_dhcpserver == other.m_dhcpserver) 145 ; 146 } 147 148 /** Returns whether the @a other passed data is equal to this one. */ 149 bool operator==(const UIDataHostNetwork &other) const { return equal(other); } 150 /** Returns whether the @a other passed data is different from this one. */ 151 bool operator!=(const UIDataHostNetwork &other) const { return !equal(other); } 152 153 /** Holds the interface data. */ 154 UIDataHostNetworkInterface m_interface; 155 /** Holds the DHCP server data. */ 156 UIDataDHCPServer m_dhcpserver; 157 }; 158 159 160 /** Host Network Manager: Host network details-widget. */ 161 class UIHostNetworkDetailsWidget : public QIWithRetranslateUI<QWidget> 60 /** Cloud Profile details widget. */ 61 class UICloudProfileDetailsWidget : public QIWithRetranslateUI<QWidget> 162 62 { 163 63 Q_OBJECT; … … 175 75 public: 176 76 177 /** Constructs medium details dialogpassing @a pParent to the base-class.77 /** Constructs cloud profile details widget passing @a pParent to the base-class. 178 78 * @param enmEmbedding Brings embedding type. */ 179 UI HostNetworkDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0);79 UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0); 180 80 181 /** Returns the host networkdata. */182 const UIData HostNetwork&data() const { return m_newData; }183 /** Defines the host network@a data. */184 void setData(const UIData HostNetwork&data);81 /** Returns the cloud profile data. */ 82 const UIDataCloudProfile &data() const { return m_newData; } 83 /** Defines the cloud profile @a data. */ 84 void setData(const UIDataCloudProfile &data); 185 85 186 86 protected: … … 193 93 /** @name Change handling stuff. 194 94 * @{ */ 195 /** Handles interface automatic configuration choice change. */ 196 void sltToggledButtonAutomatic(bool fChecked); 197 /** Handles interface manual configuration choice change. */ 198 void sltToggledButtonManual(bool fChecked); 199 /** Handles interface IPv4 text change. */ 200 void sltTextChangedIPv4(const QString &strText); 201 /** Handles interface NMv4 text change. */ 202 void sltTextChangedNMv4(const QString &strText); 203 /** Handles interface IPv6 text change. */ 204 void sltTextChangedIPv6(const QString &strText); 205 /** Handles interface NMv6 text change. */ 206 void sltTextChangedNMv6(const QString &strText); 207 208 /** Handles DHCP server status change. */ 209 void sltStatusChangedServer(int iChecked); 210 /** Handles DHCP server address text change. */ 211 void sltTextChangedAddress(const QString &strText); 212 /** Handles DHCP server mask text change. */ 213 void sltTextChangedMask(const QString &strText); 214 /** Handles DHCP server lower address text change. */ 215 void sltTextChangedLowerAddress(const QString &strText); 216 /** Handles DHCP server upper address text change. */ 217 void sltTextChangedUpperAddress(const QString &strText); 95 /** Handles table change. */ 96 void sltTableChanged(); 218 97 219 98 /** Handles button-box button click. */ … … 227 106 /** Prepares all. */ 228 107 void prepare(); 229 /** Prepares this. */ 230 void prepareThis(); 231 /** Prepares tab-widget. */ 232 void prepareTabWidget(); 233 /** Prepares 'Interface' tab. */ 234 void prepareTabInterface(); 235 /** Prepares 'DHCP server' tab. */ 236 void prepareTabDHCPServer(); 108 /** Prepares widgets. */ 109 void prepareWidgets(); 237 110 /** @} */ 238 111 239 112 /** @name Loading stuff. 240 113 * @{ */ 241 /** Loads interface data. */ 242 void loadDataForInterface(); 243 /** Loads server data. */ 244 void loadDataForDHCPServer(); 114 /** Loads data. */ 115 void loadData(); 245 116 /** @} */ 246 117 … … 258 129 * @{ */ 259 130 /** Holds the parent widget embedding type. */ 260 const EmbedTo m_enmEmbedding;131 const EmbedTo m_enmEmbedding; 261 132 262 133 /** Holds the old data copy. */ 263 UIData HostNetworkm_oldData;134 UIDataCloudProfile m_oldData; 264 135 /** Holds the new data copy. */ 265 UIDataHostNetwork m_newData; 266 267 /** Holds the tab-widget. */ 268 QITabWidget *m_pTabWidget; 136 UIDataCloudProfile m_newData; 269 137 /** @} */ 270 138 … … 272 140 * @{ */ 273 141 /** Holds the automatic interface configuration button. */ 274 QRadioButton *m_pButtonAutomatic; 275 /** Holds the automatic interface configuration error pane. */ 276 QLabel *m_pErrorPaneAutomatic; 277 278 /** Holds the manual interface configuration button. */ 279 QRadioButton *m_pButtonManual; 280 /** Holds the manual interface configuration error pane. */ 281 QLabel *m_pErrorPaneManual; 282 283 /** Holds the IPv4 address label. */ 284 QLabel *m_pLabelIPv4; 285 /** Holds the IPv4 address editor. */ 286 QILineEdit *m_pEditorIPv4; 287 /** Holds the IPv4 address error pane. */ 288 QLabel *m_pErrorPaneIPv4; 289 290 /** Holds the IPv4 network mask label. */ 291 QLabel *m_pLabelNMv4; 292 /** Holds the IPv4 network mask editor. */ 293 QILineEdit *m_pEditorNMv4; 294 /** Holds the IPv4 network mask error pane. */ 295 QLabel *m_pErrorPaneNMv4; 296 297 /** Holds the IPv6 address label. */ 298 QLabel *m_pLabelIPv6; 299 /** Holds the IPv6 address editor. */ 300 QILineEdit *m_pEditorIPv6; 301 /** Holds the IPv6 address error pane. */ 302 QLabel *m_pErrorPaneIPv6; 303 304 /** Holds the IPv6 network mask label. */ 305 QLabel *m_pLabelNMv6; 306 /** Holds the IPv6 network mask editor. */ 307 QILineEdit *m_pEditorNMv6; 308 /** Holds the IPv6 network mask error pane. */ 309 QLabel *m_pErrorPaneNMv6; 310 311 /** Holds the interface button-box instance. */ 312 QIDialogButtonBox *m_pButtonBoxInterface; 313 /** @} */ 314 315 /** @name DHCP server variables. 316 * @{ */ 317 /** Holds the DHCP server status chack-box. */ 318 QCheckBox *m_pCheckBoxDHCP; 319 320 /** Holds the DHCP address label. */ 321 QLabel *m_pLabelDHCPAddress; 322 /** Holds the DHCP address editor. */ 323 QILineEdit *m_pEditorDHCPAddress; 324 /** Holds the DHCP address error pane. */ 325 QLabel *m_pErrorPaneDHCPAddress; 326 327 /** Holds the DHCP network mask label. */ 328 QLabel *m_pLabelDHCPMask; 329 /** Holds the DHCP network mask editor. */ 330 QILineEdit *m_pEditorDHCPMask; 331 /** Holds the DHCP network mask error pane. */ 332 QLabel *m_pErrorPaneDHCPMask; 333 334 /** Holds the DHCP lower address label. */ 335 QLabel *m_pLabelDHCPLowerAddress; 336 /** Holds the DHCP lower address editor. */ 337 QILineEdit *m_pEditorDHCPLowerAddress; 338 /** Holds the DHCP lower address error pane. */ 339 QLabel *m_pErrorPaneDHCPLowerAddress; 340 341 /** Holds the DHCP upper address label. */ 342 QLabel *m_pLabelDHCPUpperAddress; 343 /** Holds the DHCP upper address editor. */ 344 QILineEdit *m_pEditorDHCPUpperAddress; 345 /** Holds the DHCP upper address error pane. */ 346 QLabel *m_pErrorPaneDHCPUpperAddress; 142 QTableWidget *m_pTableWidget; 347 143 348 144 /** Holds the server button-box instance. */ 349 QIDialogButtonBox *m_pButtonBox Server;145 QIDialogButtonBox *m_pButtonBox; 350 146 /** @} */ 351 147 }; 352 148 353 #endif /* !___UIHostNetworkDetailsWidget_h___ */354 149 150 #endif /* !___UICloudProfileDetailsWidget_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp
r74811 r74853 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI HostNetworkManager class implementation.3 * VBox Qt GUI - UICloudProfileManager class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QHeaderView>24 # include <QMenuBar>25 23 # include <QPushButton> 26 24 # include <QVBoxLayout> … … 29 27 # include "QIDialogButtonBox.h" 30 28 # include "QITreeWidget.h" 29 # include "VBoxGlobal.h" 31 30 # include "UIActionPoolSelector.h" 32 31 # include "UIExtraDataManager.h" 33 32 # include "UIIconPool.h" 34 # include "UIHostNetworkDetailsWidget.h" 35 # include "UIHostNetworkManager.h" 36 # include "UIHostNetworkUtils.h" 37 # include "UIMessageCenter.h" 33 # include "UICloudProfileDetailsWidget.h" 34 # include "UICloudProfileManager.h" 38 35 # include "UIToolBar.h" 39 36 # ifdef VBOX_WS_MAC 40 37 # include "UIWindowMenuManager.h" 41 # endif /* VBOX_WS_MAC */ 42 # include "VBoxGlobal.h" 38 # endif 43 39 44 40 /* COM includes: */ 45 # include "CDHCPServer.h" 46 # include "CHost.h" 47 # include "CHostNetworkInterface.h" 48 49 /* Other VBox includes: */ 50 # include <iprt/cidr.h> 41 #include "CCloudProfile.h" 51 42 52 43 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 57 48 { 58 49 Column_Name, 59 Column_IPv4, 60 Column_IPv6, 61 Column_DHCP, 50 /// @todo rest of columns? 62 51 Column_Max, 63 52 }; 64 53 65 54 66 /** Host Network Manager: Tree-widget item. */67 class UIItem HostNetwork : public QITreeWidgetItem, public UIDataHostNetwork55 /** Cloud Profile Manager tree-widget item. */ 56 class UIItemCloudProfile : public QITreeWidgetItem, public UIDataCloudProfile 68 57 { 69 58 public: … … 73 62 74 63 /** Returns item name. */ 75 QString name() const { return m_interface.m_strName; } 76 77 private: 78 79 /** Returns CIDR for a passed @a strMask. */ 80 static int maskToCidr(const QString &strMask); 64 QString name() const { return m_strName; } 81 65 }; 82 66 83 67 84 68 /********************************************************************************************************************************* 85 * Class UIItem HostNetwork implementation.*69 * Class UIItemCloudProfile implementation. * 86 70 *********************************************************************************************************************************/ 87 71 88 void UIItem HostNetwork::updateFields()72 void UIItemCloudProfile::updateFields() 89 73 { 90 74 /* Compose item fields: */ 91 setText(Column_Name, m_interface.m_strName); 92 setText(Column_IPv4, m_interface.m_strAddress.isEmpty() ? QString() : 93 QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask))); 94 setText(Column_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() : 95 QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt())); 96 setText(Column_DHCP, UIHostNetworkManager::tr("Enable", "DHCP Server")); 97 setCheckState(Column_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked); 75 setText(Column_Name, m_strName); 76 /// @todo assign rest of field values! 98 77 99 78 /* Compose item tool-tip: */ 100 const QString strTable("<table cellspacing=5>%1</table>"); 101 const QString strHeader("<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 102 const QString strSubHeader("<tr><td><nobr> %1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 103 QString strToolTip; 104 105 /* Interface information: */ 106 strToolTip += strHeader.arg(UIHostNetworkManager::tr("Adapter")) 107 .arg(m_interface.m_fDHCPEnabled ? 108 UIHostNetworkManager::tr("Automatically configured", "interface") : 109 UIHostNetworkManager::tr("Manually configured", "interface")); 110 strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("IPv4 Address")) 111 .arg(m_interface.m_strAddress.isEmpty() ? 112 UIHostNetworkManager::tr ("Not set", "address") : 113 m_interface.m_strAddress) + 114 strSubHeader.arg(UIHostNetworkManager::tr("IPv4 Network Mask")) 115 .arg(m_interface.m_strMask.isEmpty() ? 116 UIHostNetworkManager::tr ("Not set", "mask") : 117 m_interface.m_strMask); 118 if (m_interface.m_fSupportedIPv6) 119 { 120 strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("IPv6 Address")) 121 .arg(m_interface.m_strAddress6.isEmpty() ? 122 UIHostNetworkManager::tr("Not set", "address") : 123 m_interface.m_strAddress6) + 124 strSubHeader.arg(UIHostNetworkManager::tr("IPv6 Prefix Length")) 125 .arg(m_interface.m_strPrefixLength6.isEmpty() ? 126 UIHostNetworkManager::tr("Not set", "length") : 127 m_interface.m_strPrefixLength6); 128 } 129 130 /* DHCP server information: */ 131 strToolTip += strHeader.arg(UIHostNetworkManager::tr("DHCP Server")) 132 .arg(m_dhcpserver.m_fEnabled ? 133 UIHostNetworkManager::tr("Enabled", "server") : 134 UIHostNetworkManager::tr("Disabled", "server")); 135 if (m_dhcpserver.m_fEnabled) 136 { 137 strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("Address")) 138 .arg(m_dhcpserver.m_strAddress.isEmpty() ? 139 UIHostNetworkManager::tr("Not set", "address") : 140 m_dhcpserver.m_strAddress) + 141 strSubHeader.arg(UIHostNetworkManager::tr("Network Mask")) 142 .arg(m_dhcpserver.m_strMask.isEmpty() ? 143 UIHostNetworkManager::tr("Not set", "mask") : 144 m_dhcpserver.m_strMask) + 145 strSubHeader.arg(UIHostNetworkManager::tr("Lower Bound")) 146 .arg(m_dhcpserver.m_strLowerAddress.isEmpty() ? 147 UIHostNetworkManager::tr("Not set", "bound") : 148 m_dhcpserver.m_strLowerAddress) + 149 strSubHeader.arg(UIHostNetworkManager::tr("Upper Bound")) 150 .arg(m_dhcpserver.m_strUpperAddress.isEmpty() ? 151 UIHostNetworkManager::tr("Not set", "bound") : 152 m_dhcpserver.m_strUpperAddress); 153 } 154 155 /* Assign tool-tip finally: */ 156 setToolTip(Column_Name, strTable.arg(strToolTip)); 157 } 158 159 /* static */ 160 int UIItemHostNetwork::maskToCidr(const QString &strMask) 161 { 162 /* Parse passed mask: */ 163 QList<int> address; 164 foreach (const QString &strValue, strMask.split('.')) 165 address << strValue.toInt(); 166 167 /* Calculate CIDR: */ 168 int iCidr = 0; 169 for (int i = 0; i < 4 || i < address.size(); ++i) 170 { 171 switch(address.at(i)) 172 { 173 case 0x80: iCidr += 1; break; 174 case 0xC0: iCidr += 2; break; 175 case 0xE0: iCidr += 3; break; 176 case 0xF0: iCidr += 4; break; 177 case 0xF8: iCidr += 5; break; 178 case 0xFC: iCidr += 6; break; 179 case 0xFE: iCidr += 7; break; 180 case 0xFF: iCidr += 8; break; 181 /* Return CIDR prematurelly: */ 182 default: return iCidr; 183 } 184 } 185 186 /* Return CIDR: */ 187 return iCidr; 79 /// @todo assign tool-tips! 188 80 } 189 81 190 82 191 83 /********************************************************************************************************************************* 192 * Class UI HostNetworkManagerWidget implementation.*84 * Class UICloudProfileManagerWidget implementation. * 193 85 *********************************************************************************************************************************/ 194 86 195 UI HostNetworkManagerWidget::UIHostNetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,196 bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */)87 UICloudProfileManagerWidget::UICloudProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 88 bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */) 197 89 : QIWithRetranslateUI<QWidget>(pParent) 198 90 , m_enmEmbedding(enmEmbedding) … … 207 99 } 208 100 209 QMenu *UIHostNetworkManagerWidget::menu() const 210 { 211 return m_pActionPool->action(UIActionIndexST_M_NetworkWindow)->menu(); 212 } 213 214 void UIHostNetworkManagerWidget::retranslateUi() 101 QMenu *UICloudProfileManagerWidget::menu() const 102 { 103 /// @todo implement menu action! 104 return 0; 105 } 106 107 void UICloudProfileManagerWidget::retranslateUi() 215 108 { 216 109 /* Adjust toolbar: */ … … 226 119 227 120 /* Translate tree-widget: */ 228 const QStringList fields = QStringList() 229 << UIHostNetworkManager::tr("Name") 230 << UIHostNetworkManager::tr("IPv4 Address/Mask") 231 << UIHostNetworkManager::tr("IPv6 Address/Mask") 232 << UIHostNetworkManager::tr("DHCP Server"); 233 m_pTreeWidget->setHeaderLabels(fields); 234 } 235 236 void UIHostNetworkManagerWidget::resizeEvent(QResizeEvent *pEvent) 121 /// @todo assign tree-widget column names! 122 } 123 124 void UICloudProfileManagerWidget::resizeEvent(QResizeEvent *pEvent) 237 125 { 238 126 /* Call to base-class: */ … … 243 131 } 244 132 245 void UI HostNetworkManagerWidget::showEvent(QShowEvent *pEvent)133 void UICloudProfileManagerWidget::showEvent(QShowEvent *pEvent) 246 134 { 247 135 /* Call to base-class: */ … … 252 140 } 253 141 254 void UI HostNetworkManagerWidget::sltResetHostNetworkDetailsChanges()142 void UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges() 255 143 { 256 144 /* Just push the current item data there again: */ … … 258 146 } 259 147 260 void UI HostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges()261 { 262 /* Get networkitem: */263 UIItem HostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem());148 void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges() 149 { 150 /* Get profile item: */ 151 UIItemCloudProfile *pItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem()); 264 152 AssertMsgReturnVoid(pItem, ("Current item must not be null!\n")); 265 153 266 /* Get item data: */ 267 UIDataHostNetwork oldData = *pItem; 268 UIDataHostNetwork newData = m_pDetailsWidget->data(); 269 270 /* Get host for further activities: */ 271 CHost comHost = vboxGlobal().host(); 272 273 /* Find corresponding interface: */ 274 CHostNetworkInterface comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName); 275 276 /* Show error message if necessary: */ 277 if (!comHost.isOk() || comInterface.isNull()) 278 msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this); 279 else 280 { 281 /* Save automatic interface configuration: */ 282 if (newData.m_interface.m_fDHCPEnabled) 283 { 284 if ( comInterface.isOk() 285 && !oldData.m_interface.m_fDHCPEnabled) 286 comInterface.EnableDynamicIPConfig(); 287 } 288 /* Save manual interface configuration: */ 289 else 290 { 291 /* Save IPv4 interface configuration: */ 292 if ( comInterface.isOk() 293 && ( oldData.m_interface.m_fDHCPEnabled 294 || newData.m_interface.m_strAddress != oldData.m_interface.m_strAddress 295 || newData.m_interface.m_strMask != oldData.m_interface.m_strMask)) 296 comInterface.EnableStaticIPConfig(newData.m_interface.m_strAddress, newData.m_interface.m_strMask); 297 /* Save IPv6 interface configuration: */ 298 if ( comInterface.isOk() 299 && newData.m_interface.m_fSupportedIPv6 300 && ( oldData.m_interface.m_fDHCPEnabled 301 || newData.m_interface.m_strAddress6 != oldData.m_interface.m_strAddress6 302 || newData.m_interface.m_strPrefixLength6 != oldData.m_interface.m_strPrefixLength6)) 303 comInterface.EnableStaticIPConfigV6(newData.m_interface.m_strAddress6, newData.m_interface.m_strPrefixLength6.toULong()); 304 } 305 306 /* Show error message if necessary: */ 307 if (!comInterface.isOk()) 308 msgCenter().cannotSaveHostNetworkInterfaceParameter(comInterface, this); 309 else 310 { 311 /* Get network name for further activities: */ 312 const QString strNetworkName = comInterface.GetNetworkName(); 313 314 /* Show error message if necessary: */ 315 if (!comInterface.isOk()) 316 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); 317 else 318 { 319 /* Get VBox for further activities: */ 320 CVirtualBox comVBox = vboxGlobal().virtualBox(); 321 322 /* Find corresponding DHCP server (create if necessary): */ 323 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); 324 if (!comVBox.isOk() || comServer.isNull()) 325 comServer = comVBox.CreateDHCPServer(strNetworkName); 326 327 /* Show error message if necessary: */ 328 if (!comVBox.isOk() || comServer.isNull()) 329 msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); 330 else 331 { 332 /* Save whether DHCP server is enabled: */ 333 if ( comServer.isOk() 334 && newData.m_dhcpserver.m_fEnabled != oldData.m_dhcpserver.m_fEnabled) 335 comServer.SetEnabled(newData.m_dhcpserver.m_fEnabled); 336 /* Save DHCP server configuration: */ 337 if ( comServer.isOk() 338 && newData.m_dhcpserver.m_fEnabled 339 && ( newData.m_dhcpserver.m_strAddress != oldData.m_dhcpserver.m_strAddress 340 || newData.m_dhcpserver.m_strMask != oldData.m_dhcpserver.m_strMask 341 || newData.m_dhcpserver.m_strLowerAddress != oldData.m_dhcpserver.m_strLowerAddress 342 || newData.m_dhcpserver.m_strUpperAddress != oldData.m_dhcpserver.m_strUpperAddress)) 343 comServer.SetConfiguration(newData.m_dhcpserver.m_strAddress, newData.m_dhcpserver.m_strMask, 344 newData.m_dhcpserver.m_strLowerAddress, newData.m_dhcpserver.m_strUpperAddress); 345 346 /* Show error message if necessary: */ 347 if (!comServer.isOk()) 348 msgCenter().cannotSaveDHCPServerParameter(comServer, this); 349 } 350 } 351 } 352 353 /* Find corresponding interface again (if necessary): */ 354 if (!comInterface.isOk()) 355 { 356 comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName); 357 358 /* Show error message if necessary: */ 359 if (!comHost.isOk() || comInterface.isNull()) 360 msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this); 361 } 362 363 /* If interface is Ok now: */ 364 if (comInterface.isNotNull() && comInterface.isOk()) 365 { 366 /* Update interface in the tree: */ 367 UIDataHostNetwork data; 368 loadHostNetwork(comInterface, data); 369 updateItemForNetworkHost(data, true, pItem); 370 371 /* Make sure current item fetched: */ 372 sltHandleCurrentItemChange(); 373 374 /* Adjust tree-widget: */ 375 sltAdjustTreeWidget(); 376 } 377 } 378 } 379 380 void UIHostNetworkManagerWidget::sltCreateHostNetwork() 381 { 382 /* Get host for further activities: */ 383 CHost comHost = vboxGlobal().host(); 384 385 /* Create interface: */ 386 CHostNetworkInterface comInterface; 387 CProgress progress = comHost.CreateHostOnlyNetworkInterface(comInterface); 388 389 /* Show error message if necessary: */ 390 if (!comHost.isOk() || progress.isNull()) 391 msgCenter().cannotCreateHostNetworkInterface(comHost, this); 392 else 393 { 394 /* Show interface creation progress: */ 395 msgCenter().showModalProgressDialog(progress, tr("Adding network..."), ":/progress_network_interface_90px.png", this, 0); 396 397 /* Show error message if necessary: */ 398 if (!progress.isOk() || progress.GetResultCode() != 0) 399 msgCenter().cannotCreateHostNetworkInterface(progress, this); 400 else 401 { 402 /* Get network name for further activities: */ 403 const QString strNetworkName = comInterface.GetNetworkName(); 404 405 /* Show error message if necessary: */ 406 if (!comInterface.isOk()) 407 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); 408 else 409 { 410 /* Get VBox for further activities: */ 411 CVirtualBox comVBox = vboxGlobal().virtualBox(); 412 413 /* Find corresponding DHCP server (create if necessary): */ 414 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); 415 if (!comVBox.isOk() || comServer.isNull()) 416 comServer = comVBox.CreateDHCPServer(strNetworkName); 417 418 /* Show error message if necessary: */ 419 if (!comVBox.isOk() || comServer.isNull()) 420 msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); 421 } 422 423 /* Add interface to the tree: */ 424 UIDataHostNetwork data; 425 loadHostNetwork(comInterface, data); 426 createItemForNetworkHost(data, true); 427 428 /* Adjust tree-widget: */ 429 sltAdjustTreeWidget(); 430 } 431 } 432 } 433 434 void UIHostNetworkManagerWidget::sltRemoveHostNetwork() 435 { 436 /* Get network item: */ 437 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); 438 AssertMsgReturnVoid(pItem, ("Current item must not be null!\n")); 439 440 /* Get interface name: */ 441 const QString strInterfaceName(pItem->name()); 442 443 /* Confirm host network removal: */ 444 if (!msgCenter().confirmHostOnlyInterfaceRemoval(strInterfaceName, this)) 445 return; 446 447 /* Get host for further activities: */ 448 CHost comHost = vboxGlobal().host(); 449 450 /* Find corresponding interface: */ 451 const CHostNetworkInterface &comInterface = comHost.FindHostNetworkInterfaceByName(strInterfaceName); 452 453 /* Show error message if necessary: */ 454 if (!comHost.isOk() || comInterface.isNull()) 455 msgCenter().cannotFindHostNetworkInterface(comHost, strInterfaceName, this); 456 else 457 { 458 /* Get network name for further activities: */ 459 QString strNetworkName; 460 if (comInterface.isOk()) 461 strNetworkName = comInterface.GetNetworkName(); 462 /* Get interface id for further activities: */ 463 QString strInterfaceId; 464 if (comInterface.isOk()) 465 strInterfaceId = comInterface.GetId(); 466 467 /* Show error message if necessary: */ 468 if (!comInterface.isOk()) 469 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); 470 else 471 { 472 /* Get VBox for further activities: */ 473 CVirtualBox comVBox = vboxGlobal().virtualBox(); 474 475 /* Find corresponding DHCP server: */ 476 const CDHCPServer &comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); 477 if (comVBox.isOk() && comServer.isNotNull()) 478 { 479 /* Remove server if any: */ 480 comVBox.RemoveDHCPServer(comServer); 481 482 /* Show error message if necessary: */ 483 if (!comVBox.isOk()) 484 msgCenter().cannotRemoveDHCPServer(comVBox, strInterfaceName, this); 485 } 486 487 /* Remove interface finally: */ 488 CProgress progress = comHost.RemoveHostOnlyNetworkInterface(strInterfaceId); 489 490 /* Show error message if necessary: */ 491 if (!comHost.isOk() || progress.isNull()) 492 msgCenter().cannotRemoveHostNetworkInterface(comHost, strInterfaceName, this); 493 else 494 { 495 /* Show interface removal progress: */ 496 msgCenter().showModalProgressDialog(progress, tr("Removing network..."), ":/progress_network_interface_90px.png", this, 0); 497 498 /* Show error message if necessary: */ 499 if (!progress.isOk() || progress.GetResultCode() != 0) 500 return msgCenter().cannotRemoveHostNetworkInterface(progress, strInterfaceName, this); 501 else 502 { 503 /* Remove interface from the tree: */ 504 delete pItem; 505 506 /* Adjust tree-widget: */ 507 sltAdjustTreeWidget(); 508 } 509 } 510 } 511 } 512 } 513 514 void UIHostNetworkManagerWidget::sltToggleHostNetworkDetailsVisibility(bool fVisible) 154 /// @todo apply cloud profile details! 155 } 156 157 void UICloudProfileManagerWidget::sltCreateCloudProfile() 158 { 159 /// @todo create cloud profile! 160 } 161 162 void UICloudProfileManagerWidget::sltRemoveCloudProfile() 163 { 164 /// @todo remove cloud profile! 165 } 166 167 void UICloudProfileManagerWidget::sltToggleCloudProfileDetailsVisibility(bool fVisible) 515 168 { 516 169 /* Save the setting: */ 517 gEDataManager->setHostNetworkManagerDetailsExpanded(fVisible);170 /// @todo implement extra-data setter! 518 171 /* Show/hide details area and Apply button: */ 519 172 m_pDetailsWidget->setVisible(fVisible); 520 173 /* Notify external lsiteners: */ 521 emit sig HostNetworkDetailsVisibilityChanged(fVisible);522 } 523 524 void UI HostNetworkManagerWidget::sltRefreshHostNetworks()174 emit sigCloudProfileDetailsVisibilityChanged(fVisible); 175 } 176 177 void UICloudProfileManagerWidget::sltRefreshCloudProfiles() 525 178 { 526 179 // Not implemented. … … 528 181 } 529 182 530 void UIHostNetworkManagerWidget::sltAdjustTreeWidget() 531 { 532 /* Get the tree-widget abstract interface: */ 533 QAbstractItemView *pItemView = m_pTreeWidget; 534 /* Get the tree-widget header-view: */ 535 QHeaderView *pItemHeader = m_pTreeWidget->header(); 536 183 void UICloudProfileManagerWidget::sltAdjustTreeWidget() 184 { 537 185 /* Calculate the total tree-widget width: */ 538 186 const int iTotal = m_pTreeWidget->viewport()->width(); 539 /* Look for a minimum width hints for non-important columns: */ 540 const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4)); 541 const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6)); 542 const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP)); 543 /* Propose suitable width hints for non-important columns: */ 544 const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max; 545 const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max; 546 const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max; 187 188 /// @todo calculate proposed column widths! 189 547 190 /* Apply the proposal: */ 548 m_pTreeWidget->setColumnWidth(Column_IPv4, iWidth1); 549 m_pTreeWidget->setColumnWidth(Column_IPv6, iWidth2); 550 m_pTreeWidget->setColumnWidth(Column_DHCP, iWidth3); 551 m_pTreeWidget->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3); 552 } 553 554 void UIHostNetworkManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem) 555 { 556 /* Get network item: */ 557 UIItemHostNetwork *pChangedItem = static_cast<UIItemHostNetwork*>(pItem); 191 m_pTreeWidget->setColumnWidth(Column_Name, iTotal /*- iWidth1 - iWidth2 - iWidth3*/); 192 } 193 194 void UICloudProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem) 195 { 196 /* Get profile item: */ 197 UIItemCloudProfile *pChangedItem = static_cast<UIItemCloudProfile*>(pItem); 558 198 AssertMsgReturnVoid(pChangedItem, ("Changed item must not be null!\n")); 559 199 560 /* Get item data: */ 561 UIDataHostNetwork oldData = *pChangedItem; 562 563 /* Make sure dhcp server status changed: */ 564 if ( ( oldData.m_dhcpserver.m_fEnabled 565 && pChangedItem->checkState(Column_DHCP) == Qt::Checked) 566 || ( !oldData.m_dhcpserver.m_fEnabled 567 && pChangedItem->checkState(Column_DHCP) == Qt::Unchecked)) 568 return; 569 570 /* Get host for further activities: */ 571 CHost comHost = vboxGlobal().host(); 572 573 /* Find corresponding interface: */ 574 CHostNetworkInterface comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName); 575 576 /* Show error message if necessary: */ 577 if (!comHost.isOk() || comInterface.isNull()) 578 msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this); 579 else 580 { 581 /* Get network name for further activities: */ 582 const QString strNetworkName = comInterface.GetNetworkName(); 583 584 /* Show error message if necessary: */ 585 if (!comInterface.isOk()) 586 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); 587 else 588 { 589 /* Get VBox for further activities: */ 590 CVirtualBox comVBox = vboxGlobal().virtualBox(); 591 592 /* Find corresponding DHCP server (create if necessary): */ 593 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); 594 if (!comVBox.isOk() || comServer.isNull()) 595 comServer = comVBox.CreateDHCPServer(strNetworkName); 596 597 /* Show error message if necessary: */ 598 if (!comVBox.isOk() || comServer.isNull()) 599 msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); 600 else 601 { 602 /* Save whether DHCP server is enabled: */ 603 if (comServer.isOk()) 604 comServer.SetEnabled(!oldData.m_dhcpserver.m_fEnabled); 605 /* Save default DHCP server configuration if current is invalid: */ 606 if ( comServer.isOk() 607 && !oldData.m_dhcpserver.m_fEnabled 608 && ( oldData.m_dhcpserver.m_strAddress == "0.0.0.0" 609 || oldData.m_dhcpserver.m_strMask == "0.0.0.0" 610 || oldData.m_dhcpserver.m_strLowerAddress == "0.0.0.0" 611 || oldData.m_dhcpserver.m_strUpperAddress == "0.0.0.0")) 612 { 613 const QStringList &proposal = makeDhcpServerProposal(oldData.m_interface.m_strAddress, 614 oldData.m_interface.m_strMask); 615 comServer.SetConfiguration(proposal.at(0), proposal.at(1), proposal.at(2), proposal.at(3)); 616 } 617 618 /* Show error message if necessary: */ 619 if (!comServer.isOk()) 620 msgCenter().cannotSaveDHCPServerParameter(comServer, this); 621 { 622 /* Update interface in the tree: */ 623 UIDataHostNetwork data; 624 loadHostNetwork(comInterface, data); 625 updateItemForNetworkHost(data, true, pChangedItem); 626 627 /* Make sure current item fetched: */ 628 sltHandleCurrentItemChange(); 629 630 /* Adjust tree-widget: */ 631 sltAdjustTreeWidget(); 632 } 633 } 634 } 635 } 636 } 637 638 void UIHostNetworkManagerWidget::sltHandleCurrentItemChange() 639 { 640 /* Get network item: */ 641 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); 200 /// @todo handle item change! 201 } 202 203 void UICloudProfileManagerWidget::sltHandleCurrentItemChange() 204 { 205 /* Get profile item: */ 206 UIItemCloudProfile *pItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem()); 642 207 643 208 /* Update actions availability: */ 644 m_pActionPool->action(UIActionIndexST_M_Network_S_Remove)->setEnabled(pItem); 645 m_pActionPool->action(UIActionIndexST_M_Network_T_Details)->setEnabled(pItem); 209 /// @todo implement % enable/disable actions! 646 210 647 211 /* If there is an item => update details data: */ … … 651 215 { 652 216 /* Otherwise => clear details and close the area: */ 653 m_pDetailsWidget->setData(UIData HostNetwork());654 sltToggle HostNetworkDetailsVisibility(false);655 } 656 } 657 658 void UI HostNetworkManagerWidget::sltHandleContextMenuRequest(const QPoint &position)217 m_pDetailsWidget->setData(UIDataCloudProfile()); 218 sltToggleCloudProfileDetailsVisibility(false); 219 } 220 } 221 222 void UICloudProfileManagerWidget::sltHandleContextMenuRequest(const QPoint &position) 659 223 { 660 224 /* Compose temporary context-menu: */ 661 225 QMenu menu; 662 if (m_pTreeWidget->itemAt(position)) 663 { 664 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove)); 665 menu.addSeparator(); 666 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_T_Details)); 667 } 668 else 669 { 670 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Create)); 671 // menu.addSeparator(); 672 // menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh)); 673 } 226 /// @todo implement & insert actions! 227 674 228 /* And show it: */ 675 229 menu.exec(m_pTreeWidget->mapToGlobal(position)); 676 230 } 677 231 678 void UI HostNetworkManagerWidget::prepare()232 void UICloudProfileManagerWidget::prepare() 679 233 { 680 234 /* Prepare actions: */ … … 689 243 retranslateUi(); 690 244 691 /* Load host networks: */692 load HostNetworks();693 } 694 695 void UI HostNetworkManagerWidget::prepareActions()245 /* Load cloud profiles: */ 246 loadCloudProfiles(); 247 } 248 249 void UICloudProfileManagerWidget::prepareActions() 696 250 { 697 251 /* Connect actions: */ 698 connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Create), &QAction::triggered, 699 this, &UIHostNetworkManagerWidget::sltCreateHostNetwork); 700 connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove), &QAction::triggered, 701 this, &UIHostNetworkManagerWidget::sltRemoveHostNetwork); 702 connect(m_pActionPool->action(UIActionIndexST_M_Network_T_Details), &QAction::toggled, 703 this, &UIHostNetworkManagerWidget::sltToggleHostNetworkDetailsVisibility); 704 connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh), &QAction::triggered, 705 this, &UIHostNetworkManagerWidget::sltRefreshHostNetworks); 706 } 707 708 void UIHostNetworkManagerWidget::prepareWidgets() 252 /// @todo implement & connect actions! 253 } 254 255 void UICloudProfileManagerWidget::prepareWidgets() 709 256 { 710 257 /* Create main-layout: */ 711 258 new QVBoxLayout(this); 712 AssertPtrReturnVoid(layout());259 if (layout()) 713 260 { 714 261 /* Configure layout: */ … … 730 277 } 731 278 732 void UI HostNetworkManagerWidget::prepareToolBar()279 void UICloudProfileManagerWidget::prepareToolBar() 733 280 { 734 281 /* Create toolbar: */ 735 282 m_pToolBar = new UIToolBar(parentWidget()); 736 AssertPtrReturnVoid(m_pToolBar);283 if (m_pToolBar) 737 284 { 738 285 /* Configure toolbar: */ … … 742 289 743 290 /* Add toolbar actions: */ 744 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Create)); 745 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove)); 746 m_pToolBar->addSeparator(); 747 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_T_Details)); 748 // m_pToolBar->addSeparator(); 749 // m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh)); 291 /// @todo implement & add actions! 750 292 751 293 #ifdef VBOX_WS_MAC … … 763 305 } 764 306 765 void UI HostNetworkManagerWidget::prepareTreeWidget()307 void UICloudProfileManagerWidget::prepareTreeWidget() 766 308 { 767 309 /* Create tree-widget: */ 768 310 m_pTreeWidget = new QITreeWidget; 769 AssertPtrReturnVoid(m_pTreeWidget);311 if (m_pTreeWidget) 770 312 { 771 313 /* Configure tree-widget: */ … … 779 321 m_pTreeWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); 780 322 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 781 this, &UI HostNetworkManagerWidget::sltHandleCurrentItemChange);323 this, &UICloudProfileManagerWidget::sltHandleCurrentItemChange); 782 324 connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested, 783 this, &UI HostNetworkManagerWidget::sltHandleContextMenuRequest);325 this, &UICloudProfileManagerWidget::sltHandleContextMenuRequest); 784 326 connect(m_pTreeWidget, &QITreeWidget::itemChanged, 785 this, &UIHostNetworkManagerWidget::sltHandleItemChange); 786 connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked, 787 m_pActionPool->action(UIActionIndexST_M_Network_T_Details), &QAction::setChecked); 327 this, &UICloudProfileManagerWidget::sltHandleItemChange); 328 /// @todo implement & connect actions! 788 329 789 330 /* Add into layout: */ … … 792 333 } 793 334 794 void UI HostNetworkManagerWidget::prepareDetailsWidget()335 void UICloudProfileManagerWidget::prepareDetailsWidget() 795 336 { 796 337 /* Create details-widget: */ 797 m_pDetailsWidget = new UI HostNetworkDetailsWidget(m_enmEmbedding);798 AssertPtrReturnVoid(m_pDetailsWidget);338 m_pDetailsWidget = new UICloudProfileDetailsWidget(m_enmEmbedding); 339 if (m_pDetailsWidget) 799 340 { 800 341 /* Configure details-widget: */ 801 342 m_pDetailsWidget->setVisible(false); 802 343 m_pDetailsWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 803 connect(m_pDetailsWidget, &UI HostNetworkDetailsWidget::sigDataChanged,804 this, &UI HostNetworkManagerWidget::sigHostNetworkDetailsDataChanged);805 connect(m_pDetailsWidget, &UI HostNetworkDetailsWidget::sigDataChangeRejected,806 this, &UI HostNetworkManagerWidget::sltResetHostNetworkDetailsChanges);807 connect(m_pDetailsWidget, &UI HostNetworkDetailsWidget::sigDataChangeAccepted,808 this, &UI HostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges);344 connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChanged, 345 this, &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged); 346 connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeRejected, 347 this, &UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges); 348 connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeAccepted, 349 this, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges); 809 350 810 351 /* Add into layout: */ … … 813 354 } 814 355 815 void UI HostNetworkManagerWidget::loadSettings()356 void UICloudProfileManagerWidget::loadSettings() 816 357 { 817 358 /* Details action/widget: */ 818 m_pActionPool->action(UIActionIndexST_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded());819 } 820 821 void UI HostNetworkManagerWidget::loadHostNetworks()359 /// @todo implement extra-data getter! 360 } 361 362 void UICloudProfileManagerWidget::loadCloudProfiles() 822 363 { 823 364 /* Clear tree first of all: */ 824 365 m_pTreeWidget->clear(); 825 366 826 /* Get host for further activities: */ 827 const CHost comHost = vboxGlobal().host(); 828 829 /* Get interfaces for further activities: */ 830 const QVector<CHostNetworkInterface> interfaces = comHost.GetNetworkInterfaces(); 831 832 /* Show error message if necessary: */ 833 if (!comHost.isOk()) 834 msgCenter().cannotAcquireHostNetworkInterfaces(comHost, this); 835 else 836 { 837 /* For each host-only interface => load it to the tree: */ 838 foreach (const CHostNetworkInterface &comInterface, interfaces) 839 if (comInterface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly) 840 { 841 UIDataHostNetwork data; 842 loadHostNetwork(comInterface, data); 843 createItemForNetworkHost(data, false); 844 } 845 846 /* Choose the 1st item as current initially: */ 847 m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0)); 848 sltHandleCurrentItemChange(); 849 850 /* Adjust tree-widget: */ 851 sltAdjustTreeWidget(); 852 } 853 } 854 855 void UIHostNetworkManagerWidget::loadHostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork &data) 856 { 857 /* Gather interface settings: */ 858 if (comInterface.isOk()) 859 data.m_interface.m_strName = comInterface.GetName(); 860 if (comInterface.isOk()) 861 data.m_interface.m_fDHCPEnabled = comInterface.GetDHCPEnabled(); 862 if (comInterface.isOk()) 863 data.m_interface.m_strAddress = comInterface.GetIPAddress(); 864 if (comInterface.isOk()) 865 data.m_interface.m_strMask = comInterface.GetNetworkMask(); 866 if (comInterface.isOk()) 867 data.m_interface.m_fSupportedIPv6 = comInterface.GetIPV6Supported(); 868 if (comInterface.isOk()) 869 data.m_interface.m_strAddress6 = comInterface.GetIPV6Address(); 870 if (comInterface.isOk()) 871 data.m_interface.m_strPrefixLength6 = QString::number(comInterface.GetIPV6NetworkMaskPrefixLength()); 872 873 /* Get host interface network name for further activities: */ 874 QString strNetworkName; 875 if (comInterface.isOk()) 876 strNetworkName = comInterface.GetNetworkName(); 877 878 /* Show error message if necessary: */ 879 if (!comInterface.isOk()) 880 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); 881 882 /* Get VBox for further activities: */ 883 CVirtualBox comVBox = vboxGlobal().virtualBox(); 884 885 /* Find corresponding DHCP server (create if necessary): */ 886 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); 887 if (!comVBox.isOk() || comServer.isNull()) 888 comServer = comVBox.CreateDHCPServer(strNetworkName); 889 890 /* Show error message if necessary: */ 891 if (!comVBox.isOk() || comServer.isNull()) 892 msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); 893 else 894 { 895 /* Gather DHCP server settings: */ 896 if (comServer.isOk()) 897 data.m_dhcpserver.m_fEnabled = comServer.GetEnabled(); 898 if (comServer.isOk()) 899 data.m_dhcpserver.m_strAddress = comServer.GetIPAddress(); 900 if (comServer.isOk()) 901 data.m_dhcpserver.m_strMask = comServer.GetNetworkMask(); 902 if (comServer.isOk()) 903 data.m_dhcpserver.m_strLowerAddress = comServer.GetLowerIP(); 904 if (comServer.isOk()) 905 data.m_dhcpserver.m_strUpperAddress = comServer.GetUpperIP(); 906 907 /* Show error message if necessary: */ 908 if (!comServer.isOk()) 909 return msgCenter().cannotAcquireDHCPServerParameter(comServer, this); 910 } 911 } 912 913 void UIHostNetworkManagerWidget::createItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem) 367 /// @todo load cloud profiles! 368 } 369 370 void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, UIDataCloudProfile &data) 371 { 372 Q_UNUSED(comProfile); 373 Q_UNUSED(data); 374 375 /// @todo load cloud profile! 376 } 377 378 void UICloudProfileManagerWidget::createItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem) 914 379 { 915 380 /* Create new item: */ 916 UIItem HostNetwork *pItem = new UIItemHostNetwork;917 AssertPtrReturnVoid(pItem);381 UIItemCloudProfile *pItem = new UIItemCloudProfile; 382 if (pItem) 918 383 { 919 384 /* Configure item: */ 920 pItem->UIData HostNetwork::operator=(data);385 pItem->UIDataCloudProfile::operator=(data); 921 386 pItem->updateFields(); 922 387 /* Add item to the tree: */ … … 928 393 } 929 394 930 void UI HostNetworkManagerWidget::updateItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem, UIItemHostNetwork*pItem)395 void UICloudProfileManagerWidget::updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem) 931 396 { 932 397 /* Update passed item: */ 933 AssertPtrReturnVoid(pItem);398 if (pItem) 934 399 { 935 400 /* Configure item: */ 936 pItem->UIData HostNetwork::operator=(data);401 pItem->UIDataCloudProfile::operator=(data); 937 402 pItem->updateFields(); 938 403 /* And choose it as current if necessary: */ … … 944 409 945 410 /********************************************************************************************************************************* 946 * Class UI HostNetworkManagerFactory implementation. *411 * Class UICloudProfileManagerFactory implementation. * 947 412 *********************************************************************************************************************************/ 948 413 949 UI HostNetworkManagerFactory::UIHostNetworkManagerFactory(UIActionPool *pActionPool /* = 0 */)414 UICloudProfileManagerFactory::UICloudProfileManagerFactory(UIActionPool *pActionPool /* = 0 */) 950 415 : m_pActionPool(pActionPool) 951 416 { 952 417 } 953 418 954 void UI HostNetworkManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)955 { 956 pDialog = new UI HostNetworkManager(pCenterWidget, m_pActionPool);419 void UICloudProfileManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 420 { 421 pDialog = new UICloudProfileManager(pCenterWidget, m_pActionPool); 957 422 } 958 423 959 424 960 425 /********************************************************************************************************************************* 961 * Class UI HostNetworkManager implementation. *426 * Class UICloudProfileManager implementation. * 962 427 *********************************************************************************************************************************/ 963 428 964 UI HostNetworkManager::UIHostNetworkManager(QWidget *pCenterWidget, UIActionPool *pActionPool)429 UICloudProfileManager::UICloudProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool) 965 430 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 966 431 , m_pActionPool(pActionPool) … … 968 433 } 969 434 970 void UI HostNetworkManager::sltHandleButtonBoxClick(QAbstractButton *pButton)435 void UICloudProfileManager::sltHandleButtonBoxClick(QAbstractButton *pButton) 971 436 { 972 437 /* Disable buttons first of all: */ … … 982 447 } 983 448 984 void UI HostNetworkManager::retranslateUi()449 void UICloudProfileManager::retranslateUi() 985 450 { 986 451 /* Translate window title: */ 987 setWindowTitle(tr(" Host NetworkManager"));452 setWindowTitle(tr("Cloud Profile Manager")); 988 453 989 454 /* Translate buttons: */ … … 991 456 button(ButtonType_Apply)->setText(tr("Apply")); 992 457 button(ButtonType_Close)->setText(tr("Close")); 993 button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current host networkdetails"));994 button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current host networkdetails"));458 button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current cloud profile details")); 459 button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current cloud profile details")); 995 460 button(ButtonType_Close)->setStatusTip(tr("Close dialog without saving")); 996 461 button(ButtonType_Reset)->setShortcut(QString("Ctrl+Backspace")); … … 1002 467 } 1003 468 1004 void UI HostNetworkManager::configure()469 void UICloudProfileManager::configure() 1005 470 { 1006 471 /* Apply window icons: */ 472 /// @todo apply proper cloud profile manager icons! 1007 473 setWindowIcon(UIIconPool::iconSetFull(":/host_iface_manager_32px.png", ":/host_iface_manager_16px.png")); 1008 474 } 1009 475 1010 void UI HostNetworkManager::configureCentralWidget()476 void UICloudProfileManager::configureCentralWidget() 1011 477 { 1012 478 /* Create widget: */ 1013 UI HostNetworkManagerWidget *pWidget = new UIHostNetworkManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this);1014 AssertPtrReturnVoid(pWidget);479 UICloudProfileManagerWidget *pWidget = new UICloudProfileManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this); 480 if (pWidget) 1015 481 { 1016 482 /* Configure widget: */ … … 1020 486 setWidgetToolbar(pWidget->toolbar()); 1021 487 #endif 1022 connect(this, &UI HostNetworkManager::sigDataChangeRejected,1023 pWidget, &UI HostNetworkManagerWidget::sltResetHostNetworkDetailsChanges);1024 connect(this, &UI HostNetworkManager::sigDataChangeAccepted,1025 pWidget, &UI HostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges);488 connect(this, &UICloudProfileManager::sigDataChangeRejected, 489 pWidget, &UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges); 490 connect(this, &UICloudProfileManager::sigDataChangeAccepted, 491 pWidget, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges); 1026 492 1027 493 /* Add into layout: */ … … 1030 496 } 1031 497 1032 void UI HostNetworkManager::configureButtonBox()498 void UICloudProfileManager::configureButtonBox() 1033 499 { 1034 500 /* Configure button-box: */ 1035 connect(widget(), &UI HostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,501 connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged, 1036 502 button(ButtonType_Apply), &QPushButton::setVisible); 1037 connect(widget(), &UI HostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,503 connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged, 1038 504 button(ButtonType_Reset), &QPushButton::setVisible); 1039 connect(widget(), &UI HostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,505 connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged, 1040 506 button(ButtonType_Apply), &QPushButton::setEnabled); 1041 connect(widget(), &UI HostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,507 connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged, 1042 508 button(ButtonType_Reset), &QPushButton::setEnabled); 1043 509 connect(buttonBox(), &QIDialogButtonBox::clicked, 1044 this, &UI HostNetworkManager::sltHandleButtonBoxClick);510 this, &UICloudProfileManager::sltHandleButtonBoxClick); 1045 511 // WORKAROUND: 1046 512 // Since we connected signals later than extra-data loaded 1047 513 // for signals above, we should handle that stuff here again: 1048 button(ButtonType_Apply)->setVisible(gEDataManager->hostNetworkManagerDetailsExpanded()); 1049 button(ButtonType_Reset)->setVisible(gEDataManager->hostNetworkManagerDetailsExpanded()); 1050 } 1051 1052 void UIHostNetworkManager::finalize() 514 /// @todo implement extra-data getter! 515 } 516 517 void UICloudProfileManager::finalize() 1053 518 { 1054 519 /* Apply language settings: */ … … 1056 521 } 1057 522 1058 UIHostNetworkManagerWidget *UIHostNetworkManager::widget() 1059 { 1060 return qobject_cast<UIHostNetworkManagerWidget*>(QIManagerDialog::widget()); 1061 } 1062 523 UICloudProfileManagerWidget *UICloudProfileManager::widget() 524 { 525 return qobject_cast<UICloudProfileManagerWidget*>(QIManagerDialog::widget()); 526 } -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.h
r74811 r74853 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI HostNetworkManager class declaration.3 * VBox Qt GUI - UICloudProfileManager class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef ___UIHostNetworkManager_h___ 19 #define ___UIHostNetworkManager_h___ 20 21 /* Qt includes: */ 22 #include <QMainWindow> 18 #ifndef ___UICloudProfileManager_h___ 19 #define ___UICloudProfileManager_h___ 23 20 24 21 /* GUI includes: */ … … 27 24 28 25 /* Forward declarations: */ 29 class CHostNetworkInterface;30 26 class QAbstractButton; 31 27 class QTreeWidgetItem; 32 class QIDialogButtonBox;33 28 class QITreeWidget; 34 29 class UIActionPool; 35 class UI HostNetworkDetailsWidget;36 class UIItem HostNetwork;30 class UICloudProfileDetailsWidget; 31 class UIItemCloudProfile; 37 32 class UIToolBar; 38 struct UIDataHostNetwork; 39 40 41 /** QWidget extension providing GUI with the pane to control host network related functionality. */ 42 class UIHostNetworkManagerWidget : public QIWithRetranslateUI<QWidget> 33 struct UIDataCloudProfile; 34 class CCloudProfile; 35 36 37 /** QWidget extension providing GUI with the pane to control cloud profile related functionality. */ 38 class UICloudProfileManagerWidget : public QIWithRetranslateUI<QWidget> 43 39 { 44 40 Q_OBJECT; … … 46 42 signals: 47 43 48 /** Notifies listeners about host networkdetails-widget @a fVisible. */49 void sig HostNetworkDetailsVisibilityChanged(bool fVisible);50 /** Notifies listeners about host networkdetails data @a fDiffers. */51 void sig HostNetworkDetailsDataChanged(bool fDiffers);44 /** Notifies listeners about cloud profile details-widget @a fVisible. */ 45 void sigCloudProfileDetailsVisibilityChanged(bool fVisible); 46 /** Notifies listeners about cloud profile details data @a fDiffers. */ 47 void sigCloudProfileDetailsDataChanged(bool fDiffers); 52 48 53 49 public: 54 50 55 /** Constructs Host NetworkManager widget.51 /** Constructs Cloud Profile Manager widget. 56 52 * @param enmEmbedding Brings the type of widget embedding. 57 53 * @param pActionPool Brings the action-pool reference. 58 54 * @param fShowToolbar Brings whether we should create/show toolbar. */ 59 UI HostNetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,60 bool fShowToolbar = true, QWidget *pParent = 0);55 UICloudProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 56 bool fShowToolbar = true, QWidget *pParent = 0); 61 57 62 58 /** Returns the menu. */ … … 86 82 /** @name Details-widget stuff. 87 83 * @{ */ 88 /** Handles command to reset host networkdetails changes. */89 void sltReset HostNetworkDetailsChanges();90 /** Handles command to apply host networkdetails changes. */91 void sltApply HostNetworkDetailsChanges();84 /** Handles command to reset cloud profile details changes. */ 85 void sltResetCloudProfileDetailsChanges(); 86 /** Handles command to apply cloud profile details changes. */ 87 void sltApplyCloudProfileDetailsChanges(); 92 88 /** @} */ 93 89 … … 96 92 /** @name Menu/action stuff. 97 93 * @{ */ 98 /** Handles command to create host network. */99 void sltCreate HostNetwork();100 /** Handles command to remove host network. */101 void sltRemove HostNetwork();102 /** Handles command to make host networkdetails @a fVisible. */103 void sltToggle HostNetworkDetailsVisibility(bool fVisible);104 /** Handles command to refresh host networks. */105 void sltRefresh HostNetworks();94 /** Handles command to create cloud profile. */ 95 void sltCreateCloudProfile(); 96 /** Handles command to remove cloud profile. */ 97 void sltRemoveCloudProfile(); 98 /** Handles command to make cloud profile details @a fVisible. */ 99 void sltToggleCloudProfileDetailsVisibility(bool fVisible); 100 /** Handles command to refresh cloud profiles. */ 101 void sltRefreshCloudProfiles(); 106 102 /** @} */ 107 103 … … 141 137 /** @name Loading stuff. 142 138 * @{ */ 143 /** Loads host networks. */144 void load HostNetworks();139 /** Loads cloud profiles. */ 140 void loadCloudProfiles(); 145 141 /** Loads host @a comInterface data to passed @a data container. */ 146 void load HostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork&data);142 void loadCloudProfile(const CCloudProfile &comInterface, UIDataCloudProfile &data); 147 143 /** @} */ 148 144 … … 150 146 * @{ */ 151 147 /** Creates a new tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 152 void createItemFor NetworkHost(const UIDataHostNetwork&data, bool fChooseItem);148 void createItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem); 153 149 /** Updates the passed tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 154 void updateItemFor NetworkHost(const UIDataHostNetwork &data, bool fChooseItem, UIItemHostNetwork*pItem);150 void updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem); 155 151 /** @} */ 156 152 … … 176 172 QITreeWidget *m_pTreeWidget; 177 173 /** Holds the details-widget instance. */ 178 UI HostNetworkDetailsWidget *m_pDetailsWidget;174 UICloudProfileDetailsWidget *m_pDetailsWidget; 179 175 /** @} */ 180 176 }; 181 177 182 178 183 /** QIManagerDialogFactory extension used as a factory for Host NetworkManager dialog. */184 class UI HostNetworkManagerFactory : public QIManagerDialogFactory179 /** QIManagerDialogFactory extension used as a factory for Cloud Profile Manager dialog. */ 180 class UICloudProfileManagerFactory : public QIManagerDialogFactory 185 181 { 186 182 public: 187 183 188 /** Constructs MediaManager factory acquiring additional arguments.184 /** Constructs Cloud Profile Manager factory acquiring additional arguments. 189 185 * @param pActionPool Brings the action-pool reference. */ 190 UI HostNetworkManagerFactory(UIActionPool *pActionPool = 0);186 UICloudProfileManagerFactory(UIActionPool *pActionPool = 0); 191 187 192 188 protected: … … 201 197 202 198 203 /** QIManagerDialog extension providing GUI with the dialog to control host networkrelated functionality. */204 class UI HostNetworkManager : public QIWithRetranslateUI<QIManagerDialog>199 /** QIManagerDialog extension providing GUI with the dialog to control cloud profile related functionality. */ 200 class UICloudProfileManager : public QIWithRetranslateUI<QIManagerDialog> 205 201 { 206 202 Q_OBJECT; … … 223 219 private: 224 220 225 /** Constructs Host NetworkManager dialog.221 /** Constructs Cloud Profile Manager dialog. 226 222 * @param pCenterWidget Brings the widget reference to center according to. 227 223 * @param pActionPool Brings the action-pool reference. */ 228 UI HostNetworkManager(QWidget *pCenterWidget, UIActionPool *pActionPool);224 UICloudProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool); 229 225 230 226 /** @name Event-handling stuff. … … 249 245 * @{ */ 250 246 /** Returns the widget. */ 251 virtual UI HostNetworkManagerWidget *widget() /* override */;247 virtual UICloudProfileManagerWidget *widget() /* override */; 252 248 /** @} */ 253 249 … … 259 255 260 256 /** Allow factory access to private/protected members: */ 261 friend class UI HostNetworkManagerFactory;257 friend class UICloudProfileManagerFactory; 262 258 }; 263 259 264 #endif /* !___UIHostNetworkManager_h___ */ 265 260 #endif /* !___UICloudProfileManager_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.

