VirtualBox

Changeset 55016 in vbox for trunk/src


Ignore:
Timestamp:
Mar 30, 2015 6:40:16 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 7676: Runtime UI: Disk Encryption (DE) support: Add Password dialog: Added validation enabling/disabling Ok button depending on entered passwords correctness.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.cpp

    r55015 r55016  
    2626# include <QTableView>
    2727# include <QHeaderView>
     28# include <QPushButton>
    2829# include <QItemEditorFactory>
    2930# include <QAbstractTableModel>
     
    105106    EncryptionPasswordMap encryptionPasswords() const { return m_encryptionPasswords; }
    106107
     108    /** Returns whether the model is valid. */
     109    bool isValid() const;
     110
    107111    /** Returns the row count, taking optional @a parent instead of root if necessary. */
    108112    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
     
    145149    Q_OBJECT;
    146150
     151signals:
     152
     153    /** Notifies listeners about data change. */
     154    void sigDataChanged();
     155
    147156public:
    148157
     
    154163      * acquired from the UIEncryptionDataModel instance. */
    155164    EncryptionPasswordMap encryptionPasswords() const;
     165
     166    /** Returns whether the table is valid. */
     167    bool isValid() const;
    156168
    157169private:
     
    198210    /* Prepare: */
    199211    prepare();
     212}
     213
     214bool UIEncryptionDataModel::isValid() const
     215{
     216    /* Check whether the model contains invalid passwords: */
     217    foreach (const bool &fValue, m_encryptionPasswordStatus.values())
     218        if (!fValue)
     219            return false;
     220    /* Valid by default: */
     221    return true;
    200222}
    201223
     
    402424}
    403425
     426bool UIEncryptionDataTable::isValid() const
     427{
     428    AssertPtrReturn(m_pModelEncryptionData, false);
     429    return m_pModelEncryptionData->isValid();
     430}
     431
    404432void UIEncryptionDataTable::prepare()
    405433{
     
    410438        /* Assign configured model to table: */
    411439        setModel(m_pModelEncryptionData);
     440        /* Configure encryption-data model: */
     441        connect(m_pModelEncryptionData, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
     442                this, SIGNAL(sigDataChanged()));
    412443    }
    413444
     
    459490    , m_pLabelDescription(0)
    460491    , m_pTableEncryptionData(0)
     492    , m_pButtonBox(0)
    461493{
    462494    /* Prepare: */
     
    464496    /* Translate: */
    465497    retranslateUi();
     498    /* Validate: */
     499    revalidate();
    466500}
    467501
     
    496530            AssertPtrReturnVoid(m_pTableEncryptionData);
    497531            {
     532                /* Configure encryption-data table: */
     533                connect(m_pTableEncryptionData, SIGNAL(sigDataChanged()),
     534                        this, SLOT(sltDataChanged()));
    498535                /* Add label into layout: */
    499536                pInputLayout->addWidget(m_pTableEncryptionData);
     
    503540        }
    504541        /* Create button-box: */
    505         QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
    506         AssertPtrReturnVoid(pButtonBox);
     542        m_pButtonBox = new QIDialogButtonBox;
     543        AssertPtrReturnVoid(m_pButtonBox);
    507544        {
    508545            /* Configure button-box: */
    509             pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    510             connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
    511             connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
     546            m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     547            connect(m_pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
     548            connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
    512549            /* Add button-box into layout: */
    513             pMainLayout->addWidget(pButtonBox);
     550            pMainLayout->addWidget(m_pButtonBox);
    514551        }
    515552    }
     
    533570}
    534571
     572void UIAddDiskEncryptionPasswordDialog::revalidate()
     573{
     574    /* Validate: */
     575    AssertPtrReturnVoid(m_pButtonBox);
     576    m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_pTableEncryptionData->isValid());
     577}
     578
    535579#include "UIAddDiskEncryptionPasswordDialog.moc"
    536580
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.h

    r55015 r55016  
    2828/* Forward declarations: */
    2929class UIEncryptionDataTable;
     30class QIDialogButtonBox;
    3031class QLabel;
    3132
     
    5354    EncryptionPasswordMap encryptionPasswords() const;
    5455
     56private slots:
     57
     58    /** Handles the data change. */
     59    void sltDataChanged() { revalidate(); }
     60
    5561private:
    5662
     
    6066    /** Translation routine. */
    6167    void retranslateUi();
     68
     69    /** Validation routine. */
     70    void revalidate();
    6271
    6372    /** Holds the name of the machine we show this dialog for. */
     
    7180    /** Holds the encryption-data table instance. */
    7281    UIEncryptionDataTable *m_pTableEncryptionData;
     82    /** Holds the button-box instance. */
     83    QIDialogButtonBox *m_pButtonBox;
    7384};
    7485
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