diff --git a/ChangeLog b/ChangeLog index 1c73a86b..0e9ea683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21962,3 +21962,6 @@ rdairplay(1). 2021-06-25 Fred Gleason * Added an 'RDMeterStrip' widget. +2021-06-26 Fred Gleason + * Refactored the layout in rdairplay(1) to achieve cleaner + separation of global and per-log UI elements. diff --git a/lib/rd.h b/lib/rd.h index 745becaa..e9cea2a2 100644 --- a/lib/rd.h +++ b/lib/rd.h @@ -418,6 +418,12 @@ */ #define RDAIRPLAY_LOG_QUANTITY 3 +/* + * RDAirPlay Logo + */ +#define RD_RDAIRPLAY_LOGO_WIDTH 167 +#define RD_RDAIRPLAY_LOGO_HEIGHT 125 + /* * Cue Editor Colors */ diff --git a/lib/rdmeterstrip.cpp b/lib/rdmeterstrip.cpp index ae00c54b..505a86d0 100644 --- a/lib/rdmeterstrip.cpp +++ b/lib/rdmeterstrip.cpp @@ -34,7 +34,10 @@ RDMeterStrip::RDMeterStrip(QWidget *parent) QSize RDMeterStrip::sizeHint() const { - return QSize(40*d_types.size(),130); + if(d_types.size()==0) { + return QSize(1,125); + } + return QSize(40*d_types.size(),125); } @@ -88,6 +91,10 @@ void RDMeterStrip::pollData() void RDMeterStrip::resizeEvent(QResizeEvent *e) { + if(d_types.size()==0) { + return; + } + int w=size().width(); int h=size().height(); int margin_x=(w-sizeHint().width())/2; @@ -99,13 +106,13 @@ void RDMeterStrip::resizeEvent(QResizeEvent *e) for(int i=0;isetGeometry(margin_x+i*slot_w+slot_w/5, - 0, + 5, meter_w, - h-20); + h-25); d_meters.at(2*i+1)->setGeometry(margin_x+i*slot_w+slot_w/2, - 0, + 5, meter_w, - h-20); + h-25); d_labels.at(i)->setGeometry(margin_x+i*slot_w, h-20, slot_w, diff --git a/rdairplay/Makefile.am b/rdairplay/Makefile.am index 098ef176..a9ee0add 100644 --- a/rdairplay/Makefile.am +++ b/rdairplay/Makefile.am @@ -58,6 +58,7 @@ dist_rdairplay_SOURCES = button_log.cpp button_log.h\ rdairplay.cpp rdairplay.h\ start_button.cpp start_button.h\ stop_counter.cpp stop_counter.h\ + topstrip.cpp topstrip.h\ voicetracker.cpp voicetracker.h\ wall_clock.cpp wall_clock.h @@ -75,6 +76,7 @@ nodist_rdairplay_SOURCES = moc_button_log.cpp\ moc_rdairplay.cpp\ moc_start_button.cpp\ moc_stop_counter.cpp\ + moc_topstrip.cpp\ moc_voicetracker.cpp\ moc_wall_clock.cpp diff --git a/rdairplay/button_log.cpp b/rdairplay/button_log.cpp index 3ce9a5a6..d07755f4 100644 --- a/rdairplay/button_log.cpp +++ b/rdairplay/button_log.cpp @@ -18,6 +18,8 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // +#include + #include "button_log.h" ButtonLog::ButtonLog(RDLogPlay *log,int id,RDAirPlayConf *conf,bool allow_pause, @@ -47,6 +49,22 @@ ButtonLog::ButtonLog(RDLogPlay *log,int id,RDAirPlayConf *conf,bool allow_pause, // log_event_edit=new EditEvent(log_log,this); + // + // Top Widgets + // + log_pie_counter_widget= + new PieCounter(rda->airplayConf()->pieCountLength(),this); + log_pie_counter_widget->setCountLength(rda->airplayConf()->pieCountLength()); + log_pie_counter_widget->setFocusPolicy(Qt::NoFocus); + + log_post_counter_widget=new PostCounter(this); + log_post_counter_widget->setPostPoint(QTime(),0,false,false); + log_post_counter_widget->setFocusPolicy(Qt::NoFocus); + + log_stop_counter_widget=new StopCounter(this); + log_stop_counter_widget->setTime(QTime(0,0,0)); + log_stop_counter_widget->setFocusPolicy(Qt::NoFocus); + // // Line Boxes / Start Buttons // @@ -87,7 +105,7 @@ ButtonLog::ButtonLog(RDLogPlay *log,int id,RDAirPlayConf *conf,bool allow_pause, QSize ButtonLog::sizeHint() const { - return QSize(500,530); + return QSize(492,800); } @@ -272,6 +290,24 @@ void ButtonLog::setTimeMode(RDAirPlayConf::TimeMode mode) } +PieCounter *ButtonLog::pieCounterWidget() const +{ + return log_pie_counter_widget; +} + + +PostCounter *ButtonLog::postCounterWidget() const +{ + return log_post_counter_widget; +} + + +StopCounter *ButtonLog::stopCounterWidget() const +{ + return log_stop_counter_widget; +} + + void ButtonLog::startButton(int id) { #ifdef SHOW_SLOTS @@ -447,15 +483,31 @@ void ButtonLog::cartDroppedData(int line,RDLogLine *ll) void ButtonLog::resizeEvent(QResizeEvent *e) { + log_post_counter_widget->setGeometry(5, + 15+10, + log_post_counter_widget->sizeHint().width(), + log_post_counter_widget->sizeHint().height()); + log_pie_counter_widget->setGeometry(10+log_post_counter_widget->size().width(), + 10, + log_pie_counter_widget->sizeHint().width(), + log_pie_counter_widget->sizeHint().height()); + log_stop_counter_widget->setGeometry(10-5+log_pie_counter_widget->sizeHint().width()+ + log_post_counter_widget->size().width()+10, + 15+10, + log_stop_counter_widget->sizeHint().width(), + log_stop_counter_widget->sizeHint().height()); + + + for(int i=0;isetGeometry(10+LOGLINEBOX_FULL_HEIGHT, - (LOGLINEBOX_FULL_HEIGHT+11)*i, + 130+(LOGLINEBOX_FULL_HEIGHT+11)*i, log_line_box[i]->sizeHint().width(), log_line_box[i]->sizeHint().height()); } for(int i=0;isetGeometry(5, - (LOGLINEBOX_FULL_HEIGHT+11)*i, + 130+(LOGLINEBOX_FULL_HEIGHT+11)*i, LOGLINEBOX_FULL_HEIGHT, LOGLINEBOX_FULL_HEIGHT); } @@ -463,12 +515,12 @@ void ButtonLog::resizeEvent(QResizeEvent *e) QRect viewport=QRect(0,0,size().width(),size().height()); for(int i=BUTTON_PLAY_BUTTONS;isetGeometry(10+85, - (LOGLINEBOX_FULL_HEIGHT+11)*3+ + 130+(LOGLINEBOX_FULL_HEIGHT+11)*3+ (LOGLINEBOX_HALF_HEIGHT+11)*(i-3), log_line_box[i]->sizeHint().width(), log_line_box[i]->sizeHint().height()); log_start_button[i]->setGeometry(5, - (LOGLINEBOX_FULL_HEIGHT+11)*3+ + 130+(LOGLINEBOX_FULL_HEIGHT+11)*3+ (LOGLINEBOX_HALF_HEIGHT+11)*(i-3), LOGLINEBOX_FULL_HEIGHT, LOGLINEBOX_HALF_HEIGHT); @@ -480,6 +532,14 @@ void ButtonLog::resizeEvent(QResizeEvent *e) } +void ButtonLog::paintEvent(QPaintEvent *e) +{ + QPainter *p=new QPainter(this); + p->fillRect(0,0,size().width(),size().height(),QColor("#D0D0D0")); + delete p; +} + + void ButtonLog::UpdateEvents() { RDLogLine *logline=NULL; diff --git a/rdairplay/button_log.h b/rdairplay/button_log.h index 64ada406..aace8ef7 100644 --- a/rdairplay/button_log.h +++ b/rdairplay/button_log.h @@ -25,7 +25,10 @@ #include "list_log.h" #include "loglinebox.h" +#include "pie_counter.h" +#include "post_counter.h" #include "start_button.h" +#include "stop_counter.h" // // Widget Settings @@ -46,6 +49,9 @@ class ButtonLog : public RDWidget RDAirPlayConf::ActionMode actionMode() const; void setActionMode(RDAirPlayConf::ActionMode mode,int *cartnum=0); void setTimeMode(RDAirPlayConf::TimeMode mode); + PieCounter *pieCounterWidget() const; + PostCounter *postCounterWidget() const; + StopCounter *stopCounterWidget() const; public slots: void startButton(int); @@ -64,6 +70,7 @@ class ButtonLog : public RDWidget protected: void resizeEvent(QResizeEvent *e); + void paintEvent(QPaintEvent *e); signals: void selectClicked(int id,int line,RDLogLine::Status); @@ -83,6 +90,9 @@ class ButtonLog : public RDWidget RDAirPlayConf::TimeMode log_time_mode; EditEvent *log_event_edit; bool log_pause_enabled; + PieCounter *log_pie_counter_widget; + PostCounter *log_post_counter_widget; + StopCounter *log_stop_counter_widget; }; diff --git a/rdairplay/local_macros.cpp b/rdairplay/local_macros.cpp index 08ad004a..a291ea53 100644 --- a/rdairplay/local_macros.cpp +++ b/rdairplay/local_macros.cpp @@ -51,20 +51,20 @@ void MainWidget::RunLocalMacros(RDMacro *rml) switch(rml->command()) { case RDMacro::LB: // Label if(rml->argQuantity()==0) { - air_message_label->clear(); + air_top_strip->messageWidget()->clear(); } else { for(int i=0;i<(rml->argQuantity()-1);i++) { str+=(rml->arg(i)+" "); } str+=rml->arg(rml->argQuantity()-1); - pal=air_message_label->palette(); + 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_message_label->setPalette(pal); - air_message_label->setFont(MessageFont(str)); - air_message_label->setText(str); + air_top_strip->messageWidget()->setPalette(pal); + air_top_strip->messageWidget()->setFont(MessageFont(str)); + air_top_strip->messageWidget()->setText(str); } if(rml->echoRequested()) { rml->acknowledge(true); @@ -74,7 +74,7 @@ void MainWidget::RunLocalMacros(RDMacro *rml) case RDMacro::LC: // Color Label if(rml->argQuantity()<=1) { - air_message_label->clear(); + air_top_strip->messageWidget()->clear(); } else { QColor color(rml->arg(0)); @@ -85,12 +85,12 @@ void MainWidget::RunLocalMacros(RDMacro *rml) str+=(rml->arg(i)+" "); } str+=rml->arg(rml->argQuantity()-1); - pal=air_message_label->palette(); + pal=air_top_strip->messageWidget()->palette(); pal.setColor(QPalette::Active,QPalette::Foreground,color); pal.setColor(QPalette::Inactive,QPalette::Foreground,color); - air_message_label->setPalette(pal); - air_message_label->setFont(MessageFont(str)); - air_message_label->setText(str); + air_top_strip->messageWidget()->setPalette(pal); + air_top_strip->messageWidget()->setFont(MessageFont(str)); + air_top_strip->messageWidget()->setText(str); } if(rml->echoRequested()) { rml->acknowledge(true); diff --git a/rdairplay/pie_counter.cpp b/rdairplay/pie_counter.cpp index 5ce89b0d..a9874da6 100644 --- a/rdairplay/pie_counter.cpp +++ b/rdairplay/pie_counter.cpp @@ -43,7 +43,9 @@ PieCounter::PieCounter(int count_length,QWidget *parent) onair_on_palette=palette(); onair_on_palette.setColor(QPalette::Background,PIE_ONAIR_COLOR); onair_off_palette=palette(); - + onair_on_palette.setColor(QPalette::Background,QColor("#D0D0D0")); + setPalette(onair_on_palette); + setAutoFillBackground(true); pie_time_label=new QLabel(":00",this); @@ -236,6 +238,8 @@ void PieCounter::paintEvent(QPaintEvent *e) int talk_angle=(int) (-5760.0*((double)pie_talk_end-(double)pie_talk_start)/(double)pie_length); QPainter *p=new QPainter(&pix); + p->setRenderHint(QPainter::Antialiasing,true); + p->setRenderHint(QPainter::SmoothPixmapTransform,true); double ring_angle = ((pie_length < (pie_count_length) ? pie_length : pie_count_length) - ((pie_time > pie_count_length) ? pie_count_length : pie_time)); if (pie_count_length) diff --git a/rdairplay/pie_counter.h b/rdairplay/pie_counter.h index 7675c238..c32e460a 100644 --- a/rdairplay/pie_counter.h +++ b/rdairplay/pie_counter.h @@ -2,7 +2,7 @@ // // The pie counter widget for Rivendell // -// (C) Copyright 2002-2018 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // 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 @@ -39,8 +39,8 @@ // // Extra padding for the bounding box // -#define PIE_X_PADDING 28 -#define PIE_Y_PADDING 7 +#define PIE_X_PADDING 0 +#define PIE_Y_PADDING 0 class PieCounter : public RDWidget @@ -92,4 +92,4 @@ class PieCounter : public RDWidget QPixmap pie_pixmap; }; -#endif +#endif // PIE_COUNTER_H diff --git a/rdairplay/post_counter.cpp b/rdairplay/post_counter.cpp index edbbd61f..30daa1b7 100644 --- a/rdairplay/post_counter.cpp +++ b/rdairplay/post_counter.cpp @@ -72,7 +72,8 @@ void PostCounter::setTimeMode(RDAirPlayConf::TimeMode mode) QSize PostCounter::sizeHint() const { - return QSize(200,60); + return QSize(180,80); + // return QSize(200,60); } @@ -181,10 +182,10 @@ void PostCounter::UpdateDisplay() p->setPen(QColor(text_color)); p->setFont(subLabelFont()); p->drawText((size().width()-2-p-> - fontMetrics().width(point))/2,22,point); + fontMetrics().width(point))/2,32,point); p->setFont(bannerFont()); p->drawText((size().width()-2-p-> - fontMetrics().width(state))/2,48,state); + fontMetrics().width(state))/2,58,state); p->end(); delete p; setIcon(pix); diff --git a/rdairplay/post_counter.h b/rdairplay/post_counter.h index 5cac4c03..269257e3 100644 --- a/rdairplay/post_counter.h +++ b/rdairplay/post_counter.h @@ -2,7 +2,7 @@ // // The post counter widget for Rivendell // -// (C) Copyright 2002-2019 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // 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 diff --git a/rdairplay/rdairplay.cpp b/rdairplay/rdairplay.cpp index c081eafc..0b8e7873 100644 --- a/rdairplay/rdairplay.cpp +++ b/rdairplay/rdairplay.cpp @@ -172,6 +172,44 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) palette.setBrush(backgroundRole(),bgmap); setPalette(palette); } + + // + // Top Strip + // + air_top_strip=new TopStrip(this); + connect(air_master_timer,SIGNAL(timeout()), + air_top_strip->wallClockWidget(),SLOT(tickClock())); + connect(air_top_strip->wallClockWidget(), + SIGNAL(timeModeChanged(RDAirPlayConf::TimeMode)), + this,SLOT(timeModeData(RDAirPlayConf::TimeMode))); + + connect(air_top_strip->modeDisplayWidget(),SIGNAL(clicked()), + this,SLOT(modeButtonData())); + connect(rda->ripc(),SIGNAL(onairFlagChanged(bool)), + air_top_strip,SLOT(setOnairFlag(bool))); + + // + // Meter Strip + // + QList strip_cards; + QList strip_ports; + for(unsigned i=0;iairplayConf()->card(chan)>=0)&& + (rda->airplayConf()->port(chan)>=0))&& + ((!strip_cards.contains(rda->airplayConf()->card(chan)))|| + (!strip_ports.contains(rda->airplayConf()->port(chan))))) { + strip_cards.push_back(rda->airplayConf()->card(chan)); + strip_ports.push_back(rda->airplayConf()->port(chan)); + } + } + air_meter_strip=new RDMeterStrip(this); + for(int i=0;imeterWidget()-> + addOutputMeter(strip_cards.at(i),strip_ports.at(i), + QString().sprintf("M%d",i+1)); + } + // // Load GPIO Channel Configuration // @@ -315,79 +353,6 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) air_cart_dialog=new RDCartDialog(&air_add_filter,&air_add_group, &air_add_schedcode,"RDAirPlay",false,this); - // - // Wall Clock - // - air_clock=new WallClock(this); - air_clock->setCheckSyncEnabled(rda->airplayConf()->checkTimesync()); - connect(air_master_timer,SIGNAL(timeout()),air_clock,SLOT(tickClock())); - air_clock->setFocusPolicy(Qt::NoFocus); - connect(air_clock,SIGNAL(timeModeChanged(RDAirPlayConf::TimeMode)), - this,SLOT(timeModeData(RDAirPlayConf::TimeMode))); - - // - // Post Counter - // - air_post_counter=new PostCounter(this); - air_post_counter->setPostPoint(QTime(),0,false,false); - air_post_counter->setFocusPolicy(Qt::NoFocus); - connect(air_master_timer,SIGNAL(timeout()), - air_post_counter,SLOT(tickCounter())); - connect(air_log[0],SIGNAL(postPointChanged(QTime,int,bool,bool)), - air_post_counter,SLOT(setPostPoint(QTime,int,bool,bool))); - - // - // Pie Counter - // - air_pie_counter=new PieCounter(rda->airplayConf()->pieCountLength(),this); - air_pie_counter->setCountLength(rda->airplayConf()->pieCountLength()); - air_pie_end=rda->airplayConf()->pieEndPoint(); - air_pie_counter->setOpMode(air_op_mode[0]); - air_pie_counter->setFocusPolicy(Qt::NoFocus); - connect(air_master_timer,SIGNAL(timeout()), - air_pie_counter,SLOT(tickCounter())); - connect(rda->ripc(),SIGNAL(onairFlagChanged(bool)), - air_pie_counter,SLOT(setOnairFlag(bool))); - - // - // Audio Meter - // - air_stereo_meter=new RDStereoMeter(this); - air_stereo_meter->setMode(RDSegMeter::Peak); - air_stereo_meter->setFocusPolicy(Qt::NoFocus); - - // - // Message Label - // - air_message_label=new QLabel(this); - air_message_label->setStyleSheet("background-color: "+ - QColor(LOGLINEBOX_BACKGROUND_COLOR).name()); - air_message_label->setWordWrap(true); - air_message_label->setLineWidth(1); - air_message_label->setMidLineWidth(1); - air_message_label->setFrameStyle(QFrame::Box|QFrame::Raised); - air_message_label->setAlignment(Qt::AlignCenter); - air_message_label->setFocusPolicy(Qt::NoFocus); - - // - // Stop Counter - // - air_stop_counter=new StopCounter(this); - air_stop_counter->setTime(QTime(0,0,0)); - air_stop_counter->setFocusPolicy(Qt::NoFocus); - connect(air_master_timer,SIGNAL(timeout()), - air_stop_counter,SLOT(tickCounter())); - connect(air_log[0],SIGNAL(nextStopChanged(QTime)), - air_stop_counter,SLOT(setTime(QTime))); - - // - // Mode Display/Button - // - air_mode_display=new ModeDisplay(this); - air_mode_display->setFocusPolicy(Qt::NoFocus); - air_mode_display->setOpModeStyle(air_op_mode_style); - connect(air_mode_display,SIGNAL(clicked()),this,SLOT(modeButtonData())); - // // Create Palettes // @@ -448,13 +413,6 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) air_copy_button->setFocusPolicy(Qt::NoFocus); connect(air_copy_button,SIGNAL(clicked()),this,SLOT(copyButtonData())); - // - // Meter Timer - // - QTimer *timer=new QTimer(this); - connect(timer,SIGNAL(timeout()),this,SLOT(meterData())); - timer->start(RD_METER_UPDATE_INTERVAL); - // // Sound Panel Array // @@ -663,10 +621,23 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) // air_button_list= new ButtonLog(air_log[0],0,rda->airplayConf(),air_pause_enabled,this); + air_button_list->pieCounterWidget()->setOpMode(air_op_mode[0]); + air_pie_end=rda->airplayConf()->pieEndPoint(); connect(air_button_list,SIGNAL(selectClicked(int,int,RDLogLine::Status)), this,SLOT(selectClickedData(int,int,RDLogLine::Status))); connect(air_button_list,SIGNAL(cartDropped(int,int,RDLogLine *)), this,SLOT(cartDroppedData(int,int,RDLogLine *))); + connect(air_master_timer,SIGNAL(timeout()), + air_button_list->postCounterWidget(),SLOT(tickCounter())); + connect(air_log[0],SIGNAL(postPointChanged(QTime,int,bool,bool)), + air_button_list->postCounterWidget(), + SLOT(setPostPoint(QTime,int,bool,bool))); + connect(air_master_timer,SIGNAL(timeout()), + air_button_list->pieCounterWidget(),SLOT(tickCounter())); + connect(air_master_timer,SIGNAL(timeout()), + air_button_list->stopCounterWidget(),SLOT(tickCounter())); + connect(air_log[0],SIGNAL(nextStopChanged(QTime)), + air_button_list->stopCounterWidget(),SLOT(setTime(QTime))); // // Set Startup Mode @@ -735,7 +706,7 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) QSize MainWidget::sizeHint() const { - return QSize(1024,738); + return QSize(1024,870); } @@ -1617,27 +1588,6 @@ void MainWidget::cartDroppedData(int id,int line,RDLogLine *ll) } -void MainWidget::meterData() -{ -#ifdef SHOW_METER_SLOTS - printf("meterData()\n"); -#endif - double ratio[2]={0.0,0.0}; - short level[2]; - - for(int i=0;icae()->outputMeterUpdate(air_meter_card[i],air_meter_port[i],level); - for(int j=0;j<2;j++) { - ratio[j]+=pow(10.0,((double)level[j])/1000.0); - } - } - } - air_stereo_meter->setLeftPeakBar((int)(log10(ratio[0])*1000.0)); - air_stereo_meter->setRightPeakBar((int)(log10(ratio[1])*1000.0)); -} - - void MainWidget::masterTimerData() { static unsigned counter=0; @@ -1708,10 +1658,10 @@ void MainWidget::transportChangedData() break; } if(logline->effectiveLength()>0) { - if((air_pie_counter->line()!=logline->id())) { + if((air_button_list->pieCounterWidget()->line()!=logline->id())) { switch(pie_end) { case RDAirPlayConf::CartEnd: - air_pie_counter->setTime(logline->effectiveLength()); + air_button_list->pieCounterWidget()->setTime(logline->effectiveLength()); break; case RDAirPlayConf::CartTransition: @@ -1726,50 +1676,50 @@ void MainWidget::transportChangedData() msecsTo(QTime::currentTime())< logline->segueLength(next_logline->transType())- logline->playPosition())) { - air_pie_counter-> + air_button_list->pieCounterWidget()-> setTime(logline->segueLength(next_logline->transType())); } } else { - air_pie_counter->setTime(logline->effectiveLength()); + air_button_list->pieCounterWidget()->setTime(logline->effectiveLength()); } break; } if(logline->talkStartPoint()==0) { - air_pie_counter->setTalkStart(0); - air_pie_counter->setTalkEnd(logline->talkEndPoint()); + air_button_list->pieCounterWidget()->setTalkStart(0); + air_button_list->pieCounterWidget()->setTalkEnd(logline->talkEndPoint()); } else { - air_pie_counter-> + air_button_list->pieCounterWidget()-> setTalkStart(logline->talkStartPoint()-logline-> startPoint()); - air_pie_counter-> + air_button_list->pieCounterWidget()-> setTalkEnd(logline->talkEndPoint()-logline-> startPoint()); } - air_pie_counter->setTransType(air_log[0]->nextTrans(line)); + air_button_list->pieCounterWidget()->setTransType(air_log[0]->nextTrans(line)); if(logline->playDeck()==NULL) { - air_pie_counter->setLogline(NULL); - air_pie_counter->start(rda->station()->timeOffset()); + air_button_list->pieCounterWidget()->setLogline(NULL); + air_button_list->pieCounterWidget()->start(rda->station()->timeOffset()); } else { - air_pie_counter->setLogline(logline); - air_pie_counter->start(((RDPlayDeck *)logline->playDeck())-> + air_button_list->pieCounterWidget()->setLogline(logline); + air_button_list->pieCounterWidget()->start(((RDPlayDeck *)logline->playDeck())-> currentPosition()+ rda->station()->timeOffset()); } } } else { - air_pie_counter->stop(); - air_pie_counter->resetTime(); - air_pie_counter->setLine(-1); + air_button_list->pieCounterWidget()->stop(); + air_button_list->pieCounterWidget()->resetTime(); + air_button_list->pieCounterWidget()->setLine(-1); } } else { - air_pie_counter->stop(); - air_pie_counter->resetTime(); - air_pie_counter->setLine(-1); + air_button_list->pieCounterWidget()->stop(); + air_button_list->pieCounterWidget()->resetTime(); + air_button_list->pieCounterWidget()->setLine(-1); } } @@ -1780,8 +1730,8 @@ void MainWidget::timeModeData(RDAirPlayConf::TimeMode mode) for(int i=0;isetTimeMode(mode); } - air_stop_counter->setTimeMode(mode); - air_post_counter->setTimeMode(mode); + air_button_list->stopCounterWidget()->setTimeMode(mode); + air_button_list->postCounterWidget()->setTimeMode(mode); } @@ -1820,6 +1770,7 @@ void MainWidget::keyPressEvent(QKeyEvent *e) } } + void MainWidget::keyReleaseEvent(QKeyEvent *e) { int keyhit = e->key(); @@ -1971,6 +1922,7 @@ void MainWidget::keyReleaseEvent(QKeyEvent *e) QWidget::keyReleaseEvent(e); } + void MainWidget::closeEvent(QCloseEvent *e) { if(!rda->airplayConf()->exitPasswordValid("")) { @@ -2012,26 +1964,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) // // Top Row // - air_clock->setGeometry(10,5,air_clock->sizeHint().width(), - air_clock->sizeHint().height()); - air_post_counter->setGeometry(220,5,air_post_counter->sizeHint().width(), - air_post_counter->sizeHint().height()); - air_pie_counter->setGeometry(426,5,air_pie_counter->sizeHint().width(), - air_pie_counter->sizeHint().height()); - air_stop_counter->setGeometry(600,5,air_stop_counter->sizeHint().width(), - air_stop_counter->sizeHint().height()); - air_mode_display-> - setGeometry(sizeHint().width()-air_mode_display->sizeHint().width()-10, - 5,air_mode_display->sizeHint().width(), - air_mode_display->sizeHint().height()); - - // - // Meter Row - // - air_stereo_meter->setGeometry(50,70,air_stereo_meter->sizeHint().width(), - air_stereo_meter->sizeHint().height()); - air_message_label->setGeometry(sizeHint().width()-425,70, - MESSAGE_WIDGET_WIDTH,air_stereo_meter->sizeHint().height()); + air_top_strip->setGeometry(0,0,w,10+RD_RDAIRPLAY_LOGO_HEIGHT); // // Button Log @@ -2039,8 +1972,6 @@ void MainWidget::resizeEvent(QResizeEvent *e) air_button_list->setGeometry(10,140, air_button_list->sizeHint().width(), h-215); - // air_button_list->setGeometry(10,140,air_button_list->sizeHint().width(), - // air_button_list->sizeHint().height()); // // Sound Panel @@ -2058,7 +1989,6 @@ void MainWidget::resizeEvent(QResizeEvent *e) // Full Log Widgets // for(int i=0;isetGeometry(w/2,140,(w/2)-20,h-210); air_log_list[i]->setGeometry(510,140,w-530,h-210); } @@ -2091,16 +2021,6 @@ void MainWidget::resizeEvent(QResizeEvent *e) } -void MainWidget::paintEvent(QPaintEvent *e) -{ - QPainter *p=new QPainter(this); - p->setPen(Qt::black); - p->fillRect(10,70,410,air_stereo_meter->sizeHint().height(),Qt::black); - p->end(); - delete p; -} - - void MainWidget::wheelEvent(QWheelEvent *e) { if((air_panel!=NULL)&&(e->orientation()==Qt::Vertical)) { @@ -2184,16 +2104,16 @@ void MainWidget::SetManualMode(int mach) return; } if(mach==0) { - air_pie_counter->setOpMode(RDAirPlayConf::Manual); + air_button_list->pieCounterWidget()->setOpMode(RDAirPlayConf::Manual); } - air_mode_display->setOpMode(mach,RDAirPlayConf::Manual); + air_top_strip->modeDisplayWidget()->setOpMode(mach,RDAirPlayConf::Manual); air_op_mode[mach]=RDAirPlayConf::Manual; rda->airplayConf()->setOpMode(mach,RDAirPlayConf::Manual); air_log[mach]->setOpMode(RDAirPlayConf::Manual); air_log_list[mach]->setOpMode(RDAirPlayConf::Manual); if(mach==0) { air_button_list->setOpMode(RDAirPlayConf::Manual); - air_post_counter->setDisabled(true); + air_button_list->postCounterWidget()->setDisabled(true); } rda->syslog(LOG_INFO,"log machine %d mode set to MANUAL",mach+1); } @@ -2208,16 +2128,16 @@ void MainWidget::SetAutoMode(int mach) return; } if(mach==0) { - air_pie_counter->setOpMode(RDAirPlayConf::Auto); + air_button_list->pieCounterWidget()->setOpMode(RDAirPlayConf::Auto); } - air_mode_display->setOpMode(mach,RDAirPlayConf::Auto); + air_top_strip->modeDisplayWidget()->setOpMode(mach,RDAirPlayConf::Auto); air_op_mode[mach]=RDAirPlayConf::Auto; rda->airplayConf()->setOpMode(mach,RDAirPlayConf::Auto); air_log[mach]->setOpMode(RDAirPlayConf::Auto); air_log_list[mach]->setOpMode(RDAirPlayConf::Auto); if(mach==0) { air_button_list->setOpMode(RDAirPlayConf::Auto); - air_post_counter->setEnabled(true); + air_button_list->postCounterWidget()->setEnabled(true); } rda->syslog(LOG_INFO,"log machine %d mode set to AUTO",mach+1); } @@ -2232,16 +2152,16 @@ void MainWidget::SetLiveAssistMode(int mach) return; } if(mach==0) { - air_pie_counter->setOpMode(RDAirPlayConf::LiveAssist); + air_button_list->pieCounterWidget()->setOpMode(RDAirPlayConf::LiveAssist); } - air_mode_display->setOpMode(mach,RDAirPlayConf::LiveAssist); + air_top_strip->modeDisplayWidget()->setOpMode(mach,RDAirPlayConf::LiveAssist); air_op_mode[mach]=RDAirPlayConf::LiveAssist; rda->airplayConf()->setOpMode(mach,RDAirPlayConf::LiveAssist); air_log[mach]->setOpMode(RDAirPlayConf::LiveAssist); air_log_list[mach]->setOpMode(RDAirPlayConf::LiveAssist); if(mach==0) { air_button_list->setOpMode(RDAirPlayConf::LiveAssist); - air_post_counter->setDisabled(true); + air_button_list->postCounterWidget()->setDisabled(true); } rda->syslog(LOG_INFO,"log machine %d mode set to LIVE ASSIST",mach+1); } @@ -2449,7 +2369,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(); } diff --git a/rdairplay/rdairplay.h b/rdairplay/rdairplay.h index b8e280c5..24ef60f0 100644 --- a/rdairplay/rdairplay.h +++ b/rdairplay/rdairplay.h @@ -26,17 +26,13 @@ #include #include #include +#include #include -#include #include "button_log.h" #include "colors.h" -#include "mode_display.h" -#include "post_counter.h" -#include "pie_counter.h" -#include "stop_counter.h" +#include "topstrip.h" #include "voicetracker.h" -#include "wall_clock.h" // // Widget Settings @@ -86,7 +82,6 @@ class MainWidget : public RDMainWindow void selectClickedData(int id,int line,RDLogLine::Status status); void selectClickedData(unsigned cartnum,int row,int col); void cartDroppedData(int id,int line,RDLogLine *ll); - void meterData(); void masterTimerData(); void transportChangedData(); void timeModeData(RDAirPlayConf::TimeMode mode); @@ -96,7 +91,6 @@ class MainWidget : public RDMainWindow void keyReleaseEvent(QKeyEvent *e); void closeEvent(QCloseEvent *); void resizeEvent(QResizeEvent *e); - void paintEvent(QPaintEvent *e); void wheelEvent(QWheelEvent *e); private: @@ -120,11 +114,7 @@ class MainWidget : public RDMainWindow RDSoundPanel *air_panel; VoiceTracker *air_tracker; QPushButton *air_tracker_button; - PostCounter *air_post_counter; - PieCounter *air_pie_counter; - RDStereoMeter *air_stereo_meter; - StopCounter *air_stop_counter; - ModeDisplay *air_mode_display; + RDMeterStrip *air_meter_strip; RDPushButton *air_add_button; RDPushButton *air_delete_button; RDPushButton *air_move_button; @@ -152,7 +142,6 @@ class MainWidget : public RDMainWindow QString air_add_filter; QString air_add_group; QString air_add_schedcode; - QLabel *air_message_label; int air_source_id; int air_meter_card[3]; int air_meter_port[3]; @@ -191,9 +180,7 @@ class MainWidget : public RDMainWindow RDEventPlayer *air_event_player; RDHotKeyList *air_keylist; RDHotkeys *air_hotkeys; - - - WallClock *air_clock; + TopStrip *air_top_strip; }; diff --git a/rdairplay/stop_counter.cpp b/rdairplay/stop_counter.cpp index 37f2e9b1..e5e44abc 100644 --- a/rdairplay/stop_counter.cpp +++ b/rdairplay/stop_counter.cpp @@ -57,7 +57,8 @@ void StopCounter::setTimeMode(RDAirPlayConf::TimeMode mode) QSize StopCounter::sizeHint() const { - return QSize(200,60); + return QSize(180,80); + // return QSize(200,60); } @@ -138,7 +139,7 @@ void StopCounter::UpdateTime() QPalette::Background)); p->setPen(QColor(text_color)); p->setFont(subLabelFont()); - p->drawText((sizeHint().width()-2-p->fontMetrics().width(stop_text))/2,22, + p->drawText((sizeHint().width()-2-p->fontMetrics().width(stop_text))/2,32, stop_text); p->setFont(bannerFont()); if (msecs < 0){ @@ -151,11 +152,12 @@ void StopCounter::UpdateTime() } if(stop_running) { text=QTime(0,0,1).addMSecs(msecs).toString("hh:mm:ss"); - p->drawText((sizeHint().width()-2-p->fontMetrics().width(text))/2,49,text); + p->drawText((sizeHint().width()-2-p->fontMetrics().width(text))/2,59, + text); } else { p->drawText((sizeHint().width()-2-p-> - fontMetrics().width(tr("Stopped")))/2,49, + fontMetrics().width(tr("Stopped")))/2,59, tr("Stopped")); } p->end(); diff --git a/rdairplay/topstrip.cpp b/rdairplay/topstrip.cpp new file mode 100644 index 00000000..28d2f179 --- /dev/null +++ b/rdairplay/topstrip.cpp @@ -0,0 +1,168 @@ +// topstrip.cpp +// +// Top row of indicator widgets for rdairplay(1) +// +// (C) Copyright 2021 Fred Gleason +// +// 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 +#include + +#include "colors.h" +#include "topstrip.h" + +TopStrip::TopStrip(QWidget *parent) + : RDWidget(parent) +{ + d_onair_flag=false; + + // + // Wall Clock Widget + // + d_wall_clock_widget=new WallClock(this); + d_wall_clock_widget->setCheckSyncEnabled(rda->airplayConf()->checkTimesync()); + + // + // Mode Display Widget + // + d_mode_display_widget=new ModeDisplay(this); + d_mode_display_widget->setOpModeStyle(rda->airplayConf()->opModeStyle()); + + // + // Audio Meters + // + d_meter_widget=new RDMeterStrip(this); + + // + // Message Display + // + 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); + + // + // Logo + // + d_logo=new QLabel(this); + d_logo->setAlignment(Qt::AlignCenter); + d_logo->setFont(bannerFont()); + d_logo->setText(QString().sprintf("User Logo\n(%dx%d)", + RD_RDAIRPLAY_LOGO_WIDTH, + RD_RDAIRPLAY_LOGO_HEIGHT)); + d_logo->setStyleSheet("background-color: #99FF99"); + + setFocusPolicy(Qt::NoFocus); +} + + +TopStrip::~TopStrip() +{ + delete d_wall_clock_widget; + delete d_mode_display_widget; + delete d_meter_widget; + delete d_message_widget; + delete d_logo; +} + + +QSize TopStrip::sizeHint() const +{ + return QSize(400,130); +} + + +QSizePolicy TopStrip::sizePolicy() const +{ + return QSizePolicy(QSizePolicy::MinimumExpanding, + QSizePolicy::MinimumExpanding); +} + + +WallClock *TopStrip::wallClockWidget() const +{ + return d_wall_clock_widget; +} + + +ModeDisplay *TopStrip::modeDisplayWidget() const +{ + return d_mode_display_widget; +} + + +RDMeterStrip *TopStrip::meterWidget() +{ + return d_meter_widget; +} + + +QLabel *TopStrip::messageWidget() const +{ + return d_message_widget; +} + + +void TopStrip::setOnairFlag(bool state) +{ + if(state!=d_onair_flag) { + d_onair_flag=state; + update(); + } +} + + +void TopStrip::resizeEvent(QResizeEvent *e) +{ + d_wall_clock_widget->setGeometry(10,5, + d_wall_clock_widget->sizeHint().width(), + d_wall_clock_widget->sizeHint().height()); + + d_mode_display_widget-> + setGeometry(10, + 70, + d_mode_display_widget->sizeHint().width(), + d_mode_display_widget->sizeHint().height()); + + d_meter_widget->setGeometry(20+d_wall_clock_widget->geometry().width(), + 5, + d_meter_widget->sizeHint().width(), + d_meter_widget->sizeHint().height()); + + 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, + RD_RDAIRPLAY_LOGO_WIDTH, + RD_RDAIRPLAY_LOGO_HEIGHT); +} + + +void TopStrip::paintEvent(QPaintEvent *e) +{ + if(d_onair_flag) { + QPainter *p=new QPainter(this); + p->fillRect(0,0,size().width(),size().height(),PIE_ONAIR_COLOR); + delete p; + } +} diff --git a/rdairplay/topstrip.h b/rdairplay/topstrip.h new file mode 100644 index 00000000..4e86d1f4 --- /dev/null +++ b/rdairplay/topstrip.h @@ -0,0 +1,61 @@ +// topstrip.h +// +// Top row of indicator widgets for rdairplay(1) +// +// (C) Copyright 2021 Fred Gleason +// +// 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 TOPSTRIP_H +#define TOPSTRIP_H + +#include + +#include +#include + +#include "mode_display.h" +#include "wall_clock.h" + +class TopStrip : public RDWidget +{ + Q_OBJECT + public: + TopStrip(QWidget *parent=0); + ~TopStrip(); + QSize sizeHint() const; + QSizePolicy sizePolicy() const; + WallClock *wallClockWidget() const; + ModeDisplay *modeDisplayWidget() const; + RDMeterStrip *meterWidget(); + QLabel *messageWidget() const; + + public slots: + void setOnairFlag(bool state); + + protected: + void resizeEvent(QResizeEvent *e); + void paintEvent(QPaintEvent *e); + + private: + WallClock *d_wall_clock_widget; + ModeDisplay *d_mode_display_widget; + RDMeterStrip *d_meter_widget; + QLabel *d_message_widget; + QLabel *d_logo; + bool d_onair_flag; +}; + +#endif // TOPSTRIP_H