mirror of
				https://github.com/ElvishArtisan/rivendell.git
				synced 2025-11-04 08:04:12 +01:00 
			
		
		
		
	* Fixed a layout glitch in the 'Add Event' dialog in rdcatch(1). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
		
			
				
	
	
		
			279 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			279 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
// add_recording.cpp
 | 
						|
//
 | 
						|
// Add a Rivendell RDCatch Event
 | 
						|
//
 | 
						|
//   (C) Copyright 2002-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 <QKeyEvent>
 | 
						|
 | 
						|
#include "add_recording.h"
 | 
						|
#include "edit_recording.h"
 | 
						|
#include "edit_playout.h"
 | 
						|
#include "edit_cartevent.h"
 | 
						|
#include "edit_switchevent.h"
 | 
						|
#include "edit_download.h"
 | 
						|
#include "edit_upload.h"
 | 
						|
 | 
						|
extern RDStation *rdstation_conf;
 | 
						|
 | 
						|
AddRecording::AddRecording(QString *filter,QWidget *parent)
 | 
						|
  : RDDialog(parent)
 | 
						|
{
 | 
						|
  add_id=-1;
 | 
						|
  add_filter=filter;
 | 
						|
 | 
						|
  setWindowTitle("RDCatch");
 | 
						|
 | 
						|
  //
 | 
						|
  // Fix the Window Size
 | 
						|
  //
 | 
						|
  setMinimumSize(sizeHint());
 | 
						|
  setMaximumSize(sizeHint());
 | 
						|
 | 
						|
  //
 | 
						|
  // Title Label
 | 
						|
  //
 | 
						|
  add_title_label=new QLabel(tr("Schedule a:"),this);
 | 
						|
  add_title_label->setFont(labelFont());
 | 
						|
  add_title_label->setAlignment(Qt::AlignCenter);
 | 
						|
 | 
						|
  //
 | 
						|
  //  Recording Button
 | 
						|
  //
 | 
						|
  add_recording_button=new QPushButton(this);
 | 
						|
  add_recording_button->setFont(buttonFont());
 | 
						|
  add_recording_button->setText(tr("Recording"));
 | 
						|
  add_recording_button->setDisabled(true);
 | 
						|
  QString sql=QString("select `CHANNEL` from `DECKS` where ")+
 | 
						|
    "(`CARD_NUMBER`>=0)&&(`CHANNEL`>0)&&(`CHANNEL`<=9)";
 | 
						|
  RDSqlQuery *q=new RDSqlQuery(sql);
 | 
						|
  if(q->first()) {
 | 
						|
    add_recording_button->setEnabled(true);
 | 
						|
  }
 | 
						|
  delete q;
 | 
						|
  connect(add_recording_button,SIGNAL(clicked()),this,SLOT(recordingData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Playout Button
 | 
						|
  //
 | 
						|
  add_playout_button=new QPushButton(this);
 | 
						|
  add_playout_button->setFont(buttonFont());
 | 
						|
  add_playout_button->setText(tr("Playout"));
 | 
						|
  add_playout_button->setDisabled(true);
 | 
						|
  sql=QString("select `CHANNEL` from `DECKS` where (`CARD_NUMBER`>=0)&&")+
 | 
						|
    "(`PORT_NUMBER`>=0)&&(`CHANNEL`>128)&&(`CHANNEL`<=137)";
 | 
						|
  q=new RDSqlQuery(sql);
 | 
						|
  if(q->first()) {
 | 
						|
    add_playout_button->setEnabled(true);
 | 
						|
  }
 | 
						|
  delete q;
 | 
						|
  connect(add_playout_button,SIGNAL(clicked()),this,SLOT(playoutData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Download Event Button
 | 
						|
  //
 | 
						|
  add_download_button=new QPushButton(this);
 | 
						|
  add_download_button->setFont(buttonFont());
 | 
						|
  add_download_button->setText(tr("Download"));
 | 
						|
  connect(add_download_button,SIGNAL(clicked()),this,SLOT(downloadData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Upload Event Button
 | 
						|
  //
 | 
						|
  add_upload_button=new QPushButton(this);
 | 
						|
  add_upload_button->setFont(buttonFont());
 | 
						|
  add_upload_button->setText(tr("Upload"));
 | 
						|
  connect(add_upload_button,SIGNAL(clicked()),this,SLOT(uploadData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Macro Event Cart Button
 | 
						|
  //
 | 
						|
  add_macrocart_button=new QPushButton(this);
 | 
						|
  add_macrocart_button->setFont(buttonFont());
 | 
						|
  add_macrocart_button->setText(tr("Macro Cart"));
 | 
						|
  connect(add_macrocart_button,SIGNAL(clicked()),this,SLOT(macroData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Switch Event Cart Button
 | 
						|
  //
 | 
						|
  add_switchevent_button=new QPushButton(this);
 | 
						|
  add_switchevent_button->setFont(buttonFont());
 | 
						|
  add_switchevent_button->setText(tr("Switch Event"));
 | 
						|
  connect(add_switchevent_button,SIGNAL(clicked()),this,SLOT(switchData()));
 | 
						|
 | 
						|
  //
 | 
						|
  //  Cancel Button
 | 
						|
  //
 | 
						|
  add_cancel_button=new QPushButton(this);
 | 
						|
  add_cancel_button->setFont(buttonFont());
 | 
						|
  add_cancel_button->setText(tr("Cancel"));
 | 
						|
  add_cancel_button->setDefault(true);
 | 
						|
  connect(add_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
AddRecording::~AddRecording()
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
QSize AddRecording::sizeHint() const
 | 
						|
{
 | 
						|
  return QSize(200,400);
 | 
						|
} 
 | 
						|
 | 
						|
 | 
						|
QSizePolicy AddRecording::sizePolicy() const
 | 
						|
{
 | 
						|
  return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
int AddRecording::exec(RDRecording::Type *type,int rec_id)
 | 
						|
{
 | 
						|
  add_id=rec_id;
 | 
						|
  add_type=type;
 | 
						|
 | 
						|
  return QDialog::exec();
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::recordingData()
 | 
						|
{
 | 
						|
  EditRecording *recording=new EditRecording(add_id,NULL,add_filter,this);
 | 
						|
  if(!recording->exec()) {
 | 
						|
    delete recording;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete recording;
 | 
						|
  *add_type=RDRecording::Recording;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::playoutData()
 | 
						|
{
 | 
						|
  EditPlayout *playout=new EditPlayout(add_id,NULL,add_filter,this);
 | 
						|
  if(!playout->exec()) {
 | 
						|
    delete playout;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete playout;
 | 
						|
  *add_type=RDRecording::Playout;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::downloadData()
 | 
						|
{
 | 
						|
  EditDownload *recording=
 | 
						|
    new EditDownload(add_id,NULL,add_filter,this);
 | 
						|
  if(!recording->exec()) {
 | 
						|
    delete recording;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete recording;
 | 
						|
  *add_type=RDRecording::Download;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::uploadData()
 | 
						|
{
 | 
						|
  EditUpload *recording=new EditUpload(add_id,NULL,add_filter,this);
 | 
						|
  if(!recording->exec()) {
 | 
						|
    delete recording;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete recording;
 | 
						|
  *add_type=RDRecording::Upload;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::macroData()
 | 
						|
{
 | 
						|
  EditCartEvent *recording=new EditCartEvent(add_id,NULL,this);
 | 
						|
  if(!recording->exec()) {
 | 
						|
    delete recording;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete recording;
 | 
						|
  *add_type=RDRecording::MacroEvent;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::switchData()
 | 
						|
{
 | 
						|
  EditSwitchEvent *recording=new EditSwitchEvent(add_id,NULL,this);
 | 
						|
  if(!recording->exec()) {
 | 
						|
    delete recording;
 | 
						|
    done(false);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
  delete recording;
 | 
						|
  *add_type=RDRecording::SwitchEvent;
 | 
						|
  done(true);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::cancelData()
 | 
						|
{
 | 
						|
  done(false);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::resizeEvent(QResizeEvent *e)
 | 
						|
{
 | 
						|
  add_title_label->setGeometry(0,0,sizeHint().width(),30);
 | 
						|
 | 
						|
  add_recording_button->setGeometry(10,30,sizeHint().width()-20,50);
 | 
						|
  add_playout_button->setGeometry(10,80,sizeHint().width()-20,50);
 | 
						|
  add_download_button->setGeometry(10,130,sizeHint().width()-20,50);
 | 
						|
  add_upload_button->setGeometry(10,180,sizeHint().width()-20,50);
 | 
						|
  add_macrocart_button->setGeometry(10,230,sizeHint().width()-20,50);
 | 
						|
  add_switchevent_button->setGeometry(10,280,sizeHint().width()-20,50);
 | 
						|
 | 
						|
  add_cancel_button->setGeometry(10,340,sizeHint().width()-20,50);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::keyPressEvent(QKeyEvent *e)
 | 
						|
{
 | 
						|
  switch(e->key()) {
 | 
						|
      case Qt::Key_Escape:
 | 
						|
	cancelData();
 | 
						|
	break;
 | 
						|
 | 
						|
      default:
 | 
						|
	QWidget::keyPressEvent(e);
 | 
						|
	break;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void AddRecording::closeEvent(QCloseEvent *e)
 | 
						|
{
 | 
						|
  cancelData();
 | 
						|
}
 |