VirtualBox

Changeset 73072 in vbox


Ignore:
Timestamp:
Jul 11, 2018 4:15:10 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9152: Export Appliance wizard: Storage and Expert pages: Adding provider profile settings table.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp

    r73068 r73072  
    2525# include <QDir>
    2626# include <QGridLayout>
     27# include <QHeaderView>
    2728# include <QLabel>
    2829# include <QLineEdit>
    2930# include <QStackedWidget>
     31# include <QTableWidget>
    3032# include <QVBoxLayout>
    3133
     
    5759    , m_pProfileComboBoxLabel(0)
    5860    , m_pProfileComboBox(0)
     61    , m_pProfileSettingsTable(0)
    5962{
    6063}
     
    120123}
    121124
     125void UIWizardExportAppPage3::populateProfileSettings()
     126{
     127    /* Acquire current profile table: */
     128    // Here goes the experiamental lists with
     129    // arbitrary contents for testing purposes.
     130    QStringList keys;
     131    QStringList values;
     132    keys << "Key 1";
     133    keys << "Key 2";
     134    keys << "Key 3";
     135    keys << "Key 4";
     136    values << "Value 1";
     137    values << "Value 2";
     138    values << "Value 3";
     139    values << "Value 4";
     140    m_pProfileSettingsTable->clear();
     141    m_pProfileSettingsTable->setRowCount(4);
     142    m_pProfileSettingsTable->setColumnCount(2);
     143
     144    /* Push acquired keys/values to data fields: */
     145    for (int i = 0; i < m_pProfileSettingsTable->rowCount(); ++i)
     146    {
     147        QTableWidgetItem *pItem1 = new QTableWidgetItem(keys.at(i));
     148        pItem1->setFlags(pItem1->flags() & ~Qt::ItemIsEditable);
     149        QTableWidgetItem *pItem2 = new QTableWidgetItem(values.at(i));
     150        pItem2->setFlags(pItem2->flags() & ~Qt::ItemIsEditable);
     151        m_pProfileSettingsTable->setItem(i, 0, pItem1);
     152        m_pProfileSettingsTable->setItem(i, 1, pItem2);
     153    }
     154
     155    /* Adjust the table: */
     156    adjustProfileSettingsTable();
     157}
     158
    122159void UIWizardExportAppPage3::updatePageAppearance()
    123160{
     
    209246    AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!"));
    210247    m_pProviderComboBox->setToolTip(strCurrentToolTip);
     248}
     249
     250void UIWizardExportAppPage3::adjustProfileSettingsTable()
     251{
     252    /* Disable last column stretching temporary: */
     253    m_pProfileSettingsTable->horizontalHeader()->setStretchLastSection(false);
     254
     255    /* Resize both columns to contents: */
     256    m_pProfileSettingsTable->resizeColumnsToContents();
     257    /* Then acquire full available width: */
     258    const int iFullWidth = m_pProfileSettingsTable->viewport()->width();
     259    /* First column should not be less than it's minimum size, last gets the rest: */
     260    const int iMinimumWidth0 = qMin(m_pProfileSettingsTable->horizontalHeader()->sectionSize(0), iFullWidth / 2);
     261    m_pProfileSettingsTable->horizontalHeader()->resizeSection(0, iMinimumWidth0);
     262
     263    /* Enable last column stretching again: */
     264    m_pProfileSettingsTable->horizontalHeader()->setStretchLastSection(true);
    211265}
    212266
     
    423477                        pSettingsLayout2->addWidget(m_pProfileComboBoxLabel, 1, 0);
    424478                    }
    425 
    426                     /* Create placeholder: */
    427                     QWidget *pPlaceholder = new QWidget;
    428                     if (pPlaceholder)
    429                     {
    430                         /* Add into layout: */
    431                         pSettingsLayout2->addWidget(pPlaceholder, 2, 0, 1, 2);
     479                    /* Create profile settings table: */
     480                    m_pProfileSettingsTable = new QTableWidget;
     481                    if (m_pProfileSettingsTable)
     482                    {
     483                        const QFontMetrics fm(m_pProfileSettingsTable->font());
     484                        const int iFontWidth = fm.width('x');
     485                        const int iTotalWidth = 50 * iFontWidth;
     486                        const int iFontHeight = fm.height();
     487                        const int iTotalHeight = 4 * iFontHeight;
     488                        m_pProfileSettingsTable->setMinimumSize(QSize(iTotalWidth, iTotalHeight));
     489                        m_pProfileSettingsTable->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     490                        m_pProfileSettingsTable->setAlternatingRowColors(true);
     491                        m_pProfileSettingsTable->horizontalHeader()->setVisible(false);
     492                        m_pProfileSettingsTable->verticalHeader()->setVisible(false);
     493                        m_pProfileSettingsTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
     494
     495                        /* Add into layout: */
     496                        pSettingsLayout2->addWidget(m_pProfileSettingsTable, 2, 1);
    432497                    }
    433498                }
     
    448513    /* Populate profiles: */
    449514    populateProfiles();
     515    /* Populate profile settings: */
     516    populateProfileSettings();
    450517
    451518    /* Setup connections: */
     
    462529    registerField("format", this, "format");
    463530    registerField("manifestSelected", this, "manifestSelected");
     531}
     532
     533bool UIWizardExportAppPageBasic3::event(QEvent *pEvent)
     534{
     535    /* Handle known event types: */
     536    switch (pEvent->type())
     537    {
     538        case QEvent::Show:
     539        case QEvent::Resize:
     540        {
     541            /* Adjust profile settings table: */
     542            adjustProfileSettingsTable();
     543            break;
     544        }
     545        default:
     546            break;
     547    }
     548
     549    /* Call to base-class: */
     550    return UIWizardPage::event(pEvent);
    464551}
    465552
     
    624711void UIWizardExportAppPageBasic3::sltHandleProfileComboChange()
    625712{
    626 }
     713    /* Refresh required settings: */
     714    populateProfileSettings();
     715}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h

    r73033 r73072  
    3131class QLineEdit;
    3232class QStackedWidget;
     33class QTableWidget;
    3334class QIRichTextLabel;
    3435class UIEmptyFilePathSelector;
     
    4950    /** Populates profiles. */
    5051    void populateProfiles();
     52    /** Populates profile settings. */
     53    void populateProfileSettings();
    5154
    5255    /** Updates page appearance. */
     
    6669    /** Updates provider combo tool-tips. */
    6770    void updateProviderComboToolTip();
     71
     72    /** Adjusts profile settings table. */
     73    void adjustProfileSettingsTable();
    6874
    6975    /** Returns path. */
     
    124130
    125131    /** Holds the profile combo-box label instance. */
    126     QLabel    *m_pProfileComboBoxLabel;
     132    QLabel       *m_pProfileComboBoxLabel;
    127133    /** Holds the profile combo-box instance. */
    128     QComboBox *m_pProfileComboBox;
     134    QComboBox    *m_pProfileComboBox;
     135    /** Holds the profile settings table-widget instance. */
     136    QTableWidget *m_pProfileSettingsTable;
    129137};
    130138
     
    145153
    146154protected:
     155
     156    /** Handle any Qt @a pEvent. */
     157    virtual bool event(QEvent *pEvent) /* override */;
    147158
    148159    /** Allows access wizard-field from base part. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp

    r73033 r73072  
    2424# include <QGridLayout>
    2525# include <QGroupBox>
     26# include <QHeaderView>
    2627# include <QLabel>
    2728# include <QLineEdit>
     
    2930# include <QRadioButton>
    3031# include <QStackedWidget>
     32# include <QTableWidget>
    3133# include <QVBoxLayout>
    3234
     
    285287                                pSettingsLayout2->addWidget(m_pProfileComboBoxLabel, 1, 0);
    286288                            }
    287 
    288                             /* Create placeholder: */
    289                             QWidget *pPlaceholder = new QWidget;
    290                             if (pPlaceholder)
    291                             {
    292                                 /* Add into layout: */
    293                                 pSettingsLayout2->addWidget(pPlaceholder, 2, 0, 1, 2);
     289                            /* Create profile settings table: */
     290                            m_pProfileSettingsTable = new QTableWidget;
     291                            if (m_pProfileSettingsTable)
     292                            {
     293                                const QFontMetrics fm(m_pProfileSettingsTable->font());
     294                                const int iFontWidth = fm.width('x');
     295                                const int iTotalWidth = 50 * iFontWidth;
     296                                const int iFontHeight = fm.height();
     297                                const int iTotalHeight = 4 * iFontHeight;
     298                                m_pProfileSettingsTable->setMinimumSize(QSize(iTotalWidth, iTotalHeight));
     299                                m_pProfileSettingsTable->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     300                                m_pProfileSettingsTable->setAlternatingRowColors(true);
     301                                m_pProfileSettingsTable->horizontalHeader()->setVisible(false);
     302                                m_pProfileSettingsTable->verticalHeader()->setVisible(false);
     303                                m_pProfileSettingsTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
     304
     305                                    /* Add into layout: */
     306                                pSettingsLayout2->addWidget(m_pProfileSettingsTable, 2, 1);
    294307                            }
    295308                        }
     
    319332    /* Populate profiles: */
    320333    populateProfiles();
     334    /* Populate profile settings: */
     335    populateProfileSettings();
    321336
    322337    /* Setup connections: */
     
    344359    registerField("manifestSelected", this, "manifestSelected");
    345360    registerField("applianceWidget", this, "applianceWidget");
     361}
     362
     363bool UIWizardExportAppPageExpert::event(QEvent *pEvent)
     364{
     365    /* Handle known event types: */
     366    switch (pEvent->type())
     367    {
     368        case QEvent::Show:
     369        case QEvent::Resize:
     370        {
     371            /* Adjust profile settings table: */
     372            adjustProfileSettingsTable();
     373            break;
     374        }
     375        default:
     376            break;
     377    }
     378
     379    /* Call to base-class: */
     380    return UIWizardPage::event(pEvent);
    346381}
    347382
     
    521556void UIWizardExportAppPageExpert::sltHandleProfileComboChange()
    522557{
    523 }
     558    /* Refresh required settings: */
     559    populateProfileSettings();
     560}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h

    r73033 r73072  
    5454protected:
    5555
     56    /** Handle any Qt @a pEvent. */
     57    virtual bool event(QEvent *pEvent) /* override */;
     58
    5659    /** Allows access wizard from base part. */
    5760    UIWizard* wizardImp() { return UIWizardPage::wizard(); }
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