From dc6b28957475a1a9e52cac7835c8bcf74b373fb9 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 4 Aug 2021 10:36:12 -0400 Subject: [PATCH] 2021-08-04 Fred Gleason * Refactored the 'Mysql Login' dialog in rddbconfig(8) to be resizeable. Signed-off-by: Fred Gleason --- ChangeLog | 3 ++ utils/rddbconfig/mysql_login.cpp | 52 ++++++++++++++++++-------------- utils/rddbconfig/mysql_login.h | 38 ++++++++++++++--------- 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5827b810..6b59c259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22167,3 +22167,6 @@ 2021-08-04 Fred Gleason * Fixed a bug in rddbconfig(8) that threw a segfault when attempting to create a new database. +2021-08-04 Fred Gleason + * Refactored the 'Mysql Login' dialog in rddbconfig(8) to be + resizeable. diff --git a/utils/rddbconfig/mysql_login.cpp b/utils/rddbconfig/mysql_login.cpp index 07a6b993..7afe94c1 100644 --- a/utils/rddbconfig/mysql_login.cpp +++ b/utils/rddbconfig/mysql_login.cpp @@ -30,58 +30,51 @@ MySqlLogin::MySqlLogin(QString *username,QString *password,RDConfig *c, login_password=password; setWindowTitle(tr("mySQL Admin")); + setMinimumSize(sizeHint()); // // Message Label // - QLabel *label=new QLabel(tr("Enter your MySQL administrator username and password\nThe Hostname and Database are found in /etc/rd.conf"),this); - label->setFont(labelFont()); - label->setGeometry(10,10,sizeHint().width()-20,30); - label->setAlignment(Qt::AlignCenter); + login_message_label= + new QLabel(tr("Enter your MySQL administrator username and password\nThe Hostname and Database are found in /etc/rd.conf"),this); + login_message_label->setAlignment(Qt::AlignCenter); // // MySql Login Name // login_name_edit=new QLineEdit(this); - login_name_edit->setGeometry(sizeHint().width()/2-125+90,50,140,19); login_name_edit->setMaxLength(16); login_name_edit->setFocus(); - QLabel *login_name_label=new QLabel(tr("Username:"),this); + login_name_label=new QLabel(tr("Username:"),this); login_name_label->setFont(labelFont()); - login_name_label->setGeometry(sizeHint().width()/2-125,50,85,19); login_name_label->setAlignment(Qt::AlignRight); // // MySql Login Password // login_password_edit=new QLineEdit(this); - login_password_edit->setGeometry(sizeHint().width()/2-125+90,70,140,19); login_password_edit->setMaxLength(16); login_password_edit->setEchoMode(QLineEdit::Password); - QLabel *login_password_label=new QLabel(tr("Password:"),this); + login_password_label=new QLabel(tr("Password:"),this); login_password_label->setFont(labelFont()); - login_password_label->setGeometry(sizeHint().width()/2-125,70,85,19); login_password_label->setAlignment(Qt::AlignRight); // // OK Button // - QPushButton *ok_button=new QPushButton(this); - ok_button->setGeometry(sizeHint().width()/2-90,sizeHint().height()-60,80,50); - ok_button->setFont(buttonFont()); - ok_button->setText(tr("OK")); - ok_button->setDefault(true); - connect(ok_button,SIGNAL(clicked()),this,SLOT(okData())); + login_ok_button=new QPushButton(this); + login_ok_button->setFont(buttonFont()); + login_ok_button->setText(tr("OK")); + login_ok_button->setDefault(true); + connect(login_ok_button,SIGNAL(clicked()),this,SLOT(okData())); // // Cancel Button // - QPushButton *cancel_button=new QPushButton(this); - cancel_button->setGeometry(sizeHint().width()/2+10,sizeHint().height()-60, - 80,50); - cancel_button->setFont(buttonFont()); - cancel_button->setText(tr("Cancel")); - connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); + login_cancel_button=new QPushButton(this); + login_cancel_button->setFont(buttonFont()); + login_cancel_button->setText(tr("Cancel")); + connect(login_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); } @@ -118,3 +111,18 @@ void MySqlLogin::cancelData() done(1); } + +void MySqlLogin::resizeEvent(QResizeEvent *e) +{ + login_message_label->setGeometry(10,10,size().width()-20,30); + + login_name_label->setGeometry(size().width()/2-125,50,85,19); + login_name_edit->setGeometry(size().width()/2-125+90,50,140,19); + + login_password_label->setGeometry(size().width()/2-125,70,85,19); + login_password_edit->setGeometry(size().width()/2-125+90,70,140,19); + + login_ok_button->setGeometry(size().width()/2-90,size().height()-60,80,50); + login_cancel_button-> + setGeometry(size().width()/2+10,size().height()-60,80,50); +} diff --git a/utils/rddbconfig/mysql_login.h b/utils/rddbconfig/mysql_login.h index b1412f3b..71088cfc 100644 --- a/utils/rddbconfig/mysql_login.h +++ b/utils/rddbconfig/mysql_login.h @@ -22,29 +22,39 @@ #define MYSQL_LOGIN_H #include +#include #include +#include #include class MySqlLogin : public RDDialog { Q_OBJECT - public: - MySqlLogin(QString *username,QString *password,RDConfig *c, - QWidget *parent=0); - ~MySqlLogin(); - QSize sizeHint() const; - QSizePolicy sizePolicy() const; + public: + MySqlLogin(QString *username,QString *password,RDConfig *c, + QWidget *parent=0); + ~MySqlLogin(); + QSize sizeHint() const; + QSizePolicy sizePolicy() const; - private slots: - void okData(); - void cancelData(); + private slots: + void okData(); + void cancelData(); - private: - QString *login_name; - QLineEdit *login_name_edit; - QString *login_password; - QLineEdit *login_password_edit; + protected: + void resizeEvent(QResizeEvent *e); + + private: + QString *login_name; + QLabel *login_name_label; + QLabel *login_message_label; + QLineEdit *login_name_edit; + QString *login_password; + QLabel *login_password_label; + QLineEdit *login_password_edit; + QPushButton *login_ok_button; + QPushButton *login_cancel_button; };