VirtualBox

Changeset 66726 in vbox for trunk


Ignore:
Timestamp:
Apr 28, 2017 3:49:27 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8847: Host Network Manager: 2nd iteration: Integrate host network details-dialog directly into Host Network Manager.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.cpp

    r66725 r66726  
    2626
    2727/* GUI includes: */
    28 # include "QIDialogButtonBox.h"
    2928# include "QILineEdit.h"
    3029# include "UIGlobalSettingsNetwork.h"
     
    3534
    3635
    37 UIHostNetworkDetailsDialog::UIHostNetworkDetailsDialog(QWidget *pParent, UIDataHostNetwork &data)
    38     : QIWithRetranslateUI2<QIDialog>(pParent)
    39     , m_data(data)
     36UIHostNetworkDetailsDialog::UIHostNetworkDetailsDialog(QWidget *pParent /* = 0 */)
     37    : QIWithRetranslateUI2<QWidget>(pParent)
    4038    , m_pTabWidget(0)
    4139    , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pLabelNMv4(0), m_pEditorNMv4(0)
     
    4846}
    4947
     48void UIHostNetworkDetailsDialog::setData(const UIDataHostNetwork &data)
     49{
     50    /* Save old data: */
     51    m_oldData = data;
     52
     53    /* Invent default old values if current old values are invalid: */
     54    const quint32 uAddr = ipv4FromQStringToQuint32(m_oldData.m_interface.m_strAddress);
     55    const quint32 uMask = ipv4FromQStringToQuint32(m_oldData.m_interface.m_strMask);
     56    const quint32 uProp = uAddr & uMask;
     57    const QString strMask = ipv4FromQuint32ToQString(uMask);
     58    const QString strProp = ipv4FromQuint32ToQString(uProp);
     59//    printf("Proposal is = %s x %s\n",
     60//           strProp.toUtf8().constData(),
     61//           strMask.toUtf8().constData());
     62    if (   m_oldData.m_dhcpserver.m_strAddress.isEmpty()
     63        || m_oldData.m_dhcpserver.m_strAddress == "0.0.0.0")
     64        m_oldData.m_dhcpserver.m_strAddress = strProp;
     65    if (   m_oldData.m_dhcpserver.m_strMask.isEmpty()
     66        || m_oldData.m_dhcpserver.m_strMask == "0.0.0.0")
     67        m_oldData.m_dhcpserver.m_strMask = strMask;
     68    if (   m_oldData.m_dhcpserver.m_strLowerAddress.isEmpty()
     69        || m_oldData.m_dhcpserver.m_strLowerAddress == "0.0.0.0")
     70        m_oldData.m_dhcpserver.m_strLowerAddress = strProp;
     71    if (   m_oldData.m_dhcpserver.m_strUpperAddress.isEmpty()
     72        || m_oldData.m_dhcpserver.m_strUpperAddress == "0.0.0.0")
     73        m_oldData.m_dhcpserver.m_strUpperAddress = strProp;
     74
     75    /* Copy old data to new one: */
     76    m_newData = m_oldData;
     77
     78    /* Load 'Interface' data: */
     79    loadDataForInterface();
     80    /* Load 'DHCP server' data: */
     81    loadDataForDHCPServer();
     82}
     83
     84void UIHostNetworkDetailsDialog::clearData()
     85{
     86    /* Reset old/new data: */
     87    m_oldData = UIDataHostNetwork();
     88    m_newData = m_oldData;
     89
     90    /* Load 'Interface' data: */
     91    loadDataForInterface();
     92    /* Load 'DHCP server' data: */
     93    loadDataForDHCPServer();
     94}
     95
    5096void UIHostNetworkDetailsDialog::retranslateUi()
    5197{
    52     /* Translate this: */
    53     setWindowTitle(tr("Host Network Details"));
    54 
    5598    /* Translate tab-widget: */
    5699    m_pTabWidget->setTabText(0, tr("&Adapter"));
     
    80123}
    81124
    82 void UIHostNetworkDetailsDialog::accept()
    83 {
    84     /* Save before accept: */
    85     save();
    86 
    87     /* Call to base-class: */
    88     QIDialog::accept();
    89 }
    90 
    91125void UIHostNetworkDetailsDialog::prepare()
    92126{
     
    96130    /* Apply language settings: */
    97131    retranslateUi();
    98 
    99     /* Load: */
    100     load();
    101132}
    102133
    103134void UIHostNetworkDetailsDialog::prepareThis()
    104135{
    105     /* Apply window icons: */
    106     setWindowIcon(UIIconPool::iconSetFull(":/edit_host_iface_22px.png", ":/edit_host_iface_16px.png"));
    107 
    108136    /* Create layout: */
    109137    QVBoxLayout *pLayout = new QVBoxLayout(this);
    110138    AssertPtrReturnVoid(pLayout);
    111139    {
     140        /* Configure layout: */
     141        pLayout->setContentsMargins(0, 0, 0, 0);
    112142        /* Prepare tab-widget: */
    113143        prepareTabWidget();
    114         /* Prepare button-box: */
    115         prepareButtonBox();
    116144    }
    117145}
     
    161189                /* Configure editor: */
    162190                m_pLabelIPv4->setBuddy(m_pEditorIPv4);
     191                connect(m_pEditorIPv4, &QLineEdit::textChanged,
     192                        this, &UIHostNetworkDetailsDialog::sltTextChangedIPv4);
    163193                /* Add into layout: */
    164194                pLayoutInterface->addWidget(m_pEditorIPv4, 0, 1);
     
    179209                /* Configure editor: */
    180210                m_pLabelNMv4->setBuddy(m_pEditorNMv4);
     211                connect(m_pEditorNMv4, &QLineEdit::textChanged,
     212                        this, &UIHostNetworkDetailsDialog::sltTextChangedNMv4);
    181213                /* Add into layout: */
    182214                pLayoutInterface->addWidget(m_pEditorNMv4, 1, 1);
     
    197229                /* Configure editor: */
    198230                m_pLabelIPv6->setBuddy(m_pEditorIPv6);
    199                 m_pEditorIPv6->setFixedWidthByText(QString().fill('X', 32) + QString().fill(':', 7));
     231                connect(m_pEditorIPv6, &QLineEdit::textChanged,
     232                        this, &UIHostNetworkDetailsDialog::sltTextChangedIPv6);
    200233                /* Add into layout: */
    201234                pLayoutInterface->addWidget(m_pEditorIPv6, 2, 1);
     
    216249                /* Configure editor: */
    217250                m_pLabelNMv6->setBuddy(m_pEditorNMv6);
     251                connect(m_pEditorNMv6, &QLineEdit::textChanged,
     252                        this, &UIHostNetworkDetailsDialog::sltTextChangedNMv6);
    218253                /* Add into layout: */
    219254                pLayoutInterface->addWidget(m_pEditorNMv6, 3, 1);
     
    252287                /* Configure check-box: */
    253288                connect(m_pCheckBoxDHCP, &QCheckBox::stateChanged,
    254                         this, &UIHostNetworkDetailsDialog::sltDhcpServerStatusChanged);
     289                        this, &UIHostNetworkDetailsDialog::sltStatusChangedServer);
    255290                /* Add into layout: */
    256291                pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2);
     
    271306                /* Configure editor: */
    272307                m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress);
     308                connect(m_pEditorDHCPAddress, &QLineEdit::textChanged,
     309                        this, &UIHostNetworkDetailsDialog::sltTextChangedAddress);
    273310                /* Add into layout: */
    274311                pLayoutDHCPServer->addWidget(m_pEditorDHCPAddress, 1, 2);
     
    289326                /* Configure editor: */
    290327                m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask);
     328                connect(m_pEditorDHCPMask, &QLineEdit::textChanged,
     329                        this, &UIHostNetworkDetailsDialog::sltTextChangedMask);
    291330                /* Add into layout: */
    292331                pLayoutDHCPServer->addWidget(m_pEditorDHCPMask, 2, 2);
     
    307346                /* Configure editor: */
    308347                m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress);
     348                connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged,
     349                        this, &UIHostNetworkDetailsDialog::sltTextChangedLowerAddress);
    309350                /* Add into layout: */
    310351                pLayoutDHCPServer->addWidget(m_pEditorDHCPLowerAddress, 3, 2);
     
    325366                /* Configure editor: */
    326367                m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress);
     368                connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged,
     369                        this, &UIHostNetworkDetailsDialog::sltTextChangedUpperAddress);
    327370                /* Add into layout: */
    328371                pLayoutDHCPServer->addWidget(m_pEditorDHCPUpperAddress, 4, 2);
     
    353396}
    354397
    355 void UIHostNetworkDetailsDialog::prepareButtonBox()
    356 {
    357     /* Create dialog button-box: */
    358     QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
    359     AssertPtrReturnVoid(pButtonBox);
    360     {
    361         /* Configure button-box: */
    362         pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    363         connect(pButtonBox, &QIDialogButtonBox::accepted,
    364                 this, &UIHostNetworkDetailsDialog::accept);
    365         connect(pButtonBox, &QIDialogButtonBox::rejected,
    366                 this, &UIHostNetworkDetailsDialog::reject);
    367         /* Add button-box into layout: */
    368         layout()->addWidget(pButtonBox);
    369     }
    370 }
    371 
    372 void UIHostNetworkDetailsDialog::load()
    373 {
    374     /* Load 'Interface' data: */
    375     loadDataForInterface();
    376 
    377     /* Load 'DHCP server' data: */
    378     m_pCheckBoxDHCP->setChecked(m_data.m_dhcpserver.m_fEnabled);
    379     loadDataForDHCPServer();
    380 }
    381 
    382398void UIHostNetworkDetailsDialog::loadDataForInterface()
    383399{
    384400    /* Load IPv4 interface fields: */
    385     m_pEditorIPv4->setText(m_data.m_interface.m_strAddress);
    386     m_pEditorNMv4->setText(m_data.m_interface.m_strMask);
     401    m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress);
     402    m_pEditorNMv4->setText(m_newData.m_interface.m_strMask);
    387403
    388404    /* Toggle IPv6 interface fields availability: */
    389     const bool fIsIpv6Supported = m_data.m_interface.m_fSupportedIPv6;
     405    const bool fIsIpv6Supported = m_newData.m_interface.m_fSupportedIPv6;
    390406    m_pLabelIPv6->setEnabled(fIsIpv6Supported);
    391407    m_pLabelNMv6->setEnabled(fIsIpv6Supported);
     
    394410
    395411    /* Load IPv6 interface fields: */
    396     m_pEditorIPv6->setText(m_data.m_interface.m_strAddress6);
    397     m_pEditorNMv6->setText(m_data.m_interface.m_strMaskLength6);
     412    m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6);
     413    m_pEditorNMv6->setText(m_newData.m_interface.m_strMaskLength6);
    398414}
    399415
     
    401417{
    402418    /* Toggle DHCP server fields availability: */
    403     const bool fIsDHCPServerEnabled = m_data.m_dhcpserver.m_fEnabled;
     419    const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled;
    404420    m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled);
    405421    m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled);
     
    412428
    413429    /* Load DHCP server fields: */
    414     m_pEditorDHCPAddress->setText(m_data.m_dhcpserver.m_strAddress);
    415     m_pEditorDHCPMask->setText(m_data.m_dhcpserver.m_strMask);
    416     m_pEditorDHCPLowerAddress->setText(m_data.m_dhcpserver.m_strLowerAddress);
    417     m_pEditorDHCPUpperAddress->setText(m_data.m_dhcpserver.m_strUpperAddress);
    418 
    419     /* Invent default values where necessary: */
    420     const quint32 uAddr = ipv4FromQStringToQuint32(m_data.m_interface.m_strAddress);
    421     const quint32 uMask = ipv4FromQStringToQuint32(m_data.m_interface.m_strMask);
    422     const quint32 uProp = uAddr & uMask;
    423     const QString strMask = ipv4FromQuint32ToQString(uMask);
    424     const QString strProp = ipv4FromQuint32ToQString(uProp);
    425     //printf("Proposal is = %s x %s\n",
    426     //       strProp.toUtf8().constData(),
    427     //       strMask.toUtf8().constData());
    428     if (   m_data.m_dhcpserver.m_strAddress.isEmpty()
    429         || m_data.m_dhcpserver.m_strAddress == "0.0.0.0")
    430         m_pEditorDHCPAddress->setText(strProp);
    431     if (   m_data.m_dhcpserver.m_strMask.isEmpty()
    432         || m_data.m_dhcpserver.m_strMask == "0.0.0.0")
    433         m_pEditorDHCPMask->setText(strMask);
    434     if (   m_data.m_dhcpserver.m_strLowerAddress.isEmpty()
    435         || m_data.m_dhcpserver.m_strLowerAddress == "0.0.0.0")
    436         m_pEditorDHCPLowerAddress->setText(strProp);
    437     if (   m_data.m_dhcpserver.m_strUpperAddress.isEmpty()
    438         || m_data.m_dhcpserver.m_strUpperAddress == "0.0.0.0")
    439         m_pEditorDHCPUpperAddress->setText(strProp);
    440 }
    441 
    442 void UIHostNetworkDetailsDialog::save()
    443 {
    444     /* Save interface data: */
    445     m_data.m_interface.m_strAddress = m_pEditorIPv4->text();
    446     m_data.m_interface.m_strMask = m_pEditorNMv4->text();
    447     if (m_data.m_interface.m_fSupportedIPv6)
    448     {
    449         m_data.m_interface.m_strAddress6 = m_pEditorIPv6->text();
    450         m_data.m_interface.m_strMaskLength6 = m_pEditorNMv6->text();
    451     }
    452 
    453     /* Save DHCP server data: */
    454     m_data.m_dhcpserver.m_fEnabled = m_pCheckBoxDHCP->isChecked();
    455     if (m_data.m_dhcpserver.m_fEnabled)
    456     {
    457         m_data.m_dhcpserver.m_strAddress = m_pEditorDHCPAddress->text();
    458         m_data.m_dhcpserver.m_strMask = m_pEditorDHCPMask->text();
    459         m_data.m_dhcpserver.m_strLowerAddress = m_pEditorDHCPLowerAddress->text();
    460         m_data.m_dhcpserver.m_strUpperAddress = m_pEditorDHCPUpperAddress->text();
    461     }
     430    m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled);
     431    m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress);
     432    m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask);
     433    m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
     434    m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
     435}
     436
     437void UIHostNetworkDetailsDialog::notify()
     438{
     439//    if (m_oldData != m_newData)
     440//        printf("Interface: %s, %s, %s, %s;  DHCP server: %d, %s, %s, %s, %s\n",
     441//               m_newData.m_interface.m_strAddress.toUtf8().constData(),
     442//               m_newData.m_interface.m_strMask.toUtf8().constData(),
     443//               m_newData.m_interface.m_strAddress6.toUtf8().constData(),
     444//               m_newData.m_interface.m_strMaskLength6.toUtf8().constData(),
     445//               (int)m_newData.m_dhcpserver.m_fEnabled,
     446//               m_newData.m_dhcpserver.m_strAddress.toUtf8().constData(),
     447//               m_newData.m_dhcpserver.m_strMask.toUtf8().constData(),
     448//               m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData(),
     449//               m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData());
     450
     451    emit sigDataChanged(m_oldData != m_newData);
    462452}
    463453
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.h

    r66723 r66726  
    1919#define __UIHostNetworkDetailsDialog_h__
    2020
     21/* Qt includes: */
     22#include <QWidget>
     23
    2124/* GUI includes: */
    22 #include "QIDialog.h"
    2325#include "QIWithRetranslateUI.h"
    2426
     
    148150
    149151
    150 /** Host Network Manager: Host network details dialog. */
    151 class UIHostNetworkDetailsDialog : public QIWithRetranslateUI2<QIDialog>
     152/** Host Network Manager: Host network details widget. */
     153class UIHostNetworkDetailsDialog : public QIWithRetranslateUI2<QWidget>
    152154{
    153155    Q_OBJECT;
    154156
     157signals:
     158
     159    /** Notifies listeners about data changed and whether it @a fDiffers. */
     160    void sigDataChanged(bool fDiffers);
     161
    155162public:
    156163
    157164    /** Constructs host network details dialog for the passed @a pParent and @a data. */
    158     UIHostNetworkDetailsDialog(QWidget *pParent, UIDataHostNetwork &data);
     165    UIHostNetworkDetailsDialog(QWidget *pParent = 0);
     166
     167    /** Returns the host network data. */
     168    const UIDataHostNetwork &data() const { return m_newData; }
     169    /** Defines the host network @a data. */
     170    void setData(const UIDataHostNetwork &data);
     171    /** Clears the host network data. */
     172    void clearData();
    159173
    160174protected:
     
    165179private slots:
    166180
    167     /** Handles DHCP server status change. */
    168     void sltDhcpServerStatusChanged() { loadDataForDHCPServer(); }
    169 
    170     /** Accepts dialog changes. */
    171     void accept();
     181    /** @name Change handling stuff.
     182     * @{ */
     183        /** Handles interface IPv4 text change. */
     184        void sltTextChangedIPv4(const QString &strText) { m_newData.m_interface.m_strAddress = strText; notify(); }
     185        /** Handles interface NMv4 text change. */
     186        void sltTextChangedNMv4(const QString &strText) { m_newData.m_interface.m_strMask = strText; notify(); }
     187        /** Handles interface IPv6 text change. */
     188        void sltTextChangedIPv6(const QString &strText) { m_newData.m_interface.m_strAddress6 = strText; notify(); }
     189        /** Handles interface NMv6 text change. */
     190        void sltTextChangedNMv6(const QString &strText) { m_newData.m_interface.m_strMaskLength6 = strText; notify(); }
     191
     192        /** Handles DHCP server status change. */
     193        void sltStatusChangedServer(int iChecked) { m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked; loadDataForDHCPServer(); notify(); }
     194        /** Handles DHCP server address text change. */
     195        void sltTextChangedAddress(const QString &strText) { m_newData.m_dhcpserver.m_strAddress = strText; notify(); }
     196        /** Handles DHCP server mask text change. */
     197        void sltTextChangedMask(const QString &strText)  { m_newData.m_dhcpserver.m_strMask = strText; notify(); }
     198        /** Handles DHCP server lower address text change. */
     199        void sltTextChangedLowerAddress(const QString &strText)  { m_newData.m_dhcpserver.m_strLowerAddress = strText; notify(); }
     200        /** Handles DHCP server upper address text change. */
     201        void sltTextChangedUpperAddress(const QString &strText)  { m_newData.m_dhcpserver.m_strUpperAddress = strText; notify(); }
     202    /** @} */
    172203
    173204private:
     
    185216        /** Prepares 'DHCP server' tab. */
    186217        void prepareTabDHCPServer();
    187         /** Prepares button-box. */
    188         void prepareButtonBox();
    189     /** @} */
    190 
    191     /** @name Loading/saving stuff.
    192      * @{ */
    193         /** Loads data. */
    194         void load();
     218    /** @} */
     219
     220    /** @name Loading stuff.
     221     * @{ */
    195222        /** Loads interface data. */
    196223        void loadDataForInterface();
    197224        /** Loads server data. */
    198225        void loadDataForDHCPServer();
    199         /** Saves data. */
    200         void save();
     226    /** @} */
     227
     228    /** @name Change handling stuff.
     229     * @{ */
     230        /** Notifies listeners about data changed or not. */
     231        void notify();
    201232    /** @} */
    202233
     
    211242    /** @name General variables.
    212243     * @{ */
    213         /** Holds the external data reference. */
    214         UIDataHostNetwork &m_data;
     244        /** Holds the old data copy. */
     245        UIDataHostNetwork  m_oldData;
     246        /** Holds the new data copy. */
     247        UIDataHostNetwork  m_newData;
    215248        /** Holds the tab-widget. */
    216249        QITabWidget       *m_pTabWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp

    r66723 r66726  
    2424# include <QMenuBar>
    2525# include <QPushButton>
     26# include <QSplitter>
    2627
    2728/* GUI includes: */
     
    198199    , m_pActionRemove(0)
    199200    , m_pActionEdit(0)
     201    , m_pSplitter(0)
    200202    , m_pTreeWidget(0)
     203    , m_pDetailsWidget(0)
    201204    , m_pButtonBox(0)
    202205{
     
    433436void UIHostNetworkManager::sltEditHostNetwork()
    434437{
     438    /* Open details area: */
     439    const QList<int> sizes = m_pSplitter->sizes();
     440    AssertReturnVoid(sizes.size() >= 2);
     441    if (sizes.at(1) == 0)
     442    {
     443        m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 1);
     444        m_pButtonBox->button(QDialogButtonBox::Apply)->show();
     445    }
     446    else
     447    /* Close details area: */
     448    if (sizes.at(1) > 0)
     449    {
     450        m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0);
     451        m_pButtonBox->button(QDialogButtonBox::Apply)->hide();
     452    }
     453}
     454
     455void UIHostNetworkManager::sltHandleButtonClicked(QAbstractButton *pButton)
     456{
     457    /* Handle known button (Apply) only: */
     458    if (pButton != m_pButtonBox->button(QDialogButtonBox::Apply))
     459        return;
     460
     461    /* Disable button first of all: */
     462    m_pButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
     463
    435464    /* Get network item: */
    436465    UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem());
     
    439468    /* Get item data: */
    440469    UIDataHostNetwork oldData = *pItem;
    441     UIDataHostNetwork newData = oldData;
    442 
    443     /* Show details dialog: */
    444     UIHostNetworkDetailsDialog details(this, newData);
    445     if (details.exec() != QDialog::Accepted)
    446         return;
     470    UIDataHostNetwork newData = m_pDetailsWidget->data();
    447471
    448472    /* Get host for further activities: */
     
    633657    m_pActionRemove->setEnabled(pItem);
    634658    m_pActionEdit->setEnabled(pItem);
     659
     660    /* If there is an item => update details data: */
     661    if (pItem)
     662        m_pDetailsWidget->setData(*pItem);
     663    else
     664    {
     665        /* Otherwise => clear details and close the area: */
     666        m_pDetailsWidget->clearData();
     667        m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0);
     668        m_pButtonBox->button(QDialogButtonBox::Apply)->hide();
     669    }
    635670}
    636671
     
    765800            /* Prepare tool-bar: */
    766801            prepareToolBar();
    767             /* Prepare tree-widget: */
    768             prepareTreeWidget();
     802            /* Prepare splitter: */
     803            prepareSplitter();
    769804            /* Prepare button-box: */
    770805            prepareButtonBox();
     
    810845}
    811846
     847void UIHostNetworkManager::prepareSplitter()
     848{
     849    /* Create splitter: */
     850    m_pSplitter = new QSplitter;
     851    AssertPtrReturnVoid(m_pSplitter);
     852    {
     853        /* Prepare tree-widget: */
     854        prepareTreeWidget();
     855        /* Prepare details-widget: */
     856        prepareDetailsWidget();
     857        /* Configure splitter: */
     858        m_pSplitter->setSizes(QList<int>() << m_pSplitter->height() << 0);
     859        m_pSplitter->setOrientation(Qt::Vertical);
     860        m_pSplitter->setCollapsible(0, false);
     861        /* Add splitter into layout: */
     862        QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout());
     863        pMainLayout->addWidget(m_pSplitter);
     864    }
     865}
     866
    812867void UIHostNetworkManager::prepareTreeWidget()
    813868{
     
    832887        connect(m_pTreeWidget, &QITreeWidget::itemChanged,
    833888                this, &UIHostNetworkManager::sltHandleItemChange);
    834         /* Add tree-widget into layout: */
    835         QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout());
    836         pMainLayout->addWidget(m_pTreeWidget);
     889        /* Add tree-widget into splitter: */
     890        m_pSplitter->addWidget(m_pTreeWidget);
     891    }
     892}
     893
     894void UIHostNetworkManager::prepareDetailsWidget()
     895{
     896    /* Create details-widget: */
     897    m_pDetailsWidget = new UIHostNetworkDetailsDialog;
     898    AssertPtrReturnVoid(m_pDetailsWidget);
     899    {
     900        /* Add details-widget into splitter: */
     901        m_pSplitter->addWidget(m_pDetailsWidget);
    837902    }
    838903}
     
    845910    {
    846911        /* Configure button-box: */
    847         m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Close);
     912        m_pButtonBox->setStandardButtons(QDialogButtonBox::Close | QDialogButtonBox::Apply);
    848913        m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape);
    849         connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);
     914        m_pButtonBox->button(QDialogButtonBox::Apply)->hide();
    850915        connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIHostNetworkManager::close);
     916        connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UIHostNetworkManager::sltHandleButtonClicked);
     917        connect(m_pDetailsWidget, &UIHostNetworkDetailsDialog::sigDataChanged,
     918                m_pButtonBox->button(QDialogButtonBox::Apply), &QWidget::setEnabled);
    851919        /* Add button-box into layout: */
    852920        QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout());
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h

    r66720 r66726  
    2727/* Forward declarations: */
    2828class CHostNetworkInterface;
     29class QAbstractButton;
     30class QSplitter;
    2931class QTreeWidgetItem;
    3032class QIDialogButtonBox;
    3133class QITreeWidget;
     34class UIHostNetworkDetailsDialog;
    3235class UIItemHostNetwork;
    3336class UIToolBar;
     
    7982    /** @} */
    8083
     84    /** @name Button-box stuff.
     85     * @{ */
     86        /** Handles button-box @a pButton click. */
     87        void sltHandleButtonClicked(QAbstractButton *pButton);
     88    /** @} */
     89
    8190    /** @name Tree-widget stuff.
    8291     * @{ */
     
    108117        /** Prepares tool-bar. */
    109118        void prepareToolBar();
     119        /** Prepares splitter. */
     120        void prepareSplitter();
    110121        /** Prepares tree-widget. */
    111122        void prepareTreeWidget();
     123        /** Prepares details-widget. */
     124        void prepareDetailsWidget();
    112125        /** Prepares button-box. */
    113126        void prepareButtonBox();
     
    158171    /** @} */
    159172
    160     /** @name Tree-widget variables.
     173    /** @name Splitter variables.
    161174     * @{ */
     175        /** Holds the splitter instance. */
     176        QSplitter    *m_pSplitter;
    162177        /** Holds the tree-widget instance. */
    163178        QITreeWidget *m_pTreeWidget;
     179        /** Holds the details-widget instance. */
     180        UIHostNetworkDetailsDialog *m_pDetailsWidget;
    164181    /** @} */
    165182
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