aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-01-21 07:31:10 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-01-21 07:31:10 +0000
commite31a61e0273cc1723295565375e07acde066ad41 (patch)
treec9bd0e2b47cfc55ce3ae3f703f9b6eb64c5cd3a5 /src/plugins/General
parent7f5637710f36ecfa818b06fe008d53d1cf234ba8 (diff)
downloadqmmp-e31a61e0273cc1723295565375e07acde066ad41.tar.gz
qmmp-e31a61e0273cc1723295565375e07acde066ad41.tar.bz2
qmmp-e31a61e0273cc1723295565375e07acde066ad41.zip
improved converter
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6070 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/converter/converter.cpp11
-rw-r--r--src/plugins/General/converter/converter.h4
-rw-r--r--src/plugins/General/converter/converterdialog.cpp22
-rw-r--r--src/plugins/General/converter/converterdialog.h4
-rw-r--r--src/plugins/General/converter/converterdialog.ui5
5 files changed, 37 insertions, 9 deletions
diff --git a/src/plugins/General/converter/converter.cpp b/src/plugins/General/converter/converter.cpp
index 63fe2ffd0..702a0aae2 100644
--- a/src/plugins/General/converter/converter.cpp
+++ b/src/plugins/General/converter/converter.cpp
@@ -57,8 +57,9 @@ Converter::~Converter()
}
}
-bool Converter::prepare(const QString &url, const QVariantMap &preset)
+bool Converter::prepare(const QString &url, int row, const QVariantMap &preset)
{
+ m_row = row;
InputSource *source = InputSource::create(url, this);
if(!source->initialize())
{
@@ -126,6 +127,7 @@ void Converter::run()
qDebug("Converter: staring thread");
if(m_user_stop)
{
+ emit message(m_row, tr("Cancelled"));
emit finished(this);
return;
}
@@ -140,6 +142,7 @@ void Converter::run()
if(list.isEmpty() || out_path.isEmpty() || pattern.isEmpty())
{
qWarning("Converter: invalid parameters");
+ emit message(m_row, tr("Error"));
return;
}
@@ -171,6 +174,7 @@ void Converter::run()
command.replace("%i", "\"" + tmp_path + "\"");
qDebug("Converter: starting task '%s'", qPrintable(m_preset["name"].toString()));
+ emit message(m_row, tr("Converting"));
qDeleteAll(list);
list.clear();
@@ -205,6 +209,7 @@ void Converter::run()
if(!enc_pipe)
{
qWarning("Converter: unable to open pipe");
+ emit message(m_row, tr("Error"));
return;
}
@@ -222,6 +227,7 @@ void Converter::run()
if(m_user_stop)
{
qDebug("Converter: task '%s' aborted", qPrintable(m_preset["name"].toString()));
+ emit message(m_row, tr("Cancelled"));
m_mutex.unlock();
return;
}
@@ -232,7 +238,7 @@ void Converter::run()
if(use_file)
{
qDebug("Converter: starting file encoding...");
- //emit desriptionChanged(tr("Encoding..."));
+ emit message(m_row, tr("Encoding"));
enc_pipe = popen(qPrintable(command), "w");
if(!enc_pipe)
{
@@ -270,6 +276,7 @@ void Converter::run()
}
qDebug("Converter: thread finished");
+ emit message(m_row, tr("Finished"));
emit finished(this);
}
diff --git a/src/plugins/General/converter/converter.h b/src/plugins/General/converter/converter.h
index 0f619d864..b338f5a60 100644
--- a/src/plugins/General/converter/converter.h
+++ b/src/plugins/General/converter/converter.h
@@ -41,7 +41,7 @@ public:
explicit Converter(QObject *parent = 0);
virtual ~Converter();
- bool prepare(const QString &url, const QVariantMap &preset);
+ bool prepare(const QString &url, int row, const QVariantMap &preset);
public slots:
void stop();
@@ -49,6 +49,7 @@ public slots:
signals:
void progress(int percent);
void finished(Converter *converter);
+ void message(int row, QString message);
private:
void run();
@@ -58,6 +59,7 @@ private:
QVariantMap m_preset;
QMutex m_mutex;
bool m_user_stop;
+ int m_row;
};
diff --git a/src/plugins/General/converter/converterdialog.cpp b/src/plugins/General/converter/converterdialog.cpp
index d4deea6df..164d592dd 100644
--- a/src/plugins/General/converter/converterdialog.cpp
+++ b/src/plugins/General/converter/converterdialog.cpp
@@ -65,7 +65,7 @@ ConverterDialog::ConverterDialog(QList <PlayListTrack *> tracks, QWidget *paren
QProgressBar *progressBar = new QProgressBar(this);
progressBar->setRange(0, 100);
m_ui.tableWidget->setCellWidget(m_ui.tableWidget->rowCount() - 1, 1, progressBar);
-
+ m_ui.tableWidget->setItem(m_ui.tableWidget->rowCount() - 1, 2, new QTableWidgetItem());
}
m_ui.tableWidget->resizeColumnsToContents();
@@ -75,6 +75,7 @@ ConverterDialog::ConverterDialog(QList <PlayListTrack *> tracks, QWidget *paren
m_ui.outDirEdit->setText(settings.value("out_dir", music_path).toString());
m_ui.outFileEdit->setText(settings.value("file_name","%p - %t").toString());
m_ui.overwriteCheckBox->setChecked(settings.value("overwrite",false).toBool());
+ restoreGeometry(settings.value("geometry").toByteArray());
settings.endGroup();
createMenus();
@@ -122,19 +123,23 @@ void ConverterDialog::on_convertButton_clicked()
Converter *converter = new Converter();
- if(!converter->prepare(url, preset()))
+ if(!converter->prepare(url, i, preset()))
{
- //m_ui.tableWidget->setItem(i, 2, new QTableWidgetItem(tr("Error")));
+ m_ui.tableWidget->item(i, 2)->setText(tr("Error"));
delete converter;
continue;
}
+ else
+ m_ui.tableWidget->item(i, 2)->setText(tr("Waiting"));
converter->setAutoDelete(false);
m_converters.append(converter);
connect(converter, SIGNAL(progress(int)), m_ui.tableWidget->cellWidget(i, 1), SLOT(setValue(int)));
connect(converter, SIGNAL(finished(Converter *)), SLOT(onConvertFinished(Converter *)));
+ connect(converter, SIGNAL(message(int, QString)), SLOT(onStateChanged(int, QString)));
QThreadPool::globalInstance()->start(converter);
}
+ m_ui.tableWidget->resizeColumnsToContents();
}
void ConverterDialog::on_stopButton_clicked()
@@ -150,6 +155,12 @@ void ConverterDialog::on_stopButton_clicked()
m_ui.convertButton->setEnabled(true);
}
+void ConverterDialog::onStateChanged(int row, QString message)
+{
+ m_ui.tableWidget->item(row, 2)->setText(message);
+ m_ui.tableWidget->resizeColumnsToContents();
+}
+
void ConverterDialog::onConvertFinished(Converter *c)
{
if(m_converters.contains(c))
@@ -161,15 +172,16 @@ void ConverterDialog::onConvertFinished(Converter *c)
m_ui.convertButton->setEnabled(true);
}
-void ConverterDialog::accept()
+void ConverterDialog::reject()
{
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
settings.beginGroup("Converter");
settings.setValue("out_dir", m_ui.outDirEdit->text());
settings.value("file_name", m_ui.outFileEdit->text());
settings.setValue("overwrite", m_ui.overwriteCheckBox->isChecked());
+ settings.setValue("geometry", saveGeometry());
settings.endGroup();
- QDialog::accept();
+ QDialog::reject();
}
void ConverterDialog::createMenus()
diff --git a/src/plugins/General/converter/converterdialog.h b/src/plugins/General/converter/converterdialog.h
index 6b1234947..c8cb59838 100644
--- a/src/plugins/General/converter/converterdialog.h
+++ b/src/plugins/General/converter/converterdialog.h
@@ -23,6 +23,7 @@
#include <QDialog>
#include <QStringList>
+#include <QCloseEvent>
#include "ui_converterdialog.h"
class QAction;
@@ -41,12 +42,13 @@ public:
virtual ~ConverterDialog();
public slots:
- virtual void accept();
+ virtual void reject();
private slots:
void on_dirButton_clicked();
void on_convertButton_clicked();
void on_stopButton_clicked();
+ void onStateChanged(int row, QString message);
void onConvertFinished(Converter *c);
void addTitleString(QAction *a);
void createPreset();
diff --git a/src/plugins/General/converter/converterdialog.ui b/src/plugins/General/converter/converterdialog.ui
index c408f497a..5e24c8302 100644
--- a/src/plugins/General/converter/converterdialog.ui
+++ b/src/plugins/General/converter/converterdialog.ui
@@ -44,6 +44,11 @@
<string>Progress</string>
</property>
</column>
+ <column>
+ <property name="text">
+ <string>State</string>
+ </property>
+ </column>
</widget>
</item>
<item row="1" column="0" colspan="3">