VirtualBox

Changeset 83963 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 24, 2020 11:05:10 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Initial cloud VM settings dialog implementation.

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

Legend:

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

    r83950 r83963  
    288288VBOX_GUI_INC_DIRS = \
    289289        ./src \
     290        ./src/cloud/machinesettings \
    290291        ./src/cloud/profilemanager \
    291292        ./src/converter \
     
    614615#
    615616VirtualBox_QT_MOCHDRS = \
     617        src/cloud/machinesettings/UICloudMachineSettingsDialog.h \
     618        src/cloud/machinesettings/UICloudMachineSettingsDialogPage.h \
    616619        src/cloud/profilemanager/UICloudProfileDetailsWidget.h \
    617620        src/cloud/profilemanager/UICloudProfileManager.h \
     
    10651068VirtualBox_SOURCES = \
    10661069        src/main.cpp \
     1070        src/cloud/machinesettings/UICloudMachineSettingsDialog.cpp \
     1071        src/cloud/machinesettings/UICloudMachineSettingsDialogPage.cpp \
    10671072        src/cloud/profilemanager/UICloudProfileDetailsWidget.cpp \
    10681073        src/cloud/profilemanager/UICloudProfileManager.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/machinesettings/UICloudMachineSettingsDialog.cpp

    r83946 r83963  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewCloudVM class implementation.
     3 * VBox Qt GUI - UICloudMachineSettingsDialog class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2020 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717
    1818/* Qt includes: */
    19 #include <QAbstractButton>
     19#include <QPushButton>
     20#include <QVBoxLayout>
    2021
    2122/* GUI includes: */
     23#include "QIDialogButtonBox.h"
    2224#include "UIMessageCenter.h"
    23 #include "UIWizardNewCloudVM.h"
    24 #include "UIWizardNewCloudVMPageBasic1.h"
    25 #include "UIWizardNewCloudVMPageBasic2.h"
    26 #include "UIWizardNewCloudVMPageExpert.h"
     25#include "UICloudMachineSettingsDialog.h"
     26#include "UICloudMachineSettingsDialogPage.h"
    2727
    2828/* COM includes: */
     
    3030
    3131
    32 UIWizardNewCloudVM::UIWizardNewCloudVM(QWidget *pParent,
    33                                        const CCloudClient &comClient /* = CCloudClient() */,
    34                                        const CVirtualSystemDescription &comDescription /* = CVirtualSystemDescription() */,
    35                                        WizardMode enmMode /* = WizardMode_Auto */)
    36     : UIWizard(pParent, WizardType_NewCloudVM, enmMode)
    37     , m_comClient(comClient)
    38     , m_comVSD(comDescription)
    39     , m_fFullWizard(m_comClient.isNull() || m_comVSD.isNull())
    40     , m_fFinalStepPrevented(false)
     32UICloudMachineSettingsDialog::UICloudMachineSettingsDialog(QWidget *pParent, const CCloudMachine &comCloudMachine)
     33    : QIWithRetranslateUI<QDialog>(pParent)
     34    , m_comCloudMachine(comCloudMachine)
     35    , m_pPage(0)
     36    , m_pButtonBox(0)
    4137{
    42 #ifndef VBOX_WS_MAC
    43     /* Assign watermark: */
    44     assignWatermark(":/wizard_new_cloud_vm.png");
    45 #else
    46     /* Assign background image: */
    47     assignBackground(":/wizard_new_cloud_vm_bg.png");
    48 #endif
     38    prepare();
    4939}
    5040
    51 void UIWizardNewCloudVM::prepare()
     41int UICloudMachineSettingsDialog::exec()
    5242{
    53     /* Create corresponding pages: */
    54     switch (mode())
     43    /* Request dialog initialization: */
     44    QMetaObject::invokeMethod(this, "sltRefresh", Qt::QueuedConnection);
     45
     46    /* Call to base-class: */
     47    return QIWithRetranslateUI<QDialog>::exec();
     48}
     49
     50void UICloudMachineSettingsDialog::accept()
     51{
     52    /** Makes sure page data committed: */
     53    if (m_pPage)
     54        m_pPage->makeSureDataCommitted();
     55
     56    /* Apply form: */
     57    AssertReturnVoid(m_comForm.isNotNull());
     58    CProgress comProgress = m_comForm.Apply();
     59    if (!m_comForm.isOk())
    5560    {
    56         case WizardMode_Basic:
     61        msgCenter().cannotApplyCloudMachineFormSettings(m_comForm, m_strName, this);
     62        return;
     63    }
     64    msgCenter().showModalProgressDialog(comProgress,
     65                                        m_strName,
     66                                        ":/progress_settings_90px.png", this, 0);
     67    if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     68    {
     69        msgCenter().cannotApplyCloudMachineFormSettings(comProgress, m_strName, this);
     70        return;
     71    }
     72
     73    /* Call to base-class: */
     74    QIWithRetranslateUI<QDialog>::accept();
     75}
     76
     77void UICloudMachineSettingsDialog::retranslateUi()
     78{
     79    /* Translate title: */
     80    const QString strCaption = tr("Settings");
     81    if (m_strName.isNull())
     82        setWindowTitle(strCaption);
     83    else
     84        setWindowTitle(tr("%1 - %2").arg(m_strName, strCaption));
     85}
     86
     87void UICloudMachineSettingsDialog::sltRefresh()
     88{
     89    /* Update name: */
     90    m_strName = m_comCloudMachine.GetName();
     91    if (!m_comCloudMachine.isOk())
     92    {
     93        msgCenter().cannotAcquireCloudMachineParameter(m_comCloudMachine, this);
     94        reject();
     95    }
     96
     97    /* Retranslate title: */
     98    retranslateUi();
     99
     100    /* Update form: */
     101    CForm comForm;
     102    CProgress comProgress = m_comCloudMachine.GetSettingsForm(comForm);
     103    if (!m_comCloudMachine.isOk())
     104    {
     105        msgCenter().cannotAcquireCloudMachineParameter(m_comCloudMachine, this);
     106        reject();
     107    }
     108    msgCenter().showModalProgressDialog(comProgress,
     109                                        m_strName,
     110                                        ":/progress_settings_90px.png", this, 0);
     111    if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     112    {
     113        msgCenter().cannotAcquireCloudClientParameter(comProgress, this);
     114        reject();
     115    }
     116    m_comForm = comForm;
     117
     118    /* Assign page with form: */
     119    m_pPage->setForm(m_comForm);
     120}
     121
     122void UICloudMachineSettingsDialog::prepare()
     123{
     124    /* Prepare layout: */
     125    QVBoxLayout *pLayout = new QVBoxLayout(this);
     126    if (pLayout)
     127    {
     128        /* Prepare page: */
     129        m_pPage = new UICloudMachineSettingsDialogPage(this);
     130        if (m_pPage)
    57131        {
    58             if (m_fFullWizard)
    59                 setPage(Page1, new UIWizardNewCloudVMPageBasic1);
    60             setPage(Page2, new UIWizardNewCloudVMPageBasic2(m_fFullWizard));
    61             break;
     132            /* Add into layout: */
     133            pLayout->addWidget(m_pPage);
    62134        }
    63         case WizardMode_Expert:
     135
     136        /* Prepare button-box: */
     137        m_pButtonBox = new QIDialogButtonBox;
     138        if (m_pButtonBox)
    64139        {
    65             setPage(PageExpert, new UIWizardNewCloudVMPageExpert(m_fFullWizard));
    66             break;
    67         }
    68         default:
    69         {
    70             AssertMsgFailed(("Invalid mode: %d", mode()));
    71             break;
     140            m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     141            m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
     142            connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UICloudMachineSettingsDialog::accept);
     143            connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UICloudMachineSettingsDialog::reject);
     144            /* Add into layout: */
     145            pLayout->addWidget(m_pButtonBox);
    72146        }
    73147    }
    74     /* Call to base-class: */
    75     UIWizard::prepare();
     148
     149    /* Apply language settings: */
     150    retranslateUi();
    76151}
    77 
    78 bool UIWizardNewCloudVM::createVSDForm()
    79 {
    80     /* Prepare result: */
    81     bool fResult = false;
    82 
    83     /* Main API request sequence, can be interrupted after any step: */
    84     do
    85     {
    86         /* Acquire prepared client and description: */
    87         CCloudClient comClient = client();
    88         CVirtualSystemDescription comDescription = vsd();
    89         AssertReturn(comClient.isNotNull() && comDescription.isNotNull(), false);
    90 
    91         /* Read Cloud Client description form: */
    92         CVirtualSystemDescriptionForm comForm;
    93         CProgress comProgress = comClient.GetLaunchDescriptionForm(comDescription, comForm);
    94         if (!comClient.isOk())
    95         {
    96             msgCenter().cannotAcquireCloudClientParameter(comClient);
    97             break;
    98         }
    99 
    100         /* Show "Acquire launch form" progress: */
    101         msgCenter().showModalProgressDialog(comProgress, tr("Acquire launch form ..."),
    102                                             ":/progress_refresh_90px.png", this, 0);
    103         if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    104         {
    105             msgCenter().cannotAcquireCloudClientParameter(comProgress);
    106             break;
    107         }
    108 
    109         /* Remember Virtual System Description Form: */
    110         setVSDForm(comForm);
    111 
    112         /* Finally, success: */
    113         fResult = true;
    114     }
    115     while (0);
    116 
    117     /* Return result: */
    118     return fResult;
    119 }
    120 
    121 bool UIWizardNewCloudVM::createCloudVM()
    122 {
    123     /* Prepare result: */
    124     bool fResult = false;
    125 
    126     /* Main API request sequence, can be interrupted after any step: */
    127     do
    128     {
    129         /* Do nothing if prevented: */
    130         if (m_fFinalStepPrevented)
    131         {
    132             fResult = true;
    133             break;
    134         }
    135 
    136         /* Acquire prepared client and description: */
    137         CCloudClient comClient = client();
    138         CVirtualSystemDescription comDescription = vsd();
    139         AssertReturn(comClient.isNotNull() && comDescription.isNotNull(), false);
    140 
    141         /* Initiate cloud VM creation procedure: */
    142         CProgress comProgress = comClient.LaunchVM(comDescription);
    143         if (!comClient.isOk())
    144         {
    145             msgCenter().cannotCreateCloudMachine(comClient, this);
    146             break;
    147         }
    148 
    149         /* Show "Create Cloud Machine" progress: */
    150         msgCenter().showModalProgressDialog(comProgress, tr("Create Cloud Machine ..."),
    151                                             ":/progress_new_cloud_vm_90px.png", this, 0);
    152         if (comProgress.GetCanceled())
    153             break;
    154         if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    155         {
    156             msgCenter().cannotCreateCloudMachine(comProgress, this);
    157             break;
    158         }
    159 
    160         /* Finally, success: */
    161         fResult = true;
    162     }
    163     while (0);
    164 
    165     /* Return result: */
    166     return fResult;
    167 }
    168 
    169 void UIWizardNewCloudVM::scheduleAutoFinish()
    170 {
    171     QMetaObject::invokeMethod(this, "sltTriggerFinishButton", Qt::QueuedConnection);
    172 }
    173 
    174 void UIWizardNewCloudVM::retranslateUi()
    175 {
    176     /* Call to base-class: */
    177     UIWizard::retranslateUi();
    178 
    179     /* Translate wizard: */
    180     setWindowTitle(tr("Create Cloud Virtual Machine"));
    181     setButtonText(QWizard::FinishButton, tr("Create"));
    182 }
    183 
    184 void UIWizardNewCloudVM::sltTriggerFinishButton()
    185 {
    186     button(QWizard::FinishButton)->click();
    187 }
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/machinesettings/UICloudMachineSettingsDialog.h

    r83946 r83963  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewCloudVM class declaration.
     3 * VBox Qt GUI - UICloudMachineSettingsDialog class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2020 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVM_h
    19 #define FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVM_h
     18#ifndef FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialog_h
     19#define FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialog_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QDialog>
     26#include <QPointer>
     27
    2428/* GUI includes: */
    25 #include "UIWizard.h"
     29#include "QIWithRetranslateUI.h"
     30#include "UICloudMachineSettingsDialogPage.h"
    2631
    2732/* COM includes: */
    2833#include "COMEnums.h"
    29 #include "CCloudClient.h"
    30 #include "CVirtualSystemDescription.h"
    31 #include "CVirtualSystemDescriptionForm.h"
     34#include "CCloudMachine.h"
     35#include "CForm.h"
    3236
    33 /** New Cloud VM wizard. */
    34 class UIWizardNewCloudVM : public UIWizard
     37/* Forward declarations: */
     38class QIDialogButtonBox;
     39
     40/** Cloud machine settings dialog. */
     41class UICloudMachineSettingsDialog : public QIWithRetranslateUI<QDialog>
    3542{
    3643    Q_OBJECT;
     
    3845public:
    3946
    40     /** Basic page IDs. */
    41     enum
    42     {
    43         Page1,
    44         Page2
    45     };
     47    /** Constructs @a comCloudMachine settings dialog passing @a pParent to the base-class. */
     48    UICloudMachineSettingsDialog(QWidget *pParent, const CCloudMachine &comCloudMachine);
    4649
    47     /** Expert page IDs. */
    48     enum
    49     {
    50         PageExpert
    51     };
     50public slots:
    5251
    53     /** Constructs New Cloud VM wizard passing @a pParent to the base-class.
    54       * @param  comClient       Brings the Cloud Client object to work with.
    55       * @param  comDescription  Brings the Virtual System Description object to use. */
    56     UIWizardNewCloudVM(QWidget *pParent,
    57                        const CCloudClient &comClient = CCloudClient(),
    58                        const CVirtualSystemDescription &comDescription = CVirtualSystemDescription(),
    59                        WizardMode enmMode = WizardMode_Auto);
     52    /** Shows the dialog as a modal dialog, blocking until the user closes it. */
     53    virtual int exec() /* override */;
    6054
    61     /** Prepares all. */
    62     virtual void prepare() /* override */;
    63 
    64     /** Sets whether the final step is @a fPrevented. */
    65     void setFinalStepPrevented(bool fPrevented) { m_fFinalStepPrevented = fPrevented; }
    66 
    67     /** Defines Cloud @a comClient object. */
    68     void setClient(const CCloudClient &comClient) { m_comClient = comClient; }
    69     /** Returns Cloud Client object. */
    70     CCloudClient client() const { return m_comClient; }
    71 
    72     /** Defines Virtual System @a comDescription object. */
    73     void setVSD(const CVirtualSystemDescription &comDescription) { m_comVSD = comDescription; }
    74     /** Returns Virtual System Description object. */
    75     CVirtualSystemDescription vsd() const { return m_comVSD; }
    76 
    77     /** Defines Virtual System Description @a comForm object. */
    78     void setVSDForm(const CVirtualSystemDescriptionForm &comForm) { m_comVSDForm = comForm; }
    79     /** Returns Virtual System Description Form object. */
    80     CVirtualSystemDescriptionForm vsdForm() const { return m_comVSDForm; }
    81 
    82     /** Creates VSD Form. */
    83     bool createVSDForm();
    84 
    85     /** Creates New Cloud VM. */
    86     bool createCloudVM();
    87 
    88     /** Schedules Finish button trigger for
    89       * the next event-loop cicle. */
    90     void scheduleAutoFinish();
     55    /** Hides the modal dialog and sets the result code to Accepted. */
     56    virtual void accept() /* override */;
    9157
    9258protected:
     
    9763private slots:
    9864
    99     /** Triggers Finish button. */
    100     void sltTriggerFinishButton();
     65    /** Performs dialog refresh. */
     66    void sltRefresh();
    10167
    10268private:
    10369
    104     /** Holds the Cloud Client object reference. */
    105     CCloudClient                   m_comClient;
    106     /** Holds the Virtual System Description object reference. */
    107     CVirtualSystemDescription      m_comVSD;
    108     /** Holds the Virtual System Description Form object reference. */
    109     CVirtualSystemDescriptionForm  m_comVSDForm;
     70    /** Prepares all. */
     71    void prepare();
    11072
    111     /** Holds whether we want full wizard form or short one. */
    112     bool  m_fFullWizard;
    113     /** Holds whether the final step is prevented. */
    114     bool  m_fFinalStepPrevented;
     73    /** Holds the cloud machine object reference. */
     74    CCloudMachine  m_comCloudMachine;
     75    /** Holds the cloud machine settings form object reference. */
     76    CForm          m_comForm;
     77    /** Holds the cloud machine name. */
     78    QString        m_strName;
     79
     80    /** Holds the cloud machine settings dialog page instance. */
     81    UISafePointerCloudMachineSettingsDialogPage  m_pPage;
     82    /** Holds the dialog button-box instance. */
     83    QIDialogButtonBox                           *m_pButtonBox;
    11584};
    11685
    117 /** Safe pointer to new cloud vm wizard. */
    118 typedef QPointer<UIWizardNewCloudVM> UISafePointerWizardNewCloudVM;
     86/** Safe pointer to cloud machine settings dialog. */
     87typedef QPointer<UICloudMachineSettingsDialog> UISafePointerCloudMachineSettingsDialog;
    11988
    120 #endif /* !FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVM_h */
     89#endif /* !FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialog_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/machinesettings/UICloudMachineSettingsDialogPage.cpp

    r83946 r83963  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewCloudVMPageBasic2 class implementation.
     3 * VBox Qt GUI - UICloudMachineSettingsDialogPage class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2020 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818/* Qt includes: */
    1919#include <QHeaderView>
    20 #include <QLabel>
    2120#include <QVBoxLayout>
    2221
    2322/* GUI includes: */
    24 #include "QIRichTextLabel.h"
    25 #include "UIMessageCenter.h"
    26 #include "UIWizardNewCloudVM.h"
    27 #include "UIWizardNewCloudVMPageBasic2.h"
     23#include "UICloudMachineSettingsDialogPage.h"
    2824
    2925
    30 /*********************************************************************************************************************************
    31 *   Class UIWizardNewCloudVMPage2 implementation.                                                                                *
    32 *********************************************************************************************************************************/
    33 
    34 UIWizardNewCloudVMPage2::UIWizardNewCloudVMPage2(bool fFullWizard)
    35     : m_fFullWizard(fFullWizard)
    36     , m_fPolished(false)
     26UICloudMachineSettingsDialogPage::UICloudMachineSettingsDialogPage(QWidget *pParent)
     27    : QWidget(pParent)
    3728{
     29    prepare();
    3830}
    3931
    40 void UIWizardNewCloudVMPage2::refreshFormPropertiesTable()
     32void UICloudMachineSettingsDialogPage::setForm(const CForm &comForm)
    4133{
    42     /* Acquire VSD form: */
    43     CVirtualSystemDescriptionForm comForm = vsdForm();
    44     /* Make sure the properties table get the new description form: */
    45     if (comForm.isNotNull())
    46         m_pFormEditor->setVirtualSystemDescriptionForm(comForm);
     34    if (m_pFormEditor)
     35        m_pFormEditor->setForm(comForm);
    4736}
    4837
    49 CCloudClient UIWizardNewCloudVMPage2::client() const
     38void UICloudMachineSettingsDialogPage::makeSureDataCommitted()
    5039{
    51     return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->client();
     40    if (m_pFormEditor)
     41        m_pFormEditor->makeSureEditorDataCommitted();
    5242}
    5343
    54 CVirtualSystemDescription UIWizardNewCloudVMPage2::vsd() const
     44void UICloudMachineSettingsDialogPage::prepare()
    5545{
    56     return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->vsd();
    57 }
     46    /* Prepare layout: */
     47    QVBoxLayout *pLayout = new QVBoxLayout(this);
     48    if (pLayout)
     49    {
     50        pLayout->setContentsMargins(0, 0, 0, 0);
    5851
    59 void UIWizardNewCloudVMPage2::setVSDForm(const CVirtualSystemDescriptionForm &comForm)
    60 {
    61     qobject_cast<UIWizardNewCloudVM*>(wizardImp())->setVSDForm(comForm);
    62 }
    63 
    64 CVirtualSystemDescriptionForm UIWizardNewCloudVMPage2::vsdForm() const
    65 {
    66     return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->vsdForm();
    67 }
    68 
    69 
    70 /*********************************************************************************************************************************
    71 *   Class UIWizardNewCloudVMPageBasic2 implementation.                                                                           *
    72 *********************************************************************************************************************************/
    73 
    74 UIWizardNewCloudVMPageBasic2::UIWizardNewCloudVMPageBasic2(bool fFullWizard)
    75     : UIWizardNewCloudVMPage2(fFullWizard)
    76 {
    77     /* Create main layout: */
    78     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    79     if (pMainLayout)
    80     {
    81         /* Create label: */
    82         m_pLabel = new QIRichTextLabel(this);
    83         if (m_pLabel)
    84         {
    85             /* Add into layout: */
    86             pMainLayout->addWidget(m_pLabel);
    87         }
    88 
    89         /* Create form editor widget: */
     52        /* Prepare form editor widget: */
    9053        m_pFormEditor = new UIFormEditorWidget(this);
    9154        if (m_pFormEditor)
    9255        {
    93             /* Make form-editor fit 8 sections in height by default: */
     56            /* Make form-editor fit 12 sections in height by default: */
    9457            const int iDefaultSectionHeight = m_pFormEditor->verticalHeader()
    9558                                            ? m_pFormEditor->verticalHeader()->defaultSectionSize()
    9659                                            : 0;
    9760            if (iDefaultSectionHeight > 0)
    98                 m_pFormEditor->setMinimumHeight(8 * iDefaultSectionHeight);
     61            {
     62                const int iProposedHeight = iDefaultSectionHeight * 12;
     63                const int iProposedWidth = iProposedHeight * 1.66;
     64                m_pFormEditor->setMinimumSize(iProposedWidth, iProposedHeight);
     65            }
    9966
    10067            /* Add into layout: */
    101             pMainLayout->addWidget(m_pFormEditor);
     68            pLayout->addWidget(m_pFormEditor);
    10269        }
    10370    }
    10471}
    105 
    106 void UIWizardNewCloudVMPageBasic2::retranslateUi()
    107 {
    108     /* Translate page: */
    109     setTitle(UIWizardNewCloudVM::tr("Cloud Virtual Machine settings"));
    110 
    111     /* Translate description label: */
    112     m_pLabel->setText(UIWizardNewCloudVM::tr("These are the the suggested settings of the cloud VM creation procedure, they are "
    113                                              "influencing the resulting cloud VM instance.  You can change many of the "
    114                                              "properties shown by double-clicking on the items and disable others using the "
    115                                              "check boxes below."));
    116 }
    117 
    118 void UIWizardNewCloudVMPageBasic2::initializePage()
    119 {
    120     /* If wasn't polished yet: */
    121     if (!m_fPolished)
    122     {
    123         if (!m_fFullWizard)
    124         {
    125             /* Generate VSD form, asynchronously: */
    126             QMetaObject::invokeMethod(this, "sltInitShortWizardForm", Qt::QueuedConnection);
    127         }
    128         m_fPolished = true;
    129     }
    130 
    131     /* Refresh form properties: */
    132     refreshFormPropertiesTable();
    133 
    134     /* Translate page: */
    135     retranslateUi();
    136 }
    137 
    138 bool UIWizardNewCloudVMPageBasic2::isComplete() const
    139 {
    140     /* Initial result: */
    141     bool fResult = true;
    142 
    143     /* Check cloud settings: */
    144     fResult =    client().isNotNull()
    145               && vsd().isNotNull();
    146 
    147     /* Return result: */
    148     return fResult;
    149 }
    150 
    151 bool UIWizardNewCloudVMPageBasic2::validatePage()
    152 {
    153     /* Initial result: */
    154     bool fResult = true;
    155 
    156     /* Lock finish button: */
    157     startProcessing();
    158 
    159     /* Make sure table has own data committed: */
    160     m_pFormEditor->makeSureEditorDataCommitted();
    161 
    162     /* Check whether we have proper VSD form: */
    163     CVirtualSystemDescriptionForm comForm = vsdForm();
    164     /* Give changed VSD back: */
    165     if (comForm.isNotNull())
    166     {
    167         comForm.GetVirtualSystemDescription();
    168         fResult = comForm.isOk();
    169         if (!fResult)
    170             msgCenter().cannotAcquireVirtualSystemDescriptionFormProperty(comForm);
    171     }
    172 
    173     /* Try to create cloud VM: */
    174     if (fResult)
    175     {
    176         fResult = qobject_cast<UIWizardNewCloudVM*>(wizard())->createCloudVM();
    177 
    178         /* If the final step failed we could try
    179          * sugest user more valid form this time: */
    180         if (!fResult)
    181             sltInitShortWizardForm();
    182     }
    183 
    184     /* Unlock finish button: */
    185     endProcessing();
    186 
    187     /* Return result: */
    188     return fResult;
    189 }
    190 
    191 void UIWizardNewCloudVMPageBasic2::sltInitShortWizardForm()
    192 {
    193     /* Create Virtual System Description Form: */
    194     qobject_cast<UIWizardNewCloudVM*>(wizardImp())->createVSDForm();
    195 
    196     /* Refresh form properties table: */
    197     refreshFormPropertiesTable();
    198     emit completeChanged();
    199 }
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/machinesettings/UICloudMachineSettingsDialogPage.h

    r83946 r83963  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewCloudVMPageBasic2 class declaration.
     3 * VBox Qt GUI - UICloudMachineSettingsDialogPage class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2020 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVMPageBasic2_h
    19 #define FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVMPageBasic2_h
     18#ifndef FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialogPage_h
     19#define FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialogPage_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QPointer>
     26#include <QWidget>
     27
    2428/* GUI includes: */
    2529#include "UIFormEditorWidget.h"
    26 #include "UIWizardPage.h"
    27 
    28 /* COM includes: */
    29 #include "COMEnums.h"
    30 #include "CCloudClient.h"
    31 #include "CVirtualSystemDescription.h"
    32 #include "CVirtualSystemDescriptionForm.h"
    3330
    3431/* Forward declarations: */
    35 class QIRichTextLabel;
     32class CForm;
    3633
    37 /** UIWizardPageBase extension for 2nd page of the New Cloud VM wizard. */
    38 class UIWizardNewCloudVMPage2 : public UIWizardPageBase
    39 {
    40 protected:
    41 
    42     /** Constructs 2nd page base. */
    43     UIWizardNewCloudVMPage2(bool fFullWizard);
    44 
    45     /** Refreshes form properties table. */
    46     void refreshFormPropertiesTable();
    47 
    48     /** Returns Cloud Client object. */
    49     CCloudClient client() const;
    50     /** Returns Virtual System Description object. */
    51     CVirtualSystemDescription vsd() const;
    52 
    53     /** Defines Virtual System Description @a comForm object. */
    54     void setVSDForm(const CVirtualSystemDescriptionForm &comForm);
    55     /** Returns Virtual System Description Form object. */
    56     CVirtualSystemDescriptionForm vsdForm() const;
    57 
    58     /** Holds whether wizard should be in full form. */
    59     bool  m_fFullWizard;
    60     /** Holds whether starting page was polished. */
    61     bool  m_fPolished;
    62 
    63     /** Holds the Form Editor widget instance. */
    64     UIFormEditorWidgetPointer  m_pFormEditor;
    65 };
    66 
    67 /** UIWizardPage extension for 2nd page of the New Cloud VM wizard, extends UIWizardNewCloudVMPage2 as well. */
    68 class UIWizardNewCloudVMPageBasic2 : public UIWizardPage, public UIWizardNewCloudVMPage2
     34/** Cloud machine settings dialog page. */
     35class UICloudMachineSettingsDialogPage : public QWidget
    6936{
    7037    Q_OBJECT;
     
    7239public:
    7340
    74     /** Constructs 2nd basic page. */
    75     UIWizardNewCloudVMPageBasic2(bool fFullWizard);
     41    /** Constructs cloud machine settings dialog page passing @a pParent to the base-class. */
     42    UICloudMachineSettingsDialogPage(QWidget *pParent);
    7643
    77 protected:
     44    /** Defines page @a comForm. */
     45    void setForm(const CForm &comForm);
    7846
    79     /** Allows access wizard from base part. */
    80     virtual UIWizard *wizardImp() const /* override */ { return UIWizardPage::wizard(); }
    81 
    82     /** Handles translation event. */
    83     virtual void retranslateUi() /* override */;
    84 
    85     /** Performs page initialization. */
    86     virtual void initializePage() /* override */;
    87 
    88     /** Returns whether page is complete. */
    89     virtual bool isComplete() const /* override */;
    90 
    91     /** Performs page validation. */
    92     virtual bool validatePage() /* override */;
    93 
    94 private slots:
    95 
    96     /** Initializes short wizard form. */
    97     void sltInitShortWizardForm();
     47    /** Makes sure page data committed. */
     48    void makeSureDataCommitted();
    9849
    9950private:
    10051
    101     /** Holds the label instance. */
    102     QIRichTextLabel *m_pLabel;
     52    /** Prepares all. */
     53    void prepare();
     54
     55    /** Holds the form editor widget instance. */
     56    UIFormEditorWidgetPointer  m_pFormEditor;
    10357};
    10458
    105 #endif /* !FEQT_INCLUDED_SRC_wizards_newcloudvm_UIWizardNewCloudVMPageBasic2_h */
     59/** Safe pointer to Form Editor widget. */
     60typedef QPointer<UICloudMachineSettingsDialogPage> UISafePointerCloudMachineSettingsDialogPage;
     61
     62#endif /* !FEQT_INCLUDED_SRC_cloud_machinesettings_UICloudMachineSettingsDialogPage_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r83962 r83963  
    6262#include "CCloudProviderManager.h"
    6363#include "CDHCPServer.h"
     64#include "CForm.h"
    6465#include "CGraphicsAdapter.h"
    6566#include "CNATEngine.h"
     
    13441345             .arg(CMachine(machine).GetName(), CMachine(machine).GetSettingsFilePath()),
    13451346          UIErrorString::formatErrorInfo(machine));
     1347}
     1348
     1349void UIMessageCenter::cannotApplyCloudMachineFormSettings(const CForm &comForm, const QString &strName, QWidget *pParent /* = 0 */) const
     1350{
     1351    error(pParent, MessageType_Error,
     1352          tr("Failed to save the settings of the cloud virtual machine <b>%1</b>.").arg(strName),
     1353          UIErrorString::formatErrorInfo(comForm));
     1354}
     1355
     1356void UIMessageCenter::cannotApplyCloudMachineFormSettings(const CProgress &comProgress, const QString &strName, QWidget *pParent /* = 0 */) const
     1357{
     1358    error(pParent, MessageType_Error,
     1359          tr("Failed to save the settings of the cloud virtual machine <b>%1</b>.").arg(strName),
     1360          UIErrorString::formatErrorInfo(comProgress));
    13461361}
    13471362
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r83962 r83963  
    344344    void cannotChangeMachineAttribute(const CMachine &comMachine, QWidget *pParent = 0) const;
    345345    void cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent = 0) const;
     346    void cannotApplyCloudMachineFormSettings(const CForm &comForm, const QString &strName, QWidget *pParent = 0) const;
     347    void cannotApplyCloudMachineFormSettings(const CProgress &comProgress, const QString &strName, QWidget *pParent = 0) const;
    346348    void cannotChangeGraphicsAdapterAttribute(const CGraphicsAdapter &comAdapter, QWidget *pParent = 0) const;
    347349    void cannotChangeAudioAdapterAttribute(const CAudioAdapter &comAdapter, QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r83962 r83963  
    2525#include "QIFileDialog.h"
    2626#include "UIActionPoolManager.h"
     27#include "UICloudMachineSettingsDialog.h"
    2728#include "UICloudProfileManager.h"
    2829#include "UIDesktopServices.h"
     
    612613    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    613614
    614     /* Process href from VM details / description: */
    615     if (!strCategory.isEmpty() && strCategory[0] != '#')
    616     {
    617         uiCommon().openURL(strCategory);
    618     }
     615    /* For local machine: */
     616    if (pItem->itemType() == UIVirtualMachineItemType_Local)
     617    {
     618        /* Process href from VM details / description: */
     619        if (!strCategory.isEmpty() && strCategory[0] != '#')
     620        {
     621            uiCommon().openURL(strCategory);
     622        }
     623        else
     624        {
     625            /* Check if control is coded into the URL by %%: */
     626            if (strControl.isEmpty())
     627            {
     628                QStringList parts = strCategory.split("%%");
     629                if (parts.size() == 2)
     630                {
     631                    strCategory = parts.at(0);
     632                    strControl = parts.at(1);
     633                }
     634            }
     635
     636            /* Don't show the inaccessible warning
     637             * if the user tries to open VM settings: */
     638            m_fFirstMediumEnumerationHandled = true;
     639
     640            /* Use the "safe way" to open stack of Mac OS X Sheets: */
     641            QWidget *pDialogParent = windowManager().realParentWindow(this);
     642            UISafePointerSettingsDialogMachine pDialog = new UISettingsDialogMachine(pDialogParent,
     643                                                                                     uID.isNull() ? pItem->id() : uID,
     644                                                                                     strCategory, strControl);
     645            windowManager().registerNewParent(pDialog, pDialogParent);
     646
     647            /* Execute dialog: */
     648            pDialog->execute();
     649            delete pDialog;
     650        }
     651    }
     652    /* For cloud machine: */
    619653    else
    620654    {
    621         /* Check if control is coded into the URL by %%: */
    622         if (strControl.isEmpty())
    623         {
    624             QStringList parts = strCategory.split("%%");
    625             if (parts.size() == 2)
    626             {
    627                 strCategory = parts.at(0);
    628                 strControl = parts.at(1);
    629             }
    630         }
    631 
    632         /* Don't show the inaccessible warning
    633          * if the user tries to open VM settings: */
    634         m_fFirstMediumEnumerationHandled = true;
    635 
    636655        /* Use the "safe way" to open stack of Mac OS X Sheets: */
    637656        QWidget *pDialogParent = windowManager().realParentWindow(this);
    638         UISafePointerSettingsDialogMachine pDialog = new UISettingsDialogMachine(pDialogParent,
    639                                                                                  uID.isNull() ? pItem->id() : uID,
    640                                                                                  strCategory, strControl);
     657        UISafePointerCloudMachineSettingsDialog pDialog = new UICloudMachineSettingsDialog(pDialogParent,
     658                                                                                           pItem->toCloud()->machine());
    641659        windowManager().registerNewParent(pDialog, pDialogParent);
    642660
    643661        /* Execute dialog: */
    644         pDialog->execute();
     662        pDialog->exec();
    645663        delete pDialog;
    646664    }
     
    19882006            return !isGroupSavingInProgress() &&
    19892007                   items.size() == 1 &&
    1990                    pItem->toLocal() &&
    19912008                   pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null &&
    19922009                   (m_pWidget->currentMachineTool() != UIToolType_Snapshots ||
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp

    r83921 r83963  
    110110
    111111    /* Determine configuration access level: */
    112     m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null;
     112    if (itemType() == UIVirtualMachineItemType_CloudReal)
     113        m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Full;
     114    else
     115        m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null;
    113116
    114117    /* Determine whether we should show this VM details: */
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