2024-02-08 Fred Gleason <fredg@paravelsystems.com>

* Implemented the 'Load Message" ['LM'] RML.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2024-02-08 15:36:18 -05:00
parent 38ef094ba3
commit bfa31221f5
14 changed files with 248 additions and 78 deletions

View File

@@ -2,7 +2,7 @@
##
## Automake.am for rivendell/rdairplay
##
## (C) 2002-2023 Fred Gleason <fredg@paravelsystems.com>
## (C) 2002-2024 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
@@ -20,7 +20,7 @@
##
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -I$(top_srcdir)/lib -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -I$(top_srcdir)/lib -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ -I/usr/include/qt5/QtWebKitWidgets @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@
LIBS = -L$(top_srcdir)/lib
MOC = @QT_MOC@
@@ -48,6 +48,7 @@ dist_rdairplay_SOURCES = button_log.cpp button_log.h\
local_macros.cpp colors.h\
loglinebox.cpp loglinebox.h\
logtableview.cpp logtableview.h\
messagewidget.cpp messagewidget.h\
mode_display.cpp mode_display.h\
pie_counter.cpp pie_counter.h\
post_counter.cpp post_counter.h\
@@ -68,6 +69,7 @@ nodist_rdairplay_SOURCES = moc_button_log.cpp\
moc_list_logs.cpp\
moc_loglinebox.cpp\
moc_logtableview.cpp\
moc_messagewidget.cpp\
moc_mode_display.cpp\
moc_pie_counter.cpp\
moc_post_counter.cpp\
@@ -80,7 +82,7 @@ nodist_rdairplay_SOURCES = moc_button_log.cpp\
moc_voicetracker.cpp\
moc_wall_clock.cpp
rdairplay_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
rdairplay_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ -lQt5WebKitWidgets
rdairplay_LDFLAGS = -rdynamic
EXTRA_DIST = rdairplay.pro\

View File

