From 5ee30737be204e9db45212c3329b1e3d1d4f375c Mon Sep 17 00:00:00 2001 From: Daniel Kamil Kozar Date: Sat, 7 Dec 2019 19:37:10 +0100 Subject: [PATCH] Make the GUI look for the main binary under "tsmuxer" and "tsMuxeR" The all-lowercase binary name is the one that's emitted by the current build system, while the old one is kept for backwards compatibility. Fixes #63 --- tsMuxerGUI/tsmuxerwindow.cpp | 33 ++++++++------- tsMuxerGUI/tsmuxerwindow.h | 82 ++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/tsMuxerGUI/tsmuxerwindow.cpp b/tsMuxerGUI/tsmuxerwindow.cpp index eb00a73..6f3f4cf 100644 --- a/tsMuxerGUI/tsmuxerwindow.cpp +++ b/tsMuxerGUI/tsmuxerwindow.cpp @@ -893,10 +893,7 @@ void TsMuxerWindow::addFile() { connect(this, SIGNAL(codecListReady()), this, SLOT(continueAddFile())); connect(this, SIGNAL(fileAdded()), this, SLOT(addFile())); runInMuxMode = false; - shellExecute( - QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + - QDir::separator() + "tsMuxeR", - QStringList() << newFileName); + tsMuxerExecute(QStringList() << newFileName); } bool TsMuxerWindow::checkFileDuplicate(const QString &fileName) { @@ -1417,14 +1414,26 @@ void TsMuxerWindow::onProcessError(QProcess::ProcessError error) { msgBox.exec(); } -void TsMuxerWindow::shellExecute(const QString &process, - const QStringList &args) { +static QString getTsMuxerBinaryPath() { + const auto applicationDirPath = + QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + QDir::separator(); + for(auto binaryName : {"tsmuxer", "tsMuxeR"}) { + auto binaryPath = applicationDirPath + binaryName; + if (QFile::exists(binaryPath)) { + return binaryPath; + } + } + return QString(); +} + +void TsMuxerWindow::tsMuxerExecute(const QStringList &args) { + const auto exePath = getTsMuxerBinaryPath(); ui.buttonMux->setEnabled(false); procStdOutput.clear(); procErrOutput.clear(); processFinished = false; processExitCode = -1; - proc.start(process, args); + proc.start(exePath, args); if (muxForm.isVisible()) muxForm.setProcess(&proc); } @@ -2110,10 +2119,7 @@ void TsMuxerWindow::appendFile() { connect(this, SIGNAL(codecListReady()), this, SLOT(continueAppendFile())); connect(this, SIGNAL(fileAppended()), this, SLOT(appendFile())); runInMuxMode = false; - shellExecute( - QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + - QDir::separator() + "tsMuxeR", - QStringList() << newFileName); + tsMuxerExecute(QStringList() << newFileName); } void TsMuxerWindow::continueAppendFile() { @@ -2396,10 +2402,7 @@ void TsMuxerWindow::startMuxing() { disconnect(); // QCoreApplication::dir runInMuxMode = true; - shellExecute( - QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + - QDir::separator() + "tsMuxeR", - QStringList() << metaName << quoteStr(ui.outFileName->text())); + tsMuxerExecute(QStringList() << metaName << quoteStr(ui.outFileName->text())); } void TsMuxerWindow::saveMetaFileBtnClick() { diff --git a/tsMuxerGUI/tsmuxerwindow.h b/tsMuxerGUI/tsmuxerwindow.h index b2c587c..9787fd2 100644 --- a/tsMuxerGUI/tsmuxerwindow.h +++ b/tsMuxerGUI/tsmuxerwindow.h @@ -3,10 +3,10 @@ #if defined(__GNUC__) && ((__GNUC__ < 4) || \ (__GNUC__ == 4 && __GNUC_MINOR__ <= 6)) -#define override -#endif - - +#define override +#endif + + #include #include #include @@ -14,17 +14,17 @@ #include "ui_tsmuxerwindow.h" #include "muxForm.h" - -typedef QList ChapterList; - -enum MplsType { - MPLS_NONE, - MPLS_PRIMARY, - MPLS_M2TS, -}; - - -class QnCheckBoxedHeaderView: public QHeaderView { + +typedef QList ChapterList; + +enum MplsType { + MPLS_NONE, + MPLS_PRIMARY, + MPLS_M2TS, +}; + + +class QnCheckBoxedHeaderView: public QHeaderView { Q_OBJECT typedef QHeaderView base_type; public: @@ -32,18 +32,18 @@ public: Qt::CheckState checkState() const; void setCheckState(Qt::CheckState state); -signals: - void checkStateChanged(Qt::CheckState state); -protected: - virtual void paintEvent(QPaintEvent *e) override; - virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override; - virtual QSize sectionSizeFromContents(int logicalIndex) const override; - private slots: - void at_sectionClicked(int logicalIndex); -private: - Qt::CheckState m_checkState; - int m_checkColumnIndex; -}; +signals: + void checkStateChanged(Qt::CheckState state); +protected: + virtual void paintEvent(QPaintEvent *e) override; + virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override; + virtual QSize sectionSizeFromContents(int logicalIndex) const override; + private slots: + void at_sectionClicked(int logicalIndex); +private: + Qt::CheckState m_checkState; + int m_checkColumnIndex; +}; struct QtvCodecInfo { @@ -170,21 +170,21 @@ protected: virtual bool eventFilter(QObject *obj, QEvent* event) override; void updateMaxOffsets(); void updateCustomChapters(); - - void writeSettings(); - bool readSettings(); - QString getOutputDir() const; -private: - struct MPLSFileInfo - { - MPLSFileInfo(const QString& _name, double _duration): name(_name), duration(_duration) {} - MPLSFileInfo(): duration(0) {} - QString name; + + void writeSettings(); + bool readSettings(); + QString getOutputDir() const; +private: + struct MPLSFileInfo + { + MPLSFileInfo(const QString& _name, double _duration): name(_name), duration(_duration) {} + MPLSFileInfo(): duration(0) {} + QString name; double duration; }; bool checkFileDuplicate(const QString& fileName); - void shellExecute(const QString& process, const QStringList& args); + void tsMuxerExecute(const QStringList& args); void addLines(const QByteArray& arr, QList& outList, bool isError); void doAppendInt(const QString& fileName, const QString& parentFileName, double duration, bool doublePrefix, MplsType mplsRole); bool isDiskOutput() const; @@ -207,7 +207,7 @@ private: double getRendererAnimationTime() const; void setRendererAnimationTime(double value); void setTextItemColor(QString str); - QString getDefaultOutputFileName() const; + QString getDefaultOutputFileName() const; void updateCurrentColor(int dr, int dg, int db, int rowIndex); void colorizeCurrentRow(const QtvCodecInfo* codecInfo, int rowIndex = -1); @@ -256,5 +256,5 @@ private: }; Q_DECLARE_METATYPE(ChapterList); - -#endif + +#endif