[26714] | 1 | /* $Id: UIDetailsWidgetHostNetwork.cpp 104223 2024-04-08 10:30:04Z vboxsync $ */
|
---|
[25177] | 2 | /** @file
|
---|
[87219] | 3 | * VBox Qt GUI - UIDetailsWidgetHostNetwork class implementation.
|
---|
[25177] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
[25177] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[25177] | 26 | */
|
---|
| 27 |
|
---|
[48458] | 28 | /* Qt includes: */
|
---|
[76606] | 29 | #include <QCheckBox>
|
---|
| 30 | #include <QLabel>
|
---|
| 31 | #include <QPushButton>
|
---|
| 32 | #include <QRadioButton>
|
---|
| 33 | #include <QStyleOption>
|
---|
| 34 | #include <QVBoxLayout>
|
---|
[34162] | 35 |
|
---|
[48458] | 36 | /* GUI includes: */
|
---|
[76606] | 37 | #include "QIDialogButtonBox.h"
|
---|
| 38 | #include "QILineEdit.h"
|
---|
| 39 | #include "QITabWidget.h"
|
---|
| 40 | #include "UIIconPool.h"
|
---|
[87219] | 41 | #include "UIDetailsWidgetHostNetwork.h"
|
---|
[87306] | 42 | #include "UIMessageCenter.h"
|
---|
[95913] | 43 | #include "UINetworkManager.h"
|
---|
[86997] | 44 | #include "UINetworkManagerUtils.h"
|
---|
[91142] | 45 | #include "UINotificationCenter.h"
|
---|
[104223] | 46 | #include "UITranslationEventListener.h"
|
---|
[25177] | 47 |
|
---|
[103712] | 48 | /* Other VBox includes: */
|
---|
| 49 | #ifndef VBOX_WS_MAC
|
---|
| 50 | # include "iprt/cidr.h"
|
---|
| 51 | #endif
|
---|
[66761] | 52 |
|
---|
[103712] | 53 |
|
---|
[87219] | 54 | UIDetailsWidgetHostNetwork::UIDetailsWidgetHostNetwork(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)
|
---|
[104223] | 55 | : QWidget(pParent)
|
---|
[67575] | 56 | , m_enmEmbedding(enmEmbedding)
|
---|
[92821] | 57 | #ifdef VBOX_WS_MAC
|
---|
| 58 | , m_pLabelName(0)
|
---|
| 59 | , m_pEditorName(0)
|
---|
| 60 | , m_pLabelMask(0)
|
---|
| 61 | , m_pEditorMask(0)
|
---|
| 62 | , m_pLabelLBnd(0)
|
---|
| 63 | , m_pEditorLBnd(0)
|
---|
| 64 | , m_pLabelUBnd(0)
|
---|
| 65 | , m_pEditorUBnd(0)
|
---|
| 66 | , m_pButtonBox(0)
|
---|
| 67 | #else /* !VBOX_WS_MAC */
|
---|
[66724] | 68 | , m_pTabWidget(0)
|
---|
[87306] | 69 | , m_pButtonAutomatic(0)
|
---|
| 70 | , m_pButtonManual(0)
|
---|
| 71 | , m_pLabelIPv4(0), m_pEditorIPv4(0)
|
---|
| 72 | , m_pLabelNMv4(0), m_pEditorNMv4(0)
|
---|
| 73 | , m_pLabelIPv6(0), m_pEditorIPv6(0)
|
---|
| 74 | , m_pLabelNMv6(0), m_pEditorNMv6(0)
|
---|
[67575] | 75 | , m_pButtonBoxInterface(0)
|
---|
[66809] | 76 | , m_pCheckBoxDHCP(0)
|
---|
[87306] | 77 | , m_pLabelDHCPAddress(0), m_pEditorDHCPAddress(0)
|
---|
| 78 | , m_pLabelDHCPMask(0), m_pEditorDHCPMask(0)
|
---|
| 79 | , m_pLabelDHCPLowerAddress(0), m_pEditorDHCPLowerAddress(0)
|
---|
| 80 | , m_pLabelDHCPUpperAddress(0), m_pEditorDHCPUpperAddress(0)
|
---|
[67575] | 81 | , m_pButtonBoxServer(0)
|
---|
[92821] | 82 | #endif /* !VBOX_WS_MAC */
|
---|
[25177] | 83 | {
|
---|
[66681] | 84 | prepare();
|
---|
| 85 | }
|
---|
[25177] | 86 |
|
---|
[92821] | 87 | #ifdef VBOX_WS_MAC
|
---|
| 88 | void UIDetailsWidgetHostNetwork::setData(const UIDataHostNetwork &data,
|
---|
| 89 | const QStringList &busyNames /* = QStringList() */)
|
---|
| 90 | #else /* !VBOX_WS_MAC */
|
---|
[87219] | 91 | void UIDetailsWidgetHostNetwork::setData(const UIDataHostNetwork &data)
|
---|
[92821] | 92 | #endif /* !VBOX_WS_MAC */
|
---|
[66726] | 93 | {
|
---|
[67251] | 94 | /* Cache old/new data: */
|
---|
[66726] | 95 | m_oldData = data;
|
---|
| 96 | m_newData = m_oldData;
|
---|
[92821] | 97 | #ifdef VBOX_WS_MAC
|
---|
| 98 | m_busyNames = busyNames;
|
---|
| 99 | #endif /* VBOX_WS_MAC */
|
---|
[66726] | 100 |
|
---|
[92821] | 101 | #ifdef VBOX_WS_MAC
|
---|
| 102 | /* Load data: */
|
---|
| 103 | loadData();
|
---|
| 104 | #else /* !VBOX_WS_MAC */
|
---|
[66726] | 105 | /* Load 'Interface' data: */
|
---|
| 106 | loadDataForInterface();
|
---|
| 107 | /* Load 'DHCP server' data: */
|
---|
| 108 | loadDataForDHCPServer();
|
---|
[92821] | 109 | #endif /* !VBOX_WS_MAC */
|
---|
[66726] | 110 | }
|
---|
| 111 |
|
---|
[87306] | 112 | bool UIDetailsWidgetHostNetwork::revalidate() const
|
---|
| 113 | {
|
---|
[92821] | 114 | #ifdef VBOX_WS_MAC
|
---|
| 115 | /* Make sure network name isn't empty: */
|
---|
| 116 | if (m_newData.m_strName.isEmpty())
|
---|
| 117 | {
|
---|
| 118 | UINotificationMessage::warnAboutNoNameSpecified(m_oldData.m_strName);
|
---|
| 119 | return false;
|
---|
| 120 | }
|
---|
| 121 | else
|
---|
| 122 | {
|
---|
| 123 | /* Make sure item names are unique: */
|
---|
| 124 | if (m_busyNames.contains(m_newData.m_strName))
|
---|
| 125 | {
|
---|
| 126 | UINotificationMessage::warnAboutNameAlreadyBusy(m_newData.m_strName);
|
---|
| 127 | return false;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /* Make sure mask isn't empty: */
|
---|
| 132 | if (m_newData.m_strMask.isEmpty())
|
---|
| 133 | {
|
---|
| 134 | UINotificationMessage::warnAboutInvalidIPv4Mask(m_newData.m_strMask);
|
---|
| 135 | return false;
|
---|
| 136 | }
|
---|
| 137 | /* Make sure lower bound isn't empty: */
|
---|
| 138 | if (m_newData.m_strLBnd.isEmpty())
|
---|
| 139 | {
|
---|
| 140 | UINotificationMessage::warnAboutInvalidDHCPServerLowerAddress(m_newData.m_strLBnd);
|
---|
| 141 | return false;
|
---|
| 142 | }
|
---|
| 143 | /* Make sure upper bound isn't empty: */
|
---|
| 144 | if (m_newData.m_strUBnd.isEmpty())
|
---|
| 145 | {
|
---|
| 146 | UINotificationMessage::warnAboutInvalidDHCPServerUpperAddress(m_newData.m_strUBnd);
|
---|
| 147 | return false;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | #else /* !VBOX_WS_MAC */
|
---|
| 151 |
|
---|
[87306] | 152 | /* Validate 'Interface' tab content: */
|
---|
| 153 | if ( m_newData.m_interface.m_fDHCPEnabled
|
---|
| 154 | && !m_newData.m_dhcpserver.m_fEnabled)
|
---|
| 155 | {
|
---|
[91142] | 156 | UINotificationMessage::warnAboutDHCPServerIsNotEnabled(m_newData.m_interface.m_strName);
|
---|
[87306] | 157 | return false;
|
---|
| 158 | }
|
---|
| 159 | if ( !m_newData.m_interface.m_fDHCPEnabled
|
---|
| 160 | && !m_newData.m_interface.m_strAddress.trimmed().isEmpty()
|
---|
| 161 | && ( !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strAddress.toUtf8().constData())
|
---|
| 162 | || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strAddress.toUtf8().constData())))
|
---|
| 163 | {
|
---|
[91142] | 164 | UINotificationMessage::warnAboutInvalidIPv4Address(m_newData.m_interface.m_strName);
|
---|
[87306] | 165 | return false;
|
---|
| 166 | }
|
---|
| 167 | if ( !m_newData.m_interface.m_fDHCPEnabled
|
---|
| 168 | && !m_newData.m_interface.m_strMask.trimmed().isEmpty()
|
---|
| 169 | && ( !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strMask.toUtf8().constData())
|
---|
| 170 | || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strMask.toUtf8().constData())))
|
---|
| 171 | {
|
---|
[91142] | 172 | UINotificationMessage::warnAboutInvalidIPv4Mask(m_newData.m_interface.m_strName);
|
---|
[87306] | 173 | return false;
|
---|
| 174 | }
|
---|
| 175 | if ( !m_newData.m_interface.m_fDHCPEnabled
|
---|
| 176 | && m_newData.m_interface.m_fSupportedIPv6
|
---|
| 177 | && !m_newData.m_interface.m_strAddress6.trimmed().isEmpty()
|
---|
| 178 | && ( !RTNetIsIPv6AddrStr(m_newData.m_interface.m_strAddress6.toUtf8().constData())
|
---|
| 179 | || RTNetStrIsIPv6AddrAny(m_newData.m_interface.m_strAddress6.toUtf8().constData())))
|
---|
| 180 | {
|
---|
[91142] | 181 | UINotificationMessage::warnAboutInvalidIPv6Address(m_newData.m_interface.m_strName);
|
---|
[87306] | 182 | return false;
|
---|
| 183 | }
|
---|
| 184 | bool fIsMaskPrefixLengthNumber = false;
|
---|
| 185 | const int iMaskPrefixLength = m_newData.m_interface.m_strPrefixLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber);
|
---|
| 186 | if ( !m_newData.m_interface.m_fDHCPEnabled
|
---|
| 187 | && m_newData.m_interface.m_fSupportedIPv6
|
---|
| 188 | && ( !fIsMaskPrefixLengthNumber
|
---|
| 189 | || iMaskPrefixLength < 0
|
---|
| 190 | || iMaskPrefixLength > 128))
|
---|
| 191 | {
|
---|
[91142] | 192 | UINotificationMessage::warnAboutInvalidIPv6PrefixLength(m_newData.m_interface.m_strName);
|
---|
[87306] | 193 | return false;
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | /* Validate 'DHCP server' tab content: */
|
---|
| 197 | if ( m_newData.m_dhcpserver.m_fEnabled
|
---|
| 198 | && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData())
|
---|
| 199 | || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData())))
|
---|
| 200 | {
|
---|
[91142] | 201 | UINotificationMessage::warnAboutInvalidDHCPServerAddress(m_newData.m_interface.m_strName);
|
---|
[87306] | 202 | return false;
|
---|
| 203 | }
|
---|
| 204 | if ( m_newData.m_dhcpserver.m_fEnabled
|
---|
| 205 | && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strMask.toUtf8().constData())
|
---|
| 206 | || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strMask.toUtf8().constData())))
|
---|
| 207 | {
|
---|
[91142] | 208 | UINotificationMessage::warnAboutInvalidDHCPServerMask(m_newData.m_interface.m_strName);
|
---|
[87306] | 209 | return false;
|
---|
| 210 | }
|
---|
| 211 | if ( m_newData.m_dhcpserver.m_fEnabled
|
---|
| 212 | && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData())
|
---|
| 213 | || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData())))
|
---|
| 214 | {
|
---|
[91142] | 215 | UINotificationMessage::warnAboutInvalidDHCPServerLowerAddress(m_newData.m_interface.m_strName);
|
---|
[87306] | 216 | return false;
|
---|
| 217 | }
|
---|
| 218 | if ( m_newData.m_dhcpserver.m_fEnabled
|
---|
| 219 | && ( !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData())
|
---|
| 220 | || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData())))
|
---|
| 221 | {
|
---|
[91142] | 222 | UINotificationMessage::warnAboutInvalidDHCPServerUpperAddress(m_newData.m_interface.m_strName);
|
---|
[87306] | 223 | return false;
|
---|
| 224 | }
|
---|
[92821] | 225 | #endif /* !VBOX_WS_MAC */
|
---|
[87306] | 226 |
|
---|
| 227 | /* True by default: */
|
---|
| 228 | return true;
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | void UIDetailsWidgetHostNetwork::updateButtonStates()
|
---|
| 232 | {
|
---|
| 233 | // if (m_oldData != m_newData)
|
---|
| 234 | // printf("Interface: %s, %s, %s, %s; DHCP server: %d, %s, %s, %s, %s\n",
|
---|
| 235 | // m_newData.m_interface.m_strAddress.toUtf8().constData(),
|
---|
| 236 | // m_newData.m_interface.m_strMask.toUtf8().constData(),
|
---|
| 237 | // m_newData.m_interface.m_strAddress6.toUtf8().constData(),
|
---|
| 238 | // m_newData.m_interface.m_strPrefixLength6.toUtf8().constData(),
|
---|
| 239 | // (int)m_newData.m_dhcpserver.m_fEnabled,
|
---|
| 240 | // m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(),
|
---|
| 241 | // m_newData.m_dhcpserver.m_strMask.toUtf8().constData(),
|
---|
| 242 | // m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(),
|
---|
| 243 | // m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData());
|
---|
| 244 |
|
---|
[92821] | 245 | #ifdef VBOX_WS_MAC
|
---|
[87306] | 246 | /* Update 'Apply' / 'Reset' button states: */
|
---|
[92821] | 247 | if (m_pButtonBox)
|
---|
| 248 | {
|
---|
| 249 | m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
|
---|
| 250 | m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
|
---|
| 251 | }
|
---|
| 252 | #else /* !VBOX_WS_MAC */
|
---|
| 253 | /* Update 'Apply' / 'Reset' button states: */
|
---|
[87306] | 254 | if (m_pButtonBoxInterface)
|
---|
| 255 | {
|
---|
| 256 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
|
---|
| 257 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
|
---|
| 258 | }
|
---|
| 259 | if (m_pButtonBoxServer)
|
---|
| 260 | {
|
---|
| 261 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
|
---|
| 262 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
|
---|
| 263 | }
|
---|
[92821] | 264 | #endif /* !VBOX_WS_MAC */
|
---|
[87306] | 265 |
|
---|
| 266 | /* Notify listeners as well: */
|
---|
| 267 | emit sigDataChanged(m_oldData != m_newData);
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[104223] | 270 | void UIDetailsWidgetHostNetwork::sltRetranslateUI()
|
---|
[66681] | 271 | {
|
---|
[92821] | 272 | #ifdef VBOX_WS_MAC
|
---|
| 273 | if (m_pLabelName)
|
---|
[95913] | 274 | m_pLabelName->setText(UINetworkManager::tr("&Name:"));
|
---|
[92821] | 275 | if (m_pEditorName)
|
---|
[95913] | 276 | m_pEditorName->setToolTip(UINetworkManager::tr("Holds the name for this network."));
|
---|
[92821] | 277 | if (m_pLabelMask)
|
---|
[95913] | 278 | m_pLabelMask->setText(UINetworkManager::tr("&Mask:"));
|
---|
[92821] | 279 | if (m_pEditorMask)
|
---|
[95913] | 280 | m_pEditorMask->setToolTip(UINetworkManager::tr("Holds the mask for this network."));
|
---|
[92821] | 281 | if (m_pLabelLBnd)
|
---|
[95913] | 282 | m_pLabelLBnd->setText(UINetworkManager::tr("&Lower Bound:"));
|
---|
[92821] | 283 | if (m_pEditorLBnd)
|
---|
[95913] | 284 | m_pEditorLBnd->setToolTip(UINetworkManager::tr("Holds the lower address bound for this network."));
|
---|
[92821] | 285 | if (m_pLabelUBnd)
|
---|
[95913] | 286 | m_pLabelUBnd->setText(UINetworkManager::tr("&Upper Bound:"));
|
---|
[92821] | 287 | if (m_pEditorUBnd)
|
---|
[95913] | 288 | m_pEditorUBnd->setToolTip(UINetworkManager::tr("Holds the upper address bound for this network."));
|
---|
[92821] | 289 | if (m_pButtonBox)
|
---|
| 290 | {
|
---|
[95913] | 291 | m_pButtonBox->button(QDialogButtonBox::Cancel)->setText(UINetworkManager::tr("Reset"));
|
---|
| 292 | m_pButtonBox->button(QDialogButtonBox::Ok)->setText(UINetworkManager::tr("Apply"));
|
---|
[92821] | 293 | m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
|
---|
| 294 | m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
|
---|
[95913] | 295 | m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(UINetworkManager::tr("Reset changes in current network details"));
|
---|
| 296 | m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(UINetworkManager::tr("Apply changes in current network details"));
|
---|
[92821] | 297 | m_pButtonBox->button(QDialogButtonBox::Cancel)->
|
---|
[95913] | 298 | setToolTip(UINetworkManager::tr("Reset Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Cancel)->shortcut().toString()));
|
---|
[92821] | 299 | m_pButtonBox->button(QDialogButtonBox::Ok)->
|
---|
[95913] | 300 | setToolTip(UINetworkManager::tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString()));
|
---|
[92821] | 301 | }
|
---|
| 302 |
|
---|
| 303 | #else /* !VBOX_WS_MAC */
|
---|
| 304 |
|
---|
[66681] | 305 | /* Translate tab-widget: */
|
---|
[87268] | 306 | if (m_pTabWidget)
|
---|
| 307 | {
|
---|
[95913] | 308 | m_pTabWidget->setTabText(0, UINetworkManager::tr("&Adapter"));
|
---|
| 309 | m_pTabWidget->setTabText(1, UINetworkManager::tr("&DHCP Server"));
|
---|
[87268] | 310 | }
|
---|
[25177] | 311 |
|
---|
[66681] | 312 | /* Translate 'Interface' tab content: */
|
---|
[87268] | 313 | if (m_pButtonAutomatic)
|
---|
[95913] | 314 | m_pButtonAutomatic->setText(UINetworkManager::tr("Configure Adapter &Automatically"));
|
---|
[87268] | 315 | if (m_pButtonManual)
|
---|
[95913] | 316 | m_pButtonManual->setText(UINetworkManager::tr("Configure Adapter &Manually"));
|
---|
[87268] | 317 | if (m_pLabelIPv4)
|
---|
[95913] | 318 | m_pLabelIPv4->setText(UINetworkManager::tr("&IPv4 Address:"));
|
---|
[87268] | 319 | if (m_pEditorIPv4)
|
---|
[95913] | 320 | m_pEditorIPv4->setToolTip(UINetworkManager::tr("Holds the host IPv4 address for this adapter."));
|
---|
[87268] | 321 | if (m_pLabelNMv4)
|
---|
[95913] | 322 | m_pLabelNMv4->setText(UINetworkManager::tr("IPv4 Network &Mask:"));
|
---|
[87268] | 323 | if (m_pEditorNMv4)
|
---|
[95913] | 324 | m_pEditorNMv4->setToolTip(UINetworkManager::tr("Holds the host IPv4 network mask for this adapter."));
|
---|
[87268] | 325 | if (m_pLabelIPv6)
|
---|
[95913] | 326 | m_pLabelIPv6->setText(UINetworkManager::tr("I&Pv6 Address:"));
|
---|
[87268] | 327 | if (m_pEditorIPv6)
|
---|
[95913] | 328 | m_pEditorIPv6->setToolTip(UINetworkManager::tr("Holds the host IPv6 address for this adapter if IPv6 is supported."));
|
---|
[87268] | 329 | if (m_pLabelNMv6)
|
---|
[95913] | 330 | m_pLabelNMv6->setText(UINetworkManager::tr("IPv6 Prefix &Length:"));
|
---|
[87268] | 331 | if (m_pEditorNMv6)
|
---|
[95913] | 332 | m_pEditorNMv6->setToolTip(UINetworkManager::tr("Holds the host IPv6 prefix length for this adapter if IPv6 is supported."));
|
---|
[67575] | 333 | if (m_pButtonBoxInterface)
|
---|
| 334 | {
|
---|
[95913] | 335 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setText(UINetworkManager::tr("Reset"));
|
---|
| 336 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setText(UINetworkManager::tr("Apply"));
|
---|
[67582] | 337 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
|
---|
| 338 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
|
---|
[95913] | 339 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setStatusTip(UINetworkManager::tr("Reset changes in current interface details"));
|
---|
| 340 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setStatusTip(UINetworkManager::tr("Apply changes in current interface details"));
|
---|
[67582] | 341 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->
|
---|
[95913] | 342 | setToolTip(UINetworkManager::tr("Reset Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->shortcut().toString()));
|
---|
[67582] | 343 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->
|
---|
[95913] | 344 | setToolTip(UINetworkManager::tr("Apply Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->shortcut().toString()));
|
---|
[67575] | 345 | }
|
---|
[25177] | 346 |
|
---|
[66681] | 347 | /* Translate 'DHCP server' tab content: */
|
---|
[87268] | 348 | if (m_pCheckBoxDHCP)
|
---|
| 349 | {
|
---|
[95913] | 350 | m_pCheckBoxDHCP->setText(UINetworkManager::tr("&Enable Server"));
|
---|
| 351 | m_pCheckBoxDHCP->setToolTip(UINetworkManager::tr("When checked, the DHCP Server will be enabled for this network on machine start-up."));
|
---|
[87268] | 352 | }
|
---|
| 353 | if (m_pLabelDHCPAddress)
|
---|
[95913] | 354 | m_pLabelDHCPAddress->setText(UINetworkManager::tr("Server Add&ress:"));
|
---|
[87268] | 355 | if (m_pEditorDHCPAddress)
|
---|
[95913] | 356 | m_pEditorDHCPAddress->setToolTip(UINetworkManager::tr("Holds the address of the DHCP server servicing the network associated with this host-only adapter."));
|
---|
[87268] | 357 | if (m_pLabelDHCPMask)
|
---|
[95913] | 358 | m_pLabelDHCPMask->setText(UINetworkManager::tr("Server &Mask:"));
|
---|
[87268] | 359 | if (m_pEditorDHCPMask)
|
---|
[95913] | 360 | m_pEditorDHCPMask->setToolTip(UINetworkManager::tr("Holds the network mask of the DHCP server servicing the network associated with this host-only adapter."));
|
---|
[87268] | 361 | if (m_pLabelDHCPLowerAddress)
|
---|
[95913] | 362 | m_pLabelDHCPLowerAddress->setText(UINetworkManager::tr("&Lower Address Bound:"));
|
---|
[87268] | 363 | if (m_pEditorDHCPLowerAddress)
|
---|
[95913] | 364 | m_pEditorDHCPLowerAddress->setToolTip(UINetworkManager::tr("Holds the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
|
---|
[87268] | 365 | if (m_pLabelDHCPUpperAddress)
|
---|
[95913] | 366 | m_pLabelDHCPUpperAddress->setText(UINetworkManager::tr("&Upper Address Bound:"));
|
---|
[87268] | 367 | if (m_pEditorDHCPUpperAddress)
|
---|
[95913] | 368 | m_pEditorDHCPUpperAddress->setToolTip(UINetworkManager::tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
|
---|
[67575] | 369 | if (m_pButtonBoxServer)
|
---|
| 370 | {
|
---|
[95913] | 371 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setText(UINetworkManager::tr("Reset"));
|
---|
| 372 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setText(UINetworkManager::tr("Apply"));
|
---|
[67582] | 373 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
|
---|
| 374 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
|
---|
[95913] | 375 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setStatusTip(UINetworkManager::tr("Reset changes in current DHCP server details"));
|
---|
| 376 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setStatusTip(UINetworkManager::tr("Apply changes in current DHCP server details"));
|
---|
[67582] | 377 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->
|
---|
[95913] | 378 | setToolTip(UINetworkManager::tr("Reset Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->shortcut().toString()));
|
---|
[67582] | 379 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->
|
---|
[95913] | 380 | setToolTip(UINetworkManager::tr("Apply Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Ok)->shortcut().toString()));
|
---|
[67575] | 381 | }
|
---|
[92821] | 382 | #endif /* !VBOX_WS_MAC */
|
---|
[66681] | 383 | }
|
---|
[25177] | 384 |
|
---|
[92821] | 385 | #ifdef VBOX_WS_MAC
|
---|
| 386 | void UIDetailsWidgetHostNetwork::sltTextChangedName(const QString &strText)
|
---|
| 387 | {
|
---|
| 388 | m_newData.m_strName = strText;
|
---|
| 389 | updateButtonStates();
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 | void UIDetailsWidgetHostNetwork::sltTextChangedMask(const QString &strText)
|
---|
| 393 | {
|
---|
| 394 | m_newData.m_strMask = strText;
|
---|
| 395 | updateButtonStates();
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | void UIDetailsWidgetHostNetwork::sltTextChangedLBnd(const QString &strText)
|
---|
| 399 | {
|
---|
| 400 | m_newData.m_strLBnd = strText;
|
---|
| 401 | updateButtonStates();
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | void UIDetailsWidgetHostNetwork::sltTextChangedUBnd(const QString &strText)
|
---|
| 405 | {
|
---|
| 406 | m_newData.m_strUBnd = strText;
|
---|
| 407 | updateButtonStates();
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | #else /* !VBOX_WS_MAC */
|
---|
| 411 |
|
---|
[87219] | 412 | void UIDetailsWidgetHostNetwork::sltToggledButtonAutomatic(bool fChecked)
|
---|
[66809] | 413 | {
|
---|
| 414 | m_newData.m_interface.m_fDHCPEnabled = fChecked;
|
---|
| 415 | loadDataForInterface();
|
---|
[67575] | 416 | updateButtonStates();
|
---|
[66809] | 417 | }
|
---|
| 418 |
|
---|
[87219] | 419 | void UIDetailsWidgetHostNetwork::sltToggledButtonManual(bool fChecked)
|
---|
[66809] | 420 | {
|
---|
| 421 | m_newData.m_interface.m_fDHCPEnabled = !fChecked;
|
---|
| 422 | loadDataForInterface();
|
---|
[67575] | 423 | updateButtonStates();
|
---|
[66809] | 424 | }
|
---|
| 425 |
|
---|
[87219] | 426 | void UIDetailsWidgetHostNetwork::sltTextChangedIPv4(const QString &strText)
|
---|
[66809] | 427 | {
|
---|
| 428 | m_newData.m_interface.m_strAddress = strText;
|
---|
[67575] | 429 | updateButtonStates();
|
---|
[66809] | 430 | }
|
---|
| 431 |
|
---|
[87219] | 432 | void UIDetailsWidgetHostNetwork::sltTextChangedNMv4(const QString &strText)
|
---|
[66809] | 433 | {
|
---|
| 434 | m_newData.m_interface.m_strMask = strText;
|
---|
[67575] | 435 | updateButtonStates();
|
---|
[66809] | 436 | }
|
---|
| 437 |
|
---|
[87219] | 438 | void UIDetailsWidgetHostNetwork::sltTextChangedIPv6(const QString &strText)
|
---|
[66809] | 439 | {
|
---|
| 440 | m_newData.m_interface.m_strAddress6 = strText;
|
---|
[67575] | 441 | updateButtonStates();
|
---|
[66809] | 442 | }
|
---|
| 443 |
|
---|
[87219] | 444 | void UIDetailsWidgetHostNetwork::sltTextChangedNMv6(const QString &strText)
|
---|
[66809] | 445 | {
|
---|
[67452] | 446 | m_newData.m_interface.m_strPrefixLength6 = strText;
|
---|
[67575] | 447 | updateButtonStates();
|
---|
[66809] | 448 | }
|
---|
| 449 |
|
---|
[87219] | 450 | void UIDetailsWidgetHostNetwork::sltStatusChangedServer(int iChecked)
|
---|
[66809] | 451 | {
|
---|
| 452 | m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked;
|
---|
| 453 | loadDataForDHCPServer();
|
---|
[67575] | 454 | updateButtonStates();
|
---|
[66809] | 455 | }
|
---|
| 456 |
|
---|
[87219] | 457 | void UIDetailsWidgetHostNetwork::sltTextChangedAddress(const QString &strText)
|
---|
[66809] | 458 | {
|
---|
| 459 | m_newData.m_dhcpserver.m_strAddress = strText;
|
---|
[67575] | 460 | updateButtonStates();
|
---|
[66809] | 461 | }
|
---|
| 462 |
|
---|
[87219] | 463 | void UIDetailsWidgetHostNetwork::sltTextChangedMask(const QString &strText)
|
---|
[66809] | 464 | {
|
---|
| 465 | m_newData.m_dhcpserver.m_strMask = strText;
|
---|
[67575] | 466 | updateButtonStates();
|
---|
[66809] | 467 | }
|
---|
| 468 |
|
---|
[87219] | 469 | void UIDetailsWidgetHostNetwork::sltTextChangedLowerAddress(const QString &strText)
|
---|
[66809] | 470 | {
|
---|
| 471 | m_newData.m_dhcpserver.m_strLowerAddress = strText;
|
---|
[67575] | 472 | updateButtonStates();
|
---|
[66809] | 473 | }
|
---|
| 474 |
|
---|
[87219] | 475 | void UIDetailsWidgetHostNetwork::sltTextChangedUpperAddress(const QString &strText)
|
---|
[66809] | 476 | {
|
---|
| 477 | m_newData.m_dhcpserver.m_strUpperAddress = strText;
|
---|
[67575] | 478 | updateButtonStates();
|
---|
[66809] | 479 | }
|
---|
[92821] | 480 | #endif /* !VBOX_WS_MAC */
|
---|
[66809] | 481 |
|
---|
[87219] | 482 | void UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton)
|
---|
[67575] | 483 | {
|
---|
[92821] | 484 | #ifdef VBOX_WS_MAC
|
---|
| 485 | /* Make sure button-box exists: */
|
---|
| 486 | if (!m_pButtonBox)
|
---|
| 487 | return;
|
---|
| 488 |
|
---|
| 489 | /* Disable buttons first of all: */
|
---|
| 490 | m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
---|
| 491 | m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
| 492 |
|
---|
| 493 | /* Compare with known buttons: */
|
---|
| 494 | if ( pButton == m_pButtonBox->button(QDialogButtonBox::Cancel))
|
---|
| 495 | emit sigDataChangeRejected();
|
---|
| 496 | else
|
---|
| 497 | if ( pButton == m_pButtonBox->button(QDialogButtonBox::Ok))
|
---|
| 498 | emit sigDataChangeAccepted();
|
---|
| 499 |
|
---|
| 500 | #else /* !VBOX_WS_MAC */
|
---|
| 501 |
|
---|
[87268] | 502 | /* Make sure button-boxes exist: */
|
---|
| 503 | if (!m_pButtonBoxInterface || !m_pButtonBoxServer)
|
---|
| 504 | return;
|
---|
[67811] | 505 |
|
---|
[67575] | 506 | /* Disable buttons first of all: */
|
---|
[67811] | 507 | m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
---|
| 508 | m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
| 509 | m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
---|
| 510 | m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
[67575] | 511 |
|
---|
| 512 | /* Compare with known buttons: */
|
---|
[67811] | 513 | if ( pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)
|
---|
| 514 | || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Cancel))
|
---|
[67575] | 515 | emit sigDataChangeRejected();
|
---|
| 516 | else
|
---|
[67811] | 517 | if ( pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Ok)
|
---|
| 518 | || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Ok))
|
---|
[67575] | 519 | emit sigDataChangeAccepted();
|
---|
[92821] | 520 | #endif /* !VBOX_WS_MAC */
|
---|
[67575] | 521 | }
|
---|
| 522 |
|
---|
[87219] | 523 | void UIDetailsWidgetHostNetwork::prepare()
|
---|
[66681] | 524 | {
|
---|
| 525 | /* Prepare this: */
|
---|
| 526 | prepareThis();
|
---|
| 527 |
|
---|
[34162] | 528 | /* Apply language settings: */
|
---|
[104223] | 529 | sltRetranslateUI();
|
---|
[67575] | 530 |
|
---|
[104223] | 531 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 532 | this, &UIDetailsWidgetHostNetwork::sltRetranslateUI);
|
---|
| 533 |
|
---|
[67575] | 534 | /* Update button states finally: */
|
---|
| 535 | updateButtonStates();
|
---|
[66681] | 536 | }
|
---|
[48458] | 537 |
|
---|
[87219] | 538 | void UIDetailsWidgetHostNetwork::prepareThis()
|
---|
[66681] | 539 | {
|
---|
[92821] | 540 | #ifdef VBOX_WS_MAC
|
---|
[66681] | 541 | /* Create layout: */
|
---|
[92821] | 542 | QGridLayout *pLayout = new QGridLayout(this);
|
---|
| 543 | if (pLayout)
|
---|
| 544 | {
|
---|
| 545 | // really macOS only:
|
---|
| 546 | pLayout->setSpacing(10);
|
---|
| 547 | pLayout->setContentsMargins(10, 10, 10, 10);
|
---|
| 548 |
|
---|
| 549 | /* Prepare options: */
|
---|
| 550 | prepareOptions();
|
---|
| 551 | }
|
---|
| 552 |
|
---|
| 553 | #else /* !VBOX_WS_MAC */
|
---|
| 554 |
|
---|
| 555 | /* Create layout: */
|
---|
[87269] | 556 | new QVBoxLayout(this);
|
---|
| 557 | if (layout())
|
---|
[66681] | 558 | {
|
---|
[66726] | 559 | /* Configure layout: */
|
---|
[87269] | 560 | layout()->setContentsMargins(0, 0, 0, 0);
|
---|
[67811] | 561 |
|
---|
[66681] | 562 | /* Prepare tab-widget: */
|
---|
| 563 | prepareTabWidget();
|
---|
| 564 | }
|
---|
[92821] | 565 | #endif /* !VBOX_WS_MAC */
|
---|
[25177] | 566 | }
|
---|
| 567 |
|
---|
[92821] | 568 | #ifdef VBOX_WS_MAC
|
---|
| 569 | void UIDetailsWidgetHostNetwork::prepareOptions()
|
---|
| 570 | {
|
---|
| 571 | /* Acquire layout: */
|
---|
| 572 | QGridLayout *pLayout = static_cast<QGridLayout*>(layout());
|
---|
| 573 | if (pLayout)
|
---|
| 574 | {
|
---|
| 575 | /* Prepare name label: */
|
---|
| 576 | m_pLabelName = new QLabel(this);
|
---|
| 577 | if (m_pLabelName)
|
---|
| 578 | {
|
---|
| 579 | m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
| 580 | pLayout->addWidget(m_pLabelName, 0, 0);
|
---|
| 581 | }
|
---|
| 582 | /* Prepare name editor: */
|
---|
| 583 | m_pEditorName = new QILineEdit(this);
|
---|
| 584 | if (m_pEditorName)
|
---|
| 585 | {
|
---|
| 586 | m_pLabelName->setBuddy(m_pEditorName);
|
---|
| 587 | connect(m_pEditorName, &QLineEdit::textChanged,
|
---|
| 588 | this, &UIDetailsWidgetHostNetwork::sltTextChangedName);
|
---|
| 589 |
|
---|
| 590 | pLayout->addWidget(m_pEditorName, 0, 1);
|
---|
| 591 | }
|
---|
| 592 |
|
---|
| 593 | /* Prepare mask label: */
|
---|
| 594 | m_pLabelMask = new QLabel(this);
|
---|
| 595 | if (m_pLabelMask)
|
---|
| 596 | {
|
---|
| 597 | m_pLabelMask->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
| 598 | pLayout->addWidget(m_pLabelMask, 1, 0);
|
---|
| 599 | }
|
---|
| 600 | /* Prepare mask editor: */
|
---|
| 601 | m_pEditorMask = new QILineEdit(this);
|
---|
| 602 | if (m_pEditorMask)
|
---|
| 603 | {
|
---|
| 604 | m_pLabelMask->setBuddy(m_pEditorMask);
|
---|
| 605 | connect(m_pEditorMask, &QLineEdit::textChanged,
|
---|
| 606 | this, &UIDetailsWidgetHostNetwork::sltTextChangedMask);
|
---|
| 607 |
|
---|
| 608 | pLayout->addWidget(m_pEditorMask, 1, 1);
|
---|
| 609 | }
|
---|
| 610 |
|
---|
| 611 | /* Prepare lower bound label: */
|
---|
| 612 | m_pLabelLBnd = new QLabel(this);
|
---|
| 613 | if (m_pLabelLBnd)
|
---|
| 614 | {
|
---|
| 615 | m_pLabelLBnd->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
| 616 | pLayout->addWidget(m_pLabelLBnd, 2, 0);
|
---|
| 617 | }
|
---|
| 618 | /* Prepare lower bound editor: */
|
---|
| 619 | m_pEditorLBnd = new QILineEdit(this);
|
---|
| 620 | if (m_pEditorLBnd)
|
---|
| 621 | {
|
---|
| 622 | m_pLabelLBnd->setBuddy(m_pEditorLBnd);
|
---|
| 623 | connect(m_pEditorLBnd, &QLineEdit::textChanged,
|
---|
| 624 | this, &UIDetailsWidgetHostNetwork::sltTextChangedLBnd);
|
---|
| 625 |
|
---|
| 626 | pLayout->addWidget(m_pEditorLBnd, 2, 1);
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 | /* Prepare upper bound label: */
|
---|
| 630 | m_pLabelUBnd = new QLabel(this);
|
---|
| 631 | if (m_pLabelUBnd)
|
---|
| 632 | {
|
---|
| 633 | m_pLabelUBnd->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
| 634 | pLayout->addWidget(m_pLabelUBnd, 3, 0);
|
---|
| 635 | }
|
---|
| 636 | /* Prepare upper bound editor: */
|
---|
| 637 | m_pEditorUBnd = new QILineEdit(this);
|
---|
| 638 | if (m_pEditorUBnd)
|
---|
| 639 | {
|
---|
| 640 | m_pLabelUBnd->setBuddy(m_pEditorUBnd);
|
---|
| 641 | connect(m_pEditorUBnd, &QLineEdit::textChanged,
|
---|
| 642 | this, &UIDetailsWidgetHostNetwork::sltTextChangedUBnd);
|
---|
| 643 |
|
---|
| 644 | pLayout->addWidget(m_pEditorUBnd, 3, 1);
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 | /* If parent embedded into stack: */
|
---|
| 648 | if (m_enmEmbedding == EmbedTo_Stack)
|
---|
| 649 | {
|
---|
| 650 | /* Prepare button-box: */
|
---|
| 651 | m_pButtonBox = new QIDialogButtonBox(this);
|
---|
| 652 | if (m_pButtonBox)
|
---|
| 653 | {
|
---|
| 654 | m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
---|
| 655 | connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
|
---|
| 656 |
|
---|
| 657 | pLayout->addWidget(m_pButtonBox, 4, 0, 1, 2);
|
---|
| 658 | }
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | #else /* !VBOX_WS_MAC */
|
---|
| 664 |
|
---|
[87219] | 665 | void UIDetailsWidgetHostNetwork::prepareTabWidget()
|
---|
[25177] | 666 | {
|
---|
[66681] | 667 | /* Create tab-widget: */
|
---|
[87269] | 668 | m_pTabWidget = new QITabWidget(this);
|
---|
[87268] | 669 | if (m_pTabWidget)
|
---|
[66681] | 670 | {
|
---|
| 671 | /* Prepare 'Interface' tab: */
|
---|
| 672 | prepareTabInterface();
|
---|
| 673 | /* Prepare 'DHCP server' tab: */
|
---|
| 674 | prepareTabDHCPServer();
|
---|
[67811] | 675 |
|
---|
[66681] | 676 | /* Add into layout: */
|
---|
| 677 | layout()->addWidget(m_pTabWidget);
|
---|
| 678 | }
|
---|
[48458] | 679 | }
|
---|
[25177] | 680 |
|
---|
[87219] | 681 | void UIDetailsWidgetHostNetwork::prepareTabInterface()
|
---|
[48458] | 682 | {
|
---|
[87269] | 683 | /* Prepare 'Interface' tab: */
|
---|
| 684 | QWidget *pTabInterface = new QWidget(m_pTabWidget);
|
---|
[87268] | 685 | if (pTabInterface)
|
---|
[66681] | 686 | {
|
---|
[87269] | 687 | /* Prepare 'Interface' layout: */
|
---|
[66681] | 688 | QGridLayout *pLayoutInterface = new QGridLayout(pTabInterface);
|
---|
[87268] | 689 | if (pLayoutInterface)
|
---|
[66681] | 690 | {
|
---|
[66724] | 691 | #ifdef VBOX_WS_MAC
|
---|
[68003] | 692 | pLayoutInterface->setSpacing(10);
|
---|
[66724] | 693 | pLayoutInterface->setContentsMargins(10, 10, 10, 10);
|
---|
| 694 | #endif
|
---|
[66809] | 695 |
|
---|
[87269] | 696 | /* Prepare automatic interface configuration layout: */
|
---|
[66809] | 697 | QHBoxLayout *pLayoutAutomatic = new QHBoxLayout;
|
---|
[87268] | 698 | if (pLayoutAutomatic)
|
---|
[66781] | 699 | {
|
---|
[66809] | 700 | pLayoutAutomatic->setContentsMargins(0, 0, 0, 0);
|
---|
[67127] | 701 |
|
---|
[87269] | 702 | /* Prepare automatic interface configuration radio-button: */
|
---|
| 703 | m_pButtonAutomatic = new QRadioButton(pTabInterface);
|
---|
[87268] | 704 | if (m_pButtonAutomatic)
|
---|
[66809] | 705 | {
|
---|
| 706 | connect(m_pButtonAutomatic, &QRadioButton::toggled,
|
---|
[87219] | 707 | this, &UIDetailsWidgetHostNetwork::sltToggledButtonAutomatic);
|
---|
[66809] | 708 | pLayoutAutomatic->addWidget(m_pButtonAutomatic);
|
---|
| 709 | }
|
---|
[87269] | 710 |
|
---|
[66809] | 711 | pLayoutInterface->addLayout(pLayoutAutomatic, 0, 0, 1, 3);
|
---|
[66914] | 712 | #ifdef VBOX_WS_MAC
|
---|
| 713 | pLayoutInterface->setRowMinimumHeight(0, 22);
|
---|
| 714 | #endif
|
---|
[66781] | 715 | }
|
---|
[66809] | 716 |
|
---|
[87269] | 717 | /* Prepare manual interface configuration layout: */
|
---|
[66910] | 718 | QHBoxLayout *pLayoutManual = new QHBoxLayout;
|
---|
[87268] | 719 | if (pLayoutManual)
|
---|
[66781] | 720 | {
|
---|
[66910] | 721 | pLayoutManual->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 722 |
|
---|
| 723 | /* Prepare manual interface configuration radio-button: */
|
---|
| 724 | m_pButtonManual = new QRadioButton(pTabInterface);
|
---|
[87268] | 725 | if (m_pButtonManual)
|
---|
[66910] | 726 | {
|
---|
| 727 | connect(m_pButtonManual, &QRadioButton::toggled,
|
---|
[87219] | 728 | this, &UIDetailsWidgetHostNetwork::sltToggledButtonManual);
|
---|
[66910] | 729 | pLayoutManual->addWidget(m_pButtonManual);
|
---|
| 730 | }
|
---|
[87269] | 731 |
|
---|
[66910] | 732 | pLayoutInterface->addLayout(pLayoutManual, 1, 0, 1, 3);
|
---|
[66914] | 733 | #ifdef VBOX_WS_MAC
|
---|
| 734 | pLayoutInterface->setRowMinimumHeight(1, 22);
|
---|
| 735 | #endif
|
---|
[66781] | 736 | }
|
---|
[66809] | 737 |
|
---|
[87269] | 738 | /* Prepare IPv4 address label: */
|
---|
| 739 | m_pLabelIPv4 = new QLabel(pTabInterface);
|
---|
[87268] | 740 | if (m_pLabelIPv4)
|
---|
[66681] | 741 | {
|
---|
[92811] | 742 | m_pLabelIPv4->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66781] | 743 | pLayoutInterface->addWidget(m_pLabelIPv4, 2, 1);
|
---|
[66681] | 744 | }
|
---|
[87269] | 745 | /* Prepare IPv4 layout: */
|
---|
[66809] | 746 | QHBoxLayout *pLayoutIPv4 = new QHBoxLayout;
|
---|
[87268] | 747 | if (pLayoutIPv4)
|
---|
[66681] | 748 | {
|
---|
[66809] | 749 | pLayoutIPv4->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 750 |
|
---|
| 751 | /* Prepare IPv4 address editor: */
|
---|
| 752 | m_pEditorIPv4 = new QILineEdit(pTabInterface);
|
---|
[87268] | 753 | if (m_pEditorIPv4)
|
---|
[66809] | 754 | {
|
---|
| 755 | m_pLabelIPv4->setBuddy(m_pEditorIPv4);
|
---|
| 756 | connect(m_pEditorIPv4, &QLineEdit::textChanged,
|
---|
[87219] | 757 | this, &UIDetailsWidgetHostNetwork::sltTextChangedIPv4);
|
---|
[87269] | 758 |
|
---|
[66809] | 759 | pLayoutIPv4->addWidget(m_pEditorIPv4);
|
---|
| 760 | }
|
---|
[87269] | 761 |
|
---|
[66809] | 762 | pLayoutInterface->addLayout(pLayoutIPv4, 2, 2);
|
---|
[66681] | 763 | }
|
---|
[66809] | 764 |
|
---|
[87269] | 765 | /* Prepare NMv4 network mask label: */
|
---|
| 766 | m_pLabelNMv4 = new QLabel(pTabInterface);
|
---|
[87268] | 767 | if (m_pLabelNMv4)
|
---|
[66681] | 768 | {
|
---|
[92811] | 769 | m_pLabelNMv4->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66781] | 770 | pLayoutInterface->addWidget(m_pLabelNMv4, 3, 1);
|
---|
[66681] | 771 | }
|
---|
[87269] | 772 | /* Prepare NMv4 layout: */
|
---|
[66809] | 773 | QHBoxLayout *pLayoutNMv4 = new QHBoxLayout;
|
---|
[87268] | 774 | if (pLayoutNMv4)
|
---|
[66681] | 775 | {
|
---|
[66809] | 776 | pLayoutNMv4->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 777 |
|
---|
| 778 | /* Prepare NMv4 network mask editor: */
|
---|
| 779 | m_pEditorNMv4 = new QILineEdit(pTabInterface);
|
---|
[87268] | 780 | if (m_pEditorNMv4)
|
---|
[66809] | 781 | {
|
---|
| 782 | m_pLabelNMv4->setBuddy(m_pEditorNMv4);
|
---|
| 783 | connect(m_pEditorNMv4, &QLineEdit::textChanged,
|
---|
[87219] | 784 | this, &UIDetailsWidgetHostNetwork::sltTextChangedNMv4);
|
---|
[87269] | 785 |
|
---|
[66809] | 786 | pLayoutNMv4->addWidget(m_pEditorNMv4);
|
---|
| 787 | }
|
---|
[87269] | 788 |
|
---|
[66809] | 789 | pLayoutInterface->addLayout(pLayoutNMv4, 3, 2);
|
---|
[66681] | 790 | }
|
---|
[66809] | 791 |
|
---|
[87269] | 792 | /* Prepare IPv6 address label: */
|
---|
| 793 | m_pLabelIPv6 = new QLabel(pTabInterface);
|
---|
[87268] | 794 | if (m_pLabelIPv6)
|
---|
[66681] | 795 | {
|
---|
[92811] | 796 | m_pLabelIPv6->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66781] | 797 | pLayoutInterface->addWidget(m_pLabelIPv6, 4, 1);
|
---|
[66681] | 798 | }
|
---|
[87269] | 799 | /* Prepare IPv6 layout: */
|
---|
[66809] | 800 | QHBoxLayout *pLayoutIPv6 = new QHBoxLayout;
|
---|
[87268] | 801 | if (pLayoutIPv6)
|
---|
[66681] | 802 | {
|
---|
[66809] | 803 | pLayoutIPv6->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 804 |
|
---|
| 805 | /* Prepare IPv6 address editor: */
|
---|
| 806 | m_pEditorIPv6 = new QILineEdit(pTabInterface);
|
---|
[87268] | 807 | if (m_pEditorIPv6)
|
---|
[66809] | 808 | {
|
---|
| 809 | m_pLabelIPv6->setBuddy(m_pEditorIPv6);
|
---|
| 810 | connect(m_pEditorIPv6, &QLineEdit::textChanged,
|
---|
[87219] | 811 | this, &UIDetailsWidgetHostNetwork::sltTextChangedIPv6);
|
---|
[87269] | 812 |
|
---|
[66809] | 813 | pLayoutIPv6->addWidget(m_pEditorIPv6);
|
---|
| 814 | }
|
---|
[87269] | 815 |
|
---|
[66809] | 816 | pLayoutInterface->addLayout(pLayoutIPv6, 4, 2);
|
---|
[66681] | 817 | }
|
---|
[66809] | 818 |
|
---|
[87269] | 819 | /* Prepare NMv6 network mask label: */
|
---|
| 820 | m_pLabelNMv6 = new QLabel(pTabInterface);
|
---|
[87268] | 821 | if (m_pLabelNMv6)
|
---|
[66681] | 822 | {
|
---|
[92811] | 823 | m_pLabelNMv6->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66781] | 824 | pLayoutInterface->addWidget(m_pLabelNMv6, 5, 1);
|
---|
[66681] | 825 | }
|
---|
[87269] | 826 | /* Prepare NMv6 layout: */
|
---|
[66809] | 827 | QHBoxLayout *pLayoutNMv6 = new QHBoxLayout;
|
---|
[87268] | 828 | if (pLayoutNMv6)
|
---|
[66681] | 829 | {
|
---|
[66809] | 830 | pLayoutNMv6->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 831 |
|
---|
| 832 | /* Prepare NMv6 network mask editor: */
|
---|
| 833 | m_pEditorNMv6 = new QILineEdit(pTabInterface);
|
---|
[87268] | 834 | if (m_pEditorNMv6)
|
---|
[66809] | 835 | {
|
---|
| 836 | m_pLabelNMv6->setBuddy(m_pEditorNMv6);
|
---|
| 837 | connect(m_pEditorNMv6, &QLineEdit::textChanged,
|
---|
[87219] | 838 | this, &UIDetailsWidgetHostNetwork::sltTextChangedNMv6);
|
---|
[87269] | 839 |
|
---|
[66809] | 840 | pLayoutNMv6->addWidget(m_pEditorNMv6);
|
---|
| 841 | }
|
---|
[87269] | 842 |
|
---|
[66809] | 843 | pLayoutInterface->addLayout(pLayoutNMv6, 5, 2);
|
---|
[66681] | 844 | }
|
---|
[66809] | 845 |
|
---|
[87269] | 846 | /* Prepare indent: */
|
---|
[66781] | 847 | QStyleOption options;
|
---|
| 848 | options.initFrom(m_pButtonManual);
|
---|
| 849 | const int iWidth = m_pButtonManual->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pButtonManual) +
|
---|
| 850 | m_pButtonManual->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pButtonManual) -
|
---|
| 851 | pLayoutInterface->spacing() - 1;
|
---|
| 852 | QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
---|
[87268] | 853 | if (pSpacer1)
|
---|
[66781] | 854 | pLayoutInterface->addItem(pSpacer1, 2, 0, 4);
|
---|
[87269] | 855 | /* Prepare stretch: */
|
---|
[66781] | 856 | QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
---|
[87268] | 857 | if (pSpacer2)
|
---|
[66781] | 858 | pLayoutInterface->addItem(pSpacer2, 6, 0, 1, 3);
|
---|
[67575] | 859 |
|
---|
| 860 | /* If parent embedded into stack: */
|
---|
| 861 | if (m_enmEmbedding == EmbedTo_Stack)
|
---|
| 862 | {
|
---|
[87269] | 863 | /* Prepare button-box: */
|
---|
| 864 | m_pButtonBoxInterface = new QIDialogButtonBox(pTabInterface);
|
---|
[87268] | 865 | if (m_pButtonBoxInterface)
|
---|
| 866 | {
|
---|
| 867 | m_pButtonBoxInterface->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
---|
| 868 | connect(m_pButtonBoxInterface, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
|
---|
[67575] | 869 |
|
---|
[87268] | 870 | pLayoutInterface->addWidget(m_pButtonBoxInterface, 7, 0, 1, 3);
|
---|
| 871 | }
|
---|
[67575] | 872 | }
|
---|
[66681] | 873 | }
|
---|
[87269] | 874 |
|
---|
[66681] | 875 | m_pTabWidget->addTab(pTabInterface, QString());
|
---|
| 876 | }
|
---|
[48458] | 877 | }
|
---|
| 878 |
|
---|
[87219] | 879 | void UIDetailsWidgetHostNetwork::prepareTabDHCPServer()
|
---|
[48458] | 880 | {
|
---|
[87269] | 881 | /* Prepare 'DHCP server' tab: */
|
---|
| 882 | QWidget *pTabDHCPServer = new QWidget(m_pTabWidget);
|
---|
[87268] | 883 | if (pTabDHCPServer)
|
---|
[66681] | 884 | {
|
---|
[87269] | 885 | /* Prepare 'DHCP server' layout: */
|
---|
[66681] | 886 | QGridLayout *pLayoutDHCPServer = new QGridLayout(pTabDHCPServer);
|
---|
[87268] | 887 | if (pLayoutDHCPServer)
|
---|
[66681] | 888 | {
|
---|
[66724] | 889 | #ifdef VBOX_WS_MAC
|
---|
[68003] | 890 | pLayoutDHCPServer->setSpacing(10);
|
---|
[66724] | 891 | pLayoutDHCPServer->setContentsMargins(10, 10, 10, 10);
|
---|
| 892 | #endif
|
---|
[66809] | 893 |
|
---|
[87269] | 894 | /* Prepare DHCP server status check-box: */
|
---|
| 895 | m_pCheckBoxDHCP = new QCheckBox(pTabDHCPServer);
|
---|
[87268] | 896 | if (m_pCheckBoxDHCP)
|
---|
[66681] | 897 | {
|
---|
[66723] | 898 | connect(m_pCheckBoxDHCP, &QCheckBox::stateChanged,
|
---|
[87219] | 899 | this, &UIDetailsWidgetHostNetwork::sltStatusChangedServer);
|
---|
[66724] | 900 | pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2);
|
---|
[66914] | 901 | #ifdef VBOX_WS_MAC
|
---|
| 902 | pLayoutDHCPServer->setRowMinimumHeight(0, 22);
|
---|
| 903 | #endif
|
---|
[66681] | 904 | }
|
---|
[66809] | 905 |
|
---|
[87269] | 906 | /* Prepare DHCP address label: */
|
---|
| 907 | m_pLabelDHCPAddress = new QLabel(pTabDHCPServer);
|
---|
[87268] | 908 | if (m_pLabelDHCPAddress)
|
---|
[66681] | 909 | {
|
---|
[92811] | 910 | m_pLabelDHCPAddress->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66681] | 911 | pLayoutDHCPServer->addWidget(m_pLabelDHCPAddress, 1, 1);
|
---|
| 912 | }
|
---|
[87269] | 913 | /* Prepare DHCP address layout: */
|
---|
[66809] | 914 | QHBoxLayout *pLayoutDHCPAddress = new QHBoxLayout;
|
---|
[87268] | 915 | if (pLayoutDHCPAddress)
|
---|
[66681] | 916 | {
|
---|
[66809] | 917 | pLayoutDHCPAddress->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 918 |
|
---|
| 919 | /* Prepare DHCP address editor: */
|
---|
| 920 | m_pEditorDHCPAddress = new QILineEdit(pTabDHCPServer);
|
---|
[87268] | 921 | if (m_pEditorDHCPAddress)
|
---|
[66809] | 922 | {
|
---|
| 923 | m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress);
|
---|
| 924 | connect(m_pEditorDHCPAddress, &QLineEdit::textChanged,
|
---|
[87219] | 925 | this, &UIDetailsWidgetHostNetwork::sltTextChangedAddress);
|
---|
[87269] | 926 |
|
---|
[66809] | 927 | pLayoutDHCPAddress->addWidget(m_pEditorDHCPAddress);
|
---|
| 928 | }
|
---|
[87269] | 929 |
|
---|
[66809] | 930 | pLayoutDHCPServer->addLayout(pLayoutDHCPAddress, 1, 2);
|
---|
[66681] | 931 | }
|
---|
[66809] | 932 |
|
---|
[87269] | 933 | /* Prepare DHCP network mask label: */
|
---|
| 934 | m_pLabelDHCPMask = new QLabel(pTabDHCPServer);
|
---|
[87268] | 935 | if (m_pLabelDHCPMask)
|
---|
[66681] | 936 | {
|
---|
[92811] | 937 | m_pLabelDHCPMask->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66681] | 938 | pLayoutDHCPServer->addWidget(m_pLabelDHCPMask, 2, 1);
|
---|
| 939 | }
|
---|
[87269] | 940 | /* Prepare DHCP mask layout: */
|
---|
[66809] | 941 | QHBoxLayout *pLayoutDHCPMask = new QHBoxLayout;
|
---|
[87268] | 942 | if (pLayoutDHCPMask)
|
---|
[66681] | 943 | {
|
---|
[66809] | 944 | pLayoutDHCPMask->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 945 |
|
---|
| 946 | /* Prepare DHCP network mask editor: */
|
---|
| 947 | m_pEditorDHCPMask = new QILineEdit(pTabDHCPServer);
|
---|
[87268] | 948 | if (m_pEditorDHCPMask)
|
---|
[66809] | 949 | {
|
---|
| 950 | m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask);
|
---|
| 951 | connect(m_pEditorDHCPMask, &QLineEdit::textChanged,
|
---|
[87219] | 952 | this, &UIDetailsWidgetHostNetwork::sltTextChangedMask);
|
---|
[87269] | 953 |
|
---|
[66809] | 954 | pLayoutDHCPMask->addWidget(m_pEditorDHCPMask);
|
---|
| 955 | }
|
---|
[87269] | 956 |
|
---|
[66809] | 957 | pLayoutDHCPServer->addLayout(pLayoutDHCPMask, 2, 2);
|
---|
[66681] | 958 | }
|
---|
[66809] | 959 |
|
---|
[87269] | 960 | /* Prepare DHCP lower address label: */
|
---|
| 961 | m_pLabelDHCPLowerAddress = new QLabel(pTabDHCPServer);
|
---|
[87268] | 962 | if (m_pLabelDHCPLowerAddress)
|
---|
[66681] | 963 | {
|
---|
[92811] | 964 | m_pLabelDHCPLowerAddress->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66681] | 965 | pLayoutDHCPServer->addWidget(m_pLabelDHCPLowerAddress, 3, 1);
|
---|
| 966 | }
|
---|
[87269] | 967 | /* Prepare DHCP lower address layout: */
|
---|
[66809] | 968 | QHBoxLayout *pLayoutDHCPLowerAddress = new QHBoxLayout;
|
---|
[87268] | 969 | if (pLayoutDHCPLowerAddress)
|
---|
[66681] | 970 | {
|
---|
[66809] | 971 | pLayoutDHCPLowerAddress->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 972 |
|
---|
| 973 | /* Prepare DHCP lower address editor: */
|
---|
| 974 | m_pEditorDHCPLowerAddress = new QILineEdit(pTabDHCPServer);
|
---|
[87268] | 975 | if (m_pEditorDHCPLowerAddress)
|
---|
[66809] | 976 | {
|
---|
| 977 | m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress);
|
---|
| 978 | connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged,
|
---|
[87219] | 979 | this, &UIDetailsWidgetHostNetwork::sltTextChangedLowerAddress);
|
---|
[87269] | 980 |
|
---|
[66809] | 981 | pLayoutDHCPLowerAddress->addWidget(m_pEditorDHCPLowerAddress);
|
---|
| 982 | }
|
---|
[87269] | 983 |
|
---|
[66809] | 984 | pLayoutDHCPServer->addLayout(pLayoutDHCPLowerAddress, 3, 2);
|
---|
[66681] | 985 | }
|
---|
[66809] | 986 |
|
---|
[87269] | 987 | /* Prepare DHCP upper address label: */
|
---|
| 988 | m_pLabelDHCPUpperAddress = new QLabel(pTabDHCPServer);
|
---|
[87268] | 989 | if (m_pLabelDHCPUpperAddress)
|
---|
[66681] | 990 | {
|
---|
[92811] | 991 | m_pLabelDHCPUpperAddress->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
[66681] | 992 | pLayoutDHCPServer->addWidget(m_pLabelDHCPUpperAddress, 4, 1);
|
---|
| 993 | }
|
---|
[87269] | 994 | /* Prepare DHCP upper address layout: */
|
---|
[66809] | 995 | QHBoxLayout *pLayoutDHCPUpperAddress = new QHBoxLayout;
|
---|
[87268] | 996 | if (pLayoutDHCPUpperAddress)
|
---|
[66681] | 997 | {
|
---|
[66809] | 998 | pLayoutDHCPUpperAddress->setContentsMargins(0, 0, 0, 0);
|
---|
[87269] | 999 |
|
---|
| 1000 | /* Prepare DHCP upper address editor: */
|
---|
| 1001 | m_pEditorDHCPUpperAddress = new QILineEdit(pTabDHCPServer);
|
---|
[87268] | 1002 | if (m_pEditorDHCPUpperAddress)
|
---|
[66809] | 1003 | {
|
---|
| 1004 | m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress);
|
---|
| 1005 | connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged,
|
---|
[87219] | 1006 | this, &UIDetailsWidgetHostNetwork::sltTextChangedUpperAddress);
|
---|
[87269] | 1007 |
|
---|
[66809] | 1008 | pLayoutDHCPUpperAddress->addWidget(m_pEditorDHCPUpperAddress);
|
---|
| 1009 | }
|
---|
[87269] | 1010 |
|
---|
[66809] | 1011 | pLayoutDHCPServer->addLayout(pLayoutDHCPUpperAddress, 4, 2);
|
---|
[66681] | 1012 | }
|
---|
[66809] | 1013 |
|
---|
[87269] | 1014 | /* Prepare indent: */
|
---|
[66681] | 1015 | QStyleOption options;
|
---|
| 1016 | options.initFrom(m_pCheckBoxDHCP);
|
---|
[66781] | 1017 | const int iWidth = m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_IndicatorWidth, &options, m_pCheckBoxDHCP) +
|
---|
| 1018 | m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &options, m_pCheckBoxDHCP) -
|
---|
| 1019 | pLayoutDHCPServer->spacing() - 1;
|
---|
| 1020 | QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
---|
[87268] | 1021 | if (pSpacer1)
|
---|
[66781] | 1022 | pLayoutDHCPServer->addItem(pSpacer1, 1, 0, 4);
|
---|
[87269] | 1023 | /* Prepare stretch: */
|
---|
[66781] | 1024 | QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
---|
[87268] | 1025 | if (pSpacer2)
|
---|
[66781] | 1026 | pLayoutDHCPServer->addItem(pSpacer2, 5, 0, 1, 3);
|
---|
[67575] | 1027 |
|
---|
| 1028 | /* If parent embedded into stack: */
|
---|
| 1029 | if (m_enmEmbedding == EmbedTo_Stack)
|
---|
| 1030 | {
|
---|
[87269] | 1031 | /* Prepare button-box: */
|
---|
| 1032 | m_pButtonBoxServer = new QIDialogButtonBox(pTabDHCPServer);
|
---|
[87268] | 1033 | if (m_pButtonBoxServer)
|
---|
| 1034 | {
|
---|
| 1035 | m_pButtonBoxServer->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
---|
| 1036 | connect(m_pButtonBoxServer, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
|
---|
[67575] | 1037 |
|
---|
[87268] | 1038 | pLayoutDHCPServer->addWidget(m_pButtonBoxServer, 6, 0, 1, 3);
|
---|
| 1039 | }
|
---|
[67575] | 1040 | }
|
---|
[66681] | 1041 | }
|
---|
[87269] | 1042 |
|
---|
[66681] | 1043 | m_pTabWidget->addTab(pTabDHCPServer, QString());
|
---|
| 1044 | }
|
---|
| 1045 | }
|
---|
[92821] | 1046 | #endif /* !VBOX_WS_MAC */
|
---|
[25177] | 1047 |
|
---|
[92821] | 1048 | #ifdef VBOX_WS_MAC
|
---|
| 1049 | void UIDetailsWidgetHostNetwork::loadData()
|
---|
| 1050 | {
|
---|
| 1051 | /* Check whether network exists and configurable: */
|
---|
| 1052 | const bool fIsNetworkExists = m_newData.m_fExists;
|
---|
| 1053 |
|
---|
| 1054 | /* Toggle network fields availability: */
|
---|
| 1055 | if (m_pLabelName)
|
---|
| 1056 | m_pLabelName->setEnabled(fIsNetworkExists);
|
---|
| 1057 | if (m_pEditorName)
|
---|
| 1058 | m_pEditorName->setEnabled(fIsNetworkExists);
|
---|
| 1059 | if (m_pLabelMask)
|
---|
| 1060 | m_pLabelMask->setEnabled(fIsNetworkExists);
|
---|
| 1061 | if (m_pEditorMask)
|
---|
| 1062 | m_pEditorMask->setEnabled(fIsNetworkExists);
|
---|
| 1063 | if (m_pLabelLBnd)
|
---|
| 1064 | m_pLabelLBnd->setEnabled(fIsNetworkExists);
|
---|
| 1065 | if (m_pEditorLBnd)
|
---|
| 1066 | m_pEditorLBnd->setEnabled(fIsNetworkExists);
|
---|
| 1067 | if (m_pLabelUBnd)
|
---|
| 1068 | m_pLabelUBnd->setEnabled(fIsNetworkExists);
|
---|
| 1069 | if (m_pEditorUBnd)
|
---|
| 1070 | m_pEditorUBnd->setEnabled(fIsNetworkExists);
|
---|
| 1071 |
|
---|
| 1072 | /* Load network fields: */
|
---|
| 1073 | if (m_pEditorName)
|
---|
| 1074 | m_pEditorName->setText(m_newData.m_strName);
|
---|
| 1075 | if (m_pEditorMask)
|
---|
| 1076 | m_pEditorMask->setText(m_newData.m_strMask);
|
---|
| 1077 | if (m_pEditorLBnd)
|
---|
| 1078 | m_pEditorLBnd->setText(m_newData.m_strLBnd);
|
---|
| 1079 | if (m_pEditorUBnd)
|
---|
| 1080 | m_pEditorUBnd->setText(m_newData.m_strUBnd);
|
---|
| 1081 | }
|
---|
| 1082 |
|
---|
| 1083 | #else /* !VBOX_WS_MAC */
|
---|
| 1084 |
|
---|
[87219] | 1085 | void UIDetailsWidgetHostNetwork::loadDataForInterface()
|
---|
[66681] | 1086 | {
|
---|
[87275] | 1087 | /* Check whether interface exists and configurable: */
|
---|
| 1088 | const bool fIsInterfaceExists = m_newData.m_interface.m_fExists;
|
---|
| 1089 | const bool fIsInterfaceConfigurable = !m_newData.m_interface.m_fDHCPEnabled;
|
---|
| 1090 |
|
---|
| 1091 | /* Toggle radio-buttons availability: */
|
---|
| 1092 | if (m_pButtonAutomatic)
|
---|
| 1093 | m_pButtonAutomatic->setEnabled(fIsInterfaceExists);
|
---|
| 1094 | if (m_pButtonManual)
|
---|
| 1095 | m_pButtonManual->setEnabled(fIsInterfaceExists);
|
---|
| 1096 |
|
---|
[66781] | 1097 | /* Toggle IPv4 & IPv6 interface fields availability: */
|
---|
[87268] | 1098 | if (m_pLabelIPv4)
|
---|
[87275] | 1099 | m_pLabelIPv4->setEnabled(fIsInterfaceExists && fIsInterfaceConfigurable);
|
---|
[87268] | 1100 | if (m_pLabelNMv4)
|
---|
[87275] | 1101 | m_pLabelNMv4->setEnabled(fIsInterfaceExists && fIsInterfaceConfigurable);
|
---|
[87268] | 1102 | if (m_pEditorIPv4)
|
---|
[87275] | 1103 | m_pEditorIPv4->setEnabled(fIsInterfaceExists && fIsInterfaceConfigurable);
|
---|
[87268] | 1104 | if (m_pEditorNMv4)
|
---|
[87275] | 1105 | m_pEditorNMv4->setEnabled(fIsInterfaceExists && fIsInterfaceConfigurable);
|
---|
[66781] | 1106 |
|
---|
[66697] | 1107 | /* Load IPv4 interface fields: */
|
---|
[87268] | 1108 | if (m_pButtonAutomatic)
|
---|
| 1109 | m_pButtonAutomatic->setChecked(!fIsInterfaceConfigurable);
|
---|
| 1110 | if (m_pButtonManual)
|
---|
| 1111 | m_pButtonManual->setChecked(fIsInterfaceConfigurable);
|
---|
| 1112 | if (m_pEditorIPv4)
|
---|
| 1113 | m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress);
|
---|
| 1114 | if (m_pEditorNMv4)
|
---|
| 1115 | m_pEditorNMv4->setText(m_newData.m_interface.m_strMask);
|
---|
[25177] | 1116 |
|
---|
[66697] | 1117 | /* Toggle IPv6 interface fields availability: */
|
---|
[66781] | 1118 | const bool fIsIpv6Configurable = fIsInterfaceConfigurable && m_newData.m_interface.m_fSupportedIPv6;
|
---|
[87268] | 1119 | if (m_pLabelIPv6)
|
---|
[87275] | 1120 | m_pLabelIPv6->setEnabled(fIsInterfaceExists && fIsIpv6Configurable);
|
---|
[87268] | 1121 | if (m_pLabelNMv6)
|
---|
[87275] | 1122 | m_pLabelNMv6->setEnabled(fIsInterfaceExists && fIsIpv6Configurable);
|
---|
[87268] | 1123 | if (m_pEditorIPv6)
|
---|
[87275] | 1124 | m_pEditorIPv6->setEnabled(fIsInterfaceExists && fIsIpv6Configurable);
|
---|
[87268] | 1125 | if (m_pEditorNMv6)
|
---|
[87275] | 1126 | m_pEditorNMv6->setEnabled(fIsInterfaceExists && fIsIpv6Configurable);
|
---|
[66725] | 1127 |
|
---|
| 1128 | /* Load IPv6 interface fields: */
|
---|
[87268] | 1129 | if (m_pEditorIPv6)
|
---|
| 1130 | m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6);
|
---|
| 1131 | if (m_pEditorNMv6)
|
---|
| 1132 | m_pEditorNMv6->setText(m_newData.m_interface.m_strPrefixLength6);
|
---|
[25177] | 1133 | }
|
---|
| 1134 |
|
---|
[87219] | 1135 | void UIDetailsWidgetHostNetwork::loadDataForDHCPServer()
|
---|
[25177] | 1136 | {
|
---|
[87275] | 1137 | /* Check whether interface exists and DHCP server available: */
|
---|
| 1138 | const bool fIsInterfaceExists = m_newData.m_interface.m_fExists;
|
---|
| 1139 | const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled;
|
---|
| 1140 |
|
---|
| 1141 | /* Toggle check-box availability: */
|
---|
| 1142 | m_pCheckBoxDHCP->setEnabled(fIsInterfaceExists);
|
---|
| 1143 |
|
---|
[66697] | 1144 | /* Toggle DHCP server fields availability: */
|
---|
[87268] | 1145 | if (m_pLabelDHCPAddress)
|
---|
[87275] | 1146 | m_pLabelDHCPAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1147 | if (m_pLabelDHCPMask)
|
---|
[87275] | 1148 | m_pLabelDHCPMask->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1149 | if (m_pLabelDHCPLowerAddress)
|
---|
[87275] | 1150 | m_pLabelDHCPLowerAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1151 | if (m_pLabelDHCPUpperAddress)
|
---|
[87275] | 1152 | m_pLabelDHCPUpperAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1153 | if (m_pEditorDHCPAddress)
|
---|
[87275] | 1154 | m_pEditorDHCPAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1155 | if (m_pEditorDHCPMask)
|
---|
[87275] | 1156 | m_pEditorDHCPMask->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1157 | if (m_pEditorDHCPLowerAddress)
|
---|
[87275] | 1158 | m_pEditorDHCPLowerAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[87268] | 1159 | if (m_pEditorDHCPUpperAddress)
|
---|
[87275] | 1160 | m_pEditorDHCPUpperAddress->setEnabled(fIsInterfaceExists && fIsDHCPServerEnabled);
|
---|
[65603] | 1161 |
|
---|
[66725] | 1162 | /* Load DHCP server fields: */
|
---|
[87268] | 1163 | if (m_pCheckBoxDHCP)
|
---|
| 1164 | m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled);
|
---|
| 1165 | if (m_pEditorDHCPAddress)
|
---|
| 1166 | m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress);
|
---|
| 1167 | if (m_pEditorDHCPMask)
|
---|
| 1168 | m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask);
|
---|
| 1169 | if (m_pEditorDHCPLowerAddress)
|
---|
| 1170 | m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
|
---|
| 1171 | if (m_pEditorDHCPUpperAddress)
|
---|
| 1172 | m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
|
---|
[66860] | 1173 |
|
---|
| 1174 | /* Invent default values if server was enabled
|
---|
| 1175 | * but at least one current value is invalid: */
|
---|
| 1176 | if ( fIsDHCPServerEnabled
|
---|
[87268] | 1177 | && m_pEditorDHCPAddress
|
---|
| 1178 | && m_pEditorDHCPMask
|
---|
| 1179 | && m_pEditorDHCPLowerAddress
|
---|
| 1180 | && m_pEditorDHCPUpperAddress
|
---|
[66860] | 1181 | && ( m_pEditorDHCPAddress->text().isEmpty()
|
---|
| 1182 | || m_pEditorDHCPAddress->text() == "0.0.0.0"
|
---|
| 1183 | || m_pEditorDHCPMask->text().isEmpty()
|
---|
| 1184 | || m_pEditorDHCPMask->text() == "0.0.0.0"
|
---|
| 1185 | || m_pEditorDHCPLowerAddress->text().isEmpty()
|
---|
| 1186 | || m_pEditorDHCPLowerAddress->text() == "0.0.0.0"
|
---|
| 1187 | || m_pEditorDHCPUpperAddress->text().isEmpty()
|
---|
| 1188 | || m_pEditorDHCPUpperAddress->text() == "0.0.0.0"))
|
---|
| 1189 | {
|
---|
| 1190 | const QStringList &proposal = makeDhcpServerProposal(m_oldData.m_interface.m_strAddress,
|
---|
| 1191 | m_oldData.m_interface.m_strMask);
|
---|
| 1192 | m_pEditorDHCPAddress->setText(proposal.at(0));
|
---|
| 1193 | m_pEditorDHCPMask->setText(proposal.at(1));
|
---|
| 1194 | m_pEditorDHCPLowerAddress->setText(proposal.at(2));
|
---|
| 1195 | m_pEditorDHCPUpperAddress->setText(proposal.at(3));
|
---|
| 1196 | }
|
---|
[25177] | 1197 | }
|
---|
[92821] | 1198 | #endif /* !VBOX_WS_MAC */
|
---|