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