fixes, funcionalidad básica y nuevos botones (no cargan iconos).

graba/carga cuelists en archivo xml
This commit is contained in:
snt 2024-06-21 18:12:46 +02:00
parent 14a8aab0a4
commit d9e755cd32
8 changed files with 817 additions and 72 deletions

View file

@ -26,6 +26,7 @@ HEADERS += src/libremediaserver-audio.h \
src/slidergroup.h src/slidergroup.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/editcuetrackwidget.cpp \ src/editcuetrackwidget.cpp \
src/cuetracklistwidget.cpp \
src/showplayer.cpp \ src/showplayer.cpp \
src/clickabledoublespinbox.cpp \ src/clickabledoublespinbox.cpp \
src/clickablelabel.cpp \ src/clickablelabel.cpp \
@ -57,6 +58,3 @@ OTHER_FILES += \
docs/changelog.txt \ docs/changelog.txt \
docs/lms-audio.xlm \ docs/lms-audio.xlm \
docs/roadmap.txt docs/roadmap.txt
SOURCES += \
src/cuetracklistwidget.cpp

530
src/cuetracklistwidget.cpp Normal file
View file

@ -0,0 +1,530 @@
#include <algorithm>
#include <QWidget>
#include <QScrollArea>
#include <QEvent>
#include <QKeyEvent>
#include <QShortcut>
#include <QVBoxLayout>
#include <QTableWidget>
#include <QTableWidgetItem>
#include "cuetracklistwidget.h"
CueTrackListWidget::CueTrackListWidget(QWidget *parent)
{
layout = new QVBoxLayout(this);
tableWidget = new QTableWidget();
tableWidget->setSortingEnabled(false);
layout->addWidget(tableWidget);
setLayout(layout);
QShortcut *shortcut_up = new QShortcut(QKeySequence("Up"), parent);
QObject::connect(shortcut_up, SIGNAL(activated()), this, SLOT(key_up()));
QShortcut *shortcut_down = new QShortcut(QKeySequence("Down"), parent);
QObject::connect(shortcut_down, SIGNAL(activated()), this, SLOT(key_down()));
}
void CueTrackListWidget::addCueTrack(CueTrack* cue) {
cueTracks.push_back(cue);
displayCueTrackInTable(cue, -1);
m_size++;
}
void CueTrackListWidget::removeCueTrack(int index) {
if (index >= m_size) return;
cueTracks.erase(cueTracks.begin() + index);
tableWidget->removeRow(index);
m_size--;
}
CueTrack* CueTrackListWidget::getTrackAtIndex(int index) {
if (index < m_size) {
return cueTracks.at(index);
}
return nullptr;
}
CueTrack* CueTrackListWidget::getSelectedTrack() {
CueTrack* track = getTrackAtIndex(selectedIndex);
key_down();
return track;
}
void CueTrackListWidget::key_up() {
if (m_size > 0 && selectedIndex > 0) {
updateSelectedCueTrack(false);
selectedIndex--;
updateSelectedCueTrack(true);
tableWidget->scrollToItem(tableWidget->item(selectedIndex, 0));
}
emit changeSelectedIndex(selectedIndex);
}
void CueTrackListWidget::key_down() {
if (selectedIndex < m_size - 1 && m_size > 0) {
updateSelectedCueTrack(false);
selectedIndex++;
updateSelectedCueTrack(true);
tableWidget->scrollToItem(tableWidget->item(selectedIndex, 0));
}
emit changeSelectedIndex(selectedIndex);
}
void CueTrackListWidget::displayCueTrackInTable(CueTrack *cueTrack, int index) {
if (tableWidget->columnCount() == 0) {
tableWidget->setColumnCount(7);
QStringList headers = {"Active", "Number","Audio Channel", "Name", "Volume", "Status", "File"};
tableWidget->setHorizontalHeaderLabels(headers);
}
if (index == -1)
index = tableWidget->rowCount();
tableWidget->insertRow(index);
tableWidget->setItem(index, 0, new QTableWidgetItem(cueTrack->active ? "Yes" : "No"));
tableWidget->setItem(index, 1, new QTableWidgetItem(QStringLiteral("%1").arg(cueTrack->userNumber, 3, 10, QLatin1Char('0'))));
tableWidget->setItem(index, 2, new QTableWidgetItem(QString::number(cueTrack->audioLayer)));
tableWidget->setItem(index, 3, new QTableWidgetItem(cueTrack->name.data()));
tableWidget->setItem(index, 4, new QTableWidgetItem(QString::number(cueTrack->volume)));
QString statusStr;
statusStr = statusToString(cueTrack->status);
tableWidget->setItem(index, 5, new QTableWidgetItem(statusStr));
tableWidget->setItem(index, 6, new QTableWidgetItem(*getFileName(cueTrack->filePath)));
}
//ToDo: make shortcuts in showplayer instead
void CueTrackListWidget::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Delete) {
deleteCueTrack();
}
if (event->key() == Qt::Key_Insert) {
createNewCueTrack();
}
if (event->key() == Qt::Key_Return) {
editCueTrack();
}
}
void CueTrackListWidget::updateSelectedCueTrack(bool highlightRow) {
if (selectedIndex >= 0 && selectedIndex < tableWidget->rowCount()) {
QBrush backgroundBrush(highlightRow ? QColor(248, 248, 200) : Qt::white);
for (int column = 0; column < tableWidget->columnCount(); ++column) {
QTableWidgetItem *item = tableWidget->item(selectedIndex, column);
if (!item) {
item = new QTableWidgetItem();
tableWidget->setItem(selectedIndex, column, item);
}
item->setBackground(backgroundBrush);
}
tableWidget->resizeColumnsToContents();
tableWidget->resizeRowsToContents();
}
}
void CueTrackListWidget::cueTrackLoadDefaults(CueTrack * t)
{
t->active = false;
t->audioLayer = -1;
t->bus1 = 80;
t->bus2 = 80;
t->entryPoint = 0;
t->exitPoint = 255;
t->fadeIn = 3;
t->fadeOut = 3;
t->waitIn = 0;
t->waitOut = 0;
t->pan = 0;
t->pitch = 1;
t->status = Status::PlayingOnce;
t->userNumber = lastUserCueNumber;
lastUserCueNumber++;
t->volume = 80;
t->stopAtEnd = true;
t->filePath = "";
}
void CueTrackListWidget::createNewCueTrack()
{
CueTrack *t = new CueTrack;
cueTrackLoadDefaults(t);
EditCueTrackWidget dialog(t, this);
if (dialog.exec() == QDialog::Accepted)
addCueTrack(t);
if (m_size == 1)
{
updateSelectedCueTrack(true);
emit changeSelectedIndex(0);
} else
redrawCueTrackList();
}
void CueTrackListWidget::editCueTrack()
{
CueTrack *current = getTrackAtIndex(selectedIndex);
EditCueTrackWidget dialog(current, this);
if (dialog.exec() == QDialog::Accepted) {
copyCueTrack(dialog.cueTrack, current);
redrawCueTrackList();
emit changeSelectedIndex(selectedIndex);
}
}
void CueTrackListWidget::deleteCueTrack()
{
removeCueTrack(selectedIndex);
if (selectedIndex >= m_size)
{
selectedIndex = m_size - 1;
emit changeSelectedIndex(selectedIndex);
}
redrawCueTrackList();
}
void CueTrackListWidget::copyCueTrack(CueTrack *src, CueTrack *dst)
{
dst->active = src->active;
dst->audioLayer = src->audioLayer;
dst->bus1 = src->bus1;
dst->bus2 = src->bus2;
dst->entryPoint = src->entryPoint;
dst->exitPoint = src->exitPoint;
dst->fadeIn = src->fadeIn;
dst->fadeOut = src->fadeOut;
dst->waitIn = src->waitIn;
dst->waitOut = src->waitOut;
dst->pan = src->pan;
dst->pitch = src->pitch;
dst->status = src->status;
dst->userNumber = src->userNumber;
dst->volume = src->volume;
dst->stopAtEnd = src->stopAtEnd;
dst->name = src->name;
dst->description = src->description;
dst->filePath = src->filePath;
}
QString *CueTrackListWidget::getFileName(std::string s)
{
size_t bar = s.rfind("/");
std::string tmp = s.substr(bar + 1, strlen(s.data()));
QString *ret = new QString(tmp.data());
ret->truncate(64);
return ret;
}
void CueTrackListWidget::sortCueTrackList()
{
std::sort(cueTracks.begin(), cueTracks.end(), [](CueTrack *a, CueTrack *b) {
return a->userNumber < b->userNumber;
});
}
void CueTrackListWidget::redrawCueTrackList()
{
if (!m_size)
return;
int selected = cueTracks.at(selectedIndex)->userNumber;
clearTableWidget();
tableWidget->setColumnCount(7);
QStringList headers = {"Active", "Number","Audio Channel", "Name", "Volume", "Status", "File"};
tableWidget->setHorizontalHeaderLabels(headers);
sortCueTrackList();
selectedIndex = 0;
for (int i = 0; i < m_size; i++)
{
displayCueTrackInTable(cueTracks.at(i), i);
}
selectedIndex = 0;
while (cueTracks.at(selectedIndex)->userNumber != selected)
{
selectedIndex++;
}
updateSelectedCueTrack(true);
tableWidget->resizeColumnsToContents();
tableWidget->resizeRowsToContents();
tableWidget->scrollToItem(tableWidget->item(selectedIndex, 0));
tableWidget->blockSignals(false);
}
#include <QFile>
#include <QXmlStreamReader>
#include <iostream>
#include <string>
void CueTrackListWidget::loadCueTrackList(std::string filename)
{
QFile file(QString::fromStdString(filename));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
std::cerr << "No se pudo abrir el archivo para lectura" << std::endl;
return;
}
QXmlStreamReader xmlReader(&file);
clearCueTrackList();
while (!xmlReader.atEnd() && !xmlReader.hasError())
{
QXmlStreamReader::TokenType token = xmlReader.readNext();
if (token == QXmlStreamReader::StartElement)
{
if (xmlReader.name() == "CueTrack")
{
CueTrack *t = new CueTrack;
while (!(xmlReader.tokenType() == QXmlStreamReader::EndElement && xmlReader.name() == "CueTrack"))
{
if (xmlReader.tokenType() == QXmlStreamReader::StartElement)
{
QString elementName = xmlReader.name().toString();
xmlReader.readNext();
if (xmlReader.tokenType() == QXmlStreamReader::Characters)
{
if (elementName == "filePath") {
t->filePath = xmlReader.text().toString().toStdString();
}
else if (elementName == "volume") {
t->volume = xmlReader.text().toInt();
}
else if (elementName == "pan") {
t->pan = xmlReader.text().toInt();
}
else if (elementName == "pitch") {
t->pitch = xmlReader.text().toInt();
}
else if (elementName == "bus1") {
t->bus1 = xmlReader.text().toInt();
}
else if (elementName == "bus2") {
t->bus2 = xmlReader.text().toInt();
}
else if (elementName == "status") {
QString tmp = xmlReader.text().toString();
t->status = stringToStatus(&tmp);
}
else if (elementName == "fadeOut") {
t->fadeOut = xmlReader.text().toInt();
}
else if (elementName == "fadeIn") {
t->fadeIn = xmlReader.text().toInt();
}
else if (elementName == "waitIn") {
t->waitIn = xmlReader.text().toInt();
}
else if (elementName == "waitOut") {
t->waitOut = xmlReader.text().toInt();
}
else if (elementName == "stopAtEnd") {
t->stopAtEnd = xmlReader.text().toString().toLower() == "true";
}
else if (elementName == "name") {
t->name = xmlReader.text().toString().toStdString();
}
else if (elementName == "description") {
t->description = xmlReader.text().toString().toStdString();
}
else if (elementName == "userNumber") {
t->userNumber = xmlReader.text().toInt();
}
else if (elementName == "entryPoint") {
t->entryPoint = xmlReader.text().toInt();
}
else if (elementName == "exitPoint") {
t->exitPoint = xmlReader.text().toInt();
}
else if (elementName == "audioLayer") {
t->audioLayer = xmlReader.text().toInt();
}
else if (elementName == "active") {
t->active = xmlReader.text().toString().toLower() == "true";
}
}
}
xmlReader.readNext();
}
addCueTrack(t);
}
}
}
if (xmlReader.hasError())
{
std::cerr << "Error al leer el archivo XML: " << xmlReader.errorString().toStdString() << std::endl;
}
file.close();
redrawCueTrackList();
}
#include <fstream>
#include <string>
void CueTrackListWidget::saveCueTrackList(std::string filename)
{
std::ofstream file(filename);
if (!file.is_open())
{
return;
}
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
file << "<CueTrackList>\n";
for (int i = 0; i < m_size; i++)
{
file << cueTrackToXml(*cueTracks.at(i)) << std::endl;
}
file << "</CueTrackList>\n";
file.close();
}
std::string CueTrackListWidget::cueTrackToXml(const CueTrack& cueTrack)
{
std::string xml = " <CueTrack>\n";
xml += " <filePath>" + cueTrack.filePath + "</filePath>\n";
xml += " <volume>" + std::to_string(cueTrack.volume) + "</volume>\n";
xml += " <pan>" + std::to_string(cueTrack.pan) + "</pan>\n";
xml += " <pitch>" + std::to_string(cueTrack.pitch) + "</pitch>\n";
xml += " <bus1>" + std::to_string(cueTrack.bus1) + "</bus1>\n";
xml += " <bus2>" + std::to_string(cueTrack.bus2) + "</bus2>\n";
xml += " <status>";
xml += statusToString(cueTrack.status);
xml += "</status>\n";
xml += " <fadeOut>" + std::to_string(cueTrack.fadeOut) + "</fadeOut>\n";
xml += " <fadeIn>" + std::to_string(cueTrack.fadeIn) + "</fadeIn>\n";
xml += " <waitIn>" + std::to_string(cueTrack.waitIn) + "</waitIn>\n";
xml += " <waitOut>" + std::to_string(cueTrack.waitOut) + "</waitOut>\n";
xml += " <stopAtEnd>";
xml += (cueTrack.stopAtEnd ? "true" : "false");
xml += "</stopAtEnd>\n";
xml += " <name>" + cueTrack.name + "</name>\n";
xml += " <description>" + cueTrack.description + "</description>\n";
xml += " <userNumber>" + std::to_string(cueTrack.userNumber) + "</userNumber>\n";
xml += " <entryPoint>" + std::to_string(cueTrack.entryPoint) + "</entryPoint>\n";
xml += " <exitPoint>" + std::to_string(cueTrack.exitPoint) + "</exitPoint>\n";
xml += " <audioLayer>" + std::to_string(cueTrack.audioLayer) + "</audioLayer>\n";
xml += " <active>";
xml += (cueTrack.active ? "true" : "false");
xml += "</active>\n";
xml += " </CueTrack>\n";
return xml;
}
void CueTrackListWidget::clearCueTrackList()
{
for (int i = 0; i < m_size; i++)
{
delete cueTracks.at(i);
}
cueTracks.clear();
m_size = 0;
selectedIndex = 0;
}
#include <QFile>
#include <QXmlStreamWriter>
void saveCueTrackToXml(const CueTrack& cueTrack, const QString& filename) {
QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) {
qInfo() << "Can not open file " << filename << "\n";
return;
}
QXmlStreamWriter xmlWriter(&file);
xmlWriter.setAutoFormatting(true);
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("CueTrack");
xmlWriter.writeTextElement("filePath", QString::fromStdString(cueTrack.filePath));
xmlWriter.writeTextElement("volume", QString::number(cueTrack.volume));
xmlWriter.writeTextElement("pan", QString::number(cueTrack.pan));
xmlWriter.writeTextElement("pitch", QString::number(cueTrack.pitch));
xmlWriter.writeTextElement("bus1", QString::number(cueTrack.bus1));
xmlWriter.writeTextElement("bus2", QString::number(cueTrack.bus2));
xmlWriter.writeTextElement("status", statusToString(cueTrack.status));
xmlWriter.writeTextElement("fadeOut", QString::number(cueTrack.fadeOut));
xmlWriter.writeTextElement("fadeIn", QString::number(cueTrack.fadeIn));
xmlWriter.writeTextElement("waitIn", QString::number(cueTrack.waitIn));
xmlWriter.writeTextElement("waitOut", QString::number(cueTrack.waitOut));
xmlWriter.writeTextElement("stopAtEnd", cueTrack.stopAtEnd ? "true" : "false");
xmlWriter.writeTextElement("name", QString::fromStdString(cueTrack.name));
xmlWriter.writeTextElement("description", QString::fromStdString(cueTrack.description));
xmlWriter.writeTextElement("userNumber", QString::number(cueTrack.userNumber));
xmlWriter.writeTextElement("entryPoint", QString::number(cueTrack.entryPoint));
xmlWriter.writeTextElement("exitPoint", QString::number(cueTrack.exitPoint));
xmlWriter.writeTextElement("audioLayer", QString::number(cueTrack.audioLayer));
xmlWriter.writeTextElement("active", cueTrack.active ? "true" : "false");
xmlWriter.writeEndElement();
xmlWriter.writeEndDocument();
file.close();
}
#include <QFile>
#include <QXmlStreamReader>
#include <QString>
#include <string>
CueTrack loadCueTrackFromXml(const QString& filename) {
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
throw std::runtime_error("No se pudo abrir el archivo");
}
QXmlStreamReader xmlReader(&file);
CueTrack cueTrack;
while (!xmlReader.atEnd() && !xmlReader.hasError()) {
QXmlStreamReader::TokenType token = xmlReader.readNext();
if (token == QXmlStreamReader::StartElement) {
const QString elementName = xmlReader.name().toString();
if (elementName == "filePath") {
cueTrack.filePath = xmlReader.readElementText().toStdString();
} else if (elementName == "volume") {
cueTrack.volume = xmlReader.readElementText().toInt();
} else if (elementName == "pan") {
cueTrack.pan = xmlReader.readElementText().toInt();
} else if (elementName == "pitch") {
cueTrack.pitch = xmlReader.readElementText().toInt();
} else if (elementName == "bus1") {
cueTrack.bus1 = xmlReader.readElementText().toInt();
} else if (elementName == "bus2") {
cueTrack.bus2 = xmlReader.readElementText().toInt();
} else if (elementName == "status") {
QString tmp = xmlReader.readElementText();
cueTrack.status = stringToStatus(&tmp);
} else if (elementName == "fadeOut") {
cueTrack.fadeOut = xmlReader.readElementText().toInt();
} else if (elementName == "fadeIn") {
cueTrack.fadeIn = xmlReader.readElementText().toInt();
} else if (elementName == "waitIn") {
cueTrack.waitIn = xmlReader.readElementText().toInt();
} else if (elementName == "waitOut") {
cueTrack.waitOut = xmlReader.readElementText().toInt();
} else if (elementName == "stopAtEnd") {
cueTrack.stopAtEnd = xmlReader.readElementText() == "true";
} else if (elementName == "name") {
cueTrack.name = xmlReader.readElementText().toStdString();
} else if (elementName == "description") {
cueTrack.description = xmlReader.readElementText().toStdString();
} else if (elementName == "userNumber") {
cueTrack.userNumber = xmlReader.readElementText().toInt();
} else if (elementName == "entryPoint") {
cueTrack.entryPoint = xmlReader.readElementText().toInt();
} else if (elementName == "exitPoint") {
cueTrack.exitPoint = xmlReader.readElementText().toInt();
} else if (elementName == "audioLayer") {
cueTrack.audioLayer = xmlReader.readElementText().toInt();
} else if (elementName == "active") {
cueTrack.active = xmlReader.readElementText() == "true";
}
}
}
if (xmlReader.hasError()) {
throw std::runtime_error("Error al parsear el archivo XML");
}
file.close();
return cueTrack;
}
void CueTrackListWidget::clearTableWidget()
{
for (int i = 0; i < m_size; i++)
{
tableWidget->removeRow(i);
}
tableWidget->clear();
tableWidget->setRowCount(0);
}

