VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.cpp

Last change on this file was 104536, checked in by vboxsync, 4 months ago

FE/Qt: bugref:10678: Accessibility fixes for Network Manager; JAWS requires all buttons to have their text property assigned, cause opposing to VoiceOver it uses this property, not the tool-tip.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.8 KB
Line 
1/* $Id: UIDetailsWidgetCloudNetwork.cpp 104536 2024-05-07 16:12:41Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsWidgetCloudNetwork 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 <QComboBox>
31#include <QFontMetrics>
32#include <QGroupBox>
33#include <QLabel>
34#include <QPushButton>
35#include <QRadioButton>
36#include <QStyleOption>
37#include <QVBoxLayout>
38
39/* GUI includes: */
40#include "QIDialogButtonBox.h"
41#include "QILineEdit.h"
42#include "QITabWidget.h"
43#include "QIToolButton.h"
44#include "UICloudNetworkingStuff.h"
45#include "UIDetailsWidgetCloudNetwork.h"
46#include "UIFormEditorWidget.h"
47#include "UIIconPool.h"
48#include "UIMessageCenter.h"
49#include "UINetworkManager.h"
50#include "UINetworkManagerUtils.h"
51#include "UINotificationCenter.h"
52#include "UITranslationEventListener.h"
53
54UISubnetSelectionDialog::UISubnetSelectionDialog(QWidget *pParent,
55 const QString &strShortProviderName,
56 const QString &strProfileName,
57 const QString &strSubnetId)
58 : QDialog(pParent)
59 , m_strProviderShortName(strShortProviderName)
60 , m_strProfileName(strProfileName)
61 , m_strSubnetId(strSubnetId)
62 , m_pFormEditor(0)
63 , m_pButtonBox(0)
64 , m_pNotificationCenter(0)
65{
66 prepare();
67}
68
69UISubnetSelectionDialog::~UISubnetSelectionDialog()
70{
71 cleanup();
72}
73
74void UISubnetSelectionDialog::accept()
75{
76 /* Get altered description back: */
77 m_comForm.GetVirtualSystemDescription();
78 QVector<KVirtualSystemDescriptionType> aTypes;
79 QVector<QString> aRefs, aOVFValues, aVBoxValues, aExtraConfigValues;
80 m_comDescription.GetDescriptionByType(KVirtualSystemDescriptionType_CloudOCISubnet,
81 aTypes, aRefs, aOVFValues, aVBoxValues, aExtraConfigValues);
82 if (!m_comDescription.isOk())
83 {
84 UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(m_comDescription,
85 m_pNotificationCenter);
86 return;
87 }
88 AssertReturnVoid(!aVBoxValues.isEmpty());
89 m_strSubnetId = aVBoxValues.first();
90
91 /* Call to base-class: */
92 return QDialog::accept();
93}
94
95int UISubnetSelectionDialog::exec()
96{
97 /* Request to init dialog _after_ being executed: */
98 QMetaObject::invokeMethod(this, "sltInit", Qt::QueuedConnection);
99
100 /* Call to base-class: */
101 return QDialog::exec();
102}
103
104void UISubnetSelectionDialog::sltRetranslateUI()
105{
106 setWindowTitle(UINetworkManager::tr("Select Subnet"));
107}
108
109void UISubnetSelectionDialog::sltInit()
110{
111 /* Create description: */
112 m_comDescription = createVirtualSystemDescription(m_pNotificationCenter);
113 if (m_comDescription.isNull())
114 return;
115 /* Update it with current subnet value: */
116 m_comDescription.AddDescription(KVirtualSystemDescriptionType_CloudOCISubnet, m_strSubnetId, QString());
117
118 /* Create cloud client: */
119 CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_pNotificationCenter);
120 if (comCloudClient.isNull())
121 return;
122
123 /* Create subnet selection VSD form: */
124 UINotificationProgressSubnetSelectionVSDFormCreate *pNotification = new UINotificationProgressSubnetSelectionVSDFormCreate(comCloudClient,
125 m_comDescription,
126 m_strProviderShortName,
127 m_strProfileName);
128 connect(pNotification, &UINotificationProgressSubnetSelectionVSDFormCreate::sigVSDFormCreated,
129 this, &UISubnetSelectionDialog::sltHandleVSDFormCreated);
130 m_pNotificationCenter->append(pNotification);
131}
132
133void UISubnetSelectionDialog::sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm)
134{
135 m_comForm = comForm;
136 m_pFormEditor->setVirtualSystemDescriptionForm(m_comForm);
137}
138
139void UISubnetSelectionDialog::prepare()
140{
141 /* Prepare main layout: */
142 QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
143 if (pLayoutMain)
144 {
145 /* Prepare form editor: */
146 m_pFormEditor = new UIFormEditorWidget(this);
147 if (m_pFormEditor)
148 pLayoutMain->addWidget(m_pFormEditor);
149
150 /* Prepare button-box: */
151 m_pButtonBox = new QIDialogButtonBox(this);
152 if (m_pButtonBox)
153 {
154 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
155 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &QDialog::accept);
156 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &QDialog::reject);
157
158 pLayoutMain->addWidget(m_pButtonBox);
159 }
160 }
161
162 /* Prepare local notification-center: */
163 m_pNotificationCenter = new UINotificationCenter(this);
164 if (m_pNotificationCenter && m_pFormEditor)
165 m_pFormEditor->setNotificationCenter(m_pNotificationCenter);
166
167 /* Apply language settings: */
168 sltRetranslateUI();
169
170 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
171 this, &UISubnetSelectionDialog::sltRetranslateUI);
172}
173
174void UISubnetSelectionDialog::cleanup()
175{
176 /* Cleanup local notification-center: */
177 delete m_pNotificationCenter;
178 m_pNotificationCenter = 0;
179}
180
181
182UIDetailsWidgetCloudNetwork::UIDetailsWidgetCloudNetwork(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)
183 : QWidget(pParent)
184 , m_enmEmbedding(enmEmbedding)
185 , m_pLabelNetworkName(0)
186 , m_pEditorNetworkName(0)
187 , m_pLabelProviderName(0)
188 , m_pComboProviderName(0)
189 , m_pLabelProfileName(0)
190 , m_pComboProfileName(0)
191 , m_pLabelNetworkId(0)
192 , m_pEditorNetworkId(0)
193 , m_pButtonNetworkId(0)
194 , m_pButtonBoxOptions(0)
195{
196 prepare();
197}
198
199void UIDetailsWidgetCloudNetwork::setData(const UIDataCloudNetwork &data,
200 const QStringList &busyNames /* = QStringList() */)
201{
202 /* Cache old/new data: */
203 m_oldData = data;
204 m_newData = m_oldData;
205 m_busyNames = busyNames;
206
207 /* Load data: */
208 loadData();
209}
210
211bool UIDetailsWidgetCloudNetwork::revalidate() const
212{
213 /* Make sure network name isn't empty: */
214 if (m_newData.m_strName.isEmpty())
215 {
216 UINotificationMessage::warnAboutNoNameSpecified(m_oldData.m_strName);
217 return false;
218 }
219 else
220 {
221 /* Make sure item names are unique: */
222 if (m_busyNames.contains(m_newData.m_strName))
223 {
224 UINotificationMessage::warnAboutNameAlreadyBusy(m_newData.m_strName);
225 return false;
226 }
227 }
228
229 return true;
230}
231
232void UIDetailsWidgetCloudNetwork::updateButtonStates()
233{
234// if (m_oldData != m_newData)
235// printf("Network: %s, %s, %s, %d, %d, %d\n",
236// m_newData.m_strName.toUtf8().constData(),
237// m_newData.m_strPrefixIPv4.toUtf8().constData(),
238// m_newData.m_strPrefixIPv6.toUtf8().constData(),
239// m_newData.m_fSupportsDHCP,
240// m_newData.m_fSupportsIPv6,
241// m_newData.m_fAdvertiseDefaultIPv6Route);
242
243 /* Update 'Apply' / 'Reset' button states: */
244 if (m_pButtonBoxOptions)
245 {
246 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
247 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
248 }
249
250 /* Notify listeners as well: */
251 emit sigDataChanged(m_oldData != m_newData);
252}
253
254void UIDetailsWidgetCloudNetwork::sltRetranslateUI()
255{
256 if (m_pLabelNetworkName)
257 m_pLabelNetworkName->setText(UINetworkManager::tr("N&ame:"));
258 if (m_pEditorNetworkName)
259 m_pEditorNetworkName->setToolTip(UINetworkManager::tr("Holds the name for this network."));
260 if (m_pLabelProviderName)
261 m_pLabelProviderName->setText(UINetworkManager::tr("&Provider:"));
262 if (m_pComboProviderName)
263 m_pComboProviderName->setToolTip(UINetworkManager::tr("Holds the cloud provider for this network."));
264 if (m_pLabelProfileName)
265 m_pLabelProfileName->setText(UINetworkManager::tr("P&rofile:"));
266 if (m_pComboProfileName)
267 m_pComboProfileName->setToolTip(UINetworkManager::tr("Holds the cloud profile for this network."));
268 if (m_pLabelNetworkId)
269 m_pLabelNetworkId->setText(UINetworkManager::tr("&Id:"));
270 if (m_pEditorNetworkId)
271 m_pEditorNetworkId->setToolTip(UINetworkManager::tr("Holds the id for this network."));
272 if (m_pButtonNetworkId)
273 {
274 m_pButtonNetworkId->setText(UINetworkManager::tr("Select Network ID"));
275 m_pButtonNetworkId->setToolTip(UINetworkManager::tr("Selects the id for this network."));
276 }
277 if (m_pButtonBoxOptions)
278 {
279 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setText(UINetworkManager::tr("Reset"));
280 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setText(UINetworkManager::tr("Apply"));
281 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
282 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
283 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setStatusTip(UINetworkManager::tr("Reset changes in current "
284 "interface details"));
285 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setStatusTip(UINetworkManager::tr("Apply changes in current "
286 "interface details"));
287 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->
288 setToolTip(UINetworkManager::tr("Reset Changes (%1)").arg(m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->shortcut().toString()));
289 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->
290 setToolTip(UINetworkManager::tr("Apply Changes (%1)").arg(m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->shortcut().toString()));
291 }
292}
293
294void UIDetailsWidgetCloudNetwork::sltNetworkNameChanged(const QString &strText)
295{
296 m_newData.m_strName = strText;
297 updateButtonStates();
298}
299
300void UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged(int iIndex)
301{
302 /* Store provider: */
303 m_newData.m_strProvider = m_pComboProviderName->itemData(iIndex).toString();
304
305 /* Update profiles: */
306 prepareProfiles();
307 /* And store selected profile: */
308 sltCloudProfileNameChanged(m_pComboProfileName->currentIndex());
309
310 /* Update button states finally: */
311 updateButtonStates();
312}
313
314void UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged(int iIndex)
315{
316 /* Store profile: */
317 m_newData.m_strProfile = m_pComboProfileName->itemData(iIndex).toString();
318
319 /* Update button states finally: */
320 updateButtonStates();
321}
322
323void UIDetailsWidgetCloudNetwork::sltNetworkIdChanged(const QString &strText)
324{
325 m_newData.m_strId = strText;
326 updateButtonStates();
327}
328
329void UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested()
330{
331 /* Create subnet selection dialog: */
332 QPointer<UISubnetSelectionDialog> pDialog = new UISubnetSelectionDialog(this,
333 m_pComboProviderName->currentData().toString(),
334 m_pComboProfileName->currentData().toString(),
335 m_pEditorNetworkId->text());
336
337 /* Execute dialog to ask user for subnet: */
338 if (pDialog->exec() == QDialog::Accepted)
339 m_pEditorNetworkId->setText(pDialog->subnetId());
340
341 /* Cleanup subnet dialog finally: */
342 delete pDialog;
343}
344
345void UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton)
346{
347 /* Make sure button-box exist: */
348 if (!m_pButtonBoxOptions)
349 return;
350
351 /* Disable buttons first of all: */
352 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(false);
353 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(false);
354
355 /* Compare with known buttons: */
356 if (pButton == m_pButtonBoxOptions->button(QDialogButtonBox::Cancel))
357 emit sigDataChangeRejected();
358 else
359 if (pButton == m_pButtonBoxOptions->button(QDialogButtonBox::Ok))
360 emit sigDataChangeAccepted();
361}
362
363void UIDetailsWidgetCloudNetwork::prepare()
364{
365 /* Prepare everything: */
366 prepareThis();
367 prepareProviders();
368 prepareProfiles();
369
370 /* Apply language settings: */
371 sltRetranslateUI();
372
373 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
374 this, &UIDetailsWidgetCloudNetwork::sltRetranslateUI);
375
376 /* Update button states finally: */
377 updateButtonStates();
378}
379
380void UIDetailsWidgetCloudNetwork::prepareThis()
381{
382 /* Prepare options widget layout: */
383 QGridLayout *pLayout = new QGridLayout(this);
384 if (pLayout)
385 {
386#ifdef VBOX_WS_MAC
387 pLayout->setSpacing(10);
388 pLayout->setContentsMargins(10, 10, 10, 10);
389#endif
390
391 /* Prepare network name label: */
392 m_pLabelNetworkName = new QLabel(this);
393 if (m_pLabelNetworkName)
394 {
395 m_pLabelNetworkName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
396 pLayout->addWidget(m_pLabelNetworkName, 0, 0);
397 }
398 /* Prepare network name editor: */
399 m_pEditorNetworkName = new QLineEdit(this);
400 if (m_pEditorNetworkName)
401 {
402 if (m_pLabelNetworkName)
403 m_pLabelNetworkName->setBuddy(m_pEditorNetworkName);
404 connect(m_pEditorNetworkName, &QLineEdit::textEdited,
405 this, &UIDetailsWidgetCloudNetwork::sltNetworkNameChanged);
406 pLayout->addWidget(m_pEditorNetworkName, 0, 1, 1, 2);
407 }
408
409 /* Prepare cloud provider name label: */
410 m_pLabelProviderName = new QLabel(this);
411 if (m_pLabelProviderName)
412 {
413 m_pLabelProviderName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
414 pLayout->addWidget(m_pLabelProviderName, 1, 0);
415 }
416 /* Prepare cloud provider name combo: */
417 m_pComboProviderName = new QComboBox(this);
418 if (m_pComboProviderName)
419 {
420 if (m_pLabelProviderName)
421 m_pLabelProviderName->setBuddy(m_pComboProviderName);
422 connect(m_pComboProviderName, &QComboBox::currentIndexChanged,
423 this, &UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged);
424 pLayout->addWidget(m_pComboProviderName, 1, 1, 1, 2);
425 }
426
427 /* Prepare cloud profile name label: */
428 m_pLabelProfileName = new QLabel(this);
429 if (m_pLabelProfileName)
430 {
431 m_pLabelProfileName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
432 pLayout->addWidget(m_pLabelProfileName, 2, 0);
433 }
434 /* Prepare cloud profile name combo: */
435 m_pComboProfileName = new QComboBox(this);
436 if (m_pComboProfileName)
437 {
438 if (m_pLabelProfileName)
439 m_pLabelProfileName->setBuddy(m_pComboProfileName);
440 connect(m_pComboProfileName, &QComboBox::currentIndexChanged,
441 this, &UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged);
442 pLayout->addWidget(m_pComboProfileName, 2, 1, 1, 2);
443 }
444
445 /* Prepare network id label: */
446 m_pLabelNetworkId = new QLabel(this);
447 if (m_pLabelNetworkId)
448 {
449 m_pLabelNetworkId->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
450 pLayout->addWidget(m_pLabelNetworkId, 3, 0);
451 }
452 /* Prepare network id editor: */
453 m_pEditorNetworkId = new QLineEdit(this);
454 if (m_pEditorNetworkId)
455 {
456 if (m_pLabelNetworkId)
457 m_pLabelNetworkId->setBuddy(m_pEditorNetworkId);
458 connect(m_pEditorNetworkId, &QLineEdit::textChanged,
459 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdChanged);
460 pLayout->addWidget(m_pEditorNetworkId, 3, 1);
461 }
462 /* Prepare network id button: */
463 m_pButtonNetworkId = new QIToolButton(this);
464 if (m_pButtonNetworkId)
465 {
466 m_pButtonNetworkId->setIcon(UIIconPool::iconSet(":/subnet_16px.png"));
467 connect(m_pButtonNetworkId, &QIToolButton::clicked,
468 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested);
469 pLayout->addWidget(m_pButtonNetworkId, 3, 2);
470 }
471
472 /* If parent embedded into stack: */
473 if (m_enmEmbedding == EmbedTo_Stack)
474 {
475 /* Prepare button-box: */
476 m_pButtonBoxOptions = new QIDialogButtonBox(this);
477 if (m_pButtonBoxOptions)
478 {
479 m_pButtonBoxOptions->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
480 connect(m_pButtonBoxOptions, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick);
481 pLayout->addWidget(m_pButtonBoxOptions, 4, 0, 1, 2);
482 }
483 }
484 }
485}
486
487void UIDetailsWidgetCloudNetwork::prepareProviders()
488{
489 /* Sanity check: */
490 AssertPtrReturnVoid(m_pComboProviderName);
491
492 /* Remember current item data to be able to restore it: */
493 QString strOldData;
494 if (m_pComboProviderName->currentIndex() != -1)
495 strOldData = m_pComboProviderName->currentData().toString();
496
497 /* Block signals while updating: */
498 m_pComboProviderName->blockSignals(true);
499
500 /* Clear combo initially: */
501 m_pComboProviderName->clear();
502
503 /* Add empty item: */
504 m_pComboProviderName->addItem("--");
505
506 /* Iterate through existing providers: */
507 foreach (const CCloudProvider &comProvider, listCloudProviders())
508 {
509 /* Skip if we have nothing to populate (file missing?): */
510 if (comProvider.isNull())
511 continue;
512 /* Acquire provider name: */
513 QString strProviderName;
514 if (!cloudProviderName(comProvider, strProviderName))
515 continue;
516 /* Acquire provider short name: */
517 QString strProviderShortName;
518 if (!cloudProviderShortName(comProvider, strProviderShortName))
519 continue;
520
521 /* Compose empty item, fill the data: */
522 m_pComboProviderName->addItem(strProviderName);
523 m_pComboProviderName->setItemData(m_pComboProviderName->count() - 1, strProviderShortName);
524 }
525
526 /* Set previous/default item if possible: */
527 int iNewIndex = -1;
528 if ( iNewIndex == -1
529 && !strOldData.isNull())
530 iNewIndex = m_pComboProviderName->findData(strOldData);
531 if ( iNewIndex == -1
532 && m_pComboProviderName->count() > 0)
533 iNewIndex = 0;
534 if (iNewIndex != -1)
535 m_pComboProviderName->setCurrentIndex(iNewIndex);
536
537 /* Unblock signals after update: */
538 m_pComboProviderName->blockSignals(false);
539}
540
541void UIDetailsWidgetCloudNetwork::prepareProfiles()
542{
543 /* Sanity check: */
544 AssertPtrReturnVoid(m_pComboProfileName);
545
546 /* Remember current item data to be able to restore it: */
547 QString strOldData;
548 if (m_pComboProfileName->currentIndex() != -1)
549 strOldData = m_pComboProfileName->currentData().toString();
550
551 /* Block signals while updating: */
552 m_pComboProfileName->blockSignals(true);
553
554 /* Clear combo initially: */
555 m_pComboProfileName->clear();
556
557 /* Add empty item: */
558 m_pComboProfileName->addItem("--");
559
560 /* Acquire provider short name: */
561 const QString strProviderShortName = m_pComboProviderName->currentData().toString();
562 if (!strProviderShortName.isEmpty())
563 {
564 /* Acquire provider: */
565 CCloudProvider comProvider = cloudProviderByShortName(strProviderShortName);
566 if (comProvider.isNotNull())
567 {
568 /* Iterate through existing profiles: */
569 foreach (const CCloudProfile &comProfile, listCloudProfiles(comProvider))
570 {
571 /* Skip if we have nothing to populate (wtf happened?): */
572 if (comProfile.isNull())
573 continue;
574 /* Acquire current profile name: */
575 QString strProfileName;
576 if (!cloudProfileName(comProfile, strProfileName))
577 continue;
578
579 /* Compose item, fill the data: */
580 m_pComboProfileName->addItem(strProfileName);
581 m_pComboProfileName->setItemData(m_pComboProfileName->count() - 1, strProfileName);
582 }
583
584 /* Set previous/default item if possible: */
585 int iNewIndex = -1;
586 if ( iNewIndex == -1
587 && !strOldData.isNull())
588 iNewIndex = m_pComboProfileName->findData(strOldData);
589 if ( iNewIndex == -1
590 && m_pComboProfileName->count() > 0)
591 iNewIndex = 0;
592 if (iNewIndex != -1)
593 m_pComboProfileName->setCurrentIndex(iNewIndex);
594 }
595 }
596
597 /* Unblock signals after update: */
598 m_pComboProfileName->blockSignals(false);
599}
600
601void UIDetailsWidgetCloudNetwork::loadData()
602{
603 /* Check whether network exists and enabled: */
604 const bool fIsNetworkExists = m_newData.m_fExists;
605
606 /* Update field availability: */
607 m_pLabelNetworkName->setEnabled(fIsNetworkExists);
608 m_pEditorNetworkName->setEnabled(fIsNetworkExists);
609 m_pLabelProviderName->setEnabled(fIsNetworkExists);
610 m_pComboProviderName->setEnabled(fIsNetworkExists);
611 m_pLabelProfileName->setEnabled(fIsNetworkExists);
612 m_pComboProfileName->setEnabled(fIsNetworkExists);
613 m_pLabelNetworkId->setEnabled(fIsNetworkExists);
614 m_pEditorNetworkId->setEnabled(fIsNetworkExists);
615 m_pButtonNetworkId->setEnabled(fIsNetworkExists);
616
617 /* Load fields: */
618 m_pEditorNetworkName->setText(m_newData.m_strName);
619 const int iProviderIndex = m_pComboProviderName->findData(m_newData.m_strProvider);
620 m_pComboProviderName->setCurrentIndex(iProviderIndex == -1 ? 0 : iProviderIndex);
621 const int iProfileIndex = m_pComboProfileName->findData(m_newData.m_strProfile);
622 m_pComboProfileName->setCurrentIndex(iProfileIndex == -1 ? 0 : iProfileIndex);
623 m_pEditorNetworkId->setText(m_newData.m_strId);
624}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette