2021-06-19 Fred Gleason <fredg@paravelsystems.com>

* Added an 'RDMainWindow' class.
	* Added 'RDMainWindow' to rdairplay(1).
	* Added 'RDMainWindow' to rdpanel(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-06-19 08:53:30 -04:00
parent 8a5080ab85
commit 64a6ebabe0
9 changed files with 224 additions and 12 deletions

View File

@ -21919,3 +21919,7 @@
2021-06-17 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in the build system that caused
consolehelper(8) components to be installed incorrectly on RHEL.
2021-06-19 Fred Gleason <fredg@paravelsystems.com>
* Added an 'RDMainWindow' class.
* Added 'RDMainWindow' to rdairplay(1).
* Added 'RDMainWindow' to rdpanel(1).

View File

@ -186,6 +186,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdmacro.cpp rdmacro.h\
rdmacro_event.cpp rdmacro_event.h\
rdmacrocartmodel.cpp rdmacrocartmodel.h\
rdmainwindow.cpp rdmainwindow.h\
rdmarker_bar.cpp rdmarker_bar.h\
rdmarkerdialog.cpp rdmarkerdialog.h\
rdmarkerplayer.cpp rdmarkerplayer.h\
@ -364,6 +365,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdlogplay.cpp\
moc_rdmacro_event.cpp\
moc_rdmacrocartmodel.cpp\
moc_rdmainwindow.cpp\
moc_rdmarker_bar.cpp\
moc_rdmarkerdialog.cpp\
moc_rdmarkerplayer.cpp\

View File

@ -140,6 +140,7 @@ SOURCES += rdlogplay.cpp
SOURCES += rdmacro.cpp
SOURCES += rdmacro_event.cpp
SOURCES += rdmacrocartmodel.cpp
SOURCES += rdmainwindow.cpp
SOURCES += rdmarkerdialog.cpp
SOURCES += rdmarkerplayer.cpp
SOURCES += rdmarkerreadout.cpp
@ -319,6 +320,7 @@ HEADERS += rdlogplay.h
HEADERS += rdmacro.h
HEADERS += rdmacro_event.h
HEADERS += rdmacrocartmodel.h
HEADERS += rdmainwindow.h
HEADERS += rdmarkerdialog.h
HEADERS += rdmarkerplayer.h
HEADERS += rdmarkerreadout.h

143
lib/rdmainwindow.cpp Normal file
View File

@ -0,0 +1,143 @@
// rdmainwindow.cpp
//
// Top-level window for Rivendell GUI modules.
//
// (C) Copyright 2021 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 <stdlib.h>
#include <QMessageBox>
#include "rdmainwindow.h"
RDMainWindow::RDMainWindow(const QString &cmdname,Qt::WindowFlags f)
: RDWidget(NULL,f)
{
d_command_name=cmdname;
}
RDMainWindow::RDMainWindow(const QString &cmdname,RDConfig *c,
Qt::WindowFlags f)
: RDWidget(c,NULL,f)
{
d_command_name=cmdname;
if(getenv("HOME")!=NULL) {
d_conf_dir=new QDir(QString(getenv("HOME"))+"/.rivendell");
d_conf_path=d_conf_dir->path()+"/"+d_command_name+"rc";
if(!d_conf_dir->mkpath(d_conf_dir->path())) {
delete d_conf_dir;
d_conf_dir=NULL;
}
}
}
RDMainWindow::~RDMainWindow()
{
if(d_conf_dir!=NULL) {
delete d_conf_dir;
}
}
bool RDMainWindow::loadSettings(bool apply_geometry)
{
RDProfile *p=NULL;
int x=0;
int y=0;
int w=0;
int h=0;
if(d_conf_dir==NULL) {
return false;
}
p=new RDProfile();
if(!p->setSource(d_conf_path)) {
delete p;
return false;
}
//
// Set Geometry
//
if(apply_geometry) {
x=p->intValue(d_command_name,"X");
y=p->intValue(d_command_name,"Y");
w=p->intValue(d_command_name,"Width");
h=p->intValue(d_command_name,"Height");
if((x>=0)&&(y>=0)&&(w>0)&&(h>0)) {
setGeometry(x,y,w,h);
}
}
loadLocalSettings(p);
delete p;
return true;
}
bool RDMainWindow::saveSettings() const
{
if(d_conf_dir==NULL) {
return false;
}
//
// Save Geometry
//
QString temppath=d_conf_path+"-TEMP";
FILE *f=NULL;
if((f=fopen(temppath.toUtf8(),"w"))==NULL) {
return false;
}
fprintf(f,"[%s]\n",d_command_name.toUtf8().constData());
fprintf(f,"X=%d\n",geometry().x());
fprintf(f,"Y=%d\n",geometry().y());
fprintf(f,"Width=%d\n",geometry().width());
fprintf(f,"Height=%d\n",geometry().height());
saveLocalSettings(f);
fclose(f);
if(rename(temppath.toUtf8(),d_conf_path.toUtf8())!=0) {
unlink(temppath.toUtf8());
return false;
}
return true;
}
QString RDMainWindow::commandName() const
{
return d_command_name;
}
void RDMainWindow::loadLocalSettings(RDProfile *p)
{
}
void RDMainWindow::saveLocalSettings(FILE *f) const
{
}

55
lib/rdmainwindow.h Normal file
View File

@ -0,0 +1,55 @@
// rdmainwindow.h
//
// Top-level window for Rivendell GUI modules.
//
// (C) Copyright 2021 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 RDMAINWINDOW_H
#define RDMAINWINDOW_H
#include <stdio.h>
#include <QDir>
#include <QString>
#include <rdconfig.h>
#include <rdprofile.h>
#include <rdwidget.h>
class RDMainWindow : public RDWidget
{
Q_OBJECT;
public:
RDMainWindow(const QString &cmdname,Qt::WindowFlags f=0);
RDMainWindow(const QString &cmdname,RDConfig *c,Qt::WindowFlags f=0);
~RDMainWindow();
bool loadSettings(bool apply_geometry);
bool saveSettings() const;
protected:
QString commandName() const;
virtual void loadLocalSettings(RDProfile *p);
virtual void saveLocalSettings(FILE *f) const;
private:
QString d_command_name;
QDir *d_conf_dir;
QString d_conf_path;
};
#endif // RDWIDGET_H

View File

@ -40,7 +40,7 @@
void SigHandler(int signo);
MainWidget::MainWidget(RDConfig *config,QWidget *parent)
: RDWidget(config,parent)
: RDMainWindow("rdairplay",config)
{
QString str;
int cards[3];
@ -711,6 +711,10 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent)
}
rda->syslog(LOG_INFO,"RDAirPlay started");
if(!loadSettings(true)) {
showMaximized();
}
}
@ -1946,6 +1950,7 @@ void MainWidget::closeEvent(QCloseEvent *e)
rda->airplayConf()->setExitCode(RDAirPlayConf::ExitClean);
rda->syslog(LOG_INFO,"RDAirPlay exiting");
air_lock->unlock();
saveSettings();
exit(0);
}
if(QMessageBox::question(this,"RDAirPlay",tr("Exit RDAirPlay?"),
@ -1960,6 +1965,7 @@ void MainWidget::closeEvent(QCloseEvent *e)
rda->airplayConf()->setExitCode(RDAirPlayConf::ExitClean);
rda->syslog(LOG_INFO,"RDAirPlay exiting");
air_lock->unlock();
saveSettings();
exit(0);
}
@ -2392,7 +2398,7 @@ int main(int argc,char *argv[])
RDConfig *config=new RDConfig();
config->load();
MainWidget *w=new MainWidget(config);
w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
// w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
w->show();
return a.exec();
}