@@ -2,7 +2,7 @@
//
// Local RML Macros for the Rivendell's RDAirPlay
//
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2024 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
@@ -58,13 +58,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
str+=(rml->arg(i)+" ");
}
str+=rml->arg(rml->argQuantity()-1);
pal=air_top_strip->messageWidget()->palette();
pal.setColor(QPalette::Active,QPalette::Foreground,QColor(Qt::black));
pal.setColor(QPalette::Inactive,QPalette::Foreground,
QColor(Qt::black));
air_top_strip->messageWidget()->setPalette(pal);
air_top_strip->messageWidget()->setFont(MessageFont(str));
air_top_strip->messageWidget()->setText(str);
air_top_strip->messageWidget()->setText(str,QColor(Qt::black));
}
if(rml->echoRequested()) {
rml->acknowledge(true);
@@ -85,12 +79,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
str+=(rml->arg(i)+" ");
}
str+=rml->arg(rml->argQuantity()-1);
pal=air_top_strip->messageWidget()->palette();
pal.setColor(QPalette::Active,QPalette::Foreground,color);
pal.setColor(QPalette::Inactive,QPalette::Foreground,color);
air_top_strip->messageWidget()->setPalette(pal);
air_top_strip->messageWidget()->setFont(MessageFont(str));
air_top_strip->messageWidget()->setText(str);
air_top_strip->messageWidget()->setText(str,color);
}
if(rml->echoRequested()) {
rml->acknowledge(true);
@@ -98,6 +87,22 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
}
break;
case RDMacro::LM: // Load Message Widget
if(rml->argQuantity()==0) {
air_top_strip->messageWidget()->clear();
}
else {
for(int i=0;i<(rml->argQuantity());i++) {
str+=(rml->arg(i)+" ");
}
ok=air_top_strip->messageWidget()->setUrl(str.trimmed());
}
if(rml->echoRequested()) {
rml->acknowledge(ok);
rda->ripc()->sendRml(rml);
}
break;
case RDMacro::LL: // Load Log
if((rml->argQuantity()<1)||(rml->argQuantity()>3)) {
if(rml->echoRequested()) {
@@ -960,17 +965,6 @@ void MainWidget::RunLocalMacros(RDMacro *rml)
}
QFont MainWidget::MessageFont(QString str)
{
for(int i=(AIR_MESSAGE_FONT_QUANTITY-1);i>=0;i--) {
if(air_message_metrics[i]->width(str)<MESSAGE_WIDGET_WIDTH) {
return air_message_fonts[i];
}
}
return air_message_fonts[0];
}
bool MainWidget::GetPanel(QString str,RDAirPlayConf::PanelType *type,
int *panel)
{

109
rdairplay/messagewidget.cpp Normal file
View File

@@ -0,0 +1,109 @@
// messagewidget.cpp
//
// Message Widget for RDAirPlay Rivendell
//
// (C) Copyright 2024 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 "colors.h"
#include "messagewidget.h"
MessageWidget::MessageWidget(QWidget *parent)
: QWidget(parent)
{
setStyleSheet("background-color: "+
QColor(LOGLINEBOX_BACKGROUND_COLOR).name());
//
// Generate Fonts
//
for(unsigned i=0;i<MESSAGE_FONT_QUANTITY;i++) {
d_message_fonts[i]=QFont(font().family(),12+2*i,QFont::Normal);
d_message_fonts[i].setPixelSize(12+2*i);
d_message_metrics[i]=new QFontMetrics(d_message_fonts[i]);
}
//
// Message Display
//
d_label=new QLabel(this);
d_label->setWordWrap(true);
d_label->setAlignment(Qt::AlignCenter);
d_view=new QWebView(this);
d_view->hide();
}
void MessageWidget::setText(const QString &str,const QColor &col)
{
QPalette pal=d_label->palette();
pal.setColor(QPalette::Active,QPalette::Foreground,col);
pal.setColor(QPalette::Inactive,QPalette::Foreground,col);
d_label->setPalette(pal);
d_label->setFont(MessageFont(str));
d_label->setText(str);
d_label->show();
d_view->hide();
}
bool MessageWidget::setUrl(const QString &str)
{
QUrl url(str);
if(!url.isValid()) {
setText(tr("invalid URL")+": "+str.toUtf8().constData(),Qt::black);
return false;
}
if((url.scheme().toLower()!="http")&&
(url.scheme().toLower()!="https")&&
(url.scheme().toLower()!="file")) {
setText(tr("unsupported URL scheme")+": "+str.toUtf8().constData(),
Qt::black);
return false;
}
d_view->load(url);
d_view->show();
d_label->hide();
return true;
}
void MessageWidget::clear()
{
d_label->clear();
d_label->show();
d_view->hide();
}
void MessageWidget::resizeEvent(QResizeEvent *e)
{
d_label->setGeometry(0,0,size().width(),size().height());
d_view->setGeometry(0,0,size().width(),size().height());
}
QFont MessageWidget::MessageFont(QString str) const
{
for(int i=(MESSAGE_FONT_QUANTITY-1);i>=0;i--) {
if(d_message_metrics[i]->width(str)<MESSAGE_WIDGET_WIDTH) {
return d_message_fonts[i];
}
}
return d_message_fonts[0];
}

50
rdairplay/messagewidget.h Normal file
View File

@@ -0,0 +1,50 @@
// messagewidget.h
//
// Message Widget for RDAirPlay Rivendell
//
// (C) Copyright 2024 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 MESSAGEWIDGET_H
#define MESSAGEWIDGET_H
#include <QLabel>
#include <QWebView>
#define MESSAGE_FONT_QUANTITY 8
#define MESSAGE_WIDGET_WIDTH 410
class MessageWidget : public QWidget
{
Q_OBJECT
public:
MessageWidget(QWidget *parent=0);
void setText(const QString &str,const QColor &col);
bool setUrl(const QString &url);
void clear();
protected:
void resizeEvent(QResizeEvent *e);
private:
QFont MessageFont(QString str) const;
QLabel *d_label;
QWebView *d_view;
QFont d_message_fonts[MESSAGE_FONT_QUANTITY];
QFontMetrics *d_message_metrics[MESSAGE_FONT_QUANTITY];
};
#endif // MESSAGEWIDGET_H

View File

@@ -2,7 +2,7 @@
//
// The On Air Playout Utility for Rivendell.
//
// (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2024 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
@@ -134,15 +134,6 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent)
//
srandom(QTime::currentTime().msec());
//
// Generate Fonts
//
for(unsigned i=0;i<AIR_MESSAGE_FONT_QUANTITY;i++) {
air_message_fonts[i]=QFont(font().family(),12+2*i,QFont::Normal);
air_message_fonts[i].setPixelSize(12+2*i);
air_message_metrics[i]=new QFontMetrics(air_message_fonts[i]);
}
//
// Create And Set Icon
//

View File

@@ -2,7 +2,7 @@
//
// The On Air Playout Utility for Rivendell.
//
// (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2024 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
@@ -42,11 +42,9 @@
#define AIR_LOG_PORTS 2
#define AIR_PANEL_PORTS 1
#define AIR_TOTAL_PORTS 3
#define AIR_MESSAGE_FONT_QUANTITY 8
#define AIR_CHANNEL_LOCKOUT_INTERVAL 1000
#define METER_INTERVAL 20
#define MASTER_TIMER_INTERVAL 100
#define MESSAGE_WIDGET_WIDTH 410
#define RDAIRPLAY_USAGE "[OPTIONS]\n"
class MainWidget : public RDMainWindow
@@ -99,7 +97,6 @@ class MainWidget : public RDMainWindow
void SetLiveAssistMode(int mach);
void SetActionMode(StartButton::Mode mode);
bool GetPanel(QString str,RDAirPlayConf::PanelType *type,int *panel);
QFont MessageFont(QString str);
bool AssertChannelLock(int dir,int card,int port);
bool AssertChannelLock(int dir,int achan);
int AudioChannel(int card,int port) const;
@@ -150,8 +147,6 @@ class MainWidget : public RDMainWindow
RDAirPlayConf::ExitCode rdairplay_previous_exit_code;
QDateTime air_startup_datetime;
QPixmap *air_refresh_pixmap;
QFont air_message_fonts[AIR_MESSAGE_FONT_QUANTITY];
QFontMetrics *air_message_metrics[AIR_MESSAGE_FONT_QUANTITY];
int air_audio_channels[RDAirPlayConf::LastChannel];
int air_start_gpi_matrices[RDAirPlayConf::LastChannel];
int air_start_gpi_lines[RDAirPlayConf::LastChannel];

View File

@@ -2,7 +2,7 @@
//
// Top row of indicator widgets for rdairplay(1)
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2021-2024 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
@@ -18,6 +18,8 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <QUrl>
#include <rdapplication.h>
#include <rd.h>
@@ -45,18 +47,10 @@ TopStrip::TopStrip(QWidget *parent)
// Audio Meters
//
d_meter_widget=new RDMeterStrip(this);
//
// Message Display
// Message Widget
//
d_message_widget=new QLabel(this);
d_message_widget->setStyleSheet("background-color: "+
QColor(LOGLINEBOX_BACKGROUND_COLOR).name());
d_message_widget->setWordWrap(true);
d_message_widget->setLineWidth(1);
d_message_widget->setMidLineWidth(1);
d_message_widget->setFrameStyle(QFrame::Box|QFrame::Raised);
d_message_widget->setAlignment(Qt::AlignCenter);
d_message_widget=new MessageWidget(this);
//
// Logo
@@ -114,7 +108,7 @@ RDMeterStrip *TopStrip::meterWidget()
}
QLabel *TopStrip::messageWidget() const
MessageWidget *TopStrip::messageWidget() const
{
return d_message_widget;
}
@@ -131,6 +125,8 @@ void TopStrip::setOnairFlag(bool state)
void TopStrip::resizeEvent(QResizeEvent *e)
{
int w=size().width();
d_wall_clock_widget->setGeometry(10,5,
d_wall_clock_widget->sizeHint().width(),
d_wall_clock_widget->sizeHint().height());
@@ -148,10 +144,10 @@ void TopStrip::resizeEvent(QResizeEvent *e)
d_message_widget->setGeometry(10+d_meter_widget->geometry().x()+
d_meter_widget->geometry().width(),
5,
size().width()-(30+d_meter_widget->geometry().x()+d_meter_widget->geometry().width()+RD_RDAIRPLAY_LOGO_WIDTH),
125);
d_logo->setGeometry(size().width()-RD_RDAIRPLAY_LOGO_WIDTH-10,
5,
w-(30+d_meter_widget->geometry().x()+d_meter_widget->geometry().width()+RD_RDAIRPLAY_LOGO_WIDTH),
125);
d_logo->setGeometry(w-RD_RDAIRPLAY_LOGO_WIDTH-10,
5,
RD_RDAIRPLAY_LOGO_WIDTH,
RD_RDAIRPLAY_LOGO_HEIGHT);

View File

@@ -2,7 +2,7 @@
//
// Top row of indicator widgets for rdairplay(1)
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2021-2024 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
@@ -22,10 +22,12 @@
#define TOPSTRIP_H
#include <QLabel>
#include <QWebView>
#include <rdmeterstrip.h>
#include <rdwidget.h>
#include "messagewidget.h"
#include "mode_display.h"
#include "wall_clock.h"
@@ -40,8 +42,7 @@ class TopStrip : public RDWidget
WallClock *wallClockWidget() const;
ModeDisplay *modeDisplayWidget() const;
RDMeterStrip *meterWidget();
QLabel *messageWidget() const;
MessageWidget *messageWidget() const;
public slots:
void setOnairFlag(bool state);
@@ -50,10 +51,11 @@ class TopStrip : public RDWidget
void paintEvent(QPaintEvent *e);
private:
// QFont MessageFont(QString str) const;
WallClock *d_wall_clock_widget;
ModeDisplay *d_mode_display_widget;
RDMeterStrip *d_meter_widget;
QLabel *d_message_widget;
MessageWidget *d_message_widget;
QLabel *d_logo;
bool d_onair_flag;
};