aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/converter
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-01-21 06:34:51 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-01-21 06:34:51 +0000
commit7f5637710f36ecfa818b06fe008d53d1cf234ba8 (patch)
tree8ea340f6e3f68abc07bc1fc89a6115ff4237462a /src/plugins/General/converter
parent58eacba4daf81e8b24201c81125c97ff55742869 (diff)
downloadqmmp-7f5637710f36ecfa818b06fe008d53d1cf234ba8.tar.gz
qmmp-7f5637710f36ecfa818b06fe008d53d1cf234ba8.tar.bz2
qmmp-7f5637710f36ecfa818b06fe008d53d1cf234ba8.zip
converter: fixed some bugs
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6069 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/converter')
-rw-r--r--src/plugins/General/converter/converter.cpp7
-rw-r--r--src/plugins/General/converter/converter.h3
-rw-r--r--src/plugins/General/converter/converterdialog.cpp38
-rw-r--r--src/plugins/General/converter/converterdialog.h2
4 files changed, 43 insertions, 7 deletions
diff --git a/src/plugins/General/converter/converter.cpp b/src/plugins/General/converter/converter.cpp
index 063192932..63fe2ffd0 100644
--- a/src/plugins/General/converter/converter.cpp
+++ b/src/plugins/General/converter/converter.cpp
@@ -110,6 +110,7 @@ bool Converter::prepare(const QString &url, const QVariantMap &preset)
m_preset = preset;
if(!decoder->totalTime())
source->setOffset(-1);
+ m_user_stop = false;
return true;
}
@@ -123,7 +124,11 @@ void Converter::stop()
void Converter::run()
{
qDebug("Converter: staring thread");
- m_user_stop = false;
+ if(m_user_stop)
+ {
+ emit finished(this);
+ return;
+ }
AudioParameters ap = m_decoder->audioParameters();
QString url = m_input->url();
diff --git a/src/plugins/General/converter/converter.h b/src/plugins/General/converter/converter.h
index e2f58d22e..0f619d864 100644
--- a/src/plugins/General/converter/converter.h
+++ b/src/plugins/General/converter/converter.h
@@ -53,9 +53,6 @@ signals:
private:
void run();
bool convert(Decoder *decoder, FILE *file, bool use16bit);
- //QQueue <Decoder*> m_decoders;
- //QHash <Decoder*, InputSource*> m_inputs;
- //QHash <Decoder*, QVariantMap> m_presets;
Decoder *m_decoder;
InputSource *m_input;
QVariantMap m_preset;
diff --git a/src/plugins/General/converter/converterdialog.cpp b/src/plugins/General/converter/converterdialog.cpp
index 7bfafe37c..d4deea6df 100644
--- a/src/plugins/General/converter/converterdialog.cpp
+++ b/src/plugins/General/converter/converterdialog.cpp
@@ -25,6 +25,8 @@
#include <QDir>
#include <QProgressBar>
#include <QThreadPool>
+#include <QProcess>
+#include <QMessageBox>
#include <qmmpui/playlistitem.h>
#include <qmmpui/metadataformatter.h>
#include <qmmpui/filedialog.h>
@@ -109,6 +111,9 @@ void ConverterDialog::on_dirButton_clicked()
void ConverterDialog::on_convertButton_clicked()
{
+ if(!checkPreset(preset()))
+ return;
+
m_ui.convertButton->setEnabled(false);
m_converters.clear();
for(int i = 0; i < m_ui.tableWidget->rowCount(); ++i)
@@ -142,12 +147,16 @@ void ConverterDialog::on_stopButton_clicked()
QThreadPool::globalInstance()->waitForDone();
qDeleteAll(m_converters);
m_converters.clear();
+ m_ui.convertButton->setEnabled(true);
}
void ConverterDialog::onConvertFinished(Converter *c)
{
- m_converters.removeAll(c);
- delete c;
+ if(m_converters.contains(c))
+ {
+ m_converters.removeAll(c);
+ delete c;
+ }
if(m_converters.isEmpty())
m_ui.convertButton->setEnabled(true);
}
@@ -330,3 +339,28 @@ QString ConverterDialog::uniqueName(const QString &name)
}
return unique_name;
}
+
+bool ConverterDialog::checkPreset(const QVariantMap &preset)
+{
+ QStringList programAndArgs = preset["command"].toString().split(" ", QString::SkipEmptyParts);
+ if(programAndArgs.isEmpty())
+ return false;
+
+ QString program = programAndArgs.first();
+
+ int result = QProcess::execute(program);
+
+ if(result == -2)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Unable to execute \"%1\". Program not found.")
+ .arg(program));
+ return false;
+ }
+ else if(result < 0)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Process \"%1\" finished with error.")
+ .arg(program));
+ return false;
+ }
+ return true;
+}
diff --git a/src/plugins/General/converter/converterdialog.h b/src/plugins/General/converter/converterdialog.h
index d98756576..6b1234947 100644
--- a/src/plugins/General/converter/converterdialog.h
+++ b/src/plugins/General/converter/converterdialog.h
@@ -60,9 +60,9 @@ private:
void savePresets();
QVariantMap preset() const;
QString uniqueName(const QString &name);
+ bool checkPreset(const QVariantMap &preset);
Ui::ConverterDialog m_ui;
- QList <ConverterPreset* > m_presets;
QList <Converter *> m_converters;
};