VirtualBox

Changeset 93328 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 18, 2022 4:33:39 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10163: UINetworkManager / Cloud networking page: A possibility to choose subnet ID from dynamical tree of existing.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.cpp

    r93115 r93328  
    3232#include "QILineEdit.h"
    3333#include "QITabWidget.h"
    34 #include "UIIconPool.h"
     34#include "QIToolButton.h"
    3535#include "UICloudNetworkingStuff.h"
    3636#include "UIDetailsWidgetCloudNetwork.h"
     37#include "UIFormEditorWidget.h"
     38#include "UIIconPool.h"
    3739#include "UIMessageCenter.h"
    3840#include "UINetworkManagerUtils.h"
    3941#include "UINotificationCenter.h"
     42
     43
     44UISubnetSelectionDialog::UISubnetSelectionDialog(QWidget *pParent,
     45                                                 const QString &strShortProviderName,
     46                                                 const QString &strProfileName,
     47                                                 const QString &strSubnetId)
     48    : QIWithRetranslateUI<QDialog>(pParent)
     49    , m_strProviderShortName(strShortProviderName)
     50    , m_strProfileName(strProfileName)
     51    , m_strSubnetId(strSubnetId)
     52    , m_pFormEditor(0)
     53    , m_pButtonBox(0)
     54    , m_pNotificationCenter(0)
     55{
     56    prepare();
     57}
     58
     59UISubnetSelectionDialog::~UISubnetSelectionDialog()
     60{
     61    cleanup();
     62}
     63
     64void UISubnetSelectionDialog::accept()
     65{
     66    /* Get altered description back: */
     67    m_comForm.GetVirtualSystemDescription();
     68    QVector<KVirtualSystemDescriptionType> aTypes;
     69    QVector<QString> aRefs, aOVFValues, aVBoxValues, aExtraConfigValues;
     70    m_comDescription.GetDescriptionByType(KVirtualSystemDescriptionType_CloudOCISubnet,
     71                                          aTypes, aRefs, aOVFValues, aVBoxValues, aExtraConfigValues);
     72    if (!m_comDescription.isOk())
     73    {
     74        UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(m_comDescription,
     75                                                                              m_pNotificationCenter);
     76        return;
     77    }
     78    AssertReturnVoid(!aVBoxValues.isEmpty());
     79    m_strSubnetId = aVBoxValues.first();
     80
     81    /* Call to base-class: */
     82    return QIWithRetranslateUI<QDialog>::accept();
     83}
     84
     85int UISubnetSelectionDialog::exec()
     86{
     87    /* Request to init dialog _after_ being executed: */
     88    QMetaObject::invokeMethod(this, "sltInit", Qt::QueuedConnection);
     89
     90    /* Call to base-class: */
     91    return QIWithRetranslateUI<QDialog>::exec();
     92}
     93
     94void UISubnetSelectionDialog::retranslateUi()
     95{
     96    setWindowTitle(tr("Select Subnet"));
     97}
     98
     99void UISubnetSelectionDialog::sltInit()
     100{
     101    /* Create description: */
     102    m_comDescription = createVirtualSystemDescription(m_pNotificationCenter);
     103    if (m_comDescription.isNull())
     104        return;
     105    /* Update it with current subnet value: */
     106    m_comDescription.AddDescription(KVirtualSystemDescriptionType_CloudOCISubnet, m_strSubnetId, QString());
     107
     108    /* Create cloud client: */
     109    CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_pNotificationCenter);
     110    if (comCloudClient.isNull())
     111        return;
     112
     113    /* Create subnet selection VSD form: */
     114    UINotificationProgressSubnetSelectionVSDFormCreate *pNotification = new UINotificationProgressSubnetSelectionVSDFormCreate(comCloudClient,
     115                                                                                                                               m_comDescription,
     116                                                                                                                               m_strProviderShortName,
     117                                                                                                                               m_strProfileName);
     118    connect(pNotification, &UINotificationProgressSubnetSelectionVSDFormCreate::sigVSDFormCreated,
     119            this, &UISubnetSelectionDialog::sltHandleVSDFormCreated);
     120    m_pNotificationCenter->append(pNotification);
     121}
     122
     123void UISubnetSelectionDialog::sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm)
     124{
     125    m_comForm = comForm;
     126    m_pFormEditor->setVirtualSystemDescriptionForm(m_comForm);
     127}
     128
     129void UISubnetSelectionDialog::prepare()
     130{
     131    /* Prepare main layout: */
     132    QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
     133    if (pLayoutMain)
     134    {
     135        /* Prepare form editor: */
     136        m_pFormEditor = new UIFormEditorWidget(this);
     137        if (m_pFormEditor)
     138            pLayoutMain->addWidget(m_pFormEditor);
     139
     140        /* Prepare button-box: */
     141        m_pButtonBox = new QIDialogButtonBox(this);
     142        if (m_pButtonBox)
     143        {
     144            m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     145            connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &QDialog::accept);
     146            connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &QDialog::reject);
     147
     148            pLayoutMain->addWidget(m_pButtonBox);
     149        }
     150    }
     151
     152    /* Prepare local notification-center: */
     153    m_pNotificationCenter = new UINotificationCenter(this);
     154    if (m_pNotificationCenter && m_pFormEditor)
     155        m_pFormEditor->setNotificationCenter(m_pNotificationCenter);
     156
     157    /* Apply language settings: */
     158    retranslateUi();
     159}
     160
     161void UISubnetSelectionDialog::cleanup()
     162{
     163    /* Cleanup local notification-center: */
     164    delete m_pNotificationCenter;
     165    m_pNotificationCenter = 0;
     166}
    40167
    41168
     
    51178    , m_pLabelNetworkId(0)
    52179    , m_pEditorNetworkId(0)
     180    , m_pButtonNetworkId(0)
    53181    , m_pButtonBoxOptions(0)
    54182{
     
    129257    if (m_pEditorNetworkId)
    130258        m_pEditorNetworkId->setToolTip(tr("Holds the id for this network."));
     259    if (m_pButtonNetworkId)
     260        m_pButtonNetworkId->setToolTip(tr("Selects the id for this network."));
    131261    if (m_pButtonBoxOptions)
    132262    {
     
    179309}
    180310
     311void UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested()
     312{
     313    /* Create subnet selection dialog: */
     314    QPointer<UISubnetSelectionDialog> pDialog = new UISubnetSelectionDialog(this,
     315                                                                            m_pComboProviderName->currentData().toString(),
     316                                                                            m_pComboProfileName->currentData().toString(),
     317                                                                            m_pEditorNetworkId->text());
     318
     319    /* Execute dialog to ask user for subnet: */
     320    if (pDialog->exec() == QDialog::Accepted)
     321        m_pEditorNetworkId->setText(pDialog->subnetId());
     322
     323    /* Cleanup subnet dialog finally: */
     324    delete pDialog;
     325}
     326
    181327void UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton)
    182328{
     
    238384                    this, &UIDetailsWidgetCloudNetwork::sltNetworkNameChanged);
    239385
    240             pLayout->addWidget(m_pEditorNetworkName, 0, 1);
     386            pLayout->addWidget(m_pEditorNetworkName, 0, 1, 1, 2);
    241387        }
    242388
     
    257403                    this, &UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged);
    258404
    259             pLayout->addWidget(m_pComboProviderName, 1, 1);
     405            pLayout->addWidget(m_pComboProviderName, 1, 1, 1, 2);
    260406        }
    261407
     
    276422                    this, &UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged);
    277423
    278             pLayout->addWidget(m_pComboProfileName, 2, 1);
     424            pLayout->addWidget(m_pComboProfileName, 2, 1, 1, 2);
    279425        }
    280426
     
    292438            if (m_pLabelNetworkId)
    293439                m_pLabelNetworkId->setBuddy(m_pEditorNetworkId);
    294             connect(m_pEditorNetworkId, &QLineEdit::textEdited,
     440            connect(m_pEditorNetworkId, &QLineEdit::textChanged,
    295441                    this, &UIDetailsWidgetCloudNetwork::sltNetworkIdChanged);
    296442
    297443            pLayout->addWidget(m_pEditorNetworkId, 3, 1);
     444        }
     445        /* Prepare network id button: */
     446        m_pButtonNetworkId = new QIToolButton(this);
     447        if (m_pButtonNetworkId)
     448        {
     449            m_pButtonNetworkId->setIcon(UIIconPool::iconSet(":/subnet_16px.png"));
     450            connect(m_pButtonNetworkId, &QIToolButton::clicked,
     451                    this, &UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested);
     452
     453            pLayout->addWidget(m_pButtonNetworkId, 3, 2);
    298454        }
    299455
     
    442598    m_pLabelNetworkId->setEnabled(fIsNetworkExists);
    443599    m_pEditorNetworkId->setEnabled(fIsNetworkExists);
     600    m_pButtonNetworkId->setEnabled(fIsNetworkExists);
    444601
    445602    /* Load fields: */
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.h

    r93115 r93328  
    2929#include "QIWithRetranslateUI.h"
    3030#include "UIPortForwardingTable.h"
     31
     32/* COM includes: */
     33#include "CVirtualSystemDescription.h"
     34#include "CVirtualSystemDescriptionForm.h"
    3135
    3236/* Forward declarations: */
     
    4246class QILineEdit;
    4347class QITabWidget;
     48class QIToolButton;
     49class UIFormEditorWidget;
     50class UINotificationCenter;
     51
     52
     53/** QDialog subclass for subnet selection functionality. */
     54class UISubnetSelectionDialog : public QIWithRetranslateUI<QDialog>
     55{
     56    Q_OBJECT;
     57
     58public:
     59
     60    /** Constructs dialog passing @a pParent to the base-class.
     61      * @param  strProviderShortName  Brings the short provider name for cloud client being created.
     62      * @param  strProfileName        Brings the profile name for cloud client being created.
     63      * @param  strSubnetId           Brings the initial subnet ID to be cached. */
     64    UISubnetSelectionDialog(QWidget *pParent,
     65                            const QString &strProviderShortName,
     66                            const QString &strProfileName,
     67                            const QString &strSubnetId);
     68    /** Destructs dialog. */
     69    virtual ~UISubnetSelectionDialog() override final;
     70
     71    /** Returns cached subnet ID. */
     72    QString subnetId() const { return m_strSubnetId; }
     73
     74public slots:
     75
     76    /** Accepts dialog. */
     77    virtual void accept() override final;
     78
     79    /** Executes dialog. */
     80    virtual int exec() override final;
     81
     82protected:
     83
     84    /** Handles translation event. */
     85    virtual void retranslateUi() override final;
     86
     87private slots:
     88
     89    /** Performs dialog initialization. */
     90    void sltInit();
     91
     92    /** Handles notification about subnet selection @a comForm being created. */
     93    void sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm);
     94
     95private:
     96
     97    /** Prepares all. */
     98    void prepare();
     99    /** Cleanups all. */
     100    void cleanup();
     101
     102    /** Holds the short provider name for cloud client being created. */
     103    QString  m_strProviderShortName;
     104    /** Holds the profile name for cloud client being created. */
     105    QString  m_strProfileName;
     106    /** Holds the cached subnet ID. */
     107    QString  m_strSubnetId;
     108
     109    /** Holds the virtual system description container. */
     110    CVirtualSystemDescription      m_comDescription;
     111    /** Holds the virtual system description form. */
     112    CVirtualSystemDescriptionForm  m_comForm;
     113
     114    /** Holds the form editor instance. */
     115    UIFormEditorWidget *m_pFormEditor;
     116    /** Holds the button-box instance. */
     117    QIDialogButtonBox  *m_pButtonBox;
     118
     119    /** Holds the notification-center instance. */
     120    UINotificationCenter *m_pNotificationCenter;
     121};
    44122
    45123
     
    145223        /** Handles network id text change. */
    146224        void sltNetworkIdChanged(const QString &strText);
     225        /** Handles request to list possible network ids. */
     226        void sltNetworkIdListRequested();
    147227
    148228        /** Handles button-box button click. */
     
    184264      * @{ */
    185265        /** Holds the network name label instance. */
    186         QLabel     *m_pLabelNetworkName;
     266        QLabel       *m_pLabelNetworkName;
    187267        /** Holds the network name editor instance. */
    188         QLineEdit  *m_pEditorNetworkName;
     268        QLineEdit    *m_pEditorNetworkName;
    189269        /** Holds the cloud provider name label instance. */
    190         QLabel     *m_pLabelProviderName;
     270        QLabel       *m_pLabelProviderName;
    191271        /** Holds the cloud provider name combo instance. */
    192         QIComboBox *m_pComboProviderName;
     272        QIComboBox   *m_pComboProviderName;
    193273        /** Holds the cloud profile name label instance. */
    194         QLabel     *m_pLabelProfileName;
     274        QLabel       *m_pLabelProfileName;
    195275        /** Holds the cloud profile name combo instance. */
    196         QIComboBox *m_pComboProfileName;
     276        QIComboBox   *m_pComboProfileName;
    197277        /** Holds the network id label instance. */
    198         QLabel     *m_pLabelNetworkId;
     278        QLabel       *m_pLabelNetworkId;
    199279        /** Holds the network id editor instance. */
    200         QLineEdit  *m_pEditorNetworkId;
     280        QLineEdit    *m_pEditorNetworkId;
     281        /** Holds the network id list button instance. */
     282        QIToolButton *m_pButtonNetworkId;
    201283
    202284        /** Holds the 'Options' button-box instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r93115 r93328  
    713713        QApplication::translate("UIMessageCenter", "Failed to acquire display parameter.") +
    714714        UIErrorString::formatErrorInfo(comDisplay));
     715}
     716
     717/* static */
     718void UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(const CVirtualSystemDescription &comVsd,
     719                                                                           UINotificationCenter *pParent /* = 0 */)
     720{
     721    createMessage(
     722        QApplication::translate("UIMessageCenter", "VSD failure ..."),
     723        QApplication::translate("UIMessageCenter", "Failed to acquire virtual system description parameter.") +
     724        UIErrorString::formatErrorInfo(comVsd),
     725        QString(), QString(), pParent);
    715726}
    716727
     
    24342445    /* Return progress-wrapper: */
    24352446    return comProgress;
     2447}
     2448
     2449
     2450/*********************************************************************************************************************************
     2451*   Class UINotificationProgressSubnetSelectionVSDFormCreate implementation.                                                     *
     2452*********************************************************************************************************************************/
     2453
     2454UINotificationProgressSubnetSelectionVSDFormCreate::UINotificationProgressSubnetSelectionVSDFormCreate(const CCloudClient &comClient,
     2455                                                                                                       const CVirtualSystemDescription &comVSD,
     2456                                                                                                       const QString &strProviderShortName,
     2457                                                                                                       const QString &strProfileName)
     2458    : m_comClient(comClient)
     2459    , m_comVSD(comVSD)
     2460    , m_strProviderShortName(strProviderShortName)
     2461    , m_strProfileName(strProfileName)
     2462{
     2463    connect(this, &UINotificationProgress::sigProgressFinished,
     2464            this, &UINotificationProgressSubnetSelectionVSDFormCreate::sltHandleProgressFinished);
     2465}
     2466
     2467QString UINotificationProgressSubnetSelectionVSDFormCreate::name() const
     2468{
     2469    return UINotificationProgress::tr("Creating subnet selection VSD form ...");
     2470}
     2471
     2472QString UINotificationProgressSubnetSelectionVSDFormCreate::details() const
     2473{
     2474    return UINotificationProgress::tr("<b>Provider:</b> %1<br><b>Profile:</b> %2")
     2475                                      .arg(m_strProviderShortName, m_strProfileName);
     2476}
     2477
     2478CProgress UINotificationProgressSubnetSelectionVSDFormCreate::createProgress(COMResult &comResult)
     2479{
     2480    /* Initialize progress-wrapper: */
     2481    CProgress comProgress = m_comClient.GetSubnetSelectionForm(m_comVSD, m_comVSDForm);
     2482    /* Store COM result: */
     2483    comResult = m_comClient;
     2484    /* Return progress-wrapper: */
     2485    return comProgress;
     2486}
     2487
     2488void UINotificationProgressSubnetSelectionVSDFormCreate::sltHandleProgressFinished()
     2489{
     2490    if (m_comVSDForm.isNotNull())
     2491        emit sigVSDFormCreated(m_comVSDForm);
    24362492}
    24372493
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r93115 r93328  
    300300          * @param  comNetwork  Brings the object parameter get acquired from. */
    301301        static void cannotAcquireDispayParameter(const CDisplay &comDisplay);
     302        /** Notifies about inability to acquire IVirtualSystemDescription parameter.
     303          * @param  comVsd  Brings the object parameter get acquired from. */
     304        static void cannotAcquireVirtualSystemDescriptionParameter(const CVirtualSystemDescription &comVsd,
     305                                                                   UINotificationCenter *pParent = 0);
    302306        /** Notifies about inability to acquire IVirtualSystemDescriptionForm parameter.
    303307          * @param  comVsdForm  Brings the object parameter get acquired from. */
     
    11691173};
    11701174
     1175/** UINotificationProgress extension for subnet selection VSD form create functionality. */
     1176class SHARED_LIBRARY_STUFF UINotificationProgressSubnetSelectionVSDFormCreate : public UINotificationProgress
     1177{
     1178    Q_OBJECT;
     1179
     1180signals:
     1181
     1182    /** Notifies listeners about VSD @a comForm created.
     1183      * @param  comForm  Brings created VSD form. */
     1184    void sigVSDFormCreated(const CVirtualSystemDescriptionForm &comForm);
     1185
     1186public:
     1187
     1188    /** Constructs subnet selection VSD form create notification-progress.
     1189      * @param  comClient             Brings the cloud client being creating VSD form.
     1190      * @param  comVsd                Brings the VSD, form being created for.
     1191      * @param  strProviderShortName  Brings the short provider name.
     1192      * @param  strProfileName        Brings the profile name. */
     1193    UINotificationProgressSubnetSelectionVSDFormCreate(const CCloudClient &comClient,
     1194                                                       const CVirtualSystemDescription &comVSD,
     1195                                                       const QString &strProviderShortName,
     1196                                                       const QString &strProfileName);
     1197
     1198protected:
     1199
     1200    /** Returns object name. */
     1201    virtual QString name() const /* override final */;
     1202    /** Returns object details. */
     1203    virtual QString details() const /* override final */;
     1204    /** Creates and returns started progress-wrapper. */
     1205    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     1206
     1207private slots:
     1208
     1209    /** Handles signal about progress being finished. */
     1210    void sltHandleProgressFinished();
     1211
     1212private:
     1213
     1214    /** Holds the cloud client being creating VSD form. */
     1215    CCloudClient                   m_comClient;
     1216    /** Holds the VSD, form being created for. */
     1217    CVirtualSystemDescription      m_comVSD;
     1218    /** Holds the VSD form being created. */
     1219    CVirtualSystemDescriptionForm  m_comVSDForm;
     1220    /** Holds the short provider name. */
     1221    QString                        m_strProviderShortName;
     1222    /** Holds the profile name. */
     1223    QString                        m_strProfileName;
     1224};
     1225
    11711226/** UINotificationProgress extension for launch VSD form create functionality. */
    11721227class SHARED_LIBRARY_STUFF UINotificationProgressLaunchVSDFormCreate : public UINotificationProgress
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