diff --git a/Batch Processor/CUEy-Batch.pro b/Batch Processor/CUEy-Batch.pro deleted file mode 100644 index e1462f6..0000000 --- a/Batch Processor/CUEy-Batch.pro +++ /dev/null @@ -1,47 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2017-02-08T05:37:05 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = CUEy-Batch -TEMPLATE = app - -win32:RC_ICONS += icon.ico -` -VERSION_MAJOR = 2 -VERSION_MINOR = 0 -VERSION_BUILD = 0 - - - -DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\ - "VERSION_MINOR=$$VERSION_MINOR"\ - "VERSION_BUILD=$$VERSION_BUILD" - -VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD} - - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += main.cpp\ - mainwindow.cpp - -HEADERS += mainwindow.h - -FORMS += mainwindow.ui \ - dialog.ui diff --git a/Batch Processor/CUEy-Batch.pro.user b/Batch Processor/CUEy-Batch.pro.user deleted file mode 100644 index 2c67482..0000000 --- a/Batch Processor/CUEy-Batch.pro.user +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - EnvironmentId - {d0c633ba-424c-403a-a7cb-bd5e9419e45d} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.8.0 MSVC2015_64bit - Desktop Qt 5.8.0 MSVC2015_64bit - qt.58.win64_msvc2015_64_kit - 1 - 0 - 0 - - C:/Users/eddie/PycharmProjects/untitled/CUEy/CUEy++/CUEyPLUSPLUS/Batch/build-CUEy-Batch-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - C:/Users/eddie/PycharmProjects/untitled/CUEy/CUEy++/CUEyPLUSPLUS/Batch/build-CUEy-Batch-Desktop_Qt_5_8_0_MSVC2015_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - C:/Users/eddie/PycharmProjects/untitled/CUEy/CUEy++/CUEyPLUSPLUS/Batch/build-CUEy-Batch-Desktop_Qt_5_8_0_MSVC2015_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - CUEy-Batch - - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/eddie/PycharmProjects/untitled/CUEy/CUEy++/CUEyPLUSPLUS/Batch/CUEy-Batch/CUEy-Batch.pro - true - - CUEy-Batch.pro - false - - C:/Users/eddie/PycharmProjects/untitled/CUEy/CUEy++/CUEyPLUSPLUS/Batch/build-CUEy-Batch-Desktop_Qt_5_8_0_MSVC2015_64bit-Release - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - diff --git a/Batch Processor/icon.ico b/Batch Processor/icon.ico deleted file mode 100644 index 86d6846..0000000 Binary files a/Batch Processor/icon.ico and /dev/null differ diff --git a/Batch Processor/mainwindow.h b/Batch Processor/mainwindow.h deleted file mode 100644 index 7d81bf2..0000000 --- a/Batch Processor/mainwindow.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Ui { -class Dialog; -class MainWindow; -} - -class Dialog : public QDialog -{ - Q_OBJECT -public: - explicit Dialog(QWidget *parent = 0); - ~Dialog(); -private: - Ui::Dialog *ui; -public slots: - void setTxt(QString); -}; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - QString MainWindow::cue, MainWindow::pa, MainWindow::tra, MainWindow::genre, MainWindow::year, MainWindow::tc, MainWindow::al, MainWindow::bDir; - QStandardItemModel *MainWindow::model; - QStandardItemModel *MainWindow::model2; - QProcess *MainWindow::process; - QStringList MainWindow::cmds, MainWindow::errs, MainWindow::errList, MainWindow::jobs; - QVector> MainWindow::Files, MainWindow::Tracks; - int MainWindow::dual, MainWindow::count, MainWindow::jSize, MainWindow::bCount; - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -private slots: - void processCUE(); - void rA(int); - QString validateNamestr(QString); - void doTrack(int); - void dtTrigger(int , QProcess::ExitStatus); - void opu(); - void batchInit(); - void batchDo(); - void bTrigger(); -}; - -#endif // MAINWINDOW_H diff --git a/Batch Processor/ui_dialog.h b/Batch Processor/ui_dialog.h deleted file mode 100644 index 7adad91..0000000 --- a/Batch Processor/ui_dialog.h +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'dialog.ui' -** -** Created by: Qt User Interface Compiler version 5.8.0 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_DIALOG_H -#define UI_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_Dialog -{ -public: - QVBoxLayout *verticalLayout; - QLabel *errtxt; - QLabel *label; - QDialogButtonBox *buttonBox; - - void setupUi(QDialog *Dialog) - { - if (Dialog->objectName().isEmpty()) - Dialog->setObjectName(QStringLiteral("Dialog")); - Dialog->setEnabled(true); - Dialog->resize(373, 166); - verticalLayout = new QVBoxLayout(Dialog); - verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - errtxt = new QLabel(Dialog); - errtxt->setObjectName(QStringLiteral("errtxt")); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(errtxt->sizePolicy().hasHeightForWidth()); - errtxt->setSizePolicy(sizePolicy); - QFont font; - font.setFamily(QStringLiteral("Segoe UI")); - font.setPointSize(8); - errtxt->setFont(font); - errtxt->setAlignment(Qt::AlignCenter); - errtxt->setWordWrap(true); - - verticalLayout->addWidget(errtxt); - - label = new QLabel(Dialog); - label->setObjectName(QStringLiteral("label")); - QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Minimum); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); - label->setSizePolicy(sizePolicy1); - QFont font1; - font1.setBold(true); - font1.setItalic(false); - font1.setWeight(75); - label->setFont(font1); - - verticalLayout->addWidget(label); - - buttonBox = new QDialogButtonBox(Dialog); - buttonBox->setObjectName(QStringLiteral("buttonBox")); - QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); - sizePolicy2.setHorizontalStretch(0); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(buttonBox->sizePolicy().hasHeightForWidth()); - buttonBox->setSizePolicy(sizePolicy2); - buttonBox->setStandardButtons(QDialogButtonBox::Ok); - buttonBox->setCenterButtons(true); - - verticalLayout->addWidget(buttonBox); - - - retranslateUi(Dialog); - QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); - - QMetaObject::connectSlotsByName(Dialog); - } // setupUi - - void retranslateUi(QDialog *Dialog) - { - Dialog->setWindowTitle(QApplication::translate("Dialog", "Errors Encountered", Q_NULLPTR)); - errtxt->setText(QApplication::translate("Dialog", "The following tracks failed to encode: ", Q_NULLPTR)); - label->setText(QApplication::translate("Dialog", "Check console log for more details.", Q_NULLPTR)); - } // retranslateUi - -}; - -namespace Ui { - class Dialog: public Ui_Dialog {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_DIALOG_H diff --git a/CUEy-1.0-win32.rar b/CUEy-1.0-win32.rar deleted file mode 100644 index 5d91c85..0000000 Binary files a/CUEy-1.0-win32.rar and /dev/null differ diff --git a/CUEy-1.01-win32.rar b/CUEy-1.01-win32.rar deleted file mode 100644 index 9852ab3..0000000 Binary files a/CUEy-1.01-win32.rar and /dev/null differ diff --git a/Linux/Batch Processor/abort.ui b/Linux/Batch Processor/abort.ui new file mode 100644 index 0000000..6a341ff --- /dev/null +++ b/Linux/Batch Processor/abort.ui @@ -0,0 +1,78 @@ + + + Abort + + + + 0 + 0 + 400 + 113 + + + + Abort Confirmation + + + + + + + + Are you sure you want to abort? + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + buttonBox + accepted() + Abort + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Abort + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/Batch Processor/main.cpp b/Linux/Batch Processor/main.cpp old mode 100644 new mode 100755 similarity index 73% rename from Batch Processor/main.cpp rename to Linux/Batch Processor/main.cpp index 7e19453..98c2101 --- a/Batch Processor/main.cpp +++ b/Linux/Batch Processor/main.cpp @@ -1,10 +1,10 @@ #include "mainwindow.h" #include -#include int main(int argc, char *argv[]) { QApplication a(argc, argv); + a.setWindowIcon(QIcon("/opt/CUEy/icon.ico")); MainWindow w; w.show(); diff --git a/Batch Processor/mainwindow.cpp b/Linux/Batch Processor/mainwindow.cpp old mode 100644 new mode 100755 similarity index 86% rename from Batch Processor/mainwindow.cpp rename to Linux/Batch Processor/mainwindow.cpp index a59dcac..3db39c2 --- a/Batch Processor/mainwindow.cpp +++ b/Linux/Batch Processor/mainwindow.cpp @@ -1,16 +1,12 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "ui_dialog.h" +#include "ui_abort.h" -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) +Abort::Abort(QWidget *parent) : + QDialog(parent), + ui(new Ui::Abort) { - ui->setupUi(this); -} - -void Dialog::setTxt(QString txt) { - ui->errtxt->setText(txt); + ui->setupUi(this); } MainWindow::MainWindow(QWidget *parent) : @@ -26,21 +22,34 @@ MainWindow::MainWindow(QWidget *parent) : ui->outView->setModel(model2); connect(process, SIGNAL (readyReadStandardOutput()), this, SLOT (opu())); connect(process, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(dtTrigger(int , QProcess::ExitStatus ))); + connect(ui->abBu, SIGNAL(released()), this, SLOT(halt())); + MainWindow::stop = false; batchInit(); } +void MainWindow::halt() { + Abort abt; + if (abt.exec()) { + MainWindow::stop = true; + process->kill(); + abt.deleteLater(); + QApplication::quit(); + } + else { + abt.deleteLater(); + } +} + void MainWindow::batchInit() { MainWindow::bDir = QFileDialog::getExistingDirectory(this, "Select folder containing FLAC and CUE files...", QDir::homePath()); if (MainWindow::bDir.isEmpty()) { ui->statusbar->showMessage( "ERROR: No Folder Specified"); return; - } - QDirIterator it(MainWindow::bDir, QDirIterator::Subdirectories); + }QDirIterator it(MainWindow::bDir, QDirIterator::Subdirectories); while (it.hasNext()) { if (it.fileName().contains(".cue")) { MainWindow::jobs.append(it.filePath()); - } - it.next(); + }it.next(); }MainWindow::jSize = MainWindow::jobs.size(); QVariant bS(MainWindow::jSize); ui->bSize->setText(bS.toString()); @@ -48,6 +57,8 @@ void MainWindow::batchInit() { batchDo(); } + + void MainWindow::bTrigger () { batchDo(); } @@ -65,8 +76,7 @@ void MainWindow::batchDo() { } }else { ui->cmdout->append("Batch job completed with no fatal errors."); - } - ui->statusbar->showMessage("Job Complete."); + }ui->statusbar->showMessage("Job Complete."); }else { QVariant c(MainWindow::bCount); QString cs = c.toString(); @@ -83,6 +93,9 @@ void MainWindow::batchDo() { } void MainWindow::doTrack(int ex) { + if (MainWindow::stop) { + QApplication::quit(); + } if (MainWindow::cmds.size() != MainWindow::Tracks.size()) { if (MainWindow::count != 0) { if (ex == 1) { @@ -110,7 +123,8 @@ void MainWindow::doTrack(int ex) { process->start(MainWindow::cmds[0]); MainWindow::cmds.removeFirst(); int progress = 100 / MainWindow::Tracks.size(); - int cpro = progress * MainWindow::count; + int cc = MainWindow::count; + int cpro = progress * cc; ui->cProBar->setValue(cpro); MainWindow::count++; } @@ -175,15 +189,13 @@ void MainWindow::processCUE() { tmap["title"] = MainWindow::tra; if (!pa.isEmpty()) { tmap["artist"] = MainWindow::pa; - } - if (!year.isEmpty()) { + }if (!year.isEmpty()) { tmap["year"] = MainWindow::year; }if (!genre.isEmpty()) { tmap["genre"] = MainWindow::genre; }MainWindow::Tracks.append(tmap); } - } - first = true; + }first = true; QVectorIterator> fIt(MainWindow::Files); while (fIt.hasNext()) { if (fIt.peekNext().value("file").contains(".flac")) { @@ -204,27 +216,22 @@ void MainWindow::processCUE() { rA(1); return; } - } - QVectorIterator> tIt(MainWindow::Tracks); + }QVectorIterator> tIt(MainWindow::Tracks); while (tIt.hasNext()) { QStandardItem *q = new QStandardItem("Track " + tIt.peekNext().value("num") + " - " + tIt.peekNext().value("title")); tIt.next(); MainWindow::model2->appendRow(q); - } - if (MainWindow::Files.size() == 1) { + }if (MainWindow::Files.size() == 1) { MainWindow::dual = 1; }else { MainWindow::dual = 2; - } - if (MainWindow::cue.isEmpty() || MainWindow::Tracks.isEmpty()|| MainWindow::Files.isEmpty()) { + }if (MainWindow::cue.isEmpty() || MainWindow::Tracks.isEmpty()|| MainWindow::Files.isEmpty()) { ui->statusbar->showMessage("ERROR: Nothing to split."); return; - } - if (MainWindow::dual == 0) { + }if (MainWindow::dual == 0) { ui->statusbar->showMessage("ERROR: Invalid Format."); return; - }first = true; - bool last = false; + }bool last = false; int bcount = 0; QFileInfo fld(MainWindow::cue); QString wdir = fld.absolutePath(); @@ -273,7 +280,6 @@ void MainWindow::processCUE() { end = tIt.peekNext().value("tind").split(":"); } }amestr = side + tn + " - " + it.value("title") + ".flac"; - }else { if (first){ end = tIt.peekNext().value("tind").split(":"); @@ -288,7 +294,7 @@ void MainWindow::processCUE() { tn = it.value("num"); }amestr = tn + " - " + it.value("title") + ".flac"; }namestr = validateNamestr(amestr); - QString c = "flac.exe --best "; + QString c = "flac --best "; if (it.contains("artist")) { c = c + "-T \"ARTIST= " + it.value("artist") + "\" "; }if (it.contains("year")) { @@ -345,8 +351,16 @@ void MainWindow::dtTrigger(int d , QProcess::ExitStatus) { } void MainWindow::opu() { - QString otpt(process->readAllStandardOutput()); - ui->cmdout->append(otpt); + QString otpt(process->readAllStandardOutput()); + if (otpt.contains(", ratio=")) { + QTextCursor storeCursorPos = ui->cmdout->textCursor(); + ui->cmdout->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); + ui->cmdout->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); + ui->cmdout->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); + ui->cmdout->textCursor().removeSelectedText(); + ui->cmdout->textCursor().deletePreviousChar(); + ui->cmdout->setTextCursor(storeCursorPos); + }ui->cmdout->append(otpt); } MainWindow::~MainWindow() @@ -354,7 +368,7 @@ MainWindow::~MainWindow() delete ui; } -Dialog::~Dialog() +Abort::~Abort() { - delete ui; + delete ui; } diff --git a/Linux/Batch Processor/mainwindow.h b/Linux/Batch Processor/mainwindow.h new file mode 100755 index 0000000..c6b9846 --- /dev/null +++ b/Linux/Batch Processor/mainwindow.h @@ -0,0 +1,59 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class MainWindow; +class Abort; +} + +class Abort : public QDialog +{ + Q_OBJECT +public: + explicit Abort(QWidget *parent = 0); + ~Abort(); +private: + Ui::Abort *ui; +}; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + QString cue, pa, tra, genre, year, tc, al, bDir; + QStandardItemModel *model; + QStandardItemModel *model2; + QProcess *process; + QStringList cmds, errs, errList, jobs; + QVector> Files, Tracks; + int dual, count, jSize, bCount; + bool stop; + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +private slots: + void processCUE(); + void rA(int); + QString validateNamestr(QString); + void doTrack(int); + void dtTrigger(int , QProcess::ExitStatus); + void opu(); + void batchInit(); + void batchDo(); + void bTrigger(); + void halt(); +}; + +#endif // MAINWINDOW_H diff --git a/Batch Processor/mainwindow.ui b/Linux/Batch Processor/mainwindow.ui similarity index 95% rename from Batch Processor/mainwindow.ui rename to Linux/Batch Processor/mainwindow.ui index ee7812b..3474904 100644 --- a/Batch Processor/mainwindow.ui +++ b/Linux/Batch Processor/mainwindow.ui @@ -1,197 +1,197 @@ - - - MainWindow - - - - 0 - 0 - 796 - 769 - - - - CUEy Batch Processor - - - - - - - - - Processing File - - - - - - - - - - - - - - - of - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Current CUE File: - - - - - - - - 0 - 0 - - - - None - - - - - - - - - - - Current Job Progress - - - - - - - 0 - - - - - - - - - - - Total Progress - - - - - - - 0 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Input Files - - - - - - - Output Files - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Console Log: - - - - - - - - - - - - Abort - - - - - - - - - - - + + + MainWindow + + + + 0 + 0 + 796 + 769 + + + + CUEy Batch Processor + + + + + + + + + Processing File + + + + + + + - + + + + + + + of + + + + + + + - + + + + + + + + + + + + 0 + 0 + + + + Current CUE File: + + + + + + + + 0 + 0 + + + + None + + + + + + + + + + + Current Job Progress + + + + + + + 0 + + + + + + + + + + + Total Progress + + + + + + + 0 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Input Files + + + + + + + Output Files + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Console Log: + + + + + + + + + + + + Abort + + + + + + + + + + + diff --git a/Linux/Main Application/abort.ui b/Linux/Main Application/abort.ui new file mode 100644 index 0000000..6a341ff --- /dev/null +++ b/Linux/Main Application/abort.ui @@ -0,0 +1,78 @@ + + + Abort + + + + 0 + 0 + 400 + 113 + + + + Abort Confirmation + + + + + + + + Are you sure you want to abort? + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + buttonBox + accepted() + Abort + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Abort + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/Main Application/errdia.ui b/Linux/Main Application/dialog.ui similarity index 100% rename from Main Application/errdia.ui rename to Linux/Main Application/dialog.ui diff --git a/Linux/Main Application/main.cpp b/Linux/Main Application/main.cpp new file mode 100755 index 0000000..c38f1be --- /dev/null +++ b/Linux/Main Application/main.cpp @@ -0,0 +1,12 @@ +#include "mainwindow.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setWindowIcon(QIcon("/opt/CUEy/icon.ico")); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/Linux/Main Application/mainwindow.cpp b/Linux/Main Application/mainwindow.cpp new file mode 100755 index 0000000..88326ba --- /dev/null +++ b/Linux/Main Application/mainwindow.cpp @@ -0,0 +1,466 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "ui_dialog.h" +#include "ui_abort.h" + +Abort::Abort(QWidget *parent) : + QDialog(parent), + ui(new Ui::Abort) +{ + ui->setupUi(this); +} + + +Dialog::Dialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog) +{ + ui->setupUi(this); +} + +void Dialog::setTxt(QString txt) { + ui->errtxt->setText(txt); +} + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + connect(ui->impBu, SIGNAL(released()), this, SLOT(iBut())); + connect(ui->clearBu, SIGNAL(released()), this, SLOT(cBut())); + connect(ui->goBu, SIGNAL(released()), this, SLOT(split())); + connect(ui->abBu, SIGNAL(released()), this, SLOT(halt())); + ui->abBu->setDisabled(true); + ui->clearBu->setDisabled(true); + ui->goBu->setDisabled(true); + connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(ex())); + connect(ui->actionBatch, SIGNAL(triggered()), this, SLOT(batch())); + connect(ui->actionImport, SIGNAL(triggered()), this, SLOT(iBut())); + MainWindow::stop = false; + model = new QStandardItemModel; + ui->inView->setModel(model); + model2 = new QStandardItemModel; + process = new QProcess(this); + process->setProcessChannelMode(QProcess::MergedChannels); + ui->outView->setModel(model2); + ui->statusbar->showMessage("Ready."); + setAcceptDrops(true); + connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(opu())); + connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(dtTrigger(int, QProcess::ExitStatus))); + if (QApplication::arguments().size() > 1) { + MainWindow::cue = QApplication::arguments().at(1); + fImport(); + } +} + +void MainWindow::halt() { + Abort abt; + if (abt.exec()) { + MainWindow::stop = true; + process->kill(); + abt.deleteLater(); + } + else { + abt.deleteLater(); + } +} + +void MainWindow::batch() { + QProcess::startDetached("CUEyBatch"); + QApplication::quit(); +} + +void MainWindow::ex() { + QApplication::quit(); +} + +void MainWindow::dtTrigger(int d, QProcess::ExitStatus) { + doTrack(d); +} + +void MainWindow::dragEnterEvent(QDragEnterEvent *e) +{ + const QMimeData* mimeData = e->mimeData(); + if (mimeData->hasUrls()) { + e->acceptProposedAction(); + } + else { + e->ignore(); + } +} + +void MainWindow::dropEvent(QDropEvent *e) +{ + const QMimeData* mimeData = e->mimeData(); + if (mimeData->hasUrls()) { + QString ifile; + QList urlList = mimeData->urls(); + if (urlList.size() == 1) { + rA(0); + ifile = urlList.at(0).toLocalFile(); + MainWindow::cue = ifile; + MainWindow::fImport(); + } + else { + ui->statusbar->showMessage("ERROR: Can only import 1 File."); + e->ignore(); + } + } +} +void MainWindow::iBut() { + QString filter = "CUE Files (*.cue)"; + MainWindow::cue = QFileDialog::getOpenFileName(this, "Select a file...", QDir::homePath(), filter); + if (MainWindow::cue.isEmpty()) { + ui->statusbar->showMessage("ERROR: No File Specified."); + return; + } + MainWindow::fImport(); +} + +void MainWindow::cBut() { + rA(0); +} + + +void MainWindow::fImport() { + bool first = true; + int trackCount = 0; + int linecount = 0; + QStringList lines; + QFile file(MainWindow::cue); + file.open(QIODevice::ReadOnly); + QTextStream in(&file); + QString line; + do { + line = in.readLine(); + lines.append(line); + } while (!line.isNull()); + foreach(const QString &str, lines) + { + QMap tmap; + linecount++; + QString sr = str.simplified(); + if (sr.contains("PERFORMER", Qt::CaseSensitive)) { + MainWindow::pa = sr.mid(11); + MainWindow::pa.chop(1); + } + else if (sr.contains("REM DATE", Qt::CaseSensitive)) { + MainWindow::year = sr.right(4); + } + else if (sr.contains("REM GENRE", Qt::CaseSensitive)) { + MainWindow::genre = sr.mid(10); + MainWindow::genre.remove("\""); + } + else if (sr.contains("FILE", Qt::CaseSensitive)) { + QString fs = str.mid(6); + fs.chop(6); + QVariant lcf(linecount); + QString flc = lcf.toString(); + QMap fmap; + fmap["file"] = fs; + fmap["lind"] = flc; + fmap["aArt"] = MainWindow::pa; + MainWindow::Files.append(fmap); + } + else if (sr.contains("TITLE", Qt::CaseSensitive)) { + MainWindow::tra = sr.mid(7); + MainWindow::tra.chop(1); + if (first == true) { + first = false; + } + else { + trackCount++; + }QVariant tcs(trackCount); + MainWindow::tc = tcs.toString(); + } + else if (sr.contains("TRACK 01", Qt::CaseSensitive)) { + MainWindow::al = MainWindow::tra; + } + else if (sr.contains("INDEX 01", Qt::CaseSensitive)) { + QString tind = sr.right(8); + QVariant lcs(linecount); + QString lc = lcs.toString(); + tmap["num"] = MainWindow::tc; + tmap["tind"] = tind; + tmap["lind"] = lc; + tmap["title"] = MainWindow::tra; + if (!pa.isEmpty()) { + tmap["artist"] = MainWindow::pa; + } + if (!year.isEmpty()) { + tmap["year"] = MainWindow::year; + }if (!genre.isEmpty()) { + tmap["genre"] = MainWindow::genre; + }MainWindow::Tracks.append(tmap); + } + } + first = true; + QVectorIterator> fIt(MainWindow::Files); + while (fIt.hasNext()) { + if (fIt.peekNext().value("file").contains(".flac")) { + QFileInfo fld(MainWindow::cue); + QString dir = fld.absolutePath(); + QString file = dir + "/" + fIt.peekNext().value("file"); + if (!QFileInfo(file).exists()) { + ui->statusbar->showMessage("ERROR: Input file(s) does not exist."); + rA(1); + return; + } + else { + QStandardItem *q = new QStandardItem(fIt.next().value("file")); + MainWindow::model->appendRow(q); + } + } + else { + ui->statusbar->showMessage("ERROR: Input file(s) not in FLAC format."); + rA(1); + return; + } + } + QVectorIterator> tIt(MainWindow::Tracks); + while (tIt.hasNext()) { + QStandardItem *q = new QStandardItem("Track " + tIt.peekNext().value("num") + " - " + tIt.peekNext().value("title")); + tIt.next(); + MainWindow::model2->appendRow(q); + } + ui->cueLab->setText("Current CUE File: " + MainWindow::cue); + QVariant fc(MainWindow::Files.size()); + QString fcs = fc.toString(); + ui->statusbar->showMessage("Successfully Imported CUE File (" + tIt.peekPrevious().value("num") + " Tracks Across " + fcs + " Files)."); + ui->goBu->setDisabled(false); + ui->clearBu->setDisabled(false); +} + +void MainWindow::rA(int e) { + ui->progressBar->setValue(0); + MainWindow::model->clear(); + MainWindow::model2->clear(); + MainWindow::Files.clear(); + MainWindow::Tracks.clear(); + MainWindow::cmds.clear(); + MainWindow::count = 0; + MainWindow::cue.clear(); + MainWindow::errs.clear(); + ui->goBu->setDisabled(true); + if (e != 1) { + ui->cmdout->clear(); + ui->statusbar->showMessage("Ready."); + }ui->cueLab->setText("Current CUE File: None."); +} + +void MainWindow::split() { + ui->clearBu->setDisabled(true); + ui->goBu->setDisabled(true); + ui->abBu->setDisabled(false); + ui->impBu->setDisabled(true); + if (MainWindow::Files.size() == 1) { + MainWindow::dual = 1; + } + else { + MainWindow::dual = 2; + } + if (MainWindow::cue.isEmpty() || MainWindow::Tracks.isEmpty() || MainWindow::Files.isEmpty()) { + ui->statusbar->showMessage("ERROR: Nothing to split."); + return; + } + if (MainWindow::dual == 0) { + ui->statusbar->showMessage("ERROR: Invalid Format."); + return; + }bool first = true; + bool last = false; + int bcount = 0; + QFileInfo fld(MainWindow::cue); + QString wdir = fld.absolutePath(); + QVectorIterator> tIt(MainWindow::Tracks); + tIt.next(); + while (tIt.hasNext()) { + QStringList start, end; + QString tn, namestr, amestr, side, ifile, cmd; + QMap it; + ifile = MainWindow::Files[0].value("file"); + if (last == true) { + it = tIt.peekNext(); + } + else { + it = tIt.peekPrevious(); + }if (MainWindow::dual == 2) { + if (MainWindow::Files.size() == 2) { + if (last == true) { + side = "B"; + } + else { + tn = tIt.peekPrevious().value("num"); + }if (tIt.peekPrevious().value("lind").toInt() < MainWindow::Files[1].value("lind").toInt()) { + side = "A"; + } + else { + side = "B"; + }if (side.contains("B")) { + ifile = MainWindow::Files[1].value("file"); + bcount++; + QVariant bc(bcount); + QString bcs = bc.toString(); + tn = bcs; + } + } + else { + ui->statusbar->showMessage("ERROR: CUEs with over 2 input files not currently supported."); + return; + }if (first) { + end = tIt.peekNext().value("tind").split(":"); + } + else if (last == true) { + start = tIt.peekNext().value("tind").split(":"); + } + else { + if (tIt.peekNext().value("tind").contains("00:00:00")) { + start = tIt.peekPrevious().value("tind").split(":"); + } + else if (tIt.peekPrevious().value("tind").contains("00:00:00")) { + end = tIt.peekNext().value("tind").split(":"); + } + else { + start = tIt.peekPrevious().value("tind").split(":"); + end = tIt.peekNext().value("tind").split(":"); + } + }amestr = side + tn + " - " + it.value("title") + ".flac"; + + } + else { + if (first) { + end = tIt.peekNext().value("tind").split(":"); + } + else if (last == true) { + start = tIt.peekNext().value("tind").split(":"); + } + else { + start = tIt.peekPrevious().value("tind").split(":"); + end = tIt.peekNext().value("tind").split(":"); + }if (it.value("num").length() == 1) { + tn = "0" + it.value("num"); + } + else { + tn = it.value("num"); + }amestr = tn + " - " + it.value("title") + ".flac"; + }namestr = validateNamestr(amestr); + QString c = "flac --best "; + if (it.contains("artist")) { + c = c + "-T \"ARTIST= " + it.value("artist") + "\" "; + }if (it.contains("year")) { + c = c + "-T \"DATE= " + it.value("year") + "\" "; + }if (it.contains("genre")) { + c = c + "-T \"GENRE= " + it.value("genre") + "\" "; + }if (start.isEmpty()) { + cmd = c + "-T \"TRACKNUMBER=" + tIt.peekPrevious().value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + tIt.peekPrevious().value("title") + "\" " + "--until=" + end[0] + ":" + end[1] + "." + end[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; + } + else if (end.isEmpty()) { + cmd = c + "-T \"TRACKNUMBER=" + it.value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + it.value("title") + "\" " + "--skip=" + start[0] + ":" + start[1] + "." + start[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; + } + else { + cmd = c + "-T \"TRACKNUMBER=" + tIt.peekPrevious().value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + tIt.peekPrevious().value("title") + "\" " + "--skip=" + start[0] + ":" + start[1] + "." + start[2] + " --until=" + end[0] + ":" + end[1] + "." + end[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; + }MainWindow::cmds.append(cmd); + first = false; + tIt.next(); + if (!tIt.hasNext()) { + if (last) { + QVariant fas(MainWindow::Tracks.size()); + QString fass = fas.toString(); + ui->statusbar->showMessage("Encoding file 1 of " + fass + "."); + break; + } + else { + tIt.previous(); + last = true; + } + } + }doTrack(0); +} + +QString MainWindow::validateNamestr(QString str) { + QString illChars = "\\ | / : ? ! \" < >"; + QStringList illCharArr = illChars.split(" ", QString::SkipEmptyParts); + QList::iterator ici; + for (ici = illCharArr.begin(); ici != illCharArr.end(); ++ici) { + str.remove(*ici); + }return str; +} + +void MainWindow::doTrack(int ex) { + if (MainWindow::stop) { + QVariant c(MainWindow::count - 1); + ui->statusbar->showMessage("Job aborted after " + c.toString() + " tracks."); + MainWindow::stop = false; + ui->abBu->setDisabled(true); + ui->clearBu->setDisabled(false); + ui->impBu->setDisabled(false); + rA(1); + return; + }if (MainWindow::cmds.size() != MainWindow::Tracks.size()) { + if (MainWindow::count != 0) { + if (ex == 1) { + QVariant c(MainWindow::count); + QString cs = c.toString(); + MainWindow::errs.append(cs); + } + } + }if (MainWindow::cmds.size() == 0) { + if (!MainWindow::errs.isEmpty()) { + QString err = MainWindow::errs.join(", "); + Dialog dia; + ui->statusbar->showMessage("Encode completed with errors."); + ui->progressBar->setValue(100); + dia.setTxt("The following tracks failed to encode: " + err + "."); + dia.exec(); + } + else { + ui->statusbar->showMessage("Encode completed, ready."); + ui->progressBar->setValue(100); + }ui->abBu->setDisabled(true); + ui->clearBu->setDisabled(false); + ui->impBu->setDisabled(false); + } + else { + QVariant c(MainWindow::count + 1); + QString cs = c.toString(); + QVariant ts(MainWindow::Tracks.size()); + QString tss = ts.toString(); + ui->statusbar->showMessage("Encoding file " + cs + " of " + tss + "."); + process->start(MainWindow::cmds[0]); + MainWindow::cmds.removeFirst(); + int cc = MainWindow::Tracks.size() - 1; + int progress = 100 / cc; + int cpro = progress * MainWindow::count; + ui->progressBar->setValue(cpro); + MainWindow::count++; + } +} + +void MainWindow::opu() { + QString otpt(process->readAllStandardOutput()); + if (otpt.contains(", ratio=")) { + QTextCursor storeCursorPos = ui->cmdout->textCursor(); + ui->cmdout->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); + ui->cmdout->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); + ui->cmdout->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); + ui->cmdout->textCursor().removeSelectedText(); + ui->cmdout->textCursor().deletePreviousChar(); + ui->cmdout->setTextCursor(storeCursorPos); + } + ui->cmdout->append(otpt); +} + +Dialog::~Dialog() +{ + delete ui; +} + +Abort::~Abort() +{ + delete ui; +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/Linux/Main Application/mainwindow.h b/Linux/Main Application/mainwindow.h new file mode 100755 index 0000000..23c1580 --- /dev/null +++ b/Linux/Main Application/mainwindow.h @@ -0,0 +1,83 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { + class Dialog; + class Abort; + class MainWindow; + class Metadata; +} + +class Abort : public QDialog +{ + Q_OBJECT +public: + explicit Abort(QWidget *parent = 0); + ~Abort(); +private: + Ui::Abort *ui; +}; + +class Dialog : public QDialog +{ + Q_OBJECT +public: + explicit Dialog(QWidget *parent = 0); + ~Dialog(); +private: + Ui::Dialog *ui; + public slots: + void setTxt(QString); +}; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + QString cue, pa, tra, genre, year, tc, al, bDir; + QStandardItemModel *model; + QStandardItemModel *model2; + QProcess *process; + bool stop; + QStringList cmds, errs; + QVector> Files, Tracks; + explicit MainWindow(QWidget *parent = 0); + int dual, count; + ~MainWindow(); + +protected: + void dragEnterEvent(QDragEnterEvent *e); + void dropEvent(QDropEvent *e); + +private: + Ui::MainWindow *ui; + + private slots: + void halt(); + void ex(); + void batch(); + void fImport(); + void rA(int); + void split(); + void iBut(); + void cBut(); + QString validateNamestr(QString); + void doTrack(int); + void dtTrigger(int, QProcess::ExitStatus); + void opu(); +}; + +#endif // MAINWINDOW_H diff --git a/Main Application/mainwindow.ui b/Linux/Main Application/mainwindow.ui old mode 100644 new mode 100755 similarity index 87% rename from Main Application/mainwindow.ui rename to Linux/Main Application/mainwindow.ui index 05a8cf9..7d12eac --- a/Main Application/mainwindow.ui +++ b/Linux/Main Application/mainwindow.ui @@ -1,302 +1,322 @@ - - - MainWindow - - - - 0 - 0 - 1112 - 854 - - - - - 0 - 0 - - - - CUEy - - - - icon.icoicon.ico - - - - Qt::LeftToRight - - - - - - - - Import CUE File - - - - - - - - - Qt::Horizontal - - - - - - - - - Input Files - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Output files - - - - - - - - - Qt::Horizontal - - - - - - - - - Current CUE File: None - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - - - - 0 - - - - - - - Qt::Horizontal - - - - - - - - - - 0 - 0 - - - - - - - - Qt::Vertical - - - - - - - - - - 0 - 0 - - - - Start - - - - - - - - 0 - 0 - - - - Clear and Reset - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - - - - - - - - Console Log - - - - - - - - 0 - 0 - - - - - - - - - - - 0 - 0 - 1112 - 26 - - - - - File - - - - - - - - - - - Import CUE File - - - - - Batch Split - - - - - Exit - - - - - - + + + MainWindow + + + + 0 + 0 + 663 + 711 + + + + + 0 + 0 + + + + CUEy + + + + ../../../opt/CUEy/icon.ico../../../opt/CUEy/icon.ico + + + + Qt::LeftToRight + + + + + + + + Import CUE File + + + + + + + + + Qt::Horizontal + + + + + + + + + Input Files + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Output files + + + + + + + + + Qt::Horizontal + + + + + + + + + Current CUE File: None + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + 0 + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + + + + + Qt::Vertical + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + Start + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Abort + + + + + + + + 0 + 0 + + + + Clear and Reset + + + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + + + + + + + + Console Log + + + + + + + + 0 + 0 + + + + + + + + + + + 0 + 0 + 663 + 22 + + + + + File + + + + + + + + + + + Import CUE File + + + + + Process Batch Split + + + + + Exit + + + + + + diff --git a/Main Application/CUEyPLUSPLUS.pro b/Main Application/CUEyPLUSPLUS.pro deleted file mode 100644 index ee59ff3..0000000 --- a/Main Application/CUEyPLUSPLUS.pro +++ /dev/null @@ -1,52 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2017-01-26T03:07:57 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = CUEy -TEMPLATE = app -win32:RC_ICONS += icon.ico -` -VERSION_MAJOR = 2 -VERSION_MINOR = 0 -VERSION_BUILD = 0 - - - -DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\ - "VERSION_MINOR=$$VERSION_MINOR"\ - "VERSION_BUILD=$$VERSION_BUILD" - -VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD} - -# The following define mak es your compiler emit warnings if you use -# any feature of Qt which as been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += main.cpp\ - mainwindow.cpp - -HEADERS += mainwindow.h - -FORMS += mainwindow.ui \ - dialog.ui \ - errdia.ui \ - jobwindow.ui - -DISTFILES += \ - extras \ - ../../flac.exe - diff --git a/Main Application/icon.ico b/Main Application/icon.ico deleted file mode 100644 index 86d6846..0000000 Binary files a/Main Application/icon.ico and /dev/null differ diff --git a/Main Application/main.cpp b/Main Application/main.cpp deleted file mode 100644 index 167d531..0000000 --- a/Main Application/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "mainwindow.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - a.setWindowIcon(QIcon("icon.ico")); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/Main Application/mainwindow.cpp b/Main Application/mainwindow.cpp deleted file mode 100644 index 170b3a2..0000000 --- a/Main Application/mainwindow.cpp +++ /dev/null @@ -1,382 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "ui_dialog.h" - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); -} - -void Dialog::setTxt(QString txt) { - ui->errtxt->setText(txt); -} - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - MainWindow::dual, MainWindow::count = 0; - connect(ui->impBu, SIGNAL (released()), this, SLOT (iBut())); - connect(ui->clearBu, SIGNAL (released()), this, SLOT (cBut())); - connect(ui->goBu, SIGNAL (released()), this, SLOT (split())); - connect(ui->actionExit, SIGNAL (triggered()), this, SLOT (ex())); - connect(ui->actionBatch, SIGNAL (triggered()), this, SLOT (batch())); - connect(ui->actionImport, SIGNAL (triggered()), this, SLOT (iBut())); - model = new QStandardItemModel; - ui->inView->setModel(model); - model2 = new QStandardItemModel; - proPal = ui->progressBar->palette(); - process = new QProcess(this); - process->setProcessChannelMode(QProcess::MergedChannels); - ui->outView->setModel(model2); - ui->statusbar->showMessage("Ready."); - setAcceptDrops(true); - connect(process, SIGNAL (readyReadStandardOutput()), this, SLOT (opu())); - connect(process, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(dtTrigger(int , QProcess::ExitStatus ))); - if (QApplication::arguments().size() > 1) { - MainWindow::cue = QApplication::arguments().at(1); - fImport(); - } -} - -void MainWindow::batch() { - ui->cmdout->append("batch select"); -} - -void MainWindow::ex() { - QApplication::quit(); -} - -void MainWindow::dtTrigger(int d , QProcess::ExitStatus) { - doTrack(d); -} - -void MainWindow::dragEnterEvent(QDragEnterEvent *e) -{ - const QMimeData* mimeData = e->mimeData(); - if (mimeData->hasUrls()) { - e->acceptProposedAction(); - }else { - e->ignore(); - } -} - -void MainWindow::dropEvent(QDropEvent *e) -{ - const QMimeData* mimeData = e->mimeData(); - if (mimeData->hasUrls()) { - QString ifile; - QList urlList = mimeData->urls(); - if (urlList.size() == 1) { - rA(0); - ifile = urlList.at(0).toLocalFile(); - MainWindow::cue = ifile; - MainWindow::fImport(); - }else { - ui->statusbar->showMessage("ERROR: Can only import 1 File."); - e->ignore(); - } - } -} -void MainWindow::iBut() { - QString filter = "CUE Files (*.cue)"; - MainWindow::cue = QFileDialog::getOpenFileName(this, "Select a file...", QDir::homePath(), filter); - if(MainWindow::cue.isEmpty()) { - ui->statusbar->showMessage("ERROR: No File Specified."); - return; - } - MainWindow::fImport(); -} - -void MainWindow::cBut() { - rA(0); -} - - -void MainWindow::fImport() { - ui->cmdout->append(MainWindow::cue); - QString tind; - bool first = true; - int trackCount = 0; - int linecount = 0; - QStringList lines; - QFile file(MainWindow::cue); - file.open(QIODevice::ReadOnly); - QTextStream in (&file); - QString line; - do { - line = in.readLine(); - lines.append(line); - } - while (!line.isNull()); - foreach(const QString &str, lines) - { - QMap tmap; - linecount++; - QString sr = str.simplified(); - if(sr.contains("PERFORMER", Qt::CaseSensitive)) { - MainWindow::pa = sr.mid(11); - MainWindow::pa.chop(1); - }else if(sr.contains("REM DATE", Qt::CaseSensitive)) { - MainWindow::year = sr.right(4); - }else if(sr.contains("REM GENRE", Qt::CaseSensitive)) { - MainWindow::genre = sr.mid(10); - MainWindow::genre.remove("\""); - }else if(sr.contains("FILE", Qt::CaseSensitive)) { - QString fs = str.mid(6); - fs.chop(6); - QVariant lcf(linecount); - QString flc = lcf.toString(); - QMap fmap; - fmap["file"] = fs; - fmap["lind"] = flc; - fmap["aArt"] = MainWindow::pa; - MainWindow::Files.append(fmap); - }else if(sr.contains("TITLE", Qt::CaseSensitive)) { - MainWindow::tra = sr.mid(7); - MainWindow::tra.chop(1); - if(first == true) { - first = false; - }else { - trackCount++; - }QVariant tcs(trackCount); - MainWindow::tc = tcs.toString(); - }else if(sr.contains("TRACK 01", Qt::CaseSensitive)) { - MainWindow::al = MainWindow::tra; - }else if(sr.contains("INDEX 01", Qt::CaseSensitive)) { - QString tind = sr.right(8); - QVariant lcs(linecount); - QString lc = lcs.toString(); - tmap["num"] = MainWindow::tc; - tmap["tind"] = tind; - tmap["lind"] = lc; - tmap["title"] = MainWindow::tra; - if (!pa.isEmpty()) { - tmap["artist"] = MainWindow::pa; - } - if (!year.isEmpty()) { - tmap["year"] = MainWindow::year; - }if (!genre.isEmpty()) { - tmap["genre"] = MainWindow::genre; - }MainWindow::Tracks.append(tmap); - } - } - first = true; - QVectorIterator> fIt(MainWindow::Files); - while (fIt.hasNext()) { - if (fIt.peekNext().value("file").contains(".flac")) { - QFileInfo fld(MainWindow::cue); - QString dir = fld.absolutePath(); - QString file = dir + "/" + fIt.peekNext().value("file"); - if(!QFileInfo(file).exists()) { - ui->statusbar->showMessage("ERROR: Input file(s) does not exist."); - rA(1); - return; - }else { - QStandardItem *q = new QStandardItem(fIt.next().value("file")); - MainWindow::model->appendRow(q); - } - }else { - ui->statusbar->showMessage("ERROR: Input file(s) not in FLAC format."); - rA(1); - return; - } - } - QVectorIterator> tIt(MainWindow::Tracks); - while (tIt.hasNext()) { - QStandardItem *q = new QStandardItem("Track " + tIt.peekNext().value("num") + " - " + tIt.peekNext().value("title")); - tIt.next(); - MainWindow::model2->appendRow(q); - } - ui->cueLab->setText("Current CUE File: " + MainWindow::cue); - QVariant fc(MainWindow::Files.size()); - QString fcs = fc.toString(); -// ui->statusbar->showMessage("Successfully Imported CUE File (" + tIt.peekPrevious().value("num") + " Tracks Across " + fcs + " Files)."); -} - -void MainWindow::rA(int e) { - ui->progressBar->setValue(0); - MainWindow::model->clear(); - MainWindow::model2->clear(); - MainWindow::Files.clear(); - MainWindow::Tracks.clear(); - MainWindow::cmds.clear(); - MainWindow::count = 0; - MainWindow::cue.clear(); - if (e != 1) { - ui->cmdout->clear(); - ui->statusbar->showMessage("Ready."); - }ui->cueLab->setText("Current CUE File: None."); -} - -void MainWindow::split() { - if (MainWindow::Files.size() == 1) { - MainWindow::dual = 1; - }else { - MainWindow::dual = 2; - } - if (MainWindow::cue.isEmpty() || MainWindow::Tracks.isEmpty()|| MainWindow::Files.isEmpty()) { - ui->statusbar->showMessage("ERROR: Nothing to split."); - return; - } - if (MainWindow::dual == 0) { - ui->statusbar->showMessage("ERROR: Invalid Format."); - return; - }bool first = true; - bool last = false; - int bcount = 0; - QFileInfo fld(MainWindow::cue); - QString wdir = fld.absolutePath(); - QVectorIterator> tIt(MainWindow::Tracks); - tIt.next(); - while (tIt.hasNext()) { - QStringList start, end; - QString tn, namestr, amestr, side, ifile, cmd; - QMap it; - ifile = MainWindow::Files[0].value("file"); - if (last == true) { - it = tIt.peekNext(); - }else { - it = tIt.peekPrevious(); - }if (MainWindow::dual == 2) { - if (MainWindow::Files.size() == 2) { - if (last == true) { - side = "B"; - }else { - tn = tIt.peekPrevious().value("num"); - }if (tIt.peekPrevious().value("lind").toInt() < MainWindow::Files[1].value("lind").toInt()) { - side = "A"; - }else { - side = "B"; - }if (side.contains("B")) { - ifile = MainWindow::Files[1].value("file"); - bcount++; - QVariant bc(bcount); - QString bcs = bc.toString(); - tn = bcs; - } - }else { - ui->statusbar->showMessage("ERROR: CUEs with over 2 input files not currently supported."); - return; - }if (first){ - end = tIt.peekNext().value("tind").split(":"); - }else if (last == true) { - start = tIt.peekNext().value("tind").split(":"); - }else { - if (tIt.peekNext().value("tind").contains("00:00:00")) { - start = tIt.peekPrevious().value("tind").split(":"); - }else if (tIt.peekPrevious().value("tind").contains("00:00:00")) { - end = tIt.peekNext().value("tind").split(":"); - }else { - start = tIt.peekPrevious().value("tind").split(":"); - end = tIt.peekNext().value("tind").split(":"); - } - }amestr = side + tn + " - " + it.value("title") + ".flac"; - - }else { - if (first){ - end = tIt.peekNext().value("tind").split(":"); - }else if (last == true) { - start = tIt.peekNext().value("tind").split(":"); - }else { - start = tIt.peekPrevious().value("tind").split(":"); - end = tIt.peekNext().value("tind").split(":"); - }if(it.value("num").length() == 1) { - tn = "0" + it.value("num"); - }else { - tn = it.value("num"); - }amestr = tn + " - " + it.value("title") + ".flac"; - }namestr = validateNamestr(amestr); - QString c = "flac.exe --best "; - if (it.contains("artist")) { - c = c + "-T \"ARTIST= " + it.value("artist") + "\" "; - }if (it.contains("year")) { - c = c + "-T \"DATE= " + it.value("year") + "\" "; - }if (it.contains("genre")) { - c = c + "-T \"GENRE= " + it.value("genre") + "\" "; - }if (start.isEmpty()) { - cmd = c + "-T \"TRACKNUMBER=" + tIt.peekPrevious().value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + tIt.peekPrevious().value("title") + "\" " + "--until=" + end[0] + ":" + end[1] + "." + end[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; - }else if (end.isEmpty()) { - cmd = c + "-T \"TRACKNUMBER=" + it.value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + it.value("title") + "\" " + "--skip=" + start[0] + ":" + start[1] + "." + start[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; - }else { - cmd = c + "-T \"TRACKNUMBER=" + tIt.peekPrevious().value("num") + "\" -T \"ALBUM=" + MainWindow::al + "\" " + "-T \"TITLE=" + tIt.peekPrevious().value("title") + "\" " + "--skip=" + start[0] + ":" + start[1] + "." + start[2] + " --until=" + end[0] + ":" + end[1] + "." + end[2] + " \"" + wdir + "/" + ifile + "\" -o \"" + wdir + "/" + namestr + "\""; - }MainWindow::cmds.append(cmd); - first = false; - tIt.next(); - if (!tIt.hasNext()) { - if (last) { - QVariant fas(MainWindow::Tracks.size()); - QString fass = fas.toString(); - ui->statusbar->showMessage("Encoding file 1 of " + fass + "."); - break; - }else { - tIt.previous(); - last = true; - } - } - }doTrack(0); -} - -QString MainWindow::validateNamestr(QString str) { - QString illChars = "\\ | / : ? ! \" < >"; - QStringList illCharArr = illChars.split(" ", QString::SkipEmptyParts); - QList::iterator ici; - for (ici = illCharArr.begin(); ici != illCharArr.end(); ++ici){ - str.remove(*ici); - }return str; -} - -void MainWindow::doTrack(int ex) { - if (MainWindow::cmds.size() != MainWindow::Tracks.size()) { - if (MainWindow::count != 0) { - if (ex == 1) { - QVariant c(MainWindow::count); - QString cs = c.toString(); - MainWindow::errs.append(cs); - } - } - }if (MainWindow::cmds.size() == 0) { - if (!MainWindow::errs.isEmpty()) { - QString err = MainWindow::errs.join(", "); - Dialog dia; - ui->statusbar->showMessage("Encode completed with errors."); - ui->progressBar->setValue(100); - dia.setTxt("The following tracks failed to encode: " + err + "."); - dia.exec(); - }else{ - ui->statusbar->showMessage("Encode completed, ready."); - ui->progressBar->setValue(100); - } - }else { - QVariant c(MainWindow::count + 1); - QString cs = c.toString(); - QVariant ts(MainWindow::Tracks.size()); - QString tss = ts.toString(); - ui->statusbar->showMessage("Encoding file " + cs + " of " + tss + "."); - process->start(MainWindow::cmds[0]); - MainWindow::cmds.removeFirst(); - int progress = 100 / MainWindow::Tracks.size(); - int cpro = progress * MainWindow::count; - ui->progressBar->setValue(cpro); - MainWindow::count++; - } -} - -void MainWindow::opu() { - QString otpt(process->readAllStandardOutput()); - ui->cmdout->append(otpt); -} - -Dialog::~Dialog() -{ - delete ui; -} - - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/Main Application/mainwindow.h b/Main Application/mainwindow.h deleted file mode 100644 index 597b76a..0000000 --- a/Main Application/mainwindow.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Ui { -class Dialog; -class MainWindow; -class Metadata; -} - -class Dialog : public QDialog -{ - Q_OBJECT -public: - explicit Dialog(QWidget *parent = 0); - ~Dialog(); -private: - Ui::Dialog *ui; -public slots: - void setTxt(QString); -}; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - QString MainWindow::cue, MainWindow::pa, MainWindow::tra, MainWindow::genre, MainWindow::year, MainWindow::tc, MainWindow::al, MainWindow::bDir; - QStandardItemModel *MainWindow::model; - QStandardItemModel *MainWindow::model2; - QProcess *MainWindow::process; - QPalette MainWindow::proPal; - QStringList MainWindow::cmds, MainWindow::errs; - QVector> MainWindow::Files, MainWindow::Tracks; - explicit MainWindow(QWidget *parent = 0); - int MainWindow::dual, MainWindow::count; - ~MainWindow(); - -protected: - void dragEnterEvent(QDragEnterEvent *e); - void dropEvent(QDropEvent *e); - -private: - Ui::MainWindow *ui; - -private slots: - void ex(); - void batch(); - void fImport(); - void rA(int); - void split(); - void iBut(); - void cBut(); - QString validateNamestr(QString); - void doTrack(int); - void dtTrigger(int , QProcess::ExitStatus); - void opu(); -}; - -#endif // MAINWINDOW_H diff --git a/Main Application/ui_dialog.h b/Main Application/ui_dialog.h deleted file mode 100644 index 4619ff2..0000000 --- a/Main Application/ui_dialog.h +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'dialog.ui' -** -** Created by: Qt User Interface Compiler version 5.8.0 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_DIALOG_H -#define UI_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_Dialog -{ -public: - QVBoxLayout *verticalLayout; - QLabel *errtxt; - QLabel *label; - QDialogButtonBox *buttonBox; - - void setupUi(QDialog *Dialog) - { - if (Dialog->objectName().isEmpty()) - Dialog->setObjectName(QStringLiteral("Dialog")); - Dialog->setEnabled(true); - Dialog->resize(373, 166); - verticalLayout = new QVBoxLayout(Dialog); - verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - errtxt = new QLabel(Dialog); - errtxt->setObjectName(QStringLiteral("errtxt")); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(errtxt->sizePolicy().hasHeightForWidth()); - errtxt->setSizePolicy(sizePolicy); - QFont font; - font.setFamily(QStringLiteral("Segoe UI")); - font.setPointSize(8); - errtxt->setFont(font); - errtxt->setAlignment(Qt::AlignCenter); - errtxt->setWordWrap(true); - - verticalLayout->addWidget(errtxt); - - label = new QLabel(Dialog); - label->setObjectName(QStringLiteral("label")); - QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Minimum); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); - label->setSizePolicy(sizePolicy1); - QFont font1; - font1.setBold(true); - font1.setItalic(false); - font1.setWeight(75); - label->setFont(font1); - - verticalLayout->addWidget(label); - - buttonBox = new QDialogButtonBox(Dialog); - buttonBox->setObjectName(QStringLiteral("buttonBox")); - QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); - sizePolicy2.setHorizontalStretch(0); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(buttonBox->sizePolicy().hasHeightForWidth()); - buttonBox->setSizePolicy(sizePolicy2); - buttonBox->setStandardButtons(QDialogButtonBox::Ok); - buttonBox->setCenterButtons(true); - - verticalLayout->addWidget(buttonBox); - - - retranslateUi(Dialog); - QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); - - QMetaObject::connectSlotsByName(Dialog); - } // setupUi - - void retranslateUi(QDialog *Dialog) - { - Dialog->setWindowTitle(QApplication::translate("Dialog", "Errors Encountered", Q_NULLPTR)); - errtxt->setText(QApplication::translate("Dialog", "The following tracks failed to encode: ", Q_NULLPTR)); - label->setText(QApplication::translate("Dialog", "Check console log for more details.", Q_NULLPTR)); - } // retranslateUi - -}; - -namespace Ui { - class Dialog: public Ui_Dialog {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_DIALOG_H diff --git a/Main Application/ui_errdia.h b/Main Application/ui_errdia.h deleted file mode 100644 index 4619ff2..0000000 --- a/Main Application/ui_errdia.h +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'dialog.ui' -** -** Created by: Qt User Interface Compiler version 5.8.0 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_DIALOG_H -#define UI_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_Dialog -{ -public: - QVBoxLayout *verticalLayout; - QLabel *errtxt; - QLabel *label; - QDialogButtonBox *buttonBox; - - void setupUi(QDialog *Dialog) - { - if (Dialog->objectName().isEmpty()) - Dialog->setObjectName(QStringLiteral("Dialog")); - Dialog->setEnabled(true); - Dialog->resize(373, 166); - verticalLayout = new QVBoxLayout(Dialog); - verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - errtxt = new QLabel(Dialog); - errtxt->setObjectName(QStringLiteral("errtxt")); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(errtxt->sizePolicy().hasHeightForWidth()); - errtxt->setSizePolicy(sizePolicy); - QFont font; - font.setFamily(QStringLiteral("Segoe UI")); - font.setPointSize(8); - errtxt->setFont(font); - errtxt->setAlignment(Qt::AlignCenter); - errtxt->setWordWrap(true); - - verticalLayout->addWidget(errtxt); - - label = new QLabel(Dialog); - label->setObjectName(QStringLiteral("label")); - QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Minimum); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); - label->setSizePolicy(sizePolicy1); - QFont font1; - font1.setBold(true); - font1.setItalic(false); - font1.setWeight(75); - label->setFont(font1); - - verticalLayout->addWidget(label); - - buttonBox = new QDialogButtonBox(Dialog); - buttonBox->setObjectName(QStringLiteral("buttonBox")); - QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); - sizePolicy2.setHorizontalStretch(0); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(buttonBox->sizePolicy().hasHeightForWidth()); - buttonBox->setSizePolicy(sizePolicy2); - buttonBox->setStandardButtons(QDialogButtonBox::Ok); - buttonBox->setCenterButtons(true); - - verticalLayout->addWidget(buttonBox); - - - retranslateUi(Dialog); - QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); - - QMetaObject::connectSlotsByName(Dialog); - } // setupUi - - void retranslateUi(QDialog *Dialog) - { - Dialog->setWindowTitle(QApplication::translate("Dialog", "Errors Encountered", Q_NULLPTR)); - errtxt->setText(QApplication::translate("Dialog", "The following tracks failed to encode: ", Q_NULLPTR)); - label->setText(QApplication::translate("Dialog", "Check console log for more details.", Q_NULLPTR)); - } // retranslateUi - -}; - -namespace Ui { - class Dialog: public Ui_Dialog {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_DIALOG_H diff --git a/Windows/Main Application/errdia.ui b/Windows/Main Application/errdia.ui deleted file mode 100644 index 7ba02d5..0000000 --- a/Windows/Main Application/errdia.ui +++ /dev/null @@ -1,102 +0,0 @@ - - - Dialog - - - true - - - - 0 - 0 - 373 - 166 - - - - Errors Encountered - - - - - - - 0 - 0 - - - - - Segoe UI - 8 - - - - The following tracks failed to encode: - - - Qt::AlignCenter - - - true - - - - - - - - 0 - 0 - - - - - 75 - false - true - - - - Check console log for more details. - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Ok - - - true - - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 186 - 140 - - - 186 - 82 - - - - -