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

* Refactored rdairplay(1) to use the 'RDDialog' and 'RDWidget'
	base classes.
This commit is contained in:
Fred Gleason
2019-10-02 16:08:48 -04:00
parent 8ca15c773d
commit 44a0941df9
45 changed files with 465 additions and 711 deletions

View File

@@ -125,6 +125,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdexport_settings_dialog.cpp rdexport_settings_dialog.h\
rdfeed.cpp rdfeed.h\
rdfeedlog.cpp rdfeedlog.h\
rdfontset.cpp rdfontset.h\
rdformpost.cpp rdformpost.h\
rdflacdecode.cpp rdflacdecode.h\
rdgain_envelope.cpp rdgain_envelope.h\

View File

@@ -89,6 +89,7 @@ SOURCES += rdevent_line.cpp
SOURCES += rdeventimportlist.cpp
SOURCES += rdexception_dialog.cpp
SOURCES += rdexport_settings_dialog.cpp
SOURCES += rdfontset.cpp
SOURCES += rdget_ath.cpp
SOURCES += rdgetpasswd.cpp
SOURCES += rdgpioselector.cpp
@@ -222,6 +223,7 @@ HEADERS += rdevent_line.h
HEADERS += rdeventimportlist.h
HEADERS += rdexception_dialog.h
HEADERS += rdexport_settings_dialog.h
HEADERS += rdfontset.h
HEADERS += rdget_ath.h
HEADERS += rdgetpasswd.h
HEADERS += rdgpioselector.h

View File

@@ -171,9 +171,9 @@ int RDConfig::fontLabelSize() const
}
int RDConfig::fontDataSize() const
int RDConfig::fontDefaultSize() const
{
return conf_font_data_size;
return conf_font_default_size;
}
@@ -536,7 +536,7 @@ bool RDConfig::load()
conf_font_family=profile->stringValue("Fonts","Family");
conf_font_button_size=profile->intValue("Fonts","ButtonSize",-1);
conf_font_label_size=profile->intValue("Fonts","LabelSize",-1);
conf_font_data_size=profile->intValue("Fonts","DataSize",-1);
conf_font_default_size=profile->intValue("Fonts","DefaultSize",-1);
conf_provisioning_create_host=
profile->boolValue("Provisioning","CreateHost");
@@ -707,7 +707,7 @@ void RDConfig::clear()
conf_font_family="";
conf_font_button_size=-1;
conf_font_label_size=-1;
conf_font_data_size=-1;
conf_font_default_size=-1;
conf_audio_store_cae_hostname="";
conf_jack_ports[0].clear();
conf_jack_ports[1].clear();

View File

@@ -95,7 +95,7 @@ class RDConfig
QString fontFamily() const;
int fontButtonSize() const;
int fontLabelSize() const;
int fontDataSize() const;
int fontDefaultSize() const;
int jackConnections() const;
QString jackPort(int num,int endpt) const;
bool disableMaintChecks() const;
@@ -166,7 +166,7 @@ class RDConfig
QString conf_font_family;
int conf_font_button_size;
int conf_font_label_size;
int conf_font_data_size;
int conf_font_default_size;
QString conf_http_user_agent;
bool conf_disable_maint_checks;
bool conf_lock_rdairplay_memory;

View File

