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