From 32a1efbeacf53761be39d770f2cb71a2f985018b Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 10 Jun 2021 15:32:31 -0400 Subject: [PATCH] 2021-06-10 Fred Gleason * Refactored the 'Set Password' dialog so as to pass the password value in the 'RDPasswd::exec()' method. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ lib/rdpasswd.cpp | 21 ++++++++++++++------- lib/rdpasswd.h | 12 ++++++++---- rdadmin/edit_user.cpp | 10 +++++++--- rdadmin/edit_user.h | 2 ++ 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a073bdd..a3a81de0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21871,3 +21871,6 @@ * Fixed a bug in rdadmin(1) that caused the incorrect Login Name to appear in the 'Rivendell User List' dialog immediately after adding the user. +2021-06-10 Fred Gleason + * Refactored the 'Set Password' dialog so as to pass the password + value in the 'RDPasswd::exec()' method. diff --git a/lib/rdpasswd.cpp b/lib/rdpasswd.cpp index d663c1b3..65ad9812 100644 --- a/lib/rdpasswd.cpp +++ b/lib/rdpasswd.cpp @@ -23,7 +23,7 @@ #include "rdpasswd.h" #include "rdtextvalidator.h" -RDPasswd::RDPasswd(QString *password,QWidget *parent) +RDPasswd::RDPasswd(const QString &caption,QWidget *parent) : RDDialog(parent) { // @@ -32,8 +32,7 @@ RDPasswd::RDPasswd(QString *password,QWidget *parent) setMinimumSize(sizeHint()); setMaximumSize(sizeHint()); - passwd_password=password; - setWindowTitle(tr("Change Password")); + setWindowTitle(caption+" - "+tr("Change Password")); // // Text Validator @@ -48,7 +47,7 @@ RDPasswd::RDPasswd(QString *password,QWidget *parent) passwd_password_1_edit->setEchoMode(QLineEdit::Password); passwd_password_1_edit->setFocus(); passwd_password_1_edit->setValidator(validator); - passwd_password_1_label=new QLabel(tr("&Password:"),this); + passwd_password_1_label=new QLabel(tr("Password:"),this); passwd_password_1_label->setFont(labelFont()); passwd_password_1_label->setAlignment(Qt::AlignRight); @@ -59,7 +58,7 @@ RDPasswd::RDPasswd(QString *password,QWidget *parent) passwd_password_2_edit->setMaxLength(RD_MAX_PASSWORD_LENGTH); passwd_password_2_edit->setEchoMode(QLineEdit::Password); passwd_password_2_edit->setValidator(validator); - passwd_password_2_label=new QLabel(tr("C&onfirm:"),this); + passwd_password_2_label=new QLabel(tr("Confirm:"),this); passwd_password_2_label->setFont(labelFont()); passwd_password_2_label->setAlignment(Qt::AlignRight); @@ -68,7 +67,7 @@ RDPasswd::RDPasswd(QString *password,QWidget *parent) // passwd_ok_button=new QPushButton(this); passwd_ok_button->setFont(buttonFont()); - passwd_ok_button->setText(tr("&OK")); + passwd_ok_button->setText(tr("OK")); passwd_ok_button->setDefault(true); connect(passwd_ok_button,SIGNAL(clicked()),this,SLOT(okData())); @@ -77,7 +76,7 @@ RDPasswd::RDPasswd(QString *password,QWidget *parent) // passwd_cancel_button=new QPushButton(this); passwd_cancel_button->setFont(buttonFont()); - passwd_cancel_button->setText(tr("&Cancel")); + passwd_cancel_button->setText(tr("Cancel")); connect(passwd_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); } @@ -101,6 +100,14 @@ QSizePolicy RDPasswd::sizePolicy() const } +int RDPasswd::exec(QString *passwd) +{ + passwd_password=passwd; + + return QDialog::exec(); +} + + void RDPasswd::okData() { if(passwd_password_1_edit->text()==passwd_password_2_edit->text()) { diff --git a/lib/rdpasswd.h b/lib/rdpasswd.h index c2b3dda8..d9ecf3d6 100644 --- a/lib/rdpasswd.h +++ b/lib/rdpasswd.h @@ -2,7 +2,7 @@ // // Set Password Widget for Rivendell. // -// (C) Copyright 2002-2020 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -25,17 +25,21 @@ #include #include -#include +#include "rddialog.h" class RDPasswd : public RDDialog { - Q_OBJECT + Q_OBJECT; public: - RDPasswd(QString *password,QWidget *parent=0); + RDPasswd(const QString &caption,QWidget *parent=0); + // RDPasswd(QString *password,QWidget *parent=0); ~RDPasswd(); QSize sizeHint() const; QSizePolicy sizePolicy() const; + public slots: + int exec(QString *passwd); + private slots: void okData(); void cancelData(); diff --git a/rdadmin/edit_user.cpp b/rdadmin/edit_user.cpp index 924d38b7..890c7d4c 100644 --- a/rdadmin/edit_user.cpp +++ b/rdadmin/edit_user.cpp @@ -41,6 +41,11 @@ EditUser::EditUser(const QString &user,QWidget *parent) setWindowTitle("RDAdmin - "+tr("User: ")+user); user_user=new RDUser(user); + // + // Dialogs + // + user_password_dialog=new RDPasswd("RDAdmin",this); + // // Text Validator // @@ -470,6 +475,7 @@ EditUser::~EditUser() delete user_prod_group; delete user_traffic_group; delete user_onair_group; + delete user_password_dialog; } @@ -497,11 +503,9 @@ void EditUser::passwordData() { QString password; - RDPasswd *passwd=new RDPasswd(&password,this); - if(passwd->exec()==0) { + if(user_password_dialog->exec(&password)==0) { user_user->setPassword(password); } - delete passwd; } diff --git a/rdadmin/edit_user.h b/rdadmin/edit_user.h index 4ba63cbc..a23df65b 100644 --- a/rdadmin/edit_user.h +++ b/rdadmin/edit_user.h @@ -29,6 +29,7 @@ #include #include +#include #include class EditUser : public RDDialog @@ -53,6 +54,7 @@ class EditUser : public RDDialog void cancelData(); private: + RDPasswd *user_password_dialog; QLineEdit *user_name_edit; QLineEdit *user_full_name_edit; QLineEdit *user_email_address_edit;