VirtualBox

Ignore:
Timestamp:
Apr 8, 2019 3:41:31 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9434: Import Appliance wizard: 1st basic page: Integrate hidden for now container allowing to switch import source between local and cloud one.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppDefs.h

    r78044 r78046  
    3333Q_DECLARE_METATYPE(ImportAppliancePointer);
    3434
     35/** Import source types. */
     36enum ImportSourceType
     37{
     38    ImportSourceType_Invalid,
     39    ImportSourceType_Local,
     40    ImportSourceType_Cloud
     41};
     42Q_DECLARE_METATYPE(ImportSourceType);
     43
    3544#endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppDefs_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp

    r78044 r78046  
    1818/* Qt includes: */
    1919#include <QFileInfo>
     20#include <QLabel>
     21#include <QStackedLayout>
    2022#include <QVBoxLayout>
    2123
    2224/* GUI includes: */
     25#include "QIComboBox.h"
    2326#include "QIRichTextLabel.h"
    2427#include "VBoxGlobal.h"
     
    3033
    3134/*********************************************************************************************************************************
     35*   Namespace ImportSourceTypeConverter implementation.                                                                          *
     36*********************************************************************************************************************************/
     37
     38QString ImportSourceTypeConverter::toString(ImportSourceType enmType)
     39{
     40    switch (enmType)
     41    {
     42        case ImportSourceType_Local: return QApplication::translate("UIWizardImportApp", "Local File System");
     43        case ImportSourceType_Cloud: return QApplication::translate("UIWizardImportApp", "Cloud Content Provider");
     44        default: break;
     45    }
     46    return QString();
     47}
     48
     49
     50/*********************************************************************************************************************************
    3251*   Class UIWizardImportAppPage1 implementation.                                                                                 *
    3352*********************************************************************************************************************************/
    3453
    3554UIWizardImportAppPage1::UIWizardImportAppPage1()
    36     : m_pFileSelector(0)
     55    : m_pSourceLabel(0)
     56    , m_pSourceSelector(0)
     57    , m_pStackedLayout(0)
     58    , m_pFileSelector(0)
    3759{
    3860}
     
    5880        }
    5981
    60         /* Create file-path selector: */
    61         m_pFileSelector = new UIEmptyFilePathSelector(this);
    62         if (m_pFileSelector)
     82        /* Create source selector layout: */
     83        QHBoxLayout *pSourceSelectorLayout = new QHBoxLayout;
     84        if (pSourceSelectorLayout)
    6385        {
    64             m_pFileSelector->setHomeDir(vboxGlobal().documentsPath());
    65             m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Open);
    66             m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition);
    67             m_pFileSelector->setEditable(true);
     86            /* Create source label: */
     87            m_pSourceLabel = new QLabel(this);
     88            if (m_pSourceLabel)
     89            {
     90                m_pSourceLabel->hide();
     91                m_pSourceLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
     92                m_pSourceLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     93
     94                /* Add into layout: */
     95                pSourceSelectorLayout->addWidget(m_pSourceLabel);
     96            }
     97
     98            /* Create source selector: */
     99            m_pSourceSelector = new QIComboBox(this);
     100            if (m_pSourceSelector)
     101            {
     102                m_pSourceLabel->setBuddy(m_pSourceSelector);
     103                m_pSourceSelector->hide();
     104                m_pSourceSelector->addItem(QString(), QVariant::fromValue(ImportSourceType_Local));
     105                m_pSourceSelector->addItem(QString(), QVariant::fromValue(ImportSourceType_Cloud));
     106                connect(m_pSourceSelector, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated),
     107                        this, static_cast<void(UIWizardImportAppPageBasic1::*)(int)>(&UIWizardImportAppPageBasic1::sltHandleSourceChange));
     108
     109                /* Add into layout: */
     110                pSourceSelectorLayout->addWidget(m_pSourceSelector);
     111            }
    68112
    69113            /* Add into layout: */
    70             pMainLayout->addWidget(m_pFileSelector);
     114            pMainLayout->addLayout(pSourceSelectorLayout);
     115        }
     116
     117        /* Create stacked layout: */
     118        m_pStackedLayout = new QStackedLayout;
     119        if (m_pStackedLayout)
     120        {
     121            /* Create local container: */
     122            QWidget *pLocalContainer = new QWidget(this);
     123            if (pLocalContainer)
     124            {
     125                /* Create local container layout: */
     126                QVBoxLayout *pLocalContainerLayout = new QVBoxLayout(pLocalContainer);
     127                if (pLocalContainerLayout)
     128                {
     129                    pLocalContainerLayout->setContentsMargins(0, 0, 0, 0);
     130                    pLocalContainerLayout->setSpacing(0);
     131
     132                    /* Create file-path selector: */
     133                    m_pFileSelector = new UIEmptyFilePathSelector(this);
     134                    if (m_pFileSelector)
     135                    {
     136                        m_pFileSelector->setHomeDir(vboxGlobal().documentsPath());
     137                        m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Open);
     138                        m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition);
     139                        m_pFileSelector->setEditable(true);
     140
     141                        /* Add into layout: */
     142                        pLocalContainerLayout->addWidget(m_pFileSelector);
     143                    }
     144
     145                    /* Add stretch: */
     146                    pLocalContainerLayout->addStretch();
     147                }
     148
     149                /* Add into layout: */
     150                m_stackedLayoutIndexMap[ImportSourceType_Local] = m_pStackedLayout->addWidget(pLocalContainer);
     151            }
     152
     153            /* Create cloud container: */
     154            QWidget *pCloudContainer = new QWidget(this);
     155            if (pCloudContainer)
     156            {
     157                /* Create cloud container layout: */
     158                QVBoxLayout *pCloudContainerLayout = new QVBoxLayout(pCloudContainer);
     159                if (pCloudContainerLayout)
     160                {
     161                    pCloudContainerLayout->setContentsMargins(0, 0, 0, 0);
     162                    pCloudContainerLayout->setSpacing(0);
     163
     164                    /* Add stretch: */
     165                    pCloudContainerLayout->addStretch();
     166                }
     167
     168                /* Add into layout: */
     169                m_stackedLayoutIndexMap[ImportSourceType_Cloud] = m_pStackedLayout->addWidget(pCloudContainer);
     170            }
     171
     172            /* Add into layout: */
     173            pMainLayout->addLayout(m_pStackedLayout);
    71174        }
    72175
     
    77180    /* Setup connections: */
    78181    connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged, this, &UIWizardImportAppPageBasic1::completeChanged);
     182}
     183
     184void UIWizardImportAppPageBasic1::sltHandleSourceChange(int iIndex)
     185{
     186    m_pStackedLayout->setCurrentIndex(m_stackedLayoutIndexMap.value(m_pSourceSelector->itemData(iIndex).value<ImportSourceType>()));
    79187}
    80188
     
    88196                                            "saved in the Open Virtualization Format (OVF). "
    89197                                            "To continue, select the file to import below.</p>"));
     198
     199    /* Translate source selector: */
     200    m_pSourceLabel->setText(tr("Source:"));
     201    for (int i = 0; i < m_pSourceSelector->count(); ++i)
     202        m_pSourceSelector->setItemText(i, ImportSourceTypeConverter::toString(m_pSourceSelector->itemData(i).value<ImportSourceType>()));
    90203
    91204    /* Translate file selector: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h

    r78037 r78046  
    2323
    2424/* GUI includes: */
     25#include "UIWizardImportAppDefs.h"
    2526#include "UIWizardPage.h"
    2627
    2728/* Forward declarations: */
     29class QLabel;
     30class QStackedLayout;
     31class QIComboBox;
    2832class QIRichTextLabel;
    2933class UIEmptyFilePathSelector;
     34
     35/** Source type converter namespace. */
     36namespace ImportSourceTypeConverter
     37{
     38    /** Converts QString <= ImportSourceType. */
     39    QString toString(ImportSourceType enmType);
     40}
    3041
    3142/** UIWizardPageBase extension for 1st page of the Import Appliance wizard. */
     
    3647    /** Constructs 1st page base. */
    3748    UIWizardImportAppPage1();
     49
     50    /** Holds the source type label instance. */
     51    QLabel     *m_pSourceLabel;
     52    /** Holds the source type selector instance. */
     53    QIComboBox *m_pSourceSelector;
     54
     55    /** Holds the stacked layout instance. */
     56    QStackedLayout              *m_pStackedLayout;
     57    /** Holds the stacked layout widget indexes map. */
     58    QMap<ImportSourceType, int>  m_stackedLayoutIndexMap;
    3859
    3960    /** Holds the file selector instance. */
     
    5071    /** Constructs 1st basic page. */
    5172    UIWizardImportAppPageBasic1();
     73
     74private slots:
     75
     76    /** Handles change of import source to one with specified @a iIndex. */
     77    void sltHandleSourceChange(int iIndex);
    5278
    5379private:
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