View file

@ -17,6 +17,8 @@ class CueTrackListWidget : public QWidget {
public: public:
explicit CueTrackListWidget(QWidget *parent = nullptr); explicit CueTrackListWidget(QWidget *parent = nullptr);
public slots:
CueTrack* getSelectedTrack(); CueTrack* getSelectedTrack();
void createNewCueTrack(); void createNewCueTrack();
void editCueTrack(); void editCueTrack();
@ -24,6 +26,11 @@ public:
int getSelectedIndex() { return selectedIndex; }; int getSelectedIndex() { return selectedIndex; };
CueTrack* getTrackAtIndex(int index); CueTrack* getTrackAtIndex(int index);
QString *getFileName(std::string s); QString *getFileName(std::string s);
void loadCueTrackList(std::string filename);
void saveCueTrackList(std::string filename);
void clearCueTrackList();
void setLastUserCueNumber(size_t n) { lastUserCueNumber = n; }
size_t getLastUserCueNumber() { return lastUserCueNumber; }
private: private:
std::vector<CueTrack *> cueTracks; std::vector<CueTrack *> cueTracks;
@ -44,6 +51,11 @@ private slots:
void updateSelectedCueTrack(bool highlightRow); void updateSelectedCueTrack(bool highlightRow);
void cueTrackLoadDefaults(CueTrack * t); void cueTrackLoadDefaults(CueTrack * t);
void copyCueTrack(CueTrack *src, CueTrack *dst); void copyCueTrack(CueTrack *src, CueTrack *dst);
void sortCueTrackList();
void redrawCueTrackList();
void clearTableWidget();
std::string cueTrackToXml(const CueTrack& cueTrack);
signals: signals:
void changeSelectedIndex(int index); void changeSelectedIndex(int index);

View file

@ -57,7 +57,7 @@ constexpr const char* statusToString(Status e) noexcept
case Status::Iddle: return "Iddle"; case Status::Iddle: return "Iddle";
case Status::PlayingFolder: return "Play Folder"; case Status::PlayingFolder: return "Play Folder";
case Status::PlayingFolderLoop: return "Play Folder Loop"; case Status::PlayingFolderLoop: return "Play Folder Loop";
case Status::PlayingFolderRandom: return "Playing Folder Random"; case Status::PlayingFolderRandom: return "Play Folder Random";
default: return "--++--"; default: return "--++--";
} }
} }
@ -65,15 +65,15 @@ constexpr const char* statusToString(Status e) noexcept
#include <QString> #include <QString>
static Status stringToStatus(QString *statusStr) { static Status stringToStatus(QString *statusStr) {
if (statusStr->compare("Stopped")) return Stopped; if (!statusStr->compare("Stopped")) return Stopped;
else if (statusStr->compare("Paused")) return Paused; else if (!statusStr->compare("Paused") ) return Paused;
else if (statusStr->compare("PlayingOnce")) return PlayingOnce; else if (!statusStr->compare("Play 1")) return PlayingOnce;
else if (statusStr->compare("PlayingLoop")) return PlayingLoop; else if (!statusStr->compare("Play Loop")) return PlayingLoop;
else if (statusStr->compare("Iddle")) return Iddle; else if (!statusStr->compare("Iddle")) return Iddle;
else if (statusStr->compare("PlayingFolder")) return PlayingFolder; else if (!statusStr->compare("Play Folder")) return PlayingFolder;
else if (statusStr->compare("PlayingFolderLoop")) return PlayingFolderLoop; else if (!statusStr->compare("Play Folder Loop")) return PlayingFolderLoop;
else if (statusStr->compare("PlayingFolderRandom")) return PlayingFolderRandom; else if (!statusStr->compare("Play Folder Random")) return PlayingFolderRandom;
else return Stopped; // Valor por defecto o manejar como error else return Iddle;
} }
struct layerData { struct layerData {

View file

@ -13,62 +13,61 @@ EditCueTrackWidget::EditCueTrackWidget(CueTrack *cueTrack, QWidget *parent)
} }
void EditCueTrackWidget::setupUi() { void EditCueTrackWidget::setupUi() {
QFormLayout *layout = new QFormLayout(this);
userNumberSpin = new QSpinBox(this); userNumberSpin = new QSpinBox(this);
userNumberSpin->setRange(0, 9999);
layout->addRow("User Number", userNumberSpin);
nameEdit = new QLineEdit(this); nameEdit = new QLineEdit(this);
layout->addRow("Name", nameEdit);
audioLayerSpin = new QSpinBox(this); audioLayerSpin = new QSpinBox(this);
audioLayerSpin->setRange(0, MAX_LAYERS - 1); audioLayerSpin->setRange(0, MAX_LAYERS - 1);
layout->addRow("Audio Layer", audioLayerSpin);
filePathEdit = new QLineEdit(this); filePathEdit = new QLineEdit(this);
statusCombo = new QComboBox(this); layout->addRow("File Path", filePathEdit);
volumeSpin = new QDoubleSpinBox(this);
volumeSpin->setRange(0, 100.01f);
panSpin = new QDoubleSpinBox(this);
pitchSpin = new QDoubleSpinBox(this);
bus1Spin = new QDoubleSpinBox(this);
bus1Spin->setRange(0, 100.01f);
bus2Spin = new QDoubleSpinBox(this);
bus2Spin->setRange(0, 100.01f);
fadeInSpin = new QSpinBox(this);
fadeOutSpin = new QSpinBox(this);
waitInSpin = new QSpinBox(this);
waitOutSpin = new QSpinBox(this);
stopAtEndCheck = new QCheckBox(this);
descriptionEdit = new QLineEdit(this);
entryPointSpin = new QSpinBox(this);
exitPointSpin = new QSpinBox(this);
statusCombo->addItem("Stopped");
statusCombo->addItem("Paused");
statusCombo->addItem("PlayingOnce");
statusCombo->addItem("PlayingLoop");
statusCombo->addItem("Iddle");
statusCombo->addItem("PlayingFolder");
statusCombo->addItem("PlayingFolderLoop");
statusCombo->addItem("PlayingFolderRandom");
statusCombo->addItem("PlayingFolderRandomLoop");
browseButton = new QPushButton("Browse...", this); browseButton = new QPushButton("Browse...", this);
layout->addRow(browseButton);
statusCombo = new QComboBox(this);
layout->addRow("Status", statusCombo);
volumeSpin = new QDoubleSpinBox(this);
volumeSpin->setRange(0, 100.00f);
layout->addRow("Volume", volumeSpin);
panSpin = new QDoubleSpinBox(this);
layout->addRow("Pan", panSpin);
pitchSpin = new QDoubleSpinBox(this);
layout->addRow("Pitch", pitchSpin);
bus1Spin = new QDoubleSpinBox(this);
bus1Spin->setRange(0, 100.00f);
layout->addRow("Bus 1", bus1Spin);
bus2Spin = new QDoubleSpinBox(this);
bus2Spin->setRange(0, 100.00f);
layout->addRow("Bus 2", bus2Spin);
fadeInSpin = new QSpinBox(this);
layout->addRow("Fade In", fadeInSpin);
fadeOutSpin = new QSpinBox(this);
layout->addRow("Fade Out", fadeOutSpin);
waitInSpin = new QSpinBox(this);
layout->addRow("Wait In", waitInSpin);
waitOutSpin = new QSpinBox(this);
layout->addRow("Wait Out", waitOutSpin);
stopAtEndCheck = new QCheckBox(this);
layout->addRow("Stop At End", stopAtEndCheck);
descriptionEdit = new QLineEdit(this);
layout->addRow("Description", descriptionEdit);
entryPointSpin = new QSpinBox(this);
layout->addRow("Entry Point", entryPointSpin);
exitPointSpin = new QSpinBox(this);
layout->addRow("Exit Point", exitPointSpin);
statusCombo->addItem(statusToString(Status::Stopped));
statusCombo->addItem(statusToString(Status::Paused));
statusCombo->addItem(statusToString(Status::PlayingOnce));
statusCombo->addItem(statusToString(Status::PlayingLoop));
statusCombo->addItem(statusToString(Status::Iddle));
statusCombo->addItem(statusToString(Status::PlayingFolder));
statusCombo->addItem(statusToString(Status::PlayingFolderLoop));
statusCombo->addItem(statusToString(Status::PlayingFolderRandom));
saveButton = new QPushButton("Save", this); saveButton = new QPushButton("Save", this);
cancelButton = new QPushButton("Cancel", this); cancelButton = new QPushButton("Cancel", this);
QFormLayout *layout = new QFormLayout(this);
layout->addRow("User Number", userNumberSpin);
layout->addRow("Name", nameEdit);
layout->addRow("Audio Layer", audioLayerSpin);
layout->addRow("File Path", filePathEdit);
layout->addRow(browseButton);
layout->addRow("Status", statusCombo);
layout->addRow("Fade In", fadeInSpin);
layout->addRow("Fade Out", fadeOutSpin);
layout->addRow("Wait In", waitInSpin);
layout->addRow("Wait Out", waitOutSpin);
layout->addRow("Stop At End", stopAtEndCheck);
layout->addRow("Volume", volumeSpin);
layout->addRow("Bus 1", bus1Spin);
layout->addRow("Bus 2", bus2Spin);
layout->addRow("Pan", panSpin);
layout->addRow("Pitch", pitchSpin);
layout->addRow("Entry Point", entryPointSpin);
layout->addRow("Exit Point", exitPointSpin);
layout->addRow("Description", descriptionEdit);
layout->addRow(saveButton); layout->addRow(saveButton);
layout->addRow(cancelButton); layout->addRow(cancelButton);
} }
@ -90,8 +89,9 @@ void EditCueTrackWidget::loadCueTrack(CueTrack cueTrack) {
userNumberSpin->setValue(cueTrack.userNumber); userNumberSpin->setValue(cueTrack.userNumber);
entryPointSpin->setValue(cueTrack.entryPoint); entryPointSpin->setValue(cueTrack.entryPoint);
exitPointSpin->setValue(cueTrack.exitPoint); exitPointSpin->setValue(cueTrack.exitPoint);
statusCombo->setCurrentIndex(statusCombo->findText(statusToString(cueTrack.status)));
audioLayerSpin->setValue(cueTrack.audioLayer); audioLayerSpin->setValue(cueTrack.audioLayer);
QString tmp = statusToString(cueTrack.status);
statusCombo->setCurrentIndex(statusCombo->findText(tmp));
} }
CueTrack EditCueTrackWidget::saveCueTrack() { CueTrack EditCueTrackWidget::saveCueTrack() {
@ -136,4 +136,3 @@ void EditCueTrackWidget::onBrowseButtonClicked() {
Settings::getInstance()->setPathMedia(dir.absoluteFilePath(filePath)); Settings::getInstance()->setPathMedia(dir.absoluteFilePath(filePath));
} }
} }

