2019-10-07 Fred Gleason <fredg@paravelsystems.com>

* Refactored rddbconfig(8) to use the 'RDDialog' and 'RDWidget'
	base classes.
This commit is contained in:
Fred Gleason 2019-10-07 13:24:41 -04:00
parent 4c41f7f5aa
commit c8ed729c98
5 changed files with 35 additions and 69 deletions

View File

@ -19166,3 +19166,6 @@
2019-10-07 Fred Gleason <fredg@paravelsystems.com> 2019-10-07 Fred Gleason <fredg@paravelsystems.com>
* Refactored rdalsaconfig(8) to use the 'RDDialog' and 'RDWidget' * Refactored rdalsaconfig(8) to use the 'RDDialog' and 'RDWidget'
base classes. base classes.
2019-10-07 Fred Gleason <fredg@paravelsystems.com>
* Refactored rddbconfig(8) to use the 'RDDialog' and 'RDWidget'
base classes.

View File

@ -2,7 +2,7 @@
// //
// mySQL Administrative Login widget for RDDbConfig // mySQL Administrative Login widget for RDDbConfig
// //
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -18,42 +18,25 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
#include <qdialog.h>
#include <qdialog.h>
#include <qsize.h>
#include <qsizepolicy.h>
#include <qsqldatabase.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpixmap.h>
#include <q3progressdialog.h>
#include <qtimer.h>
#include <rdlabel.h> #include <rdlabel.h>
#include "mysql_login.h" #include "mysql_login.h"
MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent) MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent)
: QDialog(parent,"",true) : RDDialog(parent)
{ {
setCaption(tr("mySQL Admin"));
login_name=username; login_name=username;
login_password=password; login_password=password;
// setWindowTitle(tr("mySQL Admin"));
// Create Fonts
//
QFont font=QFont("Helvetica",12,QFont::Normal);
font.setPixelSize(12);
// //
// Message Label // Message Label
// //
RDLabel *label=new RDLabel(tr("Enter your MySQL administrator username and password\nThe Hostname and Database are found in /etc/rd.conf"),this); RDLabel *label=new RDLabel(tr("Enter your MySQL administrator username and password\nThe Hostname and Database are found in /etc/rd.conf"),this);
label->setFont(font); label->setFont(labelFont());
label->setGeometry(10,10,sizeHint().width()-20,30); label->setGeometry(10,10,sizeHint().width()-20,30);
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
@ -61,12 +44,11 @@ MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent)
// MySql Login Name // MySql Login Name
// //
login_name_edit=new QLineEdit(this); login_name_edit=new QLineEdit(this);
login_name_edit->setFont(font);
login_name_edit->setGeometry(sizeHint().width()/2-125+90,50,140,19); login_name_edit->setGeometry(sizeHint().width()/2-125+90,50,140,19);
login_name_edit->setMaxLength(16); login_name_edit->setMaxLength(16);
login_name_edit->setFocus(); login_name_edit->setFocus();
QLabel *login_name_label=new QLabel(login_name_edit,tr("&Username:"),this); QLabel *login_name_label=new QLabel(login_name_edit,tr("&Username:"),this);
login_name_label->setFont(font); login_name_label->setFont(labelFont());
login_name_label->setGeometry(sizeHint().width()/2-125,50,85,19); login_name_label->setGeometry(sizeHint().width()/2-125,50,85,19);
login_name_label->setAlignment(Qt::AlignRight|Qt::ShowPrefix); login_name_label->setAlignment(Qt::AlignRight|Qt::ShowPrefix);
@ -74,12 +56,12 @@ MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent)
// MySql Login Password // MySql Login Password
// //
login_password_edit=new QLineEdit(this); login_password_edit=new QLineEdit(this);
login_password_edit->setFont(font);
login_password_edit->setGeometry(sizeHint().width()/2-125+90,70,140,19); login_password_edit->setGeometry(sizeHint().width()/2-125+90,70,140,19);
login_password_edit->setMaxLength(16); login_password_edit->setMaxLength(16);
login_password_edit->setEchoMode(QLineEdit::Password); login_password_edit->setEchoMode(QLineEdit::Password);
QLabel *login_password_label=new QLabel(login_password_edit,tr("&Password:"),this); QLabel *login_password_label=
login_password_label->setFont(font); new QLabel(login_password_edit,tr("&Password:"),this);
login_password_label->setFont(labelFont());
login_password_label->setGeometry(sizeHint().width()/2-125,70,85,19); login_password_label->setGeometry(sizeHint().width()/2-125,70,85,19);
login_password_label->setAlignment(Qt::AlignRight|Qt::ShowPrefix); login_password_label->setAlignment(Qt::AlignRight|Qt::ShowPrefix);
@ -88,7 +70,7 @@ MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent)
// //
QPushButton *ok_button=new QPushButton(this); QPushButton *ok_button=new QPushButton(this);
ok_button->setGeometry(sizeHint().width()/2-90,sizeHint().height()-60,80,50); ok_button->setGeometry(sizeHint().width()/2-90,sizeHint().height()-60,80,50);
ok_button->setFont(font); ok_button->setFont(buttonFont());
ok_button->setText(tr("&OK")); ok_button->setText(tr("&OK"));
ok_button->setDefault(true); ok_button->setDefault(true);
connect(ok_button,SIGNAL(clicked()),this,SLOT(okData())); connect(ok_button,SIGNAL(clicked()),this,SLOT(okData()));
@ -99,7 +81,7 @@ MySqlLogin::MySqlLogin(QString *username,QString *password, QWidget *parent)
QPushButton *cancel_button=new QPushButton(this); QPushButton *cancel_button=new QPushButton(this);
cancel_button->setGeometry(sizeHint().width()/2+10,sizeHint().height()-60, cancel_button->setGeometry(sizeHint().width()/2+10,sizeHint().height()-60,
80,50); 80,50);
cancel_button->setFont(font); cancel_button->setFont(buttonFont());
cancel_button->setText(tr("&Cancel")); cancel_button->setText(tr("&Cancel"));
connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
} }

View File

@ -1,8 +1,8 @@
// mysql_login.h // mysql_login.h
// //
// mySQL Administrative Login Widget for RDAdmin. // mySQL Administrative Login Widget for rddbconfig(8).
// //
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -23,11 +23,10 @@
#include <qdialog.h> #include <qdialog.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qtextedit.h>
#include <qpixmap.h>
#include <qradiobutton.h>
class MySqlLogin : public QDialog #include <rddialog.h>
class MySqlLogin : public RDDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -48,6 +47,4 @@ class MySqlLogin : public QDialog
}; };
#endif #endif // MYSQL_LOGIN_H

View File

@ -44,8 +44,8 @@
// //
// Globals // Globals
// //
MainWidget::MainWidget(QWidget *parent) MainWidget::MainWidget(RDConfig *c,QWidget *parent)
: QWidget(parent) : RDWidget(c,parent)
{ {
QString err_msg; QString err_msg;
@ -65,35 +65,24 @@ MainWidget::MainWidget(QWidget *parent)
rd_config->load(); rd_config->load();
rd_config->setModuleName("rddbconfig"); rd_config->setModuleName("rddbconfig");
setWindowTitle(tr("RDDbConfig")+" v"+VERSION);
// //
// Create And Set Icon // Create And Set Icon
// //
setWindowIcon(QPixmap(rivendell_22x22_xpm)); setWindowIcon(QPixmap(rivendell_22x22_xpm));
setWindowTitle(tr("RDDbConfig")+" v"+VERSION);
// //
// Fix the Window Size // Fix the Window Size
// //
setMinimumWidth(sizeHint().width()); setMinimumSize(sizeHint());
setMinimumHeight(sizeHint().height());
//
// Generate Fonts
//
QFont font("Helvetica",12,QFont::Normal);
font.setPixelSize(12);
QFont label_font("Helvetica",12,QFont::Bold);
label_font.setPixelSize(12);
QFont day_font=QFont("Helvetica",12,QFont::Normal);
day_font.setPixelSize(12);
// //
// Labels // Labels
// //
QLabel *label=new QLabel(tr("Select an operation:"),this); QLabel *label=new QLabel(tr("Select an operation:"),this);
label->setGeometry(0,90,sizeHint().width(),16); label->setGeometry(0,90,sizeHint().width(),16);
label->setFont(label_font); label->setFont(labelFont());
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
label_hostname=new QLabel(QString().sprintf("SQL Server: %s", label_hostname=new QLabel(QString().sprintf("SQL Server: %s",
@ -123,28 +112,28 @@ MainWidget::MainWidget(QWidget *parent)
// Create Button // Create Button
// //
db_create_button=new QPushButton(tr("Create"),this); db_create_button=new QPushButton(tr("Create"),this);
db_create_button->setFont(label_font); db_create_button->setFont(buttonFont());
connect(db_create_button,SIGNAL(clicked()),this,SLOT(createData())); connect(db_create_button,SIGNAL(clicked()),this,SLOT(createData()));
// //
// Backup Button // Backup Button
// //
db_backup_button=new QPushButton(tr("Backup"),this); db_backup_button=new QPushButton(tr("Backup"),this);
db_backup_button->setFont(label_font); db_backup_button->setFont(buttonFont());
connect(db_backup_button,SIGNAL(clicked()),this,SLOT(backupData())); connect(db_backup_button,SIGNAL(clicked()),this,SLOT(backupData()));
// //
// Restore Button // Restore Button
// //
db_restore_button=new QPushButton(tr("Restore"),this); db_restore_button=new QPushButton(tr("Restore"),this);
db_restore_button->setFont(label_font); db_restore_button->setFont(buttonFont());
connect(db_restore_button,SIGNAL(clicked()),this,SLOT(restoreData())); connect(db_restore_button,SIGNAL(clicked()),this,SLOT(restoreData()));
// //
// Close Button // Close Button
// //
db_close_button=new QPushButton(tr("Close"),this); db_close_button=new QPushButton(tr("Close"),this);
db_close_button->setFont(label_font); db_close_button->setFont(buttonFont());
connect(db_close_button,SIGNAL(clicked()),this,SLOT(closeData())); connect(db_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
// //
@ -453,9 +442,10 @@ int main(int argc,char *argv[])
// //
// Start GUI // Start GUI
// //
QApplication::setStyle(RD_GUI_STYLE); RDConfig *config=new RDConfig();
config->load();
QApplication a(argc,argv); QApplication a(argc,argv);
MainWidget *w=new MainWidget(); MainWidget *w=new MainWidget(config);
a.setMainWidget(w); a.setMainWidget(w);
return a.exec(); return a.exec();
} }

View File

@ -22,26 +22,20 @@
#ifndef RDDBCONFIG_H #ifndef RDDBCONFIG_H
#define RDDBCONFIG_H #define RDDBCONFIG_H
#include <qwidget.h>
#include <q3listbox.h>
#include <qlabel.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qpushbutton.h>
#include <rdtransportbutton.h> #include <rdwidget.h>
#include <rd.h>
#include <rdconfig.h>
#include "db.h" #include "db.h"
#define RDDBCONFIG_USAGE "\n\n"; #define RDDBCONFIG_USAGE "\n\n";
class MainWidget : public QWidget class MainWidget : public RDWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWidget(QWidget *parent=0); MainWidget(RDConfig *c,QWidget *parent=0);
~MainWidget(); ~MainWidget();
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;