From 1b5a800783294e1a21c8cb0af752148280195196 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 20 Jan 2021 17:16:56 -0500 Subject: [PATCH] 2021-01-20 Fred Gleason * Updated the 'Username' control in rdlogin(1) to use 'RDUserListModel'. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ rdlogin/rdlogin.cpp | 25 +++++++++++++++---------- rdlogin/rdlogin.h | 12 +++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb55190b..53202e9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20854,3 +20854,6 @@ 2021-01-20 Fred Gleason * Updated the 'Default User' control in the 'Host' dialog in rdadmin(1) to use 'RDUserListModel'. +2021-01-20 Fred Gleason + * Updated the 'Username' control in rdlogin(1) to use + 'RDUserListModel'. diff --git a/rdlogin/rdlogin.cpp b/rdlogin/rdlogin.cpp index 915bae33..f25dcaed 100644 --- a/rdlogin/rdlogin.cpp +++ b/rdlogin/rdlogin.cpp @@ -2,7 +2,7 @@ // // The User Login/Logout Utility for Rivendell. // -// (C) Copyright 2002-2019 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 @@ -98,14 +98,19 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent) // login_username_box=new QComboBox(this); login_username_box->setFocus(); + login_username_model=new RDUserListModel(this); + login_username_model->setTypeFilter(RDUser::TypeUser); + login_username_box->setModel(login_username_model); QFontMetrics fm(font()); - sql="select LOGIN_NAME from USERS where ADMIN_CONFIG_PRIV=\"N\"\ - order by LOGIN_NAME"; + sql=QString("select ")+ + "LOGIN_NAME "+ // 00 + "from USERS where "+ + "ADMIN_CONFIG_PRIV='N'"+ + "order by LOGIN_NAME"; q=new RDSqlQuery(sql); while(q->next()) { - login_username_box->insertItem(q->value(0).toString()); - if(fm.width(q->value(0).toString())>login_user_width) { - login_user_width=fm.width(q->value(0).toString()); + if((20+fm.width(q->value(0).toString()))>login_user_width) { + login_user_width=20+fm.width(q->value(0).toString()); } } delete q; @@ -257,11 +262,11 @@ void MainWidget::resizeEvent(QResizeEvent *e) { if(login_resize) { login_label->setGeometry(0,10,size().width(),21); - login_username_box->setGeometry(110,40,size().width()-120,19); - login_username_edit->setGeometry(110,40,size().width()-120,19); + login_username_box->setGeometry(110,38,size().width()-120,23); + login_username_edit->setGeometry(110,38,size().width()-120,23); login_username_label->setGeometry(10,40,85,19); - login_password_edit->setGeometry(110,61,size().width()-120,19); - login_password_label->setGeometry(10,61,85,19); + login_password_edit->setGeometry(110,65,size().width()-120,23); + login_password_label->setGeometry(10,67,85,19); login_button->setGeometry(size().width()-270,size().height()-60,80,50); logout_button->setGeometry(size().width()-180,size().height()-60,80,50); cancel_button->setGeometry(size().width()-90,size().height()-60,80,50); diff --git a/rdlogin/rdlogin.h b/rdlogin/rdlogin.h index 4bdb3c0f..d9e402c3 100644 --- a/rdlogin/rdlogin.h +++ b/rdlogin/rdlogin.h @@ -2,7 +2,7 @@ // // The User Login/Logout Utility for Rivendell. // -// (C) Copyright 2002-2019 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 @@ -21,11 +21,12 @@ #ifndef RDLOGIN_H #define RDLOGIN_H -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #define RDLOGIN_USAGE "\n" @@ -55,6 +56,7 @@ class MainWidget : public RDWidget QLabel *login_label; QLabel *login_username_label; QComboBox *login_username_box; + RDUserListModel *login_username_model; QLineEdit *login_username_edit; QLabel *login_password_label; QLineEdit *login_password_edit;