2021-03-12 Fred Gleason <fredg@paravelsystems.com>

* Added a 'RDMarkerView' class.
	* Added a 'RDMarkerDialog' class.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2021-03-12 11:08:45 -05:00
parent f2b8f6ddba
commit e5631a1b5f
20 changed files with 955 additions and 8 deletions

184
lib/rdmarkerdialog.cpp Normal file
View File

@@ -0,0 +1,184 @@
// rdmarkerdialog.cpp
//
// Rivendell Audio Marker Editor
//
// (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 <QMessageBox>
#include "rdmarkerdialog.h"
RDMarkerDialog::RDMarkerDialog(const QString &caption,QWidget *parent)
: RDDialog(parent)
{
d_caption=caption;
setMinimumSize(sizeHint());
setMaximumSize(sizeHint());
d_marker_view=new RDMarkerView(sizeHint().width()-104,374,this);
//
// Amplitude
//
d_amplitude_box=new QGroupBox(tr("Amplitude"),this);
d_amplitude_box->setFont(labelFont());
d_amplitude_up_button=
new RDTransportButton(RDTransportButton::Up,d_amplitude_box);
connect(d_amplitude_up_button,SIGNAL(clicked()),
this,SLOT(amplitudeUpData()));
d_amplitude_down_button=
new RDTransportButton(RDTransportButton::Down,d_amplitude_box);
connect(d_amplitude_down_button,SIGNAL(clicked()),
this,SLOT(amplitudeDownData()));
//
// Time
//
d_time_box=new QGroupBox(tr("Time"),this);
d_time_box->setFont(labelFont());
d_time_fullin_button=new QPushButton(tr("Full\nIn"),d_time_box);
d_time_fullin_button->setFont(buttonFont());
connect(d_time_fullin_button,SIGNAL(clicked()),this,SLOT(timeFullInData()));
d_time_in_button=new RDTransportButton(RDTransportButton::Up,d_time_box);
connect(d_time_in_button,SIGNAL(clicked()),this,SLOT(timeInData()));
d_time_out_button=new RDTransportButton(RDTransportButton::Down,d_time_box);
connect(d_time_out_button,SIGNAL(clicked()),this,SLOT(timeOutData()));
d_time_fullout_button=new QPushButton(tr("Full\nOut"),d_time_box);
d_time_fullout_button->setFont(buttonFont());
connect(d_time_fullout_button,SIGNAL(clicked()),
d_marker_view,SLOT(setMaximumShrinkFactor()));
//
// OK Button
//
d_ok_button=new QPushButton(tr("OK"),this);
d_ok_button->setFont(buttonFont());
connect(d_ok_button,SIGNAL(clicked()),this,SLOT(okData()));
//
// Cancel Button
//
d_cancel_button=new QPushButton(tr("Cancel"),this);
d_cancel_button->setFont(buttonFont());
connect(d_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
}
RDMarkerDialog::~RDMarkerDialog()
{
}
QSize RDMarkerDialog::sizeHint() const
{
return QSize(1000,600);
}
int RDMarkerDialog::exec(unsigned cartnum,int cutnum)
{
QString err_msg;
d_cart_number=cartnum;
d_cut_number=cutnum;
setWindowTitle(d_caption+" - "+tr("Edit Audio"));
if(!d_marker_view->setCut(&err_msg,cartnum,cutnum)) {
QMessageBox::critical(this,d_caption+" - "+tr("Error"),err_msg);
return false;
}
return QDialog::exec();
}
void RDMarkerDialog::amplitudeUpData()
{
d_marker_view->setAudioGain(d_marker_view->audioGain()+300);
}
void RDMarkerDialog::amplitudeDownData()
{
d_marker_view->setAudioGain(d_marker_view->audioGain()-300);
}
void RDMarkerDialog::timeFullInData()
{
d_marker_view->setShrinkFactor(1);
}
void RDMarkerDialog::timeInData()
{
int sf=d_marker_view->shrinkFactor();
if(sf>1) {
d_marker_view->setShrinkFactor(sf/2);
}
}
void RDMarkerDialog::timeOutData()
{
d_marker_view->setShrinkFactor(2*d_marker_view->shrinkFactor());
}
void RDMarkerDialog::okData()
{
done(true);
}
void RDMarkerDialog::cancelData()
{
done(false);
}
void RDMarkerDialog::closeEvent(QCloseEvent *e)
{
cancelData();
}
void RDMarkerDialog::resizeEvent(QResizeEvent *e)
{
int w=size().width();
int h=size().height();
d_marker_view->setGeometry(2,2,w-104,d_marker_view->sizeHint().height());
d_amplitude_box->setGeometry(w-100,2,90,130);
d_amplitude_up_button->setGeometry(5,24,80,50);
d_amplitude_down_button->setGeometry(5,74,80,50);
d_time_box->setGeometry(w-100,142,90,230);
d_time_fullin_button->setGeometry(5,24,80,50);
d_time_in_button->setGeometry(5,74,80,50);
d_time_out_button->setGeometry(5,124,80,50);
d_time_fullout_button->setGeometry(5,174,80,50);
d_ok_button->setGeometry(w-180,h-60,80,50);
d_cancel_button->setGeometry(w-90,h-60,80,50);
}