VirtualBox

Changeset 74853 in vbox for trunk


Ignore:
Timestamp:
Oct 15, 2018 6:36:00 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9230: Cloud Profile Manager: Initial carcass.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 deleted
1 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r74740 r74853  
    339339VBOX_GUI_INC_DIRS = \
    340340        ./src \
     341        ./src/cloud \
    341342        ./src/converter \
    342343        ./src/extensions \
     
    680681#
    681682VirtualBox_QT_MOCHDRS = \
     683        src/cloud/UICloudProfileDetailsWidget.h \
     684        src/cloud/UICloudProfileManager.h \
    682685        src/globals/UIStarter.h \
    683686        src/hostnetwork/UIHostNetworkDetailsWidget.h \
     
    13711374VirtualBox_SOURCES = \
    13721375        src/main.cpp \
     1376        src/cloud/UICloudProfileDetailsWidget.cpp \
     1377        src/cloud/UICloudProfileManager.cpp \
    13731378        src/globals/UIStarter.cpp \
    13741379        src/hostnetwork/UIHostNetworkDetailsWidget.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.cpp

    r74811 r74853  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIHostNetworkDetailsWidget class implementation.
     3 * VBox Qt GUI - UICloudProfileDetailsWidget class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* Qt includes: */
    23 # include <QCheckBox>
    24 # include <QLabel>
    2523# include <QPushButton>
    26 # include <QRadioButton>
    27 # include <QRegExpValidator>
    28 # include <QStyleOption>
     24# include <QTableWidget>
    2925# include <QVBoxLayout>
    3026
    3127/* GUI includes: */
    3228# include "QIDialogButtonBox.h"
    33 # include "QILineEdit.h"
    34 # include "QITabWidget.h"
    35 # include "UIHostNetworkDetailsWidget.h"
    36 # include "UIHostNetworkUtils.h"
    37 # include "UIIconPool.h"
     29# include "UICloudProfileDetailsWidget.h"
    3830
    3931/* Other VBox includes: */
    4032# include "iprt/assert.h"
    41 # include "iprt/cidr.h"
    4233
    4334#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4435
    4536
    46 UIHostNetworkDetailsWidget::UIHostNetworkDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)
     37UICloudProfileDetailsWidget::UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)
    4738    : QIWithRetranslateUI<QWidget>(pParent)
    4839    , m_enmEmbedding(enmEmbedding)
    49     , m_pTabWidget(0)
    50     , m_pButtonAutomatic(0), m_pErrorPaneAutomatic(0)
    51     , m_pButtonManual(0), m_pErrorPaneManual(0)
    52     , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pErrorPaneIPv4(0)
    53     , m_pLabelNMv4(0), m_pEditorNMv4(0), m_pErrorPaneNMv4(0)
    54     , m_pLabelIPv6(0), m_pEditorIPv6(0), m_pErrorPaneIPv6(0)
    55     , m_pLabelNMv6(0), m_pEditorNMv6(0), m_pErrorPaneNMv6(0)
    56     , m_pButtonBoxInterface(0)
    57     , m_pCheckBoxDHCP(0)
    58     , m_pLabelDHCPAddress(0), m_pEditorDHCPAddress(0), m_pErrorPaneDHCPAddress(0)
    59     , m_pLabelDHCPMask(0), m_pEditorDHCPMask(0), m_pErrorPaneDHCPMask(0)
    60     , m_pLabelDHCPLowerAddress(0), m_pEditorDHCPLowerAddress(0), m_pErrorPaneDHCPLowerAddress(0)
    61     , m_pLabelDHCPUpperAddress(0), m_pEditorDHCPUpperAddress(0), m_pErrorPaneDHCPUpperAddress(0)
    62     , m_pButtonBoxServer(0)
     40    , m_pTableWidget(0)
     41    , m_pButtonBox(0)
    6342{
    6443    /* Prepare: */
     
    6645}
    6746
    68 void UIHostNetworkDetailsWidget::setData(const UIDataHostNetwork &data)
     47void UICloudProfileDetailsWidget::setData(const UIDataCloudProfile &data)
    6948{
    7049    /* Cache old/new data: */
     
    7251    m_newData = m_oldData;
    7352
    74     /* Load 'Interface' data: */
    75     loadDataForInterface();
    76     /* Load 'DHCP server' data: */
    77     loadDataForDHCPServer();
     53    /* Load data: */
     54    loadData();
    7855}
    7956
    80 void UIHostNetworkDetailsWidget::retranslateUi()
     57void UICloudProfileDetailsWidget::retranslateUi()
    8158{
    82     /* Translate tab-widget: */
    83     m_pTabWidget->setTabText(0, tr("&Adapter"));
    84     m_pTabWidget->setTabText(1, tr("&DHCP Server"));
    85 
    86     /* Translate 'Interface' tab content: */
    87     m_pButtonAutomatic->setText(tr("Configure Adapter &Automatically"));
    88     m_pButtonManual->setText(tr("Configure Adapter &Manually"));
    89     m_pLabelIPv4->setText(tr("&IPv4 Address:"));
    90     m_pEditorIPv4->setToolTip(tr("Holds the host IPv4 address for this adapter."));
    91     m_pLabelNMv4->setText(tr("IPv4 Network &Mask:"));
    92     m_pEditorNMv4->setToolTip(tr("Holds the host IPv4 network mask for this adapter."));
    93     m_pLabelIPv6->setText(tr("I&Pv6 Address:"));
    94     m_pEditorIPv6->setToolTip(tr("Holds the host IPv6 address for this adapter if IPv6 is supported."));
    95     m_pLabelNMv6->setText(tr("IPv6 Prefix &Length:"));
    96     m_pEditorNMv6->setToolTip(tr("Holds the host IPv6 prefix length for this adapter if IPv6 is supported."));
    97     if (m_pButtonBoxInterface)
    98     {
    99         m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setText(tr("Reset"));
    100         m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setText(tr("Apply"));
    101         m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    102         m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
    103         m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current interface details"));
    104         m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current interface details"));
    105         m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->
    106             setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->shortcut().toString()));
    107         m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->
    108             setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->shortcut().toString()));
    109     }
    110 
    111     /* Translate 'DHCP server' tab content: */
    112     m_pCheckBoxDHCP->setText(tr("&Enable Server"));
    113     m_pCheckBoxDHCP->setToolTip(tr("When checked, the DHCP Server will be enabled for this network on machine start-up."));
    114     m_pLabelDHCPAddress->setText(tr("Server Add&ress:"));
    115     m_pEditorDHCPAddress->setToolTip(tr("Holds the address of the DHCP server servicing the network associated with this host-only adapter."));
    116     m_pLabelDHCPMask->setText(tr("Server &Mask:"));
    117     m_pEditorDHCPMask->setToolTip(tr("Holds the network mask of the DHCP server servicing the network associated with this host-only adapter."));
    118     m_pLabelDHCPLowerAddress->setText(tr("&Lower Address Bound:"));
    119     m_pEditorDHCPLowerAddress->setToolTip(tr("Holds the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
    120     m_pLabelDHCPUpperAddress->setText(tr("&Upper Address Bound:"));
    121     m_pEditorDHCPUpperAddress->setToolTip(tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
    122     if (m_pButtonBoxServer)
    123     {
    124         m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setText(tr("Reset"));
    125         m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setText(tr("Apply"));
    126         m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    127         m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
    128         m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current DHCP server details"));
    129         m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current DHCP server details"));
    130         m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->
    131             setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->shortcut().toString()));
    132         m_pButtonBoxServer->button(QDialogButtonBox::Ok)->
    133             setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBoxServer->button(QDialogButtonBox::Ok)->shortcut().toString()));
    134     }
     59    /* Translate table-widget: */
     60    m_pTableWidget->setToolTip(tr("Contains cloud profile settings"));
    13561
    13662    /* Retranslate validation: */
     
    13864}
    13965
    140 void UIHostNetworkDetailsWidget::sltToggledButtonAutomatic(bool fChecked)
     66void UICloudProfileDetailsWidget::sltTableChanged()
    14167{
    142     m_newData.m_interface.m_fDHCPEnabled = fChecked;
    143     loadDataForInterface();
    144     revalidate();
    145     updateButtonStates();
     68    /// @todo handle profile settings table change!
    14669}
    14770
    148 void UIHostNetworkDetailsWidget::sltToggledButtonManual(bool fChecked)
    149 {
    150     m_newData.m_interface.m_fDHCPEnabled = !fChecked;
    151     loadDataForInterface();
    152     revalidate();
    153     updateButtonStates();
    154 }
    155 
    156 void UIHostNetworkDetailsWidget::sltTextChangedIPv4(const QString &strText)
    157 {
    158     m_newData.m_interface.m_strAddress = strText;
    159     revalidate(m_pErrorPaneIPv4);
    160     updateButtonStates();
    161 }
    162 
    163 void UIHostNetworkDetailsWidget::sltTextChangedNMv4(const QString &strText)
    164 {
    165     m_newData.m_interface.m_strMask = strText;
    166     revalidate(m_pErrorPaneNMv4);
    167     updateButtonStates();
    168 }
    169 
    170 void UIHostNetworkDetailsWidget::sltTextChangedIPv6(const QString &strText)
    171 {
    172     m_newData.m_interface.m_strAddress6 = strText;
    173     revalidate(m_pErrorPaneIPv6);
    174     updateButtonStates();
    175 }
    176 
    177 void UIHostNetworkDetailsWidget::sltTextChangedNMv6(const QString &strText)
    178 {
    179     m_newData.m_interface.m_strPrefixLength6 = strText;
    180     revalidate(m_pErrorPaneNMv6);
    181     updateButtonStates();
    182 }
    183 
    184 void UIHostNetworkDetailsWidget::sltStatusChangedServer(int iChecked)
    185 {
    186     m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked;
    187     loadDataForDHCPServer();
    188     revalidate();
    189     updateButtonStates();
    190 }
    191 
    192 void UIHostNetworkDetailsWidget::sltTextChangedAddress(const QString &strText)
    193 {
    194     m_newData.m_dhcpserver.m_strAddress = strText;
    195     revalidate(m_pErrorPaneDHCPAddress);
    196     updateButtonStates();
    197 }
    198 
    199 void UIHostNetworkDetailsWidget::sltTextChangedMask(const QString &strText)
    200 {
    201     m_newData.m_dhcpserver.m_strMask = strText;
    202     revalidate(m_pErrorPaneDHCPMask);
    203     updateButtonStates();
    204 }
    205 
    206 void UIHostNetworkDetailsWidget::sltTextChangedLowerAddress(const QString &strText)
    207 {
    208     m_newData.m_dhcpserver.m_strLowerAddress = strText;
    209     revalidate(m_pErrorPaneDHCPLowerAddress);
    210     updateButtonStates();
    211 }
    212 
    213 void UIHostNetworkDetailsWidget::sltTextChangedUpperAddress(const QString &strText)
    214 {
    215     m_newData.m_dhcpserver.m_strUpperAddress = strText;
    216     revalidate(m_pErrorPaneDHCPUpperAddress);
    217     updateButtonStates();
    218 }
    219 
    220 void UIHostNetworkDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton)
     71void UICloudProfileDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton)
    22172{
    22273    /* Make sure button-box exists: */
    223     AssertPtrReturnVoid(m_pButtonBoxInterface);
    224     AssertPtrReturnVoid(m_pButtonBoxServer);
     74    AssertPtrReturnVoid(m_pButtonBox);
    22575
    22676    /* Disable buttons first of all: */
    227     m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(false);
    228     m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(false);
    229     m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(false);
    230     m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(false);
     77    m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
     78    m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    23179
    23280    /* Compare with known buttons: */
    233     if (   pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)
    234         || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Cancel))
     81    if (pButton == m_pButtonBox->button(QDialogButtonBox::Cancel))
    23582        emit sigDataChangeRejected();
    23683    else
    237     if (   pButton == m_pButtonBoxInterface->button(QDialogButtonBox::Ok)
    238         || pButton == m_pButtonBoxServer->button(QDialogButtonBox::Ok))
     84    if (pButton == m_pButtonBox->button(QDialogButtonBox::Ok))
    23985        emit sigDataChangeAccepted();
    24086}
    24187
    242 void UIHostNetworkDetailsWidget::prepare()
     88void UICloudProfileDetailsWidget::prepare()
    24389{
    244     /* Prepare this: */
    245     prepareThis();
     90    /* Prepare widgets: */
     91    prepareWidgets();
    24692
    24793    /* Apply language settings: */
     
    25298}
    25399
    254 void UIHostNetworkDetailsWidget::prepareThis()
     100void UICloudProfileDetailsWidget::prepareWidgets()
    255101{
    256102    /* Create layout: */
    257103    QVBoxLayout *pLayout = new QVBoxLayout(this);
    258     AssertPtrReturnVoid(pLayout);
     104    if (pLayout)
    259105    {
    260106        /* Configure layout: */
    261107        pLayout->setContentsMargins(0, 0, 0, 0);
    262108
    263         /* Prepare tab-widget: */
    264         prepareTabWidget();
     109        /* Create tab-widget: */
     110        m_pTableWidget = new QTableWidget;
     111        if (m_pTableWidget)
     112        {
     113            /* Add into layout: */
     114            pLayout->addWidget(m_pTableWidget);
     115        }
    265116    }
    266117}
    267118
    268 void UIHostNetworkDetailsWidget::prepareTabWidget()
     119void UICloudProfileDetailsWidget::loadData()
    269120{
    270     /* Create tab-widget: */
    271     m_pTabWidget = new QITabWidget;
    272     AssertPtrReturnVoid(m_pTabWidget);
    273     {
    274         /* Prepare 'Interface' tab: */
    275         prepareTabInterface();
    276         /* Prepare 'DHCP server' tab: */
    277         prepareTabDHCPServer();
    278 
    279         /* Add into layout: */
    280         layout()->addWidget(m_pTabWidget);
    281     }
     121    /// @todo load profile settings table data!
    282122}
    283123
    284 void UIHostNetworkDetailsWidget::prepareTabInterface()
     124void UICloudProfileDetailsWidget::revalidate(QWidget *pWidget /* = 0 */)
    285125{
    286     /* Create 'Interface' tab: */
    287     QWidget *pTabInterface = new QWidget;
    288     AssertPtrReturnVoid(pTabInterface);
    289     {
    290         /* Create 'Interface' layout: */
    291         QGridLayout *pLayoutInterface = new QGridLayout(pTabInterface);
    292         AssertPtrReturnVoid(pLayoutInterface);
    293         {
    294 #ifdef VBOX_WS_MAC
    295             /* Configure layout: */
    296             pLayoutInterface->setSpacing(10);
    297             pLayoutInterface->setContentsMargins(10, 10, 10, 10);
    298 #endif
    299 
    300             /* Get the required icon metric: */
    301             const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    302 
    303             /* Create automatic interface configuration layout: */
    304             QHBoxLayout *pLayoutAutomatic = new QHBoxLayout;
    305             AssertPtrReturnVoid(pLayoutAutomatic);
    306             {
    307                 /* Configure layout: */
    308                 pLayoutAutomatic->setContentsMargins(0, 0, 0, 0);
    309 
    310                 /* Create automatic interface configuration radio-button: */
    311                 m_pButtonAutomatic = new QRadioButton;
    312                 AssertPtrReturnVoid(m_pButtonAutomatic);
    313                 {
    314                     /* Configure radio-button: */
    315                     connect(m_pButtonAutomatic, &QRadioButton::toggled,
    316                             this, &UIHostNetworkDetailsWidget::sltToggledButtonAutomatic);
    317                     /* Add into layout: */
    318                     pLayoutAutomatic->addWidget(m_pButtonAutomatic);
    319                 }
    320                 /* Create automatic interface configuration error pane: */
    321                 m_pErrorPaneAutomatic = new QLabel;
    322                 AssertPtrReturnVoid(m_pErrorPaneAutomatic);
    323                 {
    324                     /* Configure label: */
    325                     m_pErrorPaneAutomatic->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    326                     m_pErrorPaneAutomatic->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
    327                     m_pErrorPaneAutomatic->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    328                                                      .pixmap(QSize(iIconMetric, iIconMetric)));
    329                     /* Add into layout: */
    330                     pLayoutAutomatic->addWidget(m_pErrorPaneAutomatic);
    331                 }
    332                 /* Add into layout: */
    333                 pLayoutInterface->addLayout(pLayoutAutomatic, 0, 0, 1, 3);
    334 #ifdef VBOX_WS_MAC
    335                 pLayoutInterface->setRowMinimumHeight(0, 22);
    336 #endif
    337             }
    338 
    339             /* Create manual interface configuration layout: */
    340             QHBoxLayout *pLayoutManual = new QHBoxLayout;
    341             AssertPtrReturnVoid(pLayoutManual);
    342             {
    343                 /* Configure layout: */
    344                 pLayoutManual->setContentsMargins(0, 0, 0, 0);
    345                 /* Create manual interface configuration radio-button: */
    346                 m_pButtonManual = new QRadioButton;
    347                 AssertPtrReturnVoid(m_pButtonManual);
    348                 {
    349                     /* Configure radio-button: */
    350                     connect(m_pButtonManual, &QRadioButton::toggled,
    351                             this, &UIHostNetworkDetailsWidget::sltToggledButtonManual);
    352                     /* Add into layout: */
    353                     pLayoutManual->addWidget(m_pButtonManual);
    354                 }
    355                 /* Create manual interface configuration error pane: */
    356                 m_pErrorPaneManual = new QLabel;
    357                 AssertPtrReturnVoid(m_pErrorPaneManual);
    358                 {
    359                     /* Configure label: */
    360                     m_pErrorPaneManual->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    361                     m_pErrorPaneManual->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
    362                     m_pErrorPaneManual->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    363                                                   .pixmap(QSize(iIconMetric, iIconMetric)));
    364                     /* Add into layout: */
    365                     pLayoutManual->addWidget(m_pErrorPaneManual);
    366                 }
    367                 /* Add into layout: */
    368                 pLayoutInterface->addLayout(pLayoutManual, 1, 0, 1, 3);
    369 #ifdef VBOX_WS_MAC
    370                 pLayoutInterface->setRowMinimumHeight(1, 22);
    371 #endif
    372             }
    373 
    374             /* Create IPv4 address label: */
    375             m_pLabelIPv4 = new QLabel;
    376             AssertPtrReturnVoid(m_pLabelIPv4);
    377             {
    378                 /* Configure label: */
    379                 m_pLabelIPv4->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    380                 /* Add into layout: */
    381                 pLayoutInterface->addWidget(m_pLabelIPv4, 2, 1);
    382             }
    383             /* Create IPv4 layout: */
    384             QHBoxLayout *pLayoutIPv4 = new QHBoxLayout;
    385             AssertPtrReturnVoid(pLayoutIPv4);
    386             {
    387                 /* Configure layout: */
    388                 pLayoutIPv4->setContentsMargins(0, 0, 0, 0);
    389                 /* Create IPv4 address editor: */
    390                 m_pEditorIPv4 = new QILineEdit;
    391                 AssertPtrReturnVoid(m_pEditorIPv4);
    392                 {
    393                     /* Configure editor: */
    394                     m_pLabelIPv4->setBuddy(m_pEditorIPv4);
    395                     connect(m_pEditorIPv4, &QLineEdit::textChanged,
    396                             this, &UIHostNetworkDetailsWidget::sltTextChangedIPv4);
    397                     /* Add into layout: */
    398                     pLayoutIPv4->addWidget(m_pEditorIPv4);
    399                 }
    400                 /* Create IPv4 error pane: */
    401                 m_pErrorPaneIPv4 = new QLabel;
    402                 AssertPtrReturnVoid(m_pErrorPaneIPv4);
    403                 {
    404                     /* Configure label: */
    405                     m_pErrorPaneIPv4->setAlignment(Qt::AlignCenter);
    406                     m_pErrorPaneIPv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    407                                                 .pixmap(QSize(iIconMetric, iIconMetric)));
    408                     /* Add into layout: */
    409                     pLayoutIPv4->addWidget(m_pErrorPaneIPv4);
    410                 }
    411                 /* Add into layout: */
    412                 pLayoutInterface->addLayout(pLayoutIPv4, 2, 2);
    413             }
    414 
    415             /* Create NMv4 network mask label: */
    416             m_pLabelNMv4 = new QLabel;
    417             AssertPtrReturnVoid(m_pLabelNMv4);
    418             {
    419                 /* Configure label: */
    420                 m_pLabelNMv4->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    421                 /* Add into layout: */
    422                 pLayoutInterface->addWidget(m_pLabelNMv4, 3, 1);
    423             }
    424             /* Create NMv4 layout: */
    425             QHBoxLayout *pLayoutNMv4 = new QHBoxLayout;
    426             AssertPtrReturnVoid(pLayoutNMv4);
    427             {
    428                 /* Configure layout: */
    429                 pLayoutNMv4->setContentsMargins(0, 0, 0, 0);
    430                 /* Create NMv4 network mask editor: */
    431                 m_pEditorNMv4 = new QILineEdit;
    432                 AssertPtrReturnVoid(m_pEditorNMv4);
    433                 {
    434                     /* Configure editor: */
    435                     m_pLabelNMv4->setBuddy(m_pEditorNMv4);
    436                     connect(m_pEditorNMv4, &QLineEdit::textChanged,
    437                             this, &UIHostNetworkDetailsWidget::sltTextChangedNMv4);
    438                     /* Add into layout: */
    439                     pLayoutNMv4->addWidget(m_pEditorNMv4);
    440                 }
    441                 /* Create NMv4 error pane: */
    442                 m_pErrorPaneNMv4 = new QLabel;
    443                 AssertPtrReturnVoid(m_pErrorPaneNMv4);
    444                 {
    445                     /* Configure label: */
    446                     m_pErrorPaneNMv4->setAlignment(Qt::AlignCenter);
    447                     m_pErrorPaneNMv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    448                                                 .pixmap(QSize(iIconMetric, iIconMetric)));
    449                     /* Add into layout: */
    450                     pLayoutNMv4->addWidget(m_pErrorPaneNMv4);
    451                 }
    452                 /* Add into layout: */
    453                 pLayoutInterface->addLayout(pLayoutNMv4, 3, 2);
    454             }
    455 
    456             /* Create IPv6 address label: */
    457             m_pLabelIPv6 = new QLabel;
    458             AssertPtrReturnVoid(m_pLabelIPv6);
    459             {
    460                 /* Configure label: */
    461                 m_pLabelIPv6->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    462                 /* Add into layout: */
    463                 pLayoutInterface->addWidget(m_pLabelIPv6, 4, 1);
    464             }
    465             /* Create IPv6 layout: */
    466             QHBoxLayout *pLayoutIPv6 = new QHBoxLayout;
    467             AssertPtrReturnVoid(pLayoutIPv6);
    468             {
    469                 /* Configure layout: */
    470                 pLayoutIPv6->setContentsMargins(0, 0, 0, 0);
    471                 /* Create IPv6 address editor: */
    472                 m_pEditorIPv6 = new QILineEdit;
    473                 AssertPtrReturnVoid(m_pEditorIPv6);
    474                 {
    475                     /* Configure editor: */
    476                     m_pLabelIPv6->setBuddy(m_pEditorIPv6);
    477                     connect(m_pEditorIPv6, &QLineEdit::textChanged,
    478                             this, &UIHostNetworkDetailsWidget::sltTextChangedIPv6);
    479                     /* Add into layout: */
    480                     pLayoutIPv6->addWidget(m_pEditorIPv6);
    481                 }
    482                 /* Create IPv4 error pane: */
    483                 m_pErrorPaneIPv6 = new QLabel;
    484                 AssertPtrReturnVoid(m_pErrorPaneIPv6);
    485                 {
    486                     /* Configure label: */
    487                     m_pErrorPaneIPv6->setAlignment(Qt::AlignCenter);
    488                     m_pErrorPaneIPv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    489                                                 .pixmap(QSize(iIconMetric, iIconMetric)));
    490                     /* Add into layout: */
    491                     pLayoutIPv6->addWidget(m_pErrorPaneIPv6);
    492                 }
    493                 /* Add into layout: */
    494                 pLayoutInterface->addLayout(pLayoutIPv6, 4, 2);
    495             }
    496 
    497             /* Create NMv6 network mask label: */
    498             m_pLabelNMv6 = new QLabel;
    499             AssertPtrReturnVoid(m_pLabelNMv6);
    500             {
    501                 /* Configure label: */
    502                 m_pLabelNMv6->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    503                 /* Add into layout: */
    504                 pLayoutInterface->addWidget(m_pLabelNMv6, 5, 1);
    505             }
    506             /* Create NMv6 layout: */
    507             QHBoxLayout *pLayoutNMv6 = new QHBoxLayout;
    508             AssertPtrReturnVoid(pLayoutNMv6);
    509             {
    510                 /* Configure layout: */
    511                 pLayoutNMv6->setContentsMargins(0, 0, 0, 0);
    512                 /* Create NMv6 network mask editor: */
    513                 m_pEditorNMv6 = new QILineEdit;
    514                 AssertPtrReturnVoid(m_pEditorNMv6);
    515                 {
    516                     /* Configure editor: */
    517                     m_pLabelNMv6->setBuddy(m_pEditorNMv6);
    518                     connect(m_pEditorNMv6, &QLineEdit::textChanged,
    519                             this, &UIHostNetworkDetailsWidget::sltTextChangedNMv6);
    520                     /* Add into layout: */
    521                     pLayoutNMv6->addWidget(m_pEditorNMv6);
    522                 }
    523                 /* Create NMv6 error pane: */
    524                 m_pErrorPaneNMv6 = new QLabel;
    525                 AssertPtrReturnVoid(m_pErrorPaneNMv6);
    526                 {
    527                     /* Configure label: */
    528                     m_pErrorPaneNMv6->setAlignment(Qt::AlignCenter);
    529                     m_pErrorPaneNMv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    530                                                 .pixmap(QSize(iIconMetric, iIconMetric)));
    531                     /* Add into layout: */
    532                     pLayoutNMv6->addWidget(m_pErrorPaneNMv6);
    533                 }
    534                 /* Add into layout: */
    535                 pLayoutInterface->addLayout(pLayoutNMv6, 5, 2);
    536             }
    537 
    538             /* Create indent: */
    539             QStyleOption options;
    540             options.initFrom(m_pButtonManual);
    541             const int iWidth = m_pButtonManual->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pButtonManual) +
    542                                m_pButtonManual->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pButtonManual) -
    543                                pLayoutInterface->spacing() - 1;
    544             QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
    545             AssertPtrReturnVoid(pSpacer1);
    546             {
    547                 /* Add into layout: */
    548                 pLayoutInterface->addItem(pSpacer1, 2, 0, 4);
    549             }
    550             /* Create stretch: */
    551             QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    552             AssertPtrReturnVoid(pSpacer2);
    553             {
    554                 /* Add into layout: */
    555                 pLayoutInterface->addItem(pSpacer2, 6, 0, 1, 3);
    556             }
    557 
    558             /* If parent embedded into stack: */
    559             if (m_enmEmbedding == EmbedTo_Stack)
    560             {
    561                 /* Create button-box: */
    562                 m_pButtonBoxInterface = new QIDialogButtonBox;
    563                 AssertPtrReturnVoid(m_pButtonBoxInterface);
    564                 /* Configure button-box: */
    565                 m_pButtonBoxInterface->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    566                 connect(m_pButtonBoxInterface, &QIDialogButtonBox::clicked, this, &UIHostNetworkDetailsWidget::sltHandleButtonBoxClick);
    567 
    568                 /* Add into layout: */
    569                 pLayoutInterface->addWidget(m_pButtonBoxInterface, 7, 0, 1, 3);
    570             }
    571         }
    572         /* Add to tab-widget: */
    573         m_pTabWidget->addTab(pTabInterface, QString());
    574     }
    575 }
    576 
    577 void UIHostNetworkDetailsWidget::prepareTabDHCPServer()
    578 {
    579     /* Create 'DHCP server' tab: */
    580     QWidget *pTabDHCPServer = new QWidget;
    581     AssertPtrReturnVoid(pTabDHCPServer);
    582     {
    583         /* Create 'DHCP server' layout: */
    584         QGridLayout *pLayoutDHCPServer = new QGridLayout(pTabDHCPServer);
    585         AssertPtrReturnVoid(pLayoutDHCPServer);
    586         {
    587 #ifdef VBOX_WS_MAC
    588             /* Configure layout: */
    589             pLayoutDHCPServer->setSpacing(10);
    590             pLayoutDHCPServer->setContentsMargins(10, 10, 10, 10);
    591 #endif
    592 
    593             /* Get the required icon metric: */
    594             const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    595 
    596             /* Create DHCP server status check-box: */
    597             m_pCheckBoxDHCP = new QCheckBox;
    598             AssertPtrReturnVoid(m_pCheckBoxDHCP);
    599             {
    600                 /* Configure check-box: */
    601                 connect(m_pCheckBoxDHCP, &QCheckBox::stateChanged,
    602                         this, &UIHostNetworkDetailsWidget::sltStatusChangedServer);
    603                 /* Add into layout: */
    604                 pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2);
    605 #ifdef VBOX_WS_MAC
    606                 pLayoutDHCPServer->setRowMinimumHeight(0, 22);
    607 #endif
    608             }
    609 
    610             /* Create DHCP address label: */
    611             m_pLabelDHCPAddress = new QLabel;
    612             AssertPtrReturnVoid(m_pLabelDHCPAddress);
    613             {
    614                 /* Configure label: */
    615                 m_pLabelDHCPAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    616                 /* Add into layout: */
    617                 pLayoutDHCPServer->addWidget(m_pLabelDHCPAddress, 1, 1);
    618             }
    619             /* Create DHCP address layout: */
    620             QHBoxLayout *pLayoutDHCPAddress = new QHBoxLayout;
    621             AssertPtrReturnVoid(pLayoutDHCPAddress);
    622             {
    623                 /* Configure layout: */
    624                 pLayoutDHCPAddress->setContentsMargins(0, 0, 0, 0);
    625                 /* Create DHCP address editor: */
    626                 m_pEditorDHCPAddress = new QILineEdit;
    627                 AssertPtrReturnVoid(m_pEditorDHCPAddress);
    628                 {
    629                     /* Configure editor: */
    630                     m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress);
    631                     connect(m_pEditorDHCPAddress, &QLineEdit::textChanged,
    632                             this, &UIHostNetworkDetailsWidget::sltTextChangedAddress);
    633                     /* Add into layout: */
    634                     pLayoutDHCPAddress->addWidget(m_pEditorDHCPAddress);
    635                 }
    636                 /* Create DHCP address error pane: */
    637                 m_pErrorPaneDHCPAddress = new QLabel;
    638                 AssertPtrReturnVoid(m_pErrorPaneDHCPAddress);
    639                 {
    640                     /* Configure label: */
    641                     m_pErrorPaneDHCPAddress->setAlignment(Qt::AlignCenter);
    642                     m_pErrorPaneDHCPAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    643                                                        .pixmap(QSize(iIconMetric, iIconMetric)));
    644                     /* Add into layout: */
    645                     pLayoutDHCPAddress->addWidget(m_pErrorPaneDHCPAddress);
    646                 }
    647                 /* Add into layout: */
    648                 pLayoutDHCPServer->addLayout(pLayoutDHCPAddress, 1, 2);
    649             }
    650 
    651             /* Create DHCP network mask label: */
    652             m_pLabelDHCPMask = new QLabel;
    653             AssertPtrReturnVoid(m_pLabelDHCPMask);
    654             {
    655                 /* Configure label: */
    656                 m_pLabelDHCPMask->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    657                 /* Add into layout: */
    658                 pLayoutDHCPServer->addWidget(m_pLabelDHCPMask, 2, 1);
    659             }
    660             /* Create DHCP mask layout: */
    661             QHBoxLayout *pLayoutDHCPMask = new QHBoxLayout;
    662             AssertPtrReturnVoid(pLayoutDHCPMask);
    663             {
    664                 /* Configure layout: */
    665                 pLayoutDHCPMask->setContentsMargins(0, 0, 0, 0);
    666                 /* Create DHCP network mask editor: */
    667                 m_pEditorDHCPMask = new QILineEdit;
    668                 AssertPtrReturnVoid(m_pEditorDHCPMask);
    669                 {
    670                     /* Configure editor: */
    671                     m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask);
    672                     connect(m_pEditorDHCPMask, &QLineEdit::textChanged,
    673                             this, &UIHostNetworkDetailsWidget::sltTextChangedMask);
    674                     /* Add into layout: */
    675                     pLayoutDHCPMask->addWidget(m_pEditorDHCPMask);
    676                 }
    677                 /* Create DHCP mask error pane: */
    678                 m_pErrorPaneDHCPMask = new QLabel;
    679                 AssertPtrReturnVoid(m_pErrorPaneDHCPMask);
    680                 {
    681                     /* Configure label: */
    682                     m_pErrorPaneDHCPMask->setAlignment(Qt::AlignCenter);
    683                     m_pErrorPaneDHCPMask->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    684                                                     .pixmap(QSize(iIconMetric, iIconMetric)));
    685                     /* Add into layout: */
    686                     pLayoutDHCPMask->addWidget(m_pErrorPaneDHCPMask);
    687                 }
    688                 /* Add into layout: */
    689                 pLayoutDHCPServer->addLayout(pLayoutDHCPMask, 2, 2);
    690             }
    691 
    692             /* Create DHCP lower address label: */
    693             m_pLabelDHCPLowerAddress = new QLabel;
    694             AssertPtrReturnVoid(m_pLabelDHCPLowerAddress);
    695             {
    696                 /* Configure label: */
    697                 m_pLabelDHCPLowerAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    698                 /* Add into layout: */
    699                 pLayoutDHCPServer->addWidget(m_pLabelDHCPLowerAddress, 3, 1);
    700             }
    701             /* Create DHCP lower address layout: */
    702             QHBoxLayout *pLayoutDHCPLowerAddress = new QHBoxLayout;
    703             AssertPtrReturnVoid(pLayoutDHCPLowerAddress);
    704             {
    705                 /* Configure layout: */
    706                 pLayoutDHCPLowerAddress->setContentsMargins(0, 0, 0, 0);
    707                 /* Create DHCP lower address editor: */
    708                 m_pEditorDHCPLowerAddress = new QILineEdit;
    709                 AssertPtrReturnVoid(m_pEditorDHCPLowerAddress);
    710                 {
    711                     /* Configure editor: */
    712                     m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress);
    713                     connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged,
    714                             this, &UIHostNetworkDetailsWidget::sltTextChangedLowerAddress);
    715                     /* Add into layout: */
    716                     pLayoutDHCPLowerAddress->addWidget(m_pEditorDHCPLowerAddress);
    717                 }
    718                 /* Create DHCP lower address error pane: */
    719                 m_pErrorPaneDHCPLowerAddress = new QLabel;
    720                 AssertPtrReturnVoid(m_pErrorPaneDHCPLowerAddress);
    721                 {
    722                     /* Configure label: */
    723                     m_pErrorPaneDHCPLowerAddress->setAlignment(Qt::AlignCenter);
    724                     m_pErrorPaneDHCPLowerAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    725                                                             .pixmap(QSize(iIconMetric, iIconMetric)));
    726                     /* Add into layout: */
    727                     pLayoutDHCPLowerAddress->addWidget(m_pErrorPaneDHCPLowerAddress);
    728                 }
    729                 /* Add into layout: */
    730                 pLayoutDHCPServer->addLayout(pLayoutDHCPLowerAddress, 3, 2);
    731             }
    732 
    733             /* Create DHCP upper address label: */
    734             m_pLabelDHCPUpperAddress = new QLabel;
    735             AssertPtrReturnVoid(m_pLabelDHCPUpperAddress);
    736             {
    737                 /* Configure label: */
    738                 m_pLabelDHCPUpperAddress->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    739                 /* Add into layout: */
    740                 pLayoutDHCPServer->addWidget(m_pLabelDHCPUpperAddress, 4, 1);
    741             }
    742             /* Create DHCP upper address layout: */
    743             QHBoxLayout *pLayoutDHCPUpperAddress = new QHBoxLayout;
    744             AssertPtrReturnVoid(pLayoutDHCPUpperAddress);
    745             {
    746                 /* Configure layout: */
    747                 pLayoutDHCPUpperAddress->setContentsMargins(0, 0, 0, 0);
    748                 /* Create DHCP upper address editor: */
    749                 m_pEditorDHCPUpperAddress = new QILineEdit;
    750                 AssertPtrReturnVoid(m_pEditorDHCPUpperAddress);
    751                 {
    752                     /* Configure editor: */
    753                     m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress);
    754                     connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged,
    755                             this, &UIHostNetworkDetailsWidget::sltTextChangedUpperAddress);
    756                     /* Add into layout: */
    757                     pLayoutDHCPUpperAddress->addWidget(m_pEditorDHCPUpperAddress);
    758                 }
    759                 /* Create DHCP upper address error pane: */
    760                 m_pErrorPaneDHCPUpperAddress = new QLabel;
    761                 AssertPtrReturnVoid(m_pErrorPaneDHCPUpperAddress);
    762                 {
    763                     /* Configure label: */
    764                     m_pErrorPaneDHCPUpperAddress->setAlignment(Qt::AlignCenter);
    765                     m_pErrorPaneDHCPUpperAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
    766                                                             .pixmap(QSize(iIconMetric, iIconMetric)));
    767                     /* Add into layout: */
    768                     pLayoutDHCPUpperAddress->addWidget(m_pErrorPaneDHCPUpperAddress);
    769                 }
    770                 /* Add into layout: */
    771                 pLayoutDHCPServer->addLayout(pLayoutDHCPUpperAddress, 4, 2);
    772             }
    773 
    774             /* Create indent: */
    775             QStyleOption options;
    776             options.initFrom(m_pCheckBoxDHCP);
    777             const int iWidth = m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_IndicatorWidth, &options, m_pCheckBoxDHCP) +
    778                                m_pCheckBoxDHCP->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &options, m_pCheckBoxDHCP) -
    779                                pLayoutDHCPServer->spacing() - 1;
    780             QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
    781             AssertPtrReturnVoid(pSpacer1);
    782             {
    783                 /* Add into layout: */
    784                 pLayoutDHCPServer->addItem(pSpacer1, 1, 0, 4);
    785             }
    786             /* Create stretch: */
    787             QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    788             AssertPtrReturnVoid(pSpacer2);
    789             {
    790                 /* Add into layout: */
    791                 pLayoutDHCPServer->addItem(pSpacer2, 5, 0, 1, 3);
    792             }
    793 
    794             /* If parent embedded into stack: */
    795             if (m_enmEmbedding == EmbedTo_Stack)
    796             {
    797                 /* Create button-box: */
    798                 m_pButtonBoxServer = new QIDialogButtonBox;
    799                 AssertPtrReturnVoid(m_pButtonBoxServer);
    800                 /* Configure button-box: */
    801                 m_pButtonBoxServer->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    802                 connect(m_pButtonBoxServer, &QIDialogButtonBox::clicked, this, &UIHostNetworkDetailsWidget::sltHandleButtonBoxClick);
    803 
    804                 /* Add into layout: */
    805                 pLayoutDHCPServer->addWidget(m_pButtonBoxServer, 6, 0, 1, 3);
    806             }
    807         }
    808         /* Add to tab-widget: */
    809         m_pTabWidget->addTab(pTabDHCPServer, QString());
    810     }
    811 }
    812 
    813 void UIHostNetworkDetailsWidget::loadDataForInterface()
    814 {
    815     /* Toggle IPv4 & IPv6 interface fields availability: */
    816     const bool fIsInterfaceConfigurable = !m_newData.m_interface.m_fDHCPEnabled;
    817     m_pLabelIPv4->setEnabled(fIsInterfaceConfigurable);
    818     m_pLabelNMv4->setEnabled(fIsInterfaceConfigurable);
    819     m_pEditorIPv4->setEnabled(fIsInterfaceConfigurable);
    820     m_pEditorNMv4->setEnabled(fIsInterfaceConfigurable);
    821 
    822     /* Load IPv4 interface fields: */
    823     m_pButtonAutomatic->setChecked(!fIsInterfaceConfigurable);
    824     m_pButtonManual->setChecked(fIsInterfaceConfigurable);
    825     m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress);
    826     m_pEditorNMv4->setText(m_newData.m_interface.m_strMask);
    827 
    828     /* Toggle IPv6 interface fields availability: */
    829     const bool fIsIpv6Configurable = fIsInterfaceConfigurable && m_newData.m_interface.m_fSupportedIPv6;
    830     m_pLabelIPv6->setEnabled(fIsIpv6Configurable);
    831     m_pLabelNMv6->setEnabled(fIsIpv6Configurable);
    832     m_pEditorIPv6->setEnabled(fIsIpv6Configurable);
    833     m_pEditorNMv6->setEnabled(fIsIpv6Configurable);
    834 
    835     /* Load IPv6 interface fields: */
    836     m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6);
    837     m_pEditorNMv6->setText(m_newData.m_interface.m_strPrefixLength6);
    838 }
    839 
    840 void UIHostNetworkDetailsWidget::loadDataForDHCPServer()
    841 {
    842     /* Toggle DHCP server fields availability: */
    843     const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled;
    844     m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled);
    845     m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled);
    846     m_pLabelDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
    847     m_pLabelDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
    848     m_pEditorDHCPAddress->setEnabled(fIsDHCPServerEnabled);
    849     m_pEditorDHCPMask->setEnabled(fIsDHCPServerEnabled);
    850     m_pEditorDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
    851     m_pEditorDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
    852 
    853     /* Load DHCP server fields: */
    854     m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled);
    855     m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress);
    856     m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask);
    857     m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
    858     m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
    859 
    860     /* Invent default values if server was enabled
    861      * but at least one current value is invalid: */
    862     if (   fIsDHCPServerEnabled
    863         && (   m_pEditorDHCPAddress->text().isEmpty()
    864             || m_pEditorDHCPAddress->text() == "0.0.0.0"
    865             || m_pEditorDHCPMask->text().isEmpty()
    866             || m_pEditorDHCPMask->text() == "0.0.0.0"
    867             || m_pEditorDHCPLowerAddress->text().isEmpty()
    868             || m_pEditorDHCPLowerAddress->text() == "0.0.0.0"
    869             || m_pEditorDHCPUpperAddress->text().isEmpty()
    870             || m_pEditorDHCPUpperAddress->text() == "0.0.0.0"))
    871     {
    872         const QStringList &proposal = makeDhcpServerProposal(m_oldData.m_interface.m_strAddress,
    873                                                              m_oldData.m_interface.m_strMask);
    874         m_pEditorDHCPAddress->setText(proposal.at(0));
    875         m_pEditorDHCPMask->setText(proposal.at(1));
    876         m_pEditorDHCPLowerAddress->setText(proposal.at(2));
    877         m_pEditorDHCPUpperAddress->setText(proposal.at(3));
    878     }
    879 }
    880 
    881 void UIHostNetworkDetailsWidget::revalidate(QWidget *pWidget /* = 0 */)
    882 {
    883     /* Validate 'Interface' tab content: */
    884     if (!pWidget || pWidget == m_pErrorPaneAutomatic)
    885     {
    886         const bool fError =    m_newData.m_interface.m_fDHCPEnabled
    887                             && !m_newData.m_dhcpserver.m_fEnabled;
    888         m_pErrorPaneAutomatic->setVisible(fError);
    889     }
    890     if (!pWidget || pWidget == m_pErrorPaneManual)
    891     {
    892         const bool fError = false;
    893         m_pErrorPaneManual->setVisible(fError);
    894     }
    895     if (!pWidget || pWidget == m_pErrorPaneIPv4)
    896     {
    897         const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
    898                             && !m_newData.m_interface.m_strAddress.trimmed().isEmpty()
    899                             && (   !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strAddress.toUtf8().constData())
    900                                 || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strAddress.toUtf8().constData()));
    901         m_pErrorPaneIPv4->setVisible(fError);
    902     }
    903     if (!pWidget || pWidget == m_pErrorPaneNMv4)
    904     {
    905         const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
    906                             && !m_newData.m_interface.m_strMask.trimmed().isEmpty()
    907                             && (   !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strMask.toUtf8().constData())
    908                                 || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strMask.toUtf8().constData()));
    909         m_pErrorPaneNMv4->setVisible(fError);
    910     }
    911     if (!pWidget || pWidget == m_pErrorPaneIPv6)
    912     {
    913         const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
    914                             && m_newData.m_interface.m_fSupportedIPv6
    915                             && !m_newData.m_interface.m_strAddress6.trimmed().isEmpty()
    916                             && (   !RTNetIsIPv6AddrStr(m_newData.m_interface.m_strAddress6.toUtf8().constData())
    917                                 || RTNetStrIsIPv6AddrAny(m_newData.m_interface.m_strAddress6.toUtf8().constData()));
    918         m_pErrorPaneIPv6->setVisible(fError);
    919     }
    920     if (!pWidget || pWidget == m_pErrorPaneNMv6)
    921     {
    922         bool fIsMaskPrefixLengthNumber = false;
    923         const int iMaskPrefixLength = m_newData.m_interface.m_strPrefixLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber);
    924         const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
    925                             && m_newData.m_interface.m_fSupportedIPv6
    926                             && (   !fIsMaskPrefixLengthNumber
    927                                 || iMaskPrefixLength < 0
    928                                 || iMaskPrefixLength > 128);
    929         m_pErrorPaneNMv6->setVisible(fError);
    930     }
    931 
    932     /* Validate 'DHCP server' tab content: */
    933     if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
    934     {
    935         const bool fError =    m_newData.m_dhcpserver.m_fEnabled
    936                             && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData())
    937                                 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData()));
    938         m_pErrorPaneDHCPAddress->setVisible(fError);
    939     }
    940     if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
    941     {
    942         const bool fError =    m_newData.m_dhcpserver.m_fEnabled
    943                             && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strMask.toUtf8().constData())
    944                                 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strMask.toUtf8().constData()));
    945         m_pErrorPaneDHCPMask->setVisible(fError);
    946     }
    947     if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
    948     {
    949         const bool fError =    m_newData.m_dhcpserver.m_fEnabled
    950                             && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData())
    951                                 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData()));
    952         m_pErrorPaneDHCPLowerAddress->setVisible(fError);
    953     }
    954     if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
    955     {
    956         const bool fError =    m_newData.m_dhcpserver.m_fEnabled
    957                             && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData())
    958                                 || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()));
    959         m_pErrorPaneDHCPUpperAddress->setVisible(fError);
    960     }
     126    /// @todo validate profile settings table!
    961127
    962128    /* Retranslate validation: */
     
    964130}
    965131
    966 void UIHostNetworkDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */)
     132void UICloudProfileDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */)
    967133{
    968     /* Translate 'Interface' tab content: */
    969     if (!pWidget || pWidget == m_pErrorPaneAutomatic)
    970         m_pErrorPaneAutomatic->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> is set to obtain the address automatically "
    971                                              "but the corresponding DHCP server is not enabled.").arg(m_newData.m_interface.m_strName));
    972     if (!pWidget || pWidget == m_pErrorPaneIPv4)
    973         m_pErrorPaneIPv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    974                                         "IPv4 address.").arg(m_newData.m_interface.m_strName));
    975     if (!pWidget || pWidget == m_pErrorPaneNMv4)
    976         m_pErrorPaneNMv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    977                                         "IPv4 network mask.").arg(m_newData.m_interface.m_strName));
    978     if (!pWidget || pWidget == m_pErrorPaneIPv6)
    979         m_pErrorPaneIPv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    980                                         "IPv6 address.").arg(m_newData.m_interface.m_strName));
    981     if (!pWidget || pWidget == m_pErrorPaneNMv6)
    982         m_pErrorPaneNMv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    983                                         "IPv6 prefix length.").arg(m_newData.m_interface.m_strName));
     134    Q_UNUSED(pWidget);
    984135
    985     /* Translate 'DHCP server' tab content: */
    986     if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
    987         m_pErrorPaneDHCPAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    988                                                "DHCP server address.").arg(m_newData.m_interface.m_strName));
    989     if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
    990         m_pErrorPaneDHCPMask->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    991                                             "DHCP server mask.").arg(m_newData.m_interface.m_strName));
    992     if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
    993         m_pErrorPaneDHCPLowerAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    994                                                     "DHCP server lower address bound.").arg(m_newData.m_interface.m_strName));
    995     if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
    996         m_pErrorPaneDHCPUpperAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    997                                                     "DHCP server upper address bound.").arg(m_newData.m_interface.m_strName));
     136    /// @todo retranslate profile settings vaidation!
    998137}
    999138
    1000 void UIHostNetworkDetailsWidget::updateButtonStates()
     139void UICloudProfileDetailsWidget::updateButtonStates()
    1001140{
    1002 //    if (m_oldData != m_newData)
    1003 //        printf("Interface: %s, %s, %s, %s;  DHCP server: %d, %s, %s, %s, %s\n",
    1004 //               m_newData.m_interface.m_strAddress.toUtf8().constData(),
    1005 //               m_newData.m_interface.m_strMask.toUtf8().constData(),
    1006 //               m_newData.m_interface.m_strAddress6.toUtf8().constData(),
    1007 //               m_newData.m_interface.m_strPrefixLength6.toUtf8().constData(),
    1008 //               (int)m_newData.m_dhcpserver.m_fEnabled,
    1009 //               m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(),
    1010 //               m_newData.m_dhcpserver.m_strMask.toUtf8().constData(),
    1011 //               m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(),
    1012 //               m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData());
     141    /// @todo update that printf as well!
     142#if 0
     143    if (m_oldData != m_newData)
     144        printf("Interface: %s, %s, %s, %s;  DHCP server: %d, %s, %s, %s, %s\n",
     145               m_newData.m_interface.m_strAddress.toUtf8().constData(),
     146               m_newData.m_interface.m_strMask.toUtf8().constData(),
     147               m_newData.m_interface.m_strAddress6.toUtf8().constData(),
     148               m_newData.m_interface.m_strPrefixLength6.toUtf8().constData(),
     149               (int)m_newData.m_dhcpserver.m_fEnabled,
     150               m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(),
     151               m_newData.m_dhcpserver.m_strMask.toUtf8().constData(),
     152               m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(),
     153               m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData());
     154#endif
    1013155
    1014156    /* Update 'Apply' / 'Reset' button states: */
    1015     if (m_pButtonBoxInterface)
     157    if (m_pButtonBox)
    1016158    {
    1017         m_pButtonBoxInterface->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
    1018         m_pButtonBoxInterface->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
    1019     }
    1020     if (m_pButtonBoxServer)
    1021     {
    1022         m_pButtonBoxServer->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
    1023         m_pButtonBoxServer->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
     159        m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
     160        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
    1024161    }
    1025162
     
    1027164    emit sigDataChanged(m_oldData != m_newData);
    1028165}
    1029 
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.h

    r74811 r74853  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIHostNetworkDetailsWidget class declaration.
     3 * VBox Qt GUI - UICloudProfileDetailsWidget class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef ___UIHostNetworkDetailsWidget_h___
    19 #define ___UIHostNetworkDetailsWidget_h___
     18#ifndef ___UICloudProfileDetailsWidget_h___
     19#define ___UICloudProfileDetailsWidget_h___
    2020
    2121/* Qt includes: */
     
    2828/* Forward declarations: */
    2929class QAbstractButton;
    30 class QCheckBox;
    31 class QLabel;
    32 class QRadioButton;
     30class QTableWidget;
    3331class QIDialogButtonBox;
    34 class QILineEdit;
    35 class QITabWidget;
    3632
    3733
    38 /** Host Network Manager: Host Network Interface data structure. */
    39 struct UIDataHostNetworkInterface
     34/** Cloud Profile data structure. */
     35struct UIDataCloudProfile
    4036{
    4137    /** Constructs data. */
    42     UIDataHostNetworkInterface()
     38    UIDataCloudProfile()
    4339        : m_strName(QString())
    44         , m_fDHCPEnabled(false)
    45         , m_strAddress(QString())
    46         , m_strMask(QString())
    47         , m_fSupportedIPv6(false)
    48         , m_strAddress6(QString())
    49         , m_strPrefixLength6(QString())
    5040    {}
    5141
    5242    /** Returns whether the @a other passed data is equal to this one. */
    53     bool equal(const UIDataHostNetworkInterface &other) const
     43    bool equal(const UIDataCloudProfile &other) const
    5444    {
    5545        return true
    5646               && (m_strName == other.m_strName)
    57                && (m_fDHCPEnabled == other.m_fDHCPEnabled)
    58                && (m_strAddress == other.m_strAddress)
    59                && (m_strMask == other.m_strMask)
    60                && (m_fSupportedIPv6 == other.m_fSupportedIPv6)
    61                && (m_strAddress6 == other.m_strAddress6)
    62                && (m_strPrefixLength6 == other.m_strPrefixLength6)
    6347               ;
    6448    }
    6549
    6650    /** Returns whether the @a other passed data is equal to this one. */
    67     bool operator==(const UIDataHostNetworkInterface &other) const { return equal(other); }
     51    bool operator==(const UIDataCloudProfile &other) const { return equal(other); }
    6852    /** Returns whether the @a other passed data is different from this one. */
    69     bool operator!=(const UIDataHostNetworkInterface &other) const { return !equal(other); }
     53    bool operator!=(const UIDataCloudProfile &other) const { return !equal(other); }
    7054
    71     /** Holds interface name. */
    72     QString m_strName;
    73     /** Holds whether DHCP is enabled for that interface. */
    74     bool m_fDHCPEnabled;
    75     /** Holds IPv4 interface address. */
    76     QString m_strAddress;
    77     /** Holds IPv4 interface mask. */
    78     QString m_strMask;
    79     /** Holds whether IPv6 protocol supported. */
    80     bool m_fSupportedIPv6;
    81     /** Holds IPv6 interface address. */
    82     QString m_strAddress6;
    83     /** Holds IPv6 interface prefix length. */
    84     QString m_strPrefixLength6;
     55    /** Holds the snapshot name. */
     56    QString  m_strName;
    8557};
    8658
    8759
    88 /** Host Network Manager: DHCP Server data structure. */
    89 struct UIDataDHCPServer
    90 {
    91     /** Constructs data. */
    92     UIDataDHCPServer()
    93         : m_fEnabled(false)
    94         , m_strAddress(QString())
    95         , m_strMask(QString())
    96         , m_strLowerAddress(QString())
    97         , m_strUpperAddress(QString())
    98     {}
    99 
    100     /** Returns whether the @a other passed data is equal to this one. */
    101     bool equal(const UIDataDHCPServer &other) const
    102     {
    103         return true
    104                && (m_fEnabled == other.m_fEnabled)
    105                && (m_strAddress == other.m_strAddress)
    106                && (m_strMask == other.m_strMask)
    107                && (m_strLowerAddress == other.m_strLowerAddress)
    108                && (m_strUpperAddress == other.m_strUpperAddress)
    109                ;
    110     }
    111 
    112     /** Returns whether the @a other passed data is equal to this one. */
    113     bool operator==(const UIDataDHCPServer &other) const { return equal(other); }
    114     /** Returns whether the @a other passed data is different from this one. */
    115     bool operator!=(const UIDataDHCPServer &other) const { return !equal(other); }
    116 
    117     /** Holds whether DHCP server enabled. */
    118     bool m_fEnabled;
    119     /** Holds DHCP server address. */
    120     QString m_strAddress;
    121     /** Holds DHCP server mask. */
    122     QString m_strMask;
    123     /** Holds DHCP server lower address. */
    124     QString m_strLowerAddress;
    125     /** Holds DHCP server upper address. */
    126     QString m_strUpperAddress;
    127 };
    128 
    129 
    130 /** Host Network Manager: Host network data structure. */
    131 struct UIDataHostNetwork
    132 {
    133     /** Constructs data. */
    134     UIDataHostNetwork()
    135         : m_interface(UIDataHostNetworkInterface())
    136         , m_dhcpserver(UIDataDHCPServer())
    137     {}
    138 
    139     /** Returns whether the @a other passed data is equal to this one. */
    140     bool equal(const UIDataHostNetwork &other) const
    141     {
    142         return true
    143                && (m_interface == other.m_interface)
    144                && (m_dhcpserver == other.m_dhcpserver)
    145                ;
    146     }
    147 
    148     /** Returns whether the @a other passed data is equal to this one. */
    149     bool operator==(const UIDataHostNetwork &other) const { return equal(other); }
    150     /** Returns whether the @a other passed data is different from this one. */
    151     bool operator!=(const UIDataHostNetwork &other) const { return !equal(other); }
    152 
    153     /** Holds the interface data. */
    154     UIDataHostNetworkInterface m_interface;
    155     /** Holds the DHCP server data. */
    156     UIDataDHCPServer m_dhcpserver;
    157 };
    158 
    159 
    160 /** Host Network Manager: Host network details-widget. */
    161 class UIHostNetworkDetailsWidget : public QIWithRetranslateUI<QWidget>
     60/** Cloud Profile details widget. */
     61class UICloudProfileDetailsWidget : public QIWithRetranslateUI<QWidget>
    16262{
    16363    Q_OBJECT;
     
    17575public:
    17676
    177     /** Constructs medium details dialog passing @a pParent to the base-class.
     77    /** Constructs cloud profile details widget passing @a pParent to the base-class.
    17878      * @param  enmEmbedding  Brings embedding type. */
    179     UIHostNetworkDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0);
     79    UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0);
    18080
    181     /** Returns the host network data. */
    182     const UIDataHostNetwork &data() const { return m_newData; }
    183     /** Defines the host network @a data. */
    184     void setData(const UIDataHostNetwork &data);
     81    /** Returns the cloud profile data. */
     82    const UIDataCloudProfile &data() const { return m_newData; }
     83    /** Defines the cloud profile @a data. */
     84    void setData(const UIDataCloudProfile &data);
    18585
    18686protected:
     
    19393    /** @name Change handling stuff.
    19494      * @{ */
    195         /** Handles interface automatic configuration choice change. */
    196         void sltToggledButtonAutomatic(bool fChecked);
    197         /** Handles interface manual configuration choice change. */
    198         void sltToggledButtonManual(bool fChecked);
    199         /** Handles interface IPv4 text change. */
    200         void sltTextChangedIPv4(const QString &strText);
    201         /** Handles interface NMv4 text change. */
    202         void sltTextChangedNMv4(const QString &strText);
    203         /** Handles interface IPv6 text change. */
    204         void sltTextChangedIPv6(const QString &strText);
    205         /** Handles interface NMv6 text change. */
    206         void sltTextChangedNMv6(const QString &strText);
    207 
    208         /** Handles DHCP server status change. */
    209         void sltStatusChangedServer(int iChecked);
    210         /** Handles DHCP server address text change. */
    211         void sltTextChangedAddress(const QString &strText);
    212         /** Handles DHCP server mask text change. */
    213         void sltTextChangedMask(const QString &strText);
    214         /** Handles DHCP server lower address text change. */
    215         void sltTextChangedLowerAddress(const QString &strText);
    216         /** Handles DHCP server upper address text change. */
    217         void sltTextChangedUpperAddress(const QString &strText);
     95        /** Handles table change. */
     96        void sltTableChanged();
    21897
    21998        /** Handles button-box button click. */
     
    227106        /** Prepares all. */
    228107        void prepare();
    229         /** Prepares this. */
    230         void prepareThis();
    231         /** Prepares tab-widget. */
    232         void prepareTabWidget();
    233         /** Prepares 'Interface' tab. */
    234         void prepareTabInterface();
    235         /** Prepares 'DHCP server' tab. */
    236         void prepareTabDHCPServer();
     108        /** Prepares widgets. */
     109        void prepareWidgets();
    237110    /** @} */
    238111
    239112    /** @name Loading stuff.
    240113      * @{ */
    241         /** Loads interface data. */
    242         void loadDataForInterface();
    243         /** Loads server data. */
    244         void loadDataForDHCPServer();
     114        /** Loads data. */
     115        void loadData();
    245116    /** @} */
    246117
     
    258129      * @{ */
    259130        /** Holds the parent widget embedding type. */
    260         const EmbedTo m_enmEmbedding;
     131        const EmbedTo  m_enmEmbedding;
    261132
    262133        /** Holds the old data copy. */
    263         UIDataHostNetwork  m_oldData;
     134        UIDataCloudProfile  m_oldData;
    264135        /** Holds the new data copy. */
    265         UIDataHostNetwork  m_newData;
    266 
    267         /** Holds the tab-widget. */
    268         QITabWidget *m_pTabWidget;
     136        UIDataCloudProfile  m_newData;
    269137    /** @} */
    270138
     
    272140      * @{ */
    273141        /** Holds the automatic interface configuration button. */
    274         QRadioButton *m_pButtonAutomatic;
    275         /** Holds the automatic interface configuration error pane. */
    276         QLabel       *m_pErrorPaneAutomatic;
    277 
    278         /** Holds the manual interface configuration button. */
    279         QRadioButton *m_pButtonManual;
    280         /** Holds the manual interface configuration error pane. */
    281         QLabel       *m_pErrorPaneManual;
    282 
    283         /** Holds the IPv4 address label. */
    284         QLabel       *m_pLabelIPv4;
    285         /** Holds the IPv4 address editor. */
    286         QILineEdit   *m_pEditorIPv4;
    287         /** Holds the IPv4 address error pane. */
    288         QLabel       *m_pErrorPaneIPv4;
    289 
    290         /** Holds the IPv4 network mask label. */
    291         QLabel       *m_pLabelNMv4;
    292         /** Holds the IPv4 network mask editor. */
    293         QILineEdit   *m_pEditorNMv4;
    294         /** Holds the IPv4 network mask error pane. */
    295         QLabel       *m_pErrorPaneNMv4;
    296 
    297         /** Holds the IPv6 address label. */
    298         QLabel       *m_pLabelIPv6;
    299         /** Holds the IPv6 address editor. */
    300         QILineEdit   *m_pEditorIPv6;
    301         /** Holds the IPv6 address error pane. */
    302         QLabel       *m_pErrorPaneIPv6;
    303 
    304         /** Holds the IPv6 network mask label. */
    305         QLabel       *m_pLabelNMv6;
    306         /** Holds the IPv6 network mask editor. */
    307         QILineEdit   *m_pEditorNMv6;
    308         /** Holds the IPv6 network mask error pane. */
    309         QLabel       *m_pErrorPaneNMv6;
    310 
    311         /** Holds the interface button-box instance. */
    312         QIDialogButtonBox *m_pButtonBoxInterface;
    313     /** @} */
    314 
    315     /** @name DHCP server variables.
    316       * @{ */
    317         /** Holds the DHCP server status chack-box. */
    318         QCheckBox  *m_pCheckBoxDHCP;
    319 
    320         /** Holds the DHCP address label. */
    321         QLabel     *m_pLabelDHCPAddress;
    322         /** Holds the DHCP address editor. */
    323         QILineEdit *m_pEditorDHCPAddress;
    324         /** Holds the DHCP address error pane. */
    325         QLabel     *m_pErrorPaneDHCPAddress;
    326 
    327         /** Holds the DHCP network mask label. */
    328         QLabel     *m_pLabelDHCPMask;
    329         /** Holds the DHCP network mask editor. */
    330         QILineEdit *m_pEditorDHCPMask;
    331         /** Holds the DHCP network mask error pane. */
    332         QLabel     *m_pErrorPaneDHCPMask;
    333 
    334         /** Holds the DHCP lower address label. */
    335         QLabel     *m_pLabelDHCPLowerAddress;
    336         /** Holds the DHCP lower address editor. */
    337         QILineEdit *m_pEditorDHCPLowerAddress;
    338         /** Holds the DHCP lower address error pane. */
    339         QLabel     *m_pErrorPaneDHCPLowerAddress;
    340 
    341         /** Holds the DHCP upper address label. */
    342         QLabel     *m_pLabelDHCPUpperAddress;
    343         /** Holds the DHCP upper address editor. */
    344         QILineEdit *m_pEditorDHCPUpperAddress;
    345         /** Holds the DHCP upper address error pane. */
    346         QLabel     *m_pErrorPaneDHCPUpperAddress;
     142        QTableWidget *m_pTableWidget;
    347143
    348144        /** Holds the server button-box instance. */
    349         QIDialogButtonBox *m_pButtonBoxServer;
     145        QIDialogButtonBox *m_pButtonBox;
    350146    /** @} */
    351147};
    352148
    353 #endif /* !___UIHostNetworkDetailsWidget_h___ */
    354149
     150#endif /* !___UICloudProfileDetailsWidget_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp

    r74811 r74853  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIHostNetworkManager class implementation.
     3 * VBox Qt GUI - UICloudProfileManager class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* Qt includes: */
    23 # include <QHeaderView>
    24 # include <QMenuBar>
    2523# include <QPushButton>
    2624# include <QVBoxLayout>
     
    2927# include "QIDialogButtonBox.h"
    3028# include "QITreeWidget.h"
     29# include "VBoxGlobal.h"
    3130# include "UIActionPoolSelector.h"
    3231# include "UIExtraDataManager.h"
    3332# include "UIIconPool.h"
    34 # include "UIHostNetworkDetailsWidget.h"
    35 # include "UIHostNetworkManager.h"
    36 # include "UIHostNetworkUtils.h"
    37 # include "UIMessageCenter.h"
     33# include "UICloudProfileDetailsWidget.h"
     34# include "UICloudProfileManager.h"
    3835# include "UIToolBar.h"
    3936# ifdef VBOX_WS_MAC
    4037#  include "UIWindowMenuManager.h"
    41 # endif /* VBOX_WS_MAC */
    42 # include "VBoxGlobal.h"
     38# endif
    4339
    4440/* COM includes: */
    45 # include "CDHCPServer.h"
    46 # include "CHost.h"
    47 # include "CHostNetworkInterface.h"
    48 
    49 /* Other VBox includes: */
    50 # include <iprt/cidr.h>
     41#include "CCloudProfile.h"
    5142
    5243#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    5748{
    5849    Column_Name,
    59     Column_IPv4,
    60     Column_IPv6,
    61     Column_DHCP,
     50    /// @todo rest of columns?
    6251    Column_Max,
    6352};
    6453
    6554
    66 /** Host Network Manager: Tree-widget item. */
    67 class UIItemHostNetwork : public QITreeWidgetItem, public UIDataHostNetwork
     55/** Cloud Profile Manager tree-widget item. */
     56class UIItemCloudProfile : public QITreeWidgetItem, public UIDataCloudProfile
    6857{
    6958public:
     
    7362
    7463    /** Returns item name. */
    75     QString name() const { return m_interface.m_strName; }
    76 
    77 private:
    78 
    79     /** Returns CIDR for a passed @a strMask. */
    80     static int maskToCidr(const QString &strMask);
     64    QString name() const { return m_strName; }
    8165};
    8266
    8367
    8468/*********************************************************************************************************************************
    85 *   Class UIItemHostNetwork implementation.                                                                                      *
     69*   Class UIItemCloudProfile implementation.                                                                                     *
    8670*********************************************************************************************************************************/
    8771
    88 void UIItemHostNetwork::updateFields()
     72void UIItemCloudProfile::updateFields()
    8973{
    9074    /* Compose item fields: */
    91     setText(Column_Name, m_interface.m_strName);
    92     setText(Column_IPv4, m_interface.m_strAddress.isEmpty() ? QString() :
    93                          QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask)));
    94     setText(Column_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() :
    95                          QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt()));
    96     setText(Column_DHCP, UIHostNetworkManager::tr("Enable", "DHCP Server"));
    97     setCheckState(Column_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked);
     75    setText(Column_Name, m_strName);
     76    /// @todo assign rest of field values!
    9877
    9978    /* Compose item tool-tip: */
    100     const QString strTable("<table cellspacing=5>%1</table>");
    101     const QString strHeader("<tr><td><nobr>%1:&nbsp;</nobr></td><td><nobr>%2</nobr></td></tr>");
    102     const QString strSubHeader("<tr><td><nobr>&nbsp;&nbsp;%1:&nbsp;</nobr></td><td><nobr>%2</nobr></td></tr>");
    103     QString strToolTip;
    104 
    105     /* Interface information: */
    106     strToolTip += strHeader.arg(UIHostNetworkManager::tr("Adapter"))
    107                            .arg(m_interface.m_fDHCPEnabled ?
    108                                 UIHostNetworkManager::tr("Automatically configured", "interface") :
    109                                 UIHostNetworkManager::tr("Manually configured", "interface"));
    110     strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("IPv4 Address"))
    111                               .arg(m_interface.m_strAddress.isEmpty() ?
    112                                    UIHostNetworkManager::tr ("Not set", "address") :
    113                                    m_interface.m_strAddress) +
    114                   strSubHeader.arg(UIHostNetworkManager::tr("IPv4 Network Mask"))
    115                               .arg(m_interface.m_strMask.isEmpty() ?
    116                                    UIHostNetworkManager::tr ("Not set", "mask") :
    117                                    m_interface.m_strMask);
    118     if (m_interface.m_fSupportedIPv6)
    119     {
    120         strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("IPv6 Address"))
    121                                   .arg(m_interface.m_strAddress6.isEmpty() ?
    122                                        UIHostNetworkManager::tr("Not set", "address") :
    123                                        m_interface.m_strAddress6) +
    124                       strSubHeader.arg(UIHostNetworkManager::tr("IPv6 Prefix Length"))
    125                                   .arg(m_interface.m_strPrefixLength6.isEmpty() ?
    126                                        UIHostNetworkManager::tr("Not set", "length") :
    127                                        m_interface.m_strPrefixLength6);
    128     }
    129 
    130     /* DHCP server information: */
    131     strToolTip += strHeader.arg(UIHostNetworkManager::tr("DHCP Server"))
    132                            .arg(m_dhcpserver.m_fEnabled ?
    133                                 UIHostNetworkManager::tr("Enabled", "server") :
    134                                 UIHostNetworkManager::tr("Disabled", "server"));
    135     if (m_dhcpserver.m_fEnabled)
    136     {
    137         strToolTip += strSubHeader.arg(UIHostNetworkManager::tr("Address"))
    138                                   .arg(m_dhcpserver.m_strAddress.isEmpty() ?
    139                                        UIHostNetworkManager::tr("Not set", "address") :
    140                                        m_dhcpserver.m_strAddress) +
    141                       strSubHeader.arg(UIHostNetworkManager::tr("Network Mask"))
    142                                   .arg(m_dhcpserver.m_strMask.isEmpty() ?
    143                                        UIHostNetworkManager::tr("Not set", "mask") :
    144                                        m_dhcpserver.m_strMask) +
    145                       strSubHeader.arg(UIHostNetworkManager::tr("Lower Bound"))
    146                                   .arg(m_dhcpserver.m_strLowerAddress.isEmpty() ?
    147                                        UIHostNetworkManager::tr("Not set", "bound") :
    148                                        m_dhcpserver.m_strLowerAddress) +
    149                       strSubHeader.arg(UIHostNetworkManager::tr("Upper Bound"))
    150                                   .arg(m_dhcpserver.m_strUpperAddress.isEmpty() ?
    151                                        UIHostNetworkManager::tr("Not set", "bound") :
    152                                        m_dhcpserver.m_strUpperAddress);
    153     }
    154 
    155     /* Assign tool-tip finally: */
    156     setToolTip(Column_Name, strTable.arg(strToolTip));
    157 }
    158 
    159 /* static */
    160 int UIItemHostNetwork::maskToCidr(const QString &strMask)
    161 {
    162     /* Parse passed mask: */
    163     QList<int> address;
    164     foreach (const QString &strValue, strMask.split('.'))
    165         address << strValue.toInt();
    166 
    167     /* Calculate CIDR: */
    168     int iCidr = 0;
    169     for (int i = 0; i < 4 || i < address.size(); ++i)
    170     {
    171         switch(address.at(i))
    172         {
    173             case 0x80: iCidr += 1; break;
    174             case 0xC0: iCidr += 2; break;
    175             case 0xE0: iCidr += 3; break;
    176             case 0xF0: iCidr += 4; break;
    177             case 0xF8: iCidr += 5; break;
    178             case 0xFC: iCidr += 6; break;
    179             case 0xFE: iCidr += 7; break;
    180             case 0xFF: iCidr += 8; break;
    181             /* Return CIDR prematurelly: */
    182             default: return iCidr;
    183         }
    184     }
    185 
    186     /* Return CIDR: */
    187     return iCidr;
     79    /// @todo assign tool-tips!
    18880}
    18981
    19082
    19183/*********************************************************************************************************************************
    192 *   Class UIHostNetworkManagerWidget implementation.                                                                             *
     84*   Class UICloudProfileManagerWidget implementation.                                                                            *
    19385*********************************************************************************************************************************/
    19486
    195 UIHostNetworkManagerWidget::UIHostNetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
    196                                                        bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */)
     87UICloudProfileManagerWidget::UICloudProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
     88                                                         bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */)
    19789    : QIWithRetranslateUI<QWidget>(pParent)
    19890    , m_enmEmbedding(enmEmbedding)
     
    20799}
    208100
    209 QMenu *UIHostNetworkManagerWidget::menu() const
    210 {
    211     return m_pActionPool->action(UIActionIndexST_M_NetworkWindow)->menu();
    212 }
    213 
    214 void UIHostNetworkManagerWidget::retranslateUi()
     101QMenu *UICloudProfileManagerWidget::menu() const
     102{
     103    /// @todo implement menu action!
     104    return 0;
     105}
     106
     107void UICloudProfileManagerWidget::retranslateUi()
    215108{
    216109    /* Adjust toolbar: */
     
    226119
    227120    /* Translate tree-widget: */
    228     const QStringList fields = QStringList()
    229                                << UIHostNetworkManager::tr("Name")
    230                                << UIHostNetworkManager::tr("IPv4 Address/Mask")
    231                                << UIHostNetworkManager::tr("IPv6 Address/Mask")
    232                                << UIHostNetworkManager::tr("DHCP Server");
    233     m_pTreeWidget->setHeaderLabels(fields);
    234 }
    235 
    236 void UIHostNetworkManagerWidget::resizeEvent(QResizeEvent *pEvent)
     121    /// @todo assign tree-widget column names!
     122}
     123
     124void UICloudProfileManagerWidget::resizeEvent(QResizeEvent *pEvent)
    237125{
    238126    /* Call to base-class: */
     
    243131}
    244132
    245 void UIHostNetworkManagerWidget::showEvent(QShowEvent *pEvent)
     133void UICloudProfileManagerWidget::showEvent(QShowEvent *pEvent)
    246134{
    247135    /* Call to base-class: */
     
    252140}
    253141
    254 void UIHostNetworkManagerWidget::sltResetHostNetworkDetailsChanges()
     142void UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges()
    255143{
    256144    /* Just push the current item data there again: */
     
    258146}
    259147
    260 void UIHostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges()
    261 {
    262     /* Get network item: */
    263     UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem());
     148void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges()
     149{
     150    /* Get profile item: */
     151    UIItemCloudProfile *pItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem());
    264152    AssertMsgReturnVoid(pItem, ("Current item must not be null!\n"));
    265153
    266     /* Get item data: */
    267     UIDataHostNetwork oldData = *pItem;
    268     UIDataHostNetwork newData = m_pDetailsWidget->data();
    269 
    270     /* Get host for further activities: */
    271     CHost comHost = vboxGlobal().host();
    272 
    273     /* Find corresponding interface: */
    274     CHostNetworkInterface comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName);
    275 
    276     /* Show error message if necessary: */
    277     if (!comHost.isOk() || comInterface.isNull())
    278         msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this);
    279     else
    280     {
    281         /* Save automatic interface configuration: */
    282         if (newData.m_interface.m_fDHCPEnabled)
    283         {
    284             if (   comInterface.isOk()
    285                 && !oldData.m_interface.m_fDHCPEnabled)
    286                 comInterface.EnableDynamicIPConfig();
    287         }
    288         /* Save manual interface configuration: */
    289         else
    290         {
    291             /* Save IPv4 interface configuration: */
    292             if (   comInterface.isOk()
    293                 && (   oldData.m_interface.m_fDHCPEnabled
    294                     || newData.m_interface.m_strAddress != oldData.m_interface.m_strAddress
    295                     || newData.m_interface.m_strMask != oldData.m_interface.m_strMask))
    296                 comInterface.EnableStaticIPConfig(newData.m_interface.m_strAddress, newData.m_interface.m_strMask);
    297             /* Save IPv6 interface configuration: */
    298             if (   comInterface.isOk()
    299                 && newData.m_interface.m_fSupportedIPv6
    300                 && (   oldData.m_interface.m_fDHCPEnabled
    301                     || newData.m_interface.m_strAddress6 != oldData.m_interface.m_strAddress6
    302                     || newData.m_interface.m_strPrefixLength6 != oldData.m_interface.m_strPrefixLength6))
    303                 comInterface.EnableStaticIPConfigV6(newData.m_interface.m_strAddress6, newData.m_interface.m_strPrefixLength6.toULong());
    304         }
    305 
    306         /* Show error message if necessary: */
    307         if (!comInterface.isOk())
    308             msgCenter().cannotSaveHostNetworkInterfaceParameter(comInterface, this);
    309         else
    310         {
    311             /* Get network name for further activities: */
    312             const QString strNetworkName = comInterface.GetNetworkName();
    313 
    314             /* Show error message if necessary: */
    315             if (!comInterface.isOk())
    316                 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this);
    317             else
    318             {
    319                 /* Get VBox for further activities: */
    320                 CVirtualBox comVBox = vboxGlobal().virtualBox();
    321 
    322                 /* Find corresponding DHCP server (create if necessary): */
    323                 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
    324                 if (!comVBox.isOk() || comServer.isNull())
    325                     comServer = comVBox.CreateDHCPServer(strNetworkName);
    326 
    327                 /* Show error message if necessary: */
    328                 if (!comVBox.isOk() || comServer.isNull())
    329                     msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this);
    330                 else
    331                 {
    332                     /* Save whether DHCP server is enabled: */
    333                     if (   comServer.isOk()
    334                         && newData.m_dhcpserver.m_fEnabled != oldData.m_dhcpserver.m_fEnabled)
    335                         comServer.SetEnabled(newData.m_dhcpserver.m_fEnabled);
    336                     /* Save DHCP server configuration: */
    337                     if (   comServer.isOk()
    338                         && newData.m_dhcpserver.m_fEnabled
    339                         && (   newData.m_dhcpserver.m_strAddress != oldData.m_dhcpserver.m_strAddress
    340                             || newData.m_dhcpserver.m_strMask != oldData.m_dhcpserver.m_strMask
    341                             || newData.m_dhcpserver.m_strLowerAddress != oldData.m_dhcpserver.m_strLowerAddress
    342                             || newData.m_dhcpserver.m_strUpperAddress != oldData.m_dhcpserver.m_strUpperAddress))
    343                         comServer.SetConfiguration(newData.m_dhcpserver.m_strAddress, newData.m_dhcpserver.m_strMask,
    344                                                    newData.m_dhcpserver.m_strLowerAddress, newData.m_dhcpserver.m_strUpperAddress);
    345 
    346                     /* Show error message if necessary: */
    347                     if (!comServer.isOk())
    348                         msgCenter().cannotSaveDHCPServerParameter(comServer, this);
    349                 }
    350             }
    351         }
    352 
    353         /* Find corresponding interface again (if necessary): */
    354         if (!comInterface.isOk())
    355         {
    356             comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName);
    357 
    358             /* Show error message if necessary: */
    359             if (!comHost.isOk() || comInterface.isNull())
    360                 msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this);
    361         }
    362 
    363         /* If interface is Ok now: */
    364         if (comInterface.isNotNull() && comInterface.isOk())
    365         {
    366             /* Update interface in the tree: */
    367             UIDataHostNetwork data;
    368             loadHostNetwork(comInterface, data);
    369             updateItemForNetworkHost(data, true, pItem);
    370 
    371             /* Make sure current item fetched: */
    372             sltHandleCurrentItemChange();
    373 
    374             /* Adjust tree-widget: */
    375             sltAdjustTreeWidget();
    376         }
    377     }
    378 }
    379 
    380 void UIHostNetworkManagerWidget::sltCreateHostNetwork()
    381 {
    382     /* Get host for further activities: */
    383     CHost comHost = vboxGlobal().host();
    384 
    385     /* Create interface: */
    386     CHostNetworkInterface comInterface;
    387     CProgress progress = comHost.CreateHostOnlyNetworkInterface(comInterface);
    388 
    389     /* Show error message if necessary: */
    390     if (!comHost.isOk() || progress.isNull())
    391         msgCenter().cannotCreateHostNetworkInterface(comHost, this);
    392     else
    393     {
    394         /* Show interface creation progress: */
    395         msgCenter().showModalProgressDialog(progress, tr("Adding network..."), ":/progress_network_interface_90px.png", this, 0);
    396 
    397         /* Show error message if necessary: */
    398         if (!progress.isOk() || progress.GetResultCode() != 0)
    399             msgCenter().cannotCreateHostNetworkInterface(progress, this);
    400         else
    401         {
    402             /* Get network name for further activities: */
    403             const QString strNetworkName = comInterface.GetNetworkName();
    404 
    405             /* Show error message if necessary: */
    406             if (!comInterface.isOk())
    407                 msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this);
    408             else
    409             {
    410                 /* Get VBox for further activities: */
    411                 CVirtualBox comVBox = vboxGlobal().virtualBox();
    412 
    413                 /* Find corresponding DHCP server (create if necessary): */
    414                 CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
    415                 if (!comVBox.isOk() || comServer.isNull())
    416                     comServer = comVBox.CreateDHCPServer(strNetworkName);
    417 
    418                 /* Show error message if necessary: */
    419                 if (!comVBox.isOk() || comServer.isNull())
    420                     msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this);
    421             }
    422 
    423             /* Add interface to the tree: */
    424             UIDataHostNetwork data;
    425             loadHostNetwork(comInterface, data);
    426             createItemForNetworkHost(data, true);
    427 
    428             /* Adjust tree-widget: */
    429             sltAdjustTreeWidget();
    430         }
    431     }
    432 }
    433 
    434 void UIHostNetworkManagerWidget::sltRemoveHostNetwork()
    435 {
    436     /* Get network item: */
    437     UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem());
    438     AssertMsgReturnVoid(pItem, ("Current item must not be null!\n"));
    439 
    440     /* Get interface name: */
    441     const QString strInterfaceName(pItem->name());
    442 
    443     /* Confirm host network removal: */
    444     if (!msgCenter().confirmHostOnlyInterfaceRemoval(strInterfaceName, this))
    445         return;
    446 
    447     /* Get host for further activities: */
    448     CHost comHost = vboxGlobal().host();
    449 
    450     /* Find corresponding interface: */
    451     const CHostNetworkInterface &comInterface = comHost.FindHostNetworkInterfaceByName(strInterfaceName);
    452 
    453     /* Show error message if necessary: */
    454     if (!comHost.isOk() || comInterface.isNull())
    455         msgCenter().cannotFindHostNetworkInterface(comHost, strInterfaceName, this);
    456     else
    457     {
    458         /* Get network name for further activities: */
    459         QString strNetworkName;
    460         if (comInterface.isOk())
    461             strNetworkName = comInterface.GetNetworkName();
    462         /* Get interface id for further activities: */
    463         QString strInterfaceId;
    464         if (comInterface.isOk())
    465             strInterfaceId = comInterface.GetId();
    466 
    467         /* Show error message if necessary: */
    468         if (!comInterface.isOk())
    469             msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this);
    470         else
    471         {
    472             /* Get VBox for further activities: */
    473             CVirtualBox comVBox = vboxGlobal().virtualBox();
    474 
    475             /* Find corresponding DHCP server: */
    476             const CDHCPServer &comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
    477             if (comVBox.isOk() && comServer.isNotNull())
    478             {
    479                 /* Remove server if any: */
    480                 comVBox.RemoveDHCPServer(comServer);
    481 
    482                 /* Show error message if necessary: */
    483                 if (!comVBox.isOk())
    484                     msgCenter().cannotRemoveDHCPServer(comVBox, strInterfaceName, this);
    485             }
    486 
    487             /* Remove interface finally: */
    488             CProgress progress = comHost.RemoveHostOnlyNetworkInterface(strInterfaceId);
    489 
    490             /* Show error message if necessary: */
    491             if (!comHost.isOk() || progress.isNull())
    492                 msgCenter().cannotRemoveHostNetworkInterface(comHost, strInterfaceName, this);
    493             else
    494             {
    495                 /* Show interface removal progress: */
    496                 msgCenter().showModalProgressDialog(progress, tr("Removing network..."), ":/progress_network_interface_90px.png", this, 0);
    497 
    498                 /* Show error message if necessary: */
    499                 if (!progress.isOk() || progress.GetResultCode() != 0)
    500                     return msgCenter().cannotRemoveHostNetworkInterface(progress, strInterfaceName, this);
    501                 else
    502                 {
    503                     /* Remove interface from the tree: */
    504                     delete pItem;
    505 
    506                     /* Adjust tree-widget: */
    507                     sltAdjustTreeWidget();
    508                 }
    509             }
    510         }
    511     }
    512 }
    513 
    514 void UIHostNetworkManagerWidget::sltToggleHostNetworkDetailsVisibility(bool fVisible)
     154    /// @todo apply cloud profile details!
     155}
     156
     157void UICloudProfileManagerWidget::sltCreateCloudProfile()
     158{
     159    /// @todo create cloud profile!
     160}
     161
     162void UICloudProfileManagerWidget::sltRemoveCloudProfile()
     163{
     164    /// @todo remove cloud profile!
     165}
     166
     167void UICloudProfileManagerWidget::sltToggleCloudProfileDetailsVisibility(bool fVisible)
    515168{
    516169    /* Save the setting: */
    517     gEDataManager->setHostNetworkManagerDetailsExpanded(fVisible);
     170    /// @todo implement extra-data setter!
    518171    /* Show/hide details area and Apply button: */
    519172    m_pDetailsWidget->setVisible(fVisible);
    520173    /* Notify external lsiteners: */
    521     emit sigHostNetworkDetailsVisibilityChanged(fVisible);
    522 }
    523 
    524 void UIHostNetworkManagerWidget::sltRefreshHostNetworks()
     174    emit sigCloudProfileDetailsVisibilityChanged(fVisible);
     175}
     176
     177void UICloudProfileManagerWidget::sltRefreshCloudProfiles()
    525178{
    526179    // Not implemented.
     
    528181}
    529182
    530 void UIHostNetworkManagerWidget::sltAdjustTreeWidget()
    531 {
    532     /* Get the tree-widget abstract interface: */
    533     QAbstractItemView *pItemView = m_pTreeWidget;
    534     /* Get the tree-widget header-view: */
    535     QHeaderView *pItemHeader = m_pTreeWidget->header();
    536 
     183void UICloudProfileManagerWidget::sltAdjustTreeWidget()
     184{
    537185    /* Calculate the total tree-widget width: */
    538186    const int iTotal = m_pTreeWidget->viewport()->width();
    539     /* Look for a minimum width hints for non-important columns: */
    540     const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4));
    541     const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6));
    542     const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP));
    543     /* Propose suitable width hints for non-important columns: */
    544     const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max;
    545     const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max;
    546     const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max;
     187
     188    /// @todo calculate proposed column widths!
     189
    547190    /* Apply the proposal: */
    548     m_pTreeWidget->setColumnWidth(Column_IPv4, iWidth1);
    549     m_pTreeWidget->setColumnWidth(Column_IPv6, iWidth2);
    550     m_pTreeWidget->setColumnWidth(Column_DHCP, iWidth3);
    551     m_pTreeWidget->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3);
    552 }
    553 
    554 void UIHostNetworkManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem)
    555 {
    556     /* Get network item: */
    557     UIItemHostNetwork *pChangedItem = static_cast<UIItemHostNetwork*>(pItem);
     191    m_pTreeWidget->setColumnWidth(Column_Name, iTotal /*- iWidth1 - iWidth2 - iWidth3*/);
     192}
     193
     194void UICloudProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem)
     195{
     196    /* Get profile item: */
     197    UIItemCloudProfile *pChangedItem = static_cast<UIItemCloudProfile*>(pItem);
    558198    AssertMsgReturnVoid(pChangedItem, ("Changed item must not be null!\n"));
    559199
    560     /* Get item data: */
    561     UIDataHostNetwork oldData = *pChangedItem;
    562 
    563     /* Make sure dhcp server status changed: */
    564     if (   (   oldData.m_dhcpserver.m_fEnabled
    565             && pChangedItem->checkState(Column_DHCP) == Qt::Checked)
    566         || (   !oldData.m_dhcpserver.m_fEnabled
    567             && pChangedItem->checkState(Column_DHCP) == Qt::Unchecked))
    568         return;
    569 
    570     /* Get host for further activities: */
    571     CHost comHost = vboxGlobal().host();
    572 
    573     /* Find corresponding interface: */
    574     CHostNetworkInterface comInterface = comHost.FindHostNetworkInterfaceByName(oldData.m_interface.m_strName);
    575 
    576     /* Show error message if necessary: */
    577     if (!comHost.isOk() || comInterface.isNull())
    578         msgCenter().cannotFindHostNetworkInterface(comHost, oldData.m_interface.m_strName, this);
    579     else
    580     {
    581         /* Get network name for further activities: */
    582         const QString strNetworkName = comInterface.GetNetworkName();
    583 
    584         /* Show error message if necessary: */
    585         if (!comInterface.isOk())
    586             msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this);
    587         else
    588         {
    589             /* Get VBox for further activities: */
    590             CVirtualBox comVBox = vboxGlobal().virtualBox();
    591 
    592             /* Find corresponding DHCP server (create if necessary): */
    593             CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
    594             if (!comVBox.isOk() || comServer.isNull())
    595                 comServer = comVBox.CreateDHCPServer(strNetworkName);
    596 
    597             /* Show error message if necessary: */
    598             if (!comVBox.isOk() || comServer.isNull())
    599                 msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this);
    600             else
    601             {
    602                 /* Save whether DHCP server is enabled: */
    603                 if (comServer.isOk())
    604                     comServer.SetEnabled(!oldData.m_dhcpserver.m_fEnabled);
    605                 /* Save default DHCP server configuration if current is invalid: */
    606                 if (   comServer.isOk()
    607                     && !oldData.m_dhcpserver.m_fEnabled
    608                     && (   oldData.m_dhcpserver.m_strAddress == "0.0.0.0"
    609                         || oldData.m_dhcpserver.m_strMask == "0.0.0.0"
    610                         || oldData.m_dhcpserver.m_strLowerAddress == "0.0.0.0"
    611                         || oldData.m_dhcpserver.m_strUpperAddress == "0.0.0.0"))
    612                 {
    613                     const QStringList &proposal = makeDhcpServerProposal(oldData.m_interface.m_strAddress,
    614                                                                          oldData.m_interface.m_strMask);
    615                     comServer.SetConfiguration(proposal.at(0), proposal.at(1), proposal.at(2), proposal.at(3));
    616                 }
    617 
    618                 /* Show error message if necessary: */
    619                 if (!comServer.isOk())
    620                     msgCenter().cannotSaveDHCPServerParameter(comServer, this);
    621                 {
    622                     /* Update interface in the tree: */
    623                     UIDataHostNetwork data;
    624                     loadHostNetwork(comInterface, data);
    625                     updateItemForNetworkHost(data, true, pChangedItem);
    626 
    627                     /* Make sure current item fetched: */
    628                     sltHandleCurrentItemChange();
    629 
    630                     /* Adjust tree-widget: */
    631                     sltAdjustTreeWidget();
    632                 }
    633             }
    634         }
    635     }
    636 }
    637 
    638 void UIHostNetworkManagerWidget::sltHandleCurrentItemChange()
    639 {
    640     /* Get network item: */
    641     UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem());
     200    /// @todo handle item change!
     201}
     202
     203void UICloudProfileManagerWidget::sltHandleCurrentItemChange()
     204{
     205    /* Get profile item: */
     206    UIItemCloudProfile *pItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem());
    642207
    643208    /* Update actions availability: */
    644     m_pActionPool->action(UIActionIndexST_M_Network_S_Remove)->setEnabled(pItem);
    645     m_pActionPool->action(UIActionIndexST_M_Network_T_Details)->setEnabled(pItem);
     209    /// @todo implement % enable/disable actions!
    646210
    647211    /* If there is an item => update details data: */
     
    651215    {
    652216        /* Otherwise => clear details and close the area: */
    653         m_pDetailsWidget->setData(UIDataHostNetwork());
    654         sltToggleHostNetworkDetailsVisibility(false);
    655     }
    656 }
    657 
    658 void UIHostNetworkManagerWidget::sltHandleContextMenuRequest(const QPoint &position)
     217        m_pDetailsWidget->setData(UIDataCloudProfile());
     218        sltToggleCloudProfileDetailsVisibility(false);
     219    }
     220}
     221
     222void UICloudProfileManagerWidget::sltHandleContextMenuRequest(const QPoint &position)
    659223{
    660224    /* Compose temporary context-menu: */
    661225    QMenu menu;
    662     if (m_pTreeWidget->itemAt(position))
    663     {
    664         menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove));
    665         menu.addSeparator();
    666         menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_T_Details));
    667     }
    668     else
    669     {
    670         menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Create));
    671 //        menu.addSeparator();
    672 //        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh));
    673     }
     226    /// @todo implement & insert actions!
     227
    674228    /* And show it: */
    675229    menu.exec(m_pTreeWidget->mapToGlobal(position));
    676230}
    677231
    678 void UIHostNetworkManagerWidget::prepare()
     232void UICloudProfileManagerWidget::prepare()
    679233{
    680234    /* Prepare actions: */
     
    689243    retranslateUi();
    690244
    691     /* Load host networks: */
    692     loadHostNetworks();
    693 }
    694 
    695 void UIHostNetworkManagerWidget::prepareActions()
     245    /* Load cloud profiles: */
     246    loadCloudProfiles();
     247}
     248
     249void UICloudProfileManagerWidget::prepareActions()
    696250{
    697251    /* Connect actions: */
    698     connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Create), &QAction::triggered,
    699             this, &UIHostNetworkManagerWidget::sltCreateHostNetwork);
    700     connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove), &QAction::triggered,
    701             this, &UIHostNetworkManagerWidget::sltRemoveHostNetwork);
    702     connect(m_pActionPool->action(UIActionIndexST_M_Network_T_Details), &QAction::toggled,
    703             this, &UIHostNetworkManagerWidget::sltToggleHostNetworkDetailsVisibility);
    704     connect(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh), &QAction::triggered,
    705             this, &UIHostNetworkManagerWidget::sltRefreshHostNetworks);
    706 }
    707 
    708 void UIHostNetworkManagerWidget::prepareWidgets()
     252    /// @todo implement & connect actions!
     253}
     254
     255void UICloudProfileManagerWidget::prepareWidgets()
    709256{
    710257    /* Create main-layout: */
    711258    new QVBoxLayout(this);
    712     AssertPtrReturnVoid(layout());
     259    if (layout())
    713260    {
    714261        /* Configure layout: */
     
    730277}
    731278
    732 void UIHostNetworkManagerWidget::prepareToolBar()
     279void UICloudProfileManagerWidget::prepareToolBar()
    733280{
    734281    /* Create toolbar: */
    735282    m_pToolBar = new UIToolBar(parentWidget());
    736     AssertPtrReturnVoid(m_pToolBar);
     283    if (m_pToolBar)
    737284    {
    738285        /* Configure toolbar: */
     
    742289
    743290        /* Add toolbar actions: */
    744         m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Create));
    745         m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Remove));
    746         m_pToolBar->addSeparator();
    747         m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_T_Details));
    748 //        m_pToolBar->addSeparator();
    749 //        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh));
     291        /// @todo implement & add actions!
    750292
    751293#ifdef VBOX_WS_MAC
     
    763305}
    764306
    765 void UIHostNetworkManagerWidget::prepareTreeWidget()
     307void UICloudProfileManagerWidget::prepareTreeWidget()
    766308{
    767309    /* Create tree-widget: */
    768310    m_pTreeWidget = new QITreeWidget;
    769     AssertPtrReturnVoid(m_pTreeWidget);
     311    if (m_pTreeWidget)
    770312    {
    771313        /* Configure tree-widget: */
     
    779321        m_pTreeWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
    780322        connect(m_pTreeWidget, &QITreeWidget::currentItemChanged,
    781                 this, &UIHostNetworkManagerWidget::sltHandleCurrentItemChange);
     323                this, &UICloudProfileManagerWidget::sltHandleCurrentItemChange);
    782324        connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested,
    783                 this, &UIHostNetworkManagerWidget::sltHandleContextMenuRequest);
     325                this, &UICloudProfileManagerWidget::sltHandleContextMenuRequest);
    784326        connect(m_pTreeWidget, &QITreeWidget::itemChanged,
    785                 this, &UIHostNetworkManagerWidget::sltHandleItemChange);
    786         connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked,
    787                 m_pActionPool->action(UIActionIndexST_M_Network_T_Details), &QAction::setChecked);
     327                this, &UICloudProfileManagerWidget::sltHandleItemChange);
     328        /// @todo implement & connect actions!
    788329
    789330        /* Add into layout: */
     
    792333}
    793334
    794 void UIHostNetworkManagerWidget::prepareDetailsWidget()
     335void UICloudProfileManagerWidget::prepareDetailsWidget()
    795336{
    796337    /* Create details-widget: */
    797     m_pDetailsWidget = new UIHostNetworkDetailsWidget(m_enmEmbedding);
    798     AssertPtrReturnVoid(m_pDetailsWidget);
     338    m_pDetailsWidget = new UICloudProfileDetailsWidget(m_enmEmbedding);
     339    if (m_pDetailsWidget)
    799340    {
    800341        /* Configure details-widget: */
    801342        m_pDetailsWidget->setVisible(false);
    802343        m_pDetailsWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    803         connect(m_pDetailsWidget, &UIHostNetworkDetailsWidget::sigDataChanged,
    804                 this, &UIHostNetworkManagerWidget::sigHostNetworkDetailsDataChanged);
    805         connect(m_pDetailsWidget, &UIHostNetworkDetailsWidget::sigDataChangeRejected,
    806                 this, &UIHostNetworkManagerWidget::sltResetHostNetworkDetailsChanges);
    807         connect(m_pDetailsWidget, &UIHostNetworkDetailsWidget::sigDataChangeAccepted,
    808                 this, &UIHostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges);
     344        connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChanged,
     345                this, &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged);
     346        connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeRejected,
     347                this, &UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges);
     348        connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeAccepted,
     349                this, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges);
    809350
    810351        /* Add into layout: */
     
    813354}
    814355
    815 void UIHostNetworkManagerWidget::loadSettings()
     356void UICloudProfileManagerWidget::loadSettings()
    816357{
    817358    /* Details action/widget: */
    818     m_pActionPool->action(UIActionIndexST_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded());
    819 }
    820 
    821 void UIHostNetworkManagerWidget::loadHostNetworks()
     359    /// @todo implement extra-data getter!
     360}
     361
     362void UICloudProfileManagerWidget::loadCloudProfiles()
    822363{
    823364    /* Clear tree first of all: */
    824365    m_pTreeWidget->clear();
    825366
    826     /* Get host for further activities: */
    827     const CHost comHost = vboxGlobal().host();
    828 
    829     /* Get interfaces for further activities: */
    830     const QVector<CHostNetworkInterface> interfaces = comHost.GetNetworkInterfaces();
    831 
    832     /* Show error message if necessary: */
    833     if (!comHost.isOk())
    834         msgCenter().cannotAcquireHostNetworkInterfaces(comHost, this);
    835     else
    836     {
    837         /* For each host-only interface => load it to the tree: */
    838         foreach (const CHostNetworkInterface &comInterface, interfaces)
    839             if (comInterface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
    840             {
    841                 UIDataHostNetwork data;
    842                 loadHostNetwork(comInterface, data);
    843                 createItemForNetworkHost(data, false);
    844             }
    845 
    846         /* Choose the 1st item as current initially: */
    847         m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0));
    848         sltHandleCurrentItemChange();
    849 
    850         /* Adjust tree-widget: */
    851         sltAdjustTreeWidget();
    852     }
    853 }
    854 
    855 void UIHostNetworkManagerWidget::loadHostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork &data)
    856 {
    857     /* Gather interface settings: */
    858     if (comInterface.isOk())
    859         data.m_interface.m_strName = comInterface.GetName();
    860     if (comInterface.isOk())
    861         data.m_interface.m_fDHCPEnabled = comInterface.GetDHCPEnabled();
    862     if (comInterface.isOk())
    863         data.m_interface.m_strAddress = comInterface.GetIPAddress();
    864     if (comInterface.isOk())
    865         data.m_interface.m_strMask = comInterface.GetNetworkMask();
    866     if (comInterface.isOk())
    867         data.m_interface.m_fSupportedIPv6 = comInterface.GetIPV6Supported();
    868     if (comInterface.isOk())
    869         data.m_interface.m_strAddress6 = comInterface.GetIPV6Address();
    870     if (comInterface.isOk())
    871         data.m_interface.m_strPrefixLength6 = QString::number(comInterface.GetIPV6NetworkMaskPrefixLength());
    872 
    873     /* Get host interface network name for further activities: */
    874     QString strNetworkName;
    875     if (comInterface.isOk())
    876         strNetworkName = comInterface.GetNetworkName();
    877 
    878     /* Show error message if necessary: */
    879     if (!comInterface.isOk())
    880         msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this);
    881 
    882     /* Get VBox for further activities: */
    883     CVirtualBox comVBox = vboxGlobal().virtualBox();
    884 
    885     /* Find corresponding DHCP server (create if necessary): */
    886     CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
    887     if (!comVBox.isOk() || comServer.isNull())
    888         comServer = comVBox.CreateDHCPServer(strNetworkName);
    889 
    890     /* Show error message if necessary: */
    891     if (!comVBox.isOk() || comServer.isNull())
    892         msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this);
    893     else
    894     {
    895         /* Gather DHCP server settings: */
    896         if (comServer.isOk())
    897             data.m_dhcpserver.m_fEnabled = comServer.GetEnabled();
    898         if (comServer.isOk())
    899             data.m_dhcpserver.m_strAddress = comServer.GetIPAddress();
    900         if (comServer.isOk())
    901             data.m_dhcpserver.m_strMask = comServer.GetNetworkMask();
    902         if (comServer.isOk())
    903             data.m_dhcpserver.m_strLowerAddress = comServer.GetLowerIP();
    904         if (comServer.isOk())
    905             data.m_dhcpserver.m_strUpperAddress = comServer.GetUpperIP();
    906 
    907         /* Show error message if necessary: */
    908         if (!comServer.isOk())
    909             return msgCenter().cannotAcquireDHCPServerParameter(comServer, this);
    910     }
    911 }
    912 
    913 void UIHostNetworkManagerWidget::createItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem)
     367    /// @todo load cloud profiles!
     368}
     369
     370void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, UIDataCloudProfile &data)
     371{
     372    Q_UNUSED(comProfile);
     373    Q_UNUSED(data);
     374
     375    /// @todo load cloud profile!
     376}
     377
     378void UICloudProfileManagerWidget::createItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem)
    914379{
    915380    /* Create new item: */
    916     UIItemHostNetwork *pItem = new UIItemHostNetwork;
    917     AssertPtrReturnVoid(pItem);
     381    UIItemCloudProfile *pItem = new UIItemCloudProfile;
     382    if (pItem)
    918383    {
    919384        /* Configure item: */
    920         pItem->UIDataHostNetwork::operator=(data);
     385        pItem->UIDataCloudProfile::operator=(data);
    921386        pItem->updateFields();
    922387        /* Add item to the tree: */
     
    928393}
    929394
    930 void UIHostNetworkManagerWidget::updateItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem, UIItemHostNetwork *pItem)
     395void UICloudProfileManagerWidget::updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem)
    931396{
    932397    /* Update passed item: */
    933     AssertPtrReturnVoid(pItem);
     398    if (pItem)
    934399    {
    935400        /* Configure item: */
    936         pItem->UIDataHostNetwork::operator=(data);
     401        pItem->UIDataCloudProfile::operator=(data);
    937402        pItem->updateFields();
    938403        /* And choose it as current if necessary: */
     
    944409
    945410/*********************************************************************************************************************************
    946 *   Class UIHostNetworkManagerFactory implementation.                                                                            *
     411*   Class UICloudProfileManagerFactory implementation.                                                                            *
    947412*********************************************************************************************************************************/
    948413
    949 UIHostNetworkManagerFactory::UIHostNetworkManagerFactory(UIActionPool *pActionPool /* = 0 */)
     414UICloudProfileManagerFactory::UICloudProfileManagerFactory(UIActionPool *pActionPool /* = 0 */)
    950415    : m_pActionPool(pActionPool)
    951416{
    952417}
    953418
    954 void UIHostNetworkManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
    955 {
    956     pDialog = new UIHostNetworkManager(pCenterWidget, m_pActionPool);
     419void UICloudProfileManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
     420{
     421    pDialog = new UICloudProfileManager(pCenterWidget, m_pActionPool);
    957422}
    958423
    959424
    960425/*********************************************************************************************************************************
    961 *   Class UIHostNetworkManager implementation.                                                                                   *
     426*   Class UICloudProfileManager implementation.                                                                                   *
    962427*********************************************************************************************************************************/
    963428
    964 UIHostNetworkManager::UIHostNetworkManager(QWidget *pCenterWidget, UIActionPool *pActionPool)
     429UICloudProfileManager::UICloudProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool)
    965430    : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
    966431    , m_pActionPool(pActionPool)
     
    968433}
    969434
    970 void UIHostNetworkManager::sltHandleButtonBoxClick(QAbstractButton *pButton)
     435void UICloudProfileManager::sltHandleButtonBoxClick(QAbstractButton *pButton)
    971436{
    972437    /* Disable buttons first of all: */
     
    982447}
    983448
    984 void UIHostNetworkManager::retranslateUi()
     449void UICloudProfileManager::retranslateUi()
    985450{
    986451    /* Translate window title: */
    987     setWindowTitle(tr("Host Network Manager"));
     452    setWindowTitle(tr("Cloud Profile Manager"));
    988453
    989454    /* Translate buttons: */
     
    991456    button(ButtonType_Apply)->setText(tr("Apply"));
    992457    button(ButtonType_Close)->setText(tr("Close"));
    993     button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current host network details"));
    994     button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current host network details"));
     458    button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current cloud profile details"));
     459    button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current cloud profile details"));
    995460    button(ButtonType_Close)->setStatusTip(tr("Close dialog without saving"));
    996461    button(ButtonType_Reset)->setShortcut(QString("Ctrl+Backspace"));
     
    1002467}
    1003468
    1004 void UIHostNetworkManager::configure()
     469void UICloudProfileManager::configure()
    1005470{
    1006471    /* Apply window icons: */
     472    /// @todo apply proper cloud profile manager icons!
    1007473    setWindowIcon(UIIconPool::iconSetFull(":/host_iface_manager_32px.png", ":/host_iface_manager_16px.png"));
    1008474}
    1009475
    1010 void UIHostNetworkManager::configureCentralWidget()
     476void UICloudProfileManager::configureCentralWidget()
    1011477{
    1012478    /* Create widget: */
    1013     UIHostNetworkManagerWidget *pWidget = new UIHostNetworkManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this);
    1014     AssertPtrReturnVoid(pWidget);
     479    UICloudProfileManagerWidget *pWidget = new UICloudProfileManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this);
     480    if (pWidget)
    1015481    {
    1016482        /* Configure widget: */
     
    1020486        setWidgetToolbar(pWidget->toolbar());
    1021487#endif
    1022         connect(this, &UIHostNetworkManager::sigDataChangeRejected,
    1023                 pWidget, &UIHostNetworkManagerWidget::sltResetHostNetworkDetailsChanges);
    1024         connect(this, &UIHostNetworkManager::sigDataChangeAccepted,
    1025                 pWidget, &UIHostNetworkManagerWidget::sltApplyHostNetworkDetailsChanges);
     488        connect(this, &UICloudProfileManager::sigDataChangeRejected,
     489                pWidget, &UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges);
     490        connect(this, &UICloudProfileManager::sigDataChangeAccepted,
     491                pWidget, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges);
    1026492
    1027493        /* Add into layout: */
     
    1030496}
    1031497
    1032 void UIHostNetworkManager::configureButtonBox()
     498void UICloudProfileManager::configureButtonBox()
    1033499{
    1034500    /* Configure button-box: */
    1035     connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,
     501    connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged,
    1036502            button(ButtonType_Apply), &QPushButton::setVisible);
    1037     connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,
     503    connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged,
    1038504            button(ButtonType_Reset), &QPushButton::setVisible);
    1039     connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,
     505    connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged,
    1040506            button(ButtonType_Apply), &QPushButton::setEnabled);
    1041     connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,
     507    connect(widget(), &UICloudProfileManagerWidget::sigCloudProfileDetailsDataChanged,
    1042508            button(ButtonType_Reset), &QPushButton::setEnabled);
    1043509    connect(buttonBox(), &QIDialogButtonBox::clicked,
    1044             this, &UIHostNetworkManager::sltHandleButtonBoxClick);
     510            this, &UICloudProfileManager::sltHandleButtonBoxClick);
    1045511    // WORKAROUND:
    1046512    // Since we connected signals later than extra-data loaded
    1047513    // for signals above, we should handle that stuff here again:
    1048     button(ButtonType_Apply)->setVisible(gEDataManager->hostNetworkManagerDetailsExpanded());
    1049     button(ButtonType_Reset)->setVisible(gEDataManager->hostNetworkManagerDetailsExpanded());
    1050 }
    1051 
    1052 void UIHostNetworkManager::finalize()
     514    /// @todo implement extra-data getter!
     515}
     516
     517void UICloudProfileManager::finalize()
    1053518{
    1054519    /* Apply language settings: */
     
    1056521}
    1057522
    1058 UIHostNetworkManagerWidget *UIHostNetworkManager::widget()
    1059 {
    1060     return qobject_cast<UIHostNetworkManagerWidget*>(QIManagerDialog::widget());
    1061 }
    1062 
     523UICloudProfileManagerWidget *UICloudProfileManager::widget()
     524{
     525    return qobject_cast<UICloudProfileManagerWidget*>(QIManagerDialog::widget());
     526}
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.h

    r74811 r74853  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIHostNetworkManager class declaration.
     3 * VBox Qt GUI - UICloudProfileManager class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef ___UIHostNetworkManager_h___
    19 #define ___UIHostNetworkManager_h___
    20 
    21 /* Qt includes: */
    22 #include <QMainWindow>
     18#ifndef ___UICloudProfileManager_h___
     19#define ___UICloudProfileManager_h___
    2320
    2421/* GUI includes: */
     
    2724
    2825/* Forward declarations: */
    29 class CHostNetworkInterface;
    3026class QAbstractButton;
    3127class QTreeWidgetItem;
    32 class QIDialogButtonBox;
    3328class QITreeWidget;
    3429class UIActionPool;
    35 class UIHostNetworkDetailsWidget;
    36 class UIItemHostNetwork;
     30class UICloudProfileDetailsWidget;
     31class UIItemCloudProfile;
    3732class UIToolBar;
    38 struct UIDataHostNetwork;
    39 
    40 
    41 /** QWidget extension providing GUI with the pane to control host network related functionality. */
    42 class UIHostNetworkManagerWidget : public QIWithRetranslateUI<QWidget>
     33struct UIDataCloudProfile;
     34class CCloudProfile;
     35
     36
     37/** QWidget extension providing GUI with the pane to control cloud profile related functionality. */
     38class UICloudProfileManagerWidget : public QIWithRetranslateUI<QWidget>
    4339{
    4440    Q_OBJECT;
     
    4642signals:
    4743
    48     /** Notifies listeners about host network details-widget @a fVisible. */
    49     void sigHostNetworkDetailsVisibilityChanged(bool fVisible);
    50     /** Notifies listeners about host network details data @a fDiffers. */
    51     void sigHostNetworkDetailsDataChanged(bool fDiffers);
     44    /** Notifies listeners about cloud profile details-widget @a fVisible. */
     45    void sigCloudProfileDetailsVisibilityChanged(bool fVisible);
     46    /** Notifies listeners about cloud profile details data @a fDiffers. */
     47    void sigCloudProfileDetailsDataChanged(bool fDiffers);
    5248
    5349public:
    5450
    55     /** Constructs Host Network Manager widget.
     51    /** Constructs Cloud Profile Manager widget.
    5652      * @param  enmEmbedding  Brings the type of widget embedding.
    5753      * @param  pActionPool   Brings the action-pool reference.
    5854      * @param  fShowToolbar  Brings whether we should create/show toolbar. */
    59     UIHostNetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
    60                                bool fShowToolbar = true, QWidget *pParent = 0);
     55    UICloudProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
     56                                bool fShowToolbar = true, QWidget *pParent = 0);
    6157
    6258    /** Returns the menu. */
     
    8682    /** @name Details-widget stuff.
    8783      * @{ */
    88         /** Handles command to reset host network details changes. */
    89         void sltResetHostNetworkDetailsChanges();
    90         /** Handles command to apply host network details changes. */
    91         void sltApplyHostNetworkDetailsChanges();
     84        /** Handles command to reset cloud profile details changes. */
     85        void sltResetCloudProfileDetailsChanges();
     86        /** Handles command to apply cloud profile details changes. */
     87        void sltApplyCloudProfileDetailsChanges();
    9288    /** @} */
    9389
     
    9692    /** @name Menu/action stuff.
    9793      * @{ */
    98         /** Handles command to create host network. */
    99         void sltCreateHostNetwork();
    100         /** Handles command to remove host network. */
    101         void sltRemoveHostNetwork();
    102         /** Handles command to make host network details @a fVisible. */
    103         void sltToggleHostNetworkDetailsVisibility(bool fVisible);
    104         /** Handles command to refresh host networks. */
    105         void sltRefreshHostNetworks();
     94        /** Handles command to create cloud profile. */
     95        void sltCreateCloudProfile();
     96        /** Handles command to remove cloud profile. */
     97        void sltRemoveCloudProfile();
     98        /** Handles command to make cloud profile details @a fVisible. */
     99        void sltToggleCloudProfileDetailsVisibility(bool fVisible);
     100        /** Handles command to refresh cloud profiles. */
     101        void sltRefreshCloudProfiles();
    106102    /** @} */
    107103
     
    141137    /** @name Loading stuff.
    142138      * @{ */
    143         /** Loads host networks. */
    144         void loadHostNetworks();
     139        /** Loads cloud profiles. */
     140        void loadCloudProfiles();
    145141        /** Loads host @a comInterface data to passed @a data container. */
    146         void loadHostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork &data);
     142        void loadCloudProfile(const CCloudProfile &comInterface, UIDataCloudProfile &data);
    147143    /** @} */
    148144
     
    150146      * @{ */
    151147        /** Creates a new tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
    152         void createItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem);
     148        void createItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem);
    153149        /** Updates the passed tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
    154         void updateItemForNetworkHost(const UIDataHostNetwork &data, bool fChooseItem, UIItemHostNetwork *pItem);
     150        void updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem);
    155151    /** @} */
    156152
     
    176172        QITreeWidget *m_pTreeWidget;
    177173        /** Holds the details-widget instance. */
    178         UIHostNetworkDetailsWidget *m_pDetailsWidget;
     174        UICloudProfileDetailsWidget *m_pDetailsWidget;
    179175    /** @} */
    180176};
    181177
    182178
    183 /** QIManagerDialogFactory extension used as a factory for Host Network Manager dialog. */
    184 class UIHostNetworkManagerFactory : public QIManagerDialogFactory
     179/** QIManagerDialogFactory extension used as a factory for Cloud Profile Manager dialog. */
     180class UICloudProfileManagerFactory : public QIManagerDialogFactory
    185181{
    186182public:
    187183
    188     /** Constructs Media Manager factory acquiring additional arguments.
     184    /** Constructs Cloud Profile Manager factory acquiring additional arguments.
    189185      * @param  pActionPool  Brings the action-pool reference. */
    190     UIHostNetworkManagerFactory(UIActionPool *pActionPool = 0);
     186    UICloudProfileManagerFactory(UIActionPool *pActionPool = 0);
    191187
    192188protected:
     
    201197
    202198
    203 /** QIManagerDialog extension providing GUI with the dialog to control host network related functionality. */
    204 class UIHostNetworkManager : public QIWithRetranslateUI<QIManagerDialog>
     199/** QIManagerDialog extension providing GUI with the dialog to control cloud profile related functionality. */
     200class UICloudProfileManager : public QIWithRetranslateUI<QIManagerDialog>
    205201{
    206202    Q_OBJECT;
     
    223219private:
    224220
    225     /** Constructs Host Network Manager dialog.
     221    /** Constructs Cloud Profile Manager dialog.
    226222      * @param  pCenterWidget  Brings the widget reference to center according to.
    227223      * @param  pActionPool    Brings the action-pool reference. */
    228     UIHostNetworkManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
     224    UICloudProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
    229225
    230226    /** @name Event-handling stuff.
     
    249245      * @{ */
    250246        /** Returns the widget. */
    251         virtual UIHostNetworkManagerWidget *widget() /* override */;
     247        virtual UICloudProfileManagerWidget *widget() /* override */;
    252248    /** @} */
    253249
     
    259255
    260256    /** Allow factory access to private/protected members: */
    261     friend class UIHostNetworkManagerFactory;
     257    friend class UICloudProfileManagerFactory;
    262258};
    263259
    264 #endif /* !___UIHostNetworkManager_h___ */
    265 
     260#endif /* !___UICloudProfileManager_h___ */
Note: See TracChangeset for help on using the changeset viewer.

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