View File

@ -25,9 +25,9 @@
#include <rdhotkeylist.h>
#include <rdhotkeys.h>
#include <rdinstancelock.h>
#include <rdmainwindow.h>
#include <rdsound_panel.h>
#include <rdstereometer.h>
#include <rdwidget.h>
#include "button_log.h"
#include "colors.h"
@ -54,7 +54,7 @@
#define MESSAGE_WIDGET_WIDTH 410
#define RDAIRPLAY_USAGE "[OPTIONS]\n"
class MainWidget : public RDWidget
class MainWidget : public RDMainWindow
{
Q_OBJECT
public:

View File

@ -40,7 +40,7 @@ RDAudioPort *rdaudioport_conf;
RDCartDialog *panel_cart_dialog;
MainWidget::MainWidget(RDConfig *c,QWidget *parent)
: RDWidget(c,parent)
: RDMainWindow("rdpanel",c)
{
QPixmap panel_skin_pixmap;
QString err_msg;
@ -48,10 +48,7 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
//
// Fix the Window Size
//
#ifndef RESIZABLE
setMinimumSize(sizeHint());
// setMaximumSize(sizeHint());
#endif // RESIZABLE
//
// Open the Database
@ -247,6 +244,10 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
panel_empty_cart->hide();
}
if(!loadSettings(true)) {
showMaximized();
}
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
}
@ -345,6 +346,7 @@ void MainWidget::wheelEvent(QWheelEvent *e)
void MainWidget::closeEvent(QCloseEvent *e)
{
panel_db->removeDatabase(rda->config()->mysqlDbname());
saveSettings();
exit(0);
}
@ -392,7 +394,6 @@ int main(int argc,char *argv[])
RDConfig *config=new RDConfig();
config->load();
MainWidget *w=new MainWidget(config);
w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
w->show();
return a.exec();
}

View File

@ -22,6 +22,7 @@
#define RDPANEL_H
#include <rdemptycart.h>
#include <rdmainwindow.h>
#include <rdsound_panel.h>
#include <rdstereometer.h>
#include <rdwidget.h>
@ -31,11 +32,9 @@
//
#define MASTER_TIMER_INTERVAL 100
#define METER_INTERVAL 50
//#define RDPANEL_PANEL_BUTTON_ROWS 7
//#define RDPANEL_PANEL_BUTTON_COLUMNS 9
#define RDPANEL_USAGE "\n"
class MainWidget : public RDWidget
class MainWidget : public RDMainWindow
{
Q_OBJECT
public: