From 2471e74aab02792958f4c4d451aa05f40d59ebd3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 15:43:53 +0100 Subject: [PATCH] [users] Provide some accessors to the UI-page data --- src/modules/users/UsersPage.cpp | 51 ++++++++++++++++++++++----------- src/modules/users/UsersPage.h | 7 +++++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index f4e88b629..f2b9187af 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -166,6 +166,37 @@ UsersPage::isReady() return readyFields && m_readyRootPassword; } +QString +UsersPage::getHostname() const +{ + return ui->textBoxHostname->text(); +} + +QString +UsersPage::getRootPassword() const +{ + if ( m_writeRootPassword ) + { + if ( ui->checkBoxReusePassword->isChecked() ) + { + return ui->textBoxUserPassword->text(); + } + else + { + return ui->textBoxRootPassword->text(); + } + } + else + { + return QString(); + } +} + +QPair< QString, QString > +UsersPage::getUserPassword() const +{ + return QPair< QString, QString >( ui->textBoxUsername->text(), ui->textBoxUserPassword->text() ); +} QList< Calamares::job_ptr > UsersPage::createJobs( const QStringList& defaultGroupsList ) @@ -192,25 +223,11 @@ UsersPage::createJobs( const QStringList& defaultGroupsList ) if ( m_writeRootPassword ) { gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() ); - if ( ui->checkBoxReusePassword->isChecked() ) - { - j = new SetPasswordJob( "root", ui->textBoxUserPassword->text() ); - } - else - { - j = new SetPasswordJob( "root", ui->textBoxRootPassword->text() ); - } - list.append( Calamares::job_ptr( j ) ); - } - else - { - j = new SetPasswordJob( "root", - "" ); //explicitly disable root password - list.append( Calamares::job_ptr( j ) ); } + j = new SetPasswordJob( "root", getRootPassword() ); + list.append( Calamares::job_ptr( j ) ); - j = new SetHostNameJob( ui->textBoxHostname->text(), - SetHostNameJob::Action::EtcHostname | SetHostNameJob::Action::EtcHosts ); + j = new SetHostNameJob( getHostname(), SetHostNameJob::Action::EtcHostname | SetHostNameJob::Action::EtcHosts ); list.append( Calamares::job_ptr( j ) ); gs->insert( "hostname", ui->textBoxHostname->text() ); diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h index c6bf87ecf..3382e9335 100644 --- a/src/modules/users/UsersPage.h +++ b/src/modules/users/UsersPage.h @@ -63,6 +63,13 @@ public: */ void addPasswordCheck( const QString& key, const QVariant& value ); + ///@brief Hostname as entered / auto-filled + QString getHostname() const; + ///@brief Root password, depends on settings, may be empty + QString getRootPassword() const; + ///@brief User name and password + QPair< QString, QString > getUserPassword() const; + protected slots: void onFullNameTextEdited( const QString& ); void fillSuggestions();