@@ -21,104 +21,16 @@
#include "rddialog.h"
RDDialog::RDDialog(QWidget *parent,Qt::WindowFlags f)
: QDialog(parent,f)
: QDialog(parent,f), RDFontSet(font())
{
setModal(true);
dialog_config=rda->config();
MakeFonts();
setFont(dataFont());
setFont(defaultFont());
}
RDDialog::RDDialog(RDConfig *config,QWidget *parent,Qt::WindowFlags f)
: QDialog(parent,f)
: QDialog(parent,f), RDFontSet(font(),config)
{
dialog_config=config;
MakeFonts();
}
QFont RDDialog::buttonFont() const
{
return dialog_button_font;
}
QFont RDDialog::subButtonFont() const
{
return dialog_sub_button_font;
}
QFont RDDialog::sectionLabelFont() const
{
return dialog_section_label_font;
}
QFont RDDialog::labelFont() const
{
return dialog_label_font;
}
QFont RDDialog::subLabelFont() const
{
return dialog_sub_label_font;
}
QFont RDDialog::progressFont() const
{
return dialog_progress_font;
}
QFont RDDialog::dataFont() const
{
return dialog_data_font;
}
void RDDialog::MakeFonts()
{
QString family=font().family();
int button_size=font().pixelSize();
int label_size=font().pixelSize();
int data_size=font().pixelSize();
if(!dialog_config->fontFamily().isEmpty()) {
family=dialog_config->fontFamily();
}
if(dialog_config->fontButtonSize()>0) {
button_size=dialog_config->fontButtonSize();
}
if(dialog_config->fontLabelSize()>0) {
label_size=dialog_config->fontLabelSize();
}
if(dialog_config->fontDataSize()>0) {
data_size=dialog_config->fontDataSize();
}
dialog_button_font=QFont(family,button_size,QFont::Bold);
dialog_button_font.setPixelSize(button_size);
dialog_sub_button_font=QFont(family,button_size-2,QFont::Normal);
dialog_sub_button_font.setPixelSize(button_size-2);
dialog_section_label_font=QFont(family,label_size+2,QFont::Bold);
dialog_section_label_font.setPixelSize(label_size+2);
dialog_label_font=QFont(family,label_size,QFont::Bold);
dialog_label_font.setPixelSize(label_size);
dialog_sub_label_font=QFont(family,label_size,QFont::Normal);
dialog_sub_label_font.setPixelSize(label_size);
dialog_progress_font=QFont(family,label_size+4,QFont::Bold);
dialog_progress_font.setPixelSize(label_size+4);
dialog_data_font=QFont(family,data_size,QFont::Normal);
dialog_data_font.setPixelSize(data_size);
setModal(true);
setFont(defaultFont());
}

View File

@@ -24,32 +24,14 @@
#include <qdialog.h>
#include <qfont.h>
#include <rdapplication.h>
#include <rdfontset.h>
class RDDialog : public QDialog
class RDDialog : public QDialog, public RDFontSet
{
Q_OBJECT;
public:
RDDialog(QWidget *parent=0,Qt::WindowFlags f=0);
RDDialog(RDConfig *config,QWidget *parent=0,Qt::WindowFlags f=0);
QFont buttonFont() const;
QFont subButtonFont() const;
QFont sectionLabelFont() const;
QFont labelFont() const;
QFont subLabelFont() const;
QFont progressFont() const;
QFont dataFont() const;
private:
void MakeFonts();
QFont dialog_button_font;
QFont dialog_sub_button_font;
QFont dialog_section_label_font;
QFont dialog_label_font;
QFont dialog_sub_label_font;
QFont dialog_progress_font;
QFont dialog_data_font;
RDConfig *dialog_config;
};

137
lib/rdfontset.cpp Normal file
View File

