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

* Refactored rdselect(8) to use the 'RDDialog' and 'RDWidget'
	base classes.
This commit is contained in:
Fred Gleason 2019-10-07 12:56:54 -04:00
parent 84d4696160
commit 8f5dd2a9f3
3 changed files with 20 additions and 46 deletions

View File

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

View File

@ -2,7 +2,7 @@
// //
// System Selector for Rivendell // System Selector for Rivendell
// //
// (C) Copyright 2012-2018 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2012-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,30 +18,16 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <errno.h>
#include <qapplication.h> #include <qapplication.h>
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#include <qdir.h> #include <qdir.h>
#include <qlabel.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qpainter.h>
#include <qprocess.h> #include <qprocess.h>
#include <qtextcodec.h>
#include <qtranslator.h> #include <qtranslator.h>
#include <qwindowsstyle.h>
#include <rd.h> #include <dbversion.h>
#include <rdconf.h>
#include <rdcmd_switch.h>
#include <rdpaths.h> #include <rdpaths.h>
#include <rdstatus.h> #include <rdstatus.h>
#include <dbversion.h>
#include "rdselect.h" #include "rdselect.h"
@ -52,8 +38,8 @@
#include "../icons/greencheckmark.xpm" #include "../icons/greencheckmark.xpm"
#include "../icons/redx.xpm" #include "../icons/redx.xpm"
MainWidget::MainWidget(QWidget *parent) MainWidget::MainWidget(RDConfig *c,QWidget *parent)
:QWidget(parent) : RDWidget(c,parent)
{ {
// //
// Read Command Options // Read Command Options
@ -103,19 +89,7 @@ MainWidget::MainWidget(QWidget *parent)
// //
// Fix the Window Size // Fix the Window Size
// //
setMinimumWidth(sizeHint().width()); setMinimumSize(sizeHint());
setMinimumHeight(sizeHint().height());
//
// Generate Fonts
//
QFont default_font("Helvetica",12,QFont::Normal);
default_font.setPixelSize(12);
qApp->setFont(default_font);
QFont button_font=QFont("Helvetica",12,QFont::Bold);
button_font.setPixelSize(12);
QFont label_font=QFont("Helvetica",16,QFont::Bold);
label_font.setPixelSize(16);
// //
// Create And Set Icons // Create And Set Icons
@ -158,27 +132,26 @@ MainWidget::MainWidget(QWidget *parent)
// Current System Label // Current System Label
// //
select_current_label=new QLabel(this); select_current_label=new QLabel(this);
select_current_label->setFont(label_font); select_current_label->setFont(progressFont());
select_current_label->setAlignment(Qt::AlignCenter); select_current_label->setAlignment(Qt::AlignCenter);
// //
// Selector Box // Selector Box
// //
select_box=new Q3ListBox(this); select_box=new Q3ListBox(this);
select_box->setFont(default_font);
connect(select_box,SIGNAL(doubleClicked(Q3ListBoxItem *)), connect(select_box,SIGNAL(doubleClicked(Q3ListBoxItem *)),
this,SLOT(doubleClickedData(Q3ListBoxItem *))); this,SLOT(doubleClickedData(Q3ListBoxItem *)));
for(unsigned i=0;i<select_configs.size();i++) { for(unsigned i=0;i<select_configs.size();i++) {
select_box->insertItem(select_configs[i]->label()); select_box->insertItem(select_configs[i]->label());
} }
select_label=new QLabel(select_box,tr("Available Systems"),this); select_label=new QLabel(select_box,tr("Available Systems"),this);
select_label->setFont(button_font); select_label->setFont(labelFont());
// //
// Ok Button // Ok Button
// //
ok_button=new QPushButton(this); ok_button=new QPushButton(this);
ok_button->setFont(button_font); ok_button->setFont(buttonFont());
ok_button->setText(tr("Select")); ok_button->setText(tr("Select"));
connect(ok_button,SIGNAL(clicked()),this,SLOT(okData())); connect(ok_button,SIGNAL(clicked()),this,SLOT(okData()));
@ -186,7 +159,7 @@ MainWidget::MainWidget(QWidget *parent)
// Cancel Button // Cancel Button
// //
cancel_button=new QPushButton(this,"cancel_button"); cancel_button=new QPushButton(this,"cancel_button");
cancel_button->setFont(button_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()));
@ -335,7 +308,9 @@ int main(int argc,char *argv[])
// //
// Start Event Loop // Start Event Loop
// //
MainWidget *w=new MainWidget(); RDConfig *config=new RDConfig();
config->load();
MainWidget *w=new MainWidget(config);
a.setMainWidget(w); a.setMainWidget(w);
w->show(); w->show();
return a.exec(); return a.exec();

View File

@ -2,7 +2,7 @@
// //
// System Selector for Rivendell // System Selector for Rivendell
// //
// (C) Copyright 2012-2018 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2012-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
@ -21,25 +21,21 @@
#ifndef RDSELECT_H #ifndef RDSELECT_H
#define RDSELECT_H #define RDSELECT_H
#include <vector> #include <q3listbox.h>
#include <qwidget.h>
#include <qsize.h>
#include <qsizepolicy.h>
#include <q3listbox.h> #include <q3listbox.h>
#include <qlabel.h> #include <qlabel.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qstringlist.h>
#include <qpixmap.h>
#include <rdconfig.h> #include <rdconfig.h>
#include <rdmonitor_config.h> #include <rdmonitor_config.h>
#include <rdwidget.h>
class MainWidget : public QWidget class MainWidget : public RDWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWidget(QWidget *parent=0); MainWidget(RDConfig *c,QWidget *parent=0);
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;