VirtualBox

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


Ignore:
Timestamp:
Jun 22, 2020 2:34:49 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Using the user name and password during unattended install.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r84892 r84906  
    18941894    comUnattendedInstaller.SetMachine(comMachine);
    18951895    checkUnattendedInstallError(comUnattendedInstaller);
     1896    comUnattendedInstaller.SetUser(unattendedData.m_strUserName);
     1897    comUnattendedInstaller.SetPassword(unattendedData.m_strPassword);
    18961898    comUnattendedInstaller.Prepare();
    18971899    checkUnattendedInstallError(comUnattendedInstaller);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r84892 r84906  
    514514{
    515515    m_unattendedInstallData = unattendedInstallData;
     516    UIWizardNewVMPageBasicInstallSetup *pPage = qobject_cast<UIWizardNewVMPageBasicInstallSetup *>(page(PageInstallSetup));
     517    if (pPage)
     518        pPage->setDefaultUnattendedInstallData(unattendedInstallData);
    516519}
    517520
     
    529532    if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::Bool))
    530533        m_unattendedInstallData.m_fStartHeadless = fieldValue.toBool();
     534
     535    fieldValue = field("userName");
     536    if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::QString))
     537        m_unattendedInstallData.m_strUserName = fieldValue.toString();
     538
     539    fieldValue = field("password");
     540    if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::QString))
     541        m_unattendedInstallData.m_strPassword = fieldValue.toString();
    531542
    532543    m_unattendedInstallData.m_uMachineUid = createdMachineId();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicInstallSetup.cpp

    r84890 r84906  
    4747}
    4848
     49QString UIUserNamePasswordEditor::userName() const
     50{
     51    if (m_pUserNameField)
     52        return m_pUserNameField->text();
     53    return QString();
     54}
     55
     56void UIUserNamePasswordEditor::setUserName(const QString &strUserName)
     57{
     58    if (m_pUserNameField)
     59        return m_pUserNameField->setText(strUserName);
     60}
     61
     62QString UIUserNamePasswordEditor::password() const
     63{
     64    if (m_pPasswordField)
     65        return m_pPasswordField->text();
     66    return QString();
     67}
     68
     69void UIUserNamePasswordEditor::setPassword(const QString &strPassword)
     70{
     71    if (m_pPasswordField)
     72        m_pPasswordField->setText(strPassword);
     73    if (m_pPasswordRepeatField)
     74        m_pPasswordRepeatField->setText(strPassword);
     75}
     76
    4977void UIUserNamePasswordEditor::retranslateUi()
    5078{
     
    6896}
    6997
    70 void UIUserNamePasswordEditor::addField(QLabel *&pLabel, QLineEdit *&pLineEdit, QGridLayout *pLayout, bool fIsPasswordField /* = false */)
     98void UIUserNamePasswordEditor::addLineEdit(QLabel *&pLabel, QLineEdit *&pLineEdit, QGridLayout *pLayout, bool fIsPasswordField /* = false */)
    7199{
    72100    static int iRow = 0;
     
    97125    setLayout(pMainLayout);
    98126
    99     addField(m_pUserNameFieldLabel, m_pUserNameField, pMainLayout);
    100     addField(m_pPasswordFieldLabel, m_pPasswordField, pMainLayout, true);
    101     addField(m_pPasswordRepeatFieldLabel, m_pPasswordRepeatField, pMainLayout, true);
     127    addLineEdit(m_pUserNameFieldLabel, m_pUserNameField, pMainLayout);
     128    addLineEdit(m_pPasswordFieldLabel, m_pPasswordField, pMainLayout, true);
     129    addLineEdit(m_pPasswordRepeatFieldLabel, m_pPasswordRepeatField, pMainLayout, true);
     130
    102131    retranslateUi();
    103132}
     
    107136{
    108137}
     138
     139QString UIWizardNewVMPageInstallSetup::userName() const
     140{
     141    if (m_pUserNamePasswordEditor)
     142        return m_pUserNamePasswordEditor->userName();
     143    return QString();
     144}
     145
     146QString UIWizardNewVMPageInstallSetup::password() const
     147{
     148    if (m_pUserNamePasswordEditor)
     149        return m_pUserNamePasswordEditor->password();
     150    return QString();
     151}
     152
    109153
    110154UIWizardNewVMPageBasicInstallSetup::UIWizardNewVMPageBasicInstallSetup()
     
    126170    }
    127171
     172
    128173    /* Register fields: */
    129     // registerField("baseMemory", this, "baseMemory");
    130     // registerField("VCPUCount", this, "VCPUCount");
     174    registerField("userName", this, "userName");
     175    registerField("password", this, "password");
     176}
     177
     178void UIWizardNewVMPageBasicInstallSetup::setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData)
     179{
     180    /* Initialize the widget data: */
     181
     182    if (m_pUserNamePasswordEditor)
     183    {
     184        m_pUserNamePasswordEditor->setUserName(unattendedInstallData.m_strUserName);
     185        m_pUserNamePasswordEditor->setPassword(unattendedInstallData.m_strPassword);
     186    }
    131187}
    132188
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicInstallSetup.h

    r84889 r84906  
    3535class QSpinBox;
    3636class QIRichTextLabel;
     37struct UIUnattendedInstallData;
    3738
    3839class UIUserNamePasswordEditor : public QIWithRetranslateUI<QWidget>
     
    4546    UIUserNamePasswordEditor(QWidget *pParent = 0);
    4647
     48    QString userName() const;
     49    void setUserName(const QString &strUserName);
     50
     51    QString password() const;
     52    void setPassword(const QString &strPassword);
     53
    4754protected:
    4855
     
    5259
    5360    void prepare();
    54     void addField(QLabel *&pLabel, QLineEdit *&pLineEdit, QGridLayout *pLayout, bool fIsPasswordField = false);
     61    void addLineEdit(QLabel *&pLabel, QLineEdit *&pLineEdit, QGridLayout *pLayout, bool fIsPasswordField = false);
    5562
    5663    QLineEdit *m_pUserNameField;
     
    6774class UIWizardNewVMPageInstallSetup : public UIWizardPageBase
    6875{
     76public:
     77
     78    UIWizardNewVMPageInstallSetup();
     79
     80    QString userName() const;
     81    QString password() const;
     82
    6983protected:
    7084
    71     /* Constructor: */
    72     UIWizardNewVMPageInstallSetup();
    7385
    7486
     
    8193{
    8294    Q_OBJECT;
     95    Q_PROPERTY(QString userName READ userName);
     96    Q_PROPERTY(QString password READ password);
    8397
    8498public:
     
    86100    /* Constructor: */
    87101    UIWizardNewVMPageBasicInstallSetup();
     102    void setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData);
    88103
    89104private slots:
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