@@ -0,0 +1,137 @@
// rdfontset.cpp
//
// Base set of fonts for Rivendell UIs
//
// (C) Copyright 2019 Fred Gleason <fredg@paravelsystems.com>
//
// 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdapplication.h>
#include "rdfontset.h"
RDFontSet::RDFontSet(const QFont &default_font,RDConfig *c)
{
if(c==NULL) {
font_config=rda->config();
}
else {
font_config=c;
}
MakeFonts(default_font);
}
QFont RDFontSet::buttonFont() const
{
return font_button_font;
}
QFont RDFontSet::bigButtonFont() const
{
return font_big_button_font;
}
QFont RDFontSet::subButtonFont() const
{
return font_sub_button_font;
}
QFont RDFontSet::sectionLabelFont() const
{
return font_section_label_font;
}
QFont RDFontSet::labelFont() const
{
return font_label_font;
}
QFont RDFontSet::subLabelFont() const
{
return font_sub_label_font;
}
QFont RDFontSet::progressFont() const
{
return font_progress_font;
}
QFont RDFontSet::bannerFont() const
{
return font_banner_font;
}
QFont RDFontSet::defaultFont() const
{
return font_default_font;
}
void RDFontSet::MakeFonts(const QFont &default_font)
{
QString family=default_font.family();
int button_size=default_font.pixelSize();
int label_size=default_font.pixelSize();
int default_size=default_font.pixelSize();
if(!font_config->fontFamily().isEmpty()) {
family=font_config->fontFamily();
}
if(font_config->fontButtonSize()>0) {
button_size=font_config->fontButtonSize();
}
if(font_config->fontLabelSize()>0) {
label_size=font_config->fontLabelSize();
}
if(font_config->fontDefaultSize()>0) {
default_size=font_config->fontDefaultSize();
}
font_button_font=QFont(family,button_size,QFont::Bold);
font_button_font.setPixelSize(button_size);
font_big_button_font=QFont(family,button_size+4,QFont::DemiBold);
font_big_button_font.setPixelSize(button_size+4);
font_sub_button_font=QFont(family,button_size-2,QFont::Normal);
font_sub_button_font.setPixelSize(button_size-2);
font_section_label_font=QFont(family,label_size+2,QFont::Bold);
font_section_label_font.setPixelSize(label_size+2);
font_label_font=QFont(family,label_size,QFont::Bold);
font_label_font.setPixelSize(label_size);
font_sub_label_font=QFont(family,label_size,QFont::Normal);
font_sub_label_font.setPixelSize(label_size);
font_progress_font=QFont(family,label_size+4,QFont::Bold);
font_progress_font.setPixelSize(label_size+4);
font_banner_font=QFont(family,26,QFont::Normal);
font_banner_font.setPixelSize(26);
font_default_font=QFont(family,default_size,QFont::Normal);
font_default_font.setPixelSize(default_size);
}

57
lib/rdfontset.h Normal file
View File

@@ -0,0 +1,57 @@
// rdfontset.h
//
// Base set of fonts for Rivendell UIs
//
// (C) Copyright 2019 Fred Gleason <fredg@paravelsystems.com>
//
// 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDFONTSET_H
#define RDFONTSET_H
#include <qfont.h>
#include <rdapplication.h>
class RDFontSet
{
public:
RDFontSet(const QFont &default_font,RDConfig *c=NULL);
QFont buttonFont() const;
QFont bigButtonFont() const;
QFont subButtonFont() const;
QFont sectionLabelFont() const;
QFont labelFont() const;
QFont subLabelFont() const;
QFont progressFont() const;
QFont bannerFont() const;
QFont defaultFont() const;
private:
void MakeFonts(const QFont &default_font);
QFont font_button_font;
QFont font_big_button_font;
QFont font_sub_button_font;
QFont font_section_label_font;
QFont font_label_font;
QFont font_sub_label_font;
QFont font_progress_font;
QFont font_banner_font;
QFont font_default_font;
RDConfig *font_config;
};
#endif // RDFONTSET_H

View File

@@ -2,7 +2,7 @@
//
// An flashing button widget.
//
// (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
// it under the terms of the GNU Library General Public License
@@ -31,21 +31,21 @@
RDPushButton::RDPushButton(QWidget *parent=0)
: QPushButton(parent)
: QPushButton(parent), RDFontSet(font())
{
Init();
}
RDPushButton::RDPushButton(const QString &text,QWidget *parent)
: QPushButton(text,parent)
: QPushButton(text,parent), RDFontSet(font())
{
Init();
}
RDPushButton::RDPushButton(const QIcon &icon,const QString &text,
QWidget *parent)
: QPushButton(text,parent)
: QPushButton(text,parent), RDFontSet(font())
{
Init();
}

View File