View file

@ -6,7 +6,11 @@ ShowPlayer::ShowPlayer(QWidget *parent) :
, ui(new Ui::ShowPlayer) , ui(new Ui::ShowPlayer)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->addCueButton, SIGNAL(clicked()), this, SLOT(onAddTrack())); connect(ui->NewCue, SIGNAL(clicked()), this, SLOT(onAddTrack()));
connect(ui->EditCue, SIGNAL(clicked()), ui->cueListWidget, SLOT(editCueTrack()));
connect(ui->RemoveCue, SIGNAL(clicked()), ui->cueListWidget, SLOT(deleteCueTrack()));
connect(ui->SaveCueList, SIGNAL(clicked()), this, SLOT(saveCueTrackList()));
connect(ui->LoadCueList, SIGNAL(clicked()), this, SLOT(loadCueTrackList()));
connect(ui->goButton, SIGNAL(clicked()), this, SLOT(go())); connect(ui->goButton, SIGNAL(clicked()), this, SLOT(go()));
filesLoaded = 0; filesLoaded = 0;
currentStatus = Status::Iddle; currentStatus = Status::Iddle;
@ -54,7 +58,23 @@ void ShowPlayer::updateTrackStateInEngine(CueTrack *track) {
void ShowPlayer::changeSelectedIndex(int i) void ShowPlayer::changeSelectedIndex(int i)
{ {
CueTrack *t = ui->cueListWidget->getTrackAtIndex(i); CueTrack *t = ui->cueListWidget->getTrackAtIndex(i);
ui->nextCueNumber->display(i); ui->nextCueNumber->display(t->userNumber);
ui->nextCueLabel->setText(t->name.data()); ui->nextCueLabel->setText(t->name.data());
lastIndex = i; lastIndex = t->userNumber;
}
void ShowPlayer::loadCueTrackList()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("XML Files (*.xml)"));
if (fileName.isEmpty())
return;
ui->cueListWidget->loadCueTrackList(fileName.toStdString());
}
void ShowPlayer::saveCueTrackList()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", tr("XML Files (*.xml)"));
if (fileName.isEmpty())
return;
ui->cueListWidget->saveCueTrackList(fileName.toStdString());
} }

