From ec44f2e4f4f5e000a75463d2c0583a553641fa07 Mon Sep 17 00:00:00 2001 From: Philip Date: Tue, 6 Dec 2016 21:56:40 +0100 Subject: [PATCH] [users] implement upstream fixes --- src/modules/users/README.md | 2 +- src/modules/users/gui/AddUserDialog.cpp | 8 +- src/modules/users/gui/AddUserDialog.h | 5 +- src/modules/users/gui/UsersPage.cpp | 8 +- src/modules/users/gui/UsersPage.h | 4 + src/modules/users/gui/adduserdialog.ui | 126 ++++++++++++------------ src/modules/users/gui/page_usersetup.ui | 10 +- 7 files changed, 85 insertions(+), 78 deletions(-) diff --git a/src/modules/users/README.md b/src/modules/users/README.md index caae37275..cd0991078 100644 --- a/src/modules/users/README.md +++ b/src/modules/users/README.md @@ -8,7 +8,7 @@ The following settings are available in **users.conf**: - ```defaultGroups```: list of groups every user will be added to. - ```autologinGroup```: group to add the user with autologin to, if any. - - ```doAutologin```: allow for users with autologin (at most one per system). Defaults to false. + - ```doAutologin```: if autologin is allowed, set it to "yes" by default. Defaults to false. - ```sudoersGroup```: group for sudoers usage. - ```setRootPassword```: allow to set the root password in the installed system. Defaults to false. - ```availableShells```: comma-separated list of available shells for new users. If not present, new users will not have any explicit shell in /etc/passwd, therefore the system default (usually, /bin/bash) will be used. diff --git a/src/modules/users/gui/AddUserDialog.cpp b/src/modules/users/gui/AddUserDialog.cpp index c480f1c80..861a4fcc0 100644 --- a/src/modules/users/gui/AddUserDialog.cpp +++ b/src/modules/users/gui/AddUserDialog.cpp @@ -31,7 +31,7 @@ #include "AddUserDialog.h" #include "utils/CalamaresUtilsGui.h" -AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool autologin, const QStringList& shells, bool haveRootPassword, QWidget* parent) +AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool allowAutologin, bool checkAutologin, const QStringList& shells, bool haveRootPassword, QWidget* parent) : QDialog(parent), m_existingUsers(existingUsers) { @@ -80,8 +80,10 @@ AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool ui.rootUsesUserPwCheckBox->setEnabled(false); } - if (!autologin) { + if (!allowAutologin) { ui.autoLoginCheckBox->setEnabled(false); + } else { + ui.autoLoginCheckBox->setChecked(checkAutologin); } if (!avatar) { @@ -106,7 +108,7 @@ void AddUserDialog::accept() { shell = ui.loginShellSelection->currentText(); fullName = ui.nameLine->text(); - autoLogin = ui.autoLoginCheckBox->isEnabled(); + autoLogin = ui.autoLoginCheckBox->isChecked(); useUserPw = ui.rootUsesUserPwCheckBox->isChecked(); QDialog::accept(); diff --git a/src/modules/users/gui/AddUserDialog.h b/src/modules/users/gui/AddUserDialog.h index 411c4a030..97ce68d42 100644 --- a/src/modules/users/gui/AddUserDialog.h +++ b/src/modules/users/gui/AddUserDialog.h @@ -38,10 +38,11 @@ public: * - existingUsers: username of the users that were already created. * This avoids us creating a second one with the same name. * - avatar: whether we should allow to choose an avatar. - * - autologin: whether we should allow the autologin option. + * - allowAutologin: whether we should allow the autologin option. + * - checkAutologin: if allowAutologin is true, will it be checked by default or not? Ignored if false. * - shells: the available login shells for users. */ - AddUserDialog(const QStringList &existingUsers, bool avatar, bool autologin, const QStringList &shells, bool haveRootPassword, QWidget *parent = 0); + AddUserDialog(const QStringList &existingUsers, bool avatar, bool allowAutologin, bool checkAutologin, const QStringList &shells, bool haveRootPassword, QWidget *parent = 0); virtual ~AddUserDialog(); QString login; diff --git a/src/modules/users/gui/UsersPage.cpp b/src/modules/users/gui/UsersPage.cpp index ec8b835d8..ce9d5e73b 100644 --- a/src/modules/users/gui/UsersPage.cpp +++ b/src/modules/users/gui/UsersPage.cpp @@ -141,6 +141,7 @@ UsersPage::UsersPage( QWidget* parent ) , ui( new Ui::UserCreation ) , m_readyHostname( false ) , m_readyRootPassword( false ) + , m_autologin( false ) , m_haveRootPassword( true ) { ui->setupUi( this ); @@ -179,12 +180,11 @@ UsersPage::addUserClicked() { } } - // Only allow autologin if the module configuration allows it, - // and there exists no other users with autologin enabled. - bool allowAutologin = m_autologin && !userHasAutologin; + // Only allow autologin if there exists no other users with autologin enabled. + bool allowAutologin = !userHasAutologin; QPointer dlg = new AddUserDialog( - existingUsers, !m_avatarFilePath.isEmpty(), allowAutologin, m_availableShells, m_haveRootPassword, this ); + existingUsers, !m_avatarFilePath.isEmpty(), allowAutologin, m_autologin, m_availableShells, m_haveRootPassword, this ); if ( dlg->exec() == QDialog::Accepted ) { addUser(dlg->login, dlg->fullName, dlg->password, dlg->shell, dlg->avatarFile, dlg->autoLogin); diff --git a/src/modules/users/gui/UsersPage.h b/src/modules/users/gui/UsersPage.h index aa027fa3a..b803b6f16 100644 --- a/src/modules/users/gui/UsersPage.h +++ b/src/modules/users/gui/UsersPage.h @@ -130,9 +130,13 @@ private: bool m_readyHostname; bool m_readyRootPassword; + // Check autologin by default (if no other user is already in autologin mode)? bool m_autologin; + // Allow to set a root password? bool m_haveRootPassword; + // Path to copy the avatar file to, if the user selects one. QString m_avatarFilePath; + // List of available shells for new users. QStringList m_availableShells; }; diff --git a/src/modules/users/gui/adduserdialog.ui b/src/modules/users/gui/adduserdialog.ui index 0c5a3ab83..6dd8f85f1 100644 --- a/src/modules/users/gui/adduserdialog.ui +++ b/src/modules/users/gui/adduserdialog.ui @@ -68,6 +68,45 @@ + + + + + 150 + 0 + + + + + + + + Confirm Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + @@ -84,16 +123,32 @@ - - - - Confirm Password: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + 150 + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 50 + 20 + + + + @@ -154,7 +209,7 @@ - 40 + 30 16777215 @@ -174,61 +229,6 @@ - - - - - 150 - 0 - - - - - - - - - 150 - 0 - - - - - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 50 - 20 - - - - diff --git a/src/modules/users/gui/page_usersetup.ui b/src/modules/users/gui/page_usersetup.ui index 2bdbf4830..64cac7966 100644 --- a/src/modules/users/gui/page_usersetup.ui +++ b/src/modules/users/gui/page_usersetup.ui @@ -7,7 +7,7 @@ 0 0 694 - 474 + 475 @@ -109,7 +109,7 @@ 0 0 678 - 248 + 249 @@ -233,13 +233,13 @@ - 50 + 40 0 - 50 + 40 16777215 @@ -252,7 +252,7 @@ - 50 + 30 16777215