@@ -2,7 +2,7 @@
//
// An flashing button widget.
//
// (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
// it under the terms of the GNU Library General Public License
@@ -28,13 +28,15 @@
//Added by qt3to4:
#include <QMouseEvent>
#include <rdfontset.h>
/*
* Widget Defaults
*/
#define RDPUSHBUTTON_DEFAULT_FLASH_PERIOD 300
#define RDPUSHBUTTON_DEFAULT_FLASH_COLOR Qt::blue
class RDPushButton : public QPushButton
class RDPushButton : public QPushButton, public RDFontSet
{
Q_OBJECT
public:

View File

@@ -21,103 +21,14 @@
#include "rdwidget.h"
RDWidget::RDWidget(QWidget *parent,Qt::WindowFlags f)
: QWidget(parent,f)
: QWidget(parent,f), RDFontSet(font())
{
widget_config=rda->config();
MakeFonts();
setFont(dataFont());
setFont(defaultFont());
}
RDWidget::RDWidget(RDConfig *config,QWidget *parent,Qt::WindowFlags f)
: QWidget(parent,f)
: QWidget(parent,f), RDFontSet(font(),config)
{
widget_config=config;
MakeFonts();
setFont(dataFont());
}
QFont RDWidget::buttonFont() const
{
return widget_button_font;
}
QFont RDWidget::subButtonFont() const
{
return widget_sub_button_font;
}
QFont RDWidget::sectionLabelFont() const
{
return widget_section_label_font;
}
QFont RDWidget::labelFont() const
{
return widget_label_font;
}
QFont RDWidget::subLabelFont() const
{
return widget_sub_label_font;
}
QFont RDWidget::progressFont() const
{
return widget_progress_font;
}
QFont RDWidget::dataFont() const
{
return widget_data_font;
}
void RDWidget::MakeFonts()
{
QString family=font().family();
int button_size=font().pixelSize();
int label_size=font().pixelSize();
int data_size=font().pixelSize();
if(!widget_config->fontFamily().isEmpty()) {
family=widget_config->fontFamily();
}
if(widget_config->fontButtonSize()>0) {
button_size=widget_config->fontButtonSize();
}
if(widget_config->fontLabelSize()>0) {
label_size=widget_config->fontLabelSize();
}
if(widget_config->fontDataSize()>0) {
data_size=widget_config->fontDataSize();
}
widget_button_font=QFont(family,button_size,QFont::Bold);
widget_button_font.setPixelSize(button_size);
widget_sub_button_font=QFont(family,button_size-2,QFont::Normal);
widget_sub_button_font.setPixelSize(button_size-2);
widget_section_label_font=QFont(family,label_size+2,QFont::Bold);
widget_section_label_font.setPixelSize(label_size+2);
widget_label_font=QFont(family,label_size,QFont::Bold);
widget_label_font.setPixelSize(label_size);
widget_sub_label_font=QFont(family,label_size,QFont::Normal);
widget_sub_label_font.setPixelSize(label_size);
widget_progress_font=QFont(family,label_size+4,QFont::Bold);
widget_progress_font.setPixelSize(label_size+4);
widget_data_font=QFont(family,data_size,QFont::Normal);
widget_data_font.setPixelSize(data_size);
setFont(defaultFont());
}

View File

@@ -24,32 +24,14 @@
#include <qwidget.h>
#include <qfont.h>
#include <rdapplication.h>
#include <rdfontset.h>
class RDWidget : public QWidget
class RDWidget : public QWidget, public RDFontSet
{
Q_OBJECT;
public:
RDWidget(QWidget *parent=0,Qt::WindowFlags f=0);
RDWidget(RDConfig *config,QWidget *parent=0,Qt::WindowFlags f=0);
QFont buttonFont() const;
QFont subButtonFont() const;
QFont sectionLabelFont() const;
QFont labelFont() const;
QFont subLabelFont() const;
QFont progressFont() const;
QFont dataFont() const;
private:
void MakeFonts();
QFont widget_button_font;
QFont widget_sub_button_font;
QFont widget_section_label_font;
QFont widget_label_font;
QFont widget_sub_label_font;
QFont widget_progress_font;
QFont widget_data_font;
RDConfig *widget_config;
};