View file

@ -37,6 +37,8 @@ private slots:
void onAddTrack(); void onAddTrack();
void go(); void go();
void changeSelectedIndex(int i); void changeSelectedIndex(int i);
void loadCueTrackList();
void saveCueTrackList();
signals: signals:
void uiPlaybackChanged(int layer, Status s); void uiPlaybackChanged(int layer, Status s);

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>538</width> <width>743</width>
<height>554</height> <height>671</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -23,18 +23,42 @@
<item> <item>
<widget class="QSplitter" name="splitter"> <widget class="QSplitter" name="splitter">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="handleWidth">
<number>8</number>
</property>
<widget class="QSplitter" name="masterSplitter"> <widget class="QSplitter" name="masterSplitter">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="handleWidth">
<number>8</number>
</property>
<widget class="QPushButton" name="goButton"> <widget class="QPushButton" name="goButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -42,6 +66,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text"> <property name="text">
<string>GO</string> <string>GO</string>
</property> </property>
@ -51,6 +78,12 @@
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="statusLayout"> <layout class="QGridLayout" name="statusLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLCDNumber" name="activeCueNumber"/> <widget class="QLCDNumber" name="activeCueNumber"/>
</item> </item>
@ -97,28 +130,173 @@
</widget> </widget>
<widget class="QWidget" name="horizontalLayoutWidget"> <widget class="QWidget" name="horizontalLayoutWidget">
<layout class="QHBoxLayout" name="ButtonToolBarLayout"> <layout class="QHBoxLayout" name="ButtonToolBarLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetMinimumSize</enum>
</property> </property>
<property name="leftMargin">
<number>100</number>
</property>
<property name="rightMargin">
<number>100</number>
</property>
<item> <item>
<widget class="QToolButton" name="rmCueButton"> <widget class="QToolButton" name="LoadCueList">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset>
<normaloff>../resources/load_button.png</normaloff>../resources/load_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="addCueButton"> <widget class="QToolButton" name="SaveCueList">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset>
<normaloff>../resources/save_button.png</normaloff>../resources/save_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="editCueButton"> <widget class="QToolButton" name="CopyCue">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset>
<normaloff>../resources/copy_button.png</normaloff>../resources/copy_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="CutCue">
<property name="toolTip">
<string>Load Cue List</string>
</property>
<property name="accessibleName">
<string>Load Cue List</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/cut_button.png</normaloff>../resources/cut_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="PasteCue">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/paste_button.png</normaloff>../resources/paste_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="NewCue">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/new_button.png</normaloff>../resources/new_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="EditCue">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/edit_button.png</normaloff>../resources/edit_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="RemoveCue">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/remove_button.png</normaloff>../resources/remove_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -155,6 +333,12 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>cueListWidget</tabstop>
<tabstop>NewCue</tabstop>
<tabstop>EditCue</tabstop>
<tabstop>RemoveCue</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>