Add log to organise error dialog
This commit is contained in:
parent
3483736490
commit
cb844084e8
@ -28,12 +28,14 @@
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
#include <QUrl>
|
||||
#include <QStandardPaths>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/utilities.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "organise.h"
|
||||
#ifdef HAVE_GSTREAMER
|
||||
# include "transcoder/transcoder.h"
|
||||
@ -88,6 +90,7 @@ void Organise::Start() {
|
||||
connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles()));
|
||||
#ifdef HAVE_GSTREAMER
|
||||
connect(transcoder_, SIGNAL(JobComplete(QString, QString, bool)), SLOT(FileTranscoded(QString, QString, bool)));
|
||||
connect(transcoder_, SIGNAL(LogLine(QString)), SLOT(LogLine(QString)));
|
||||
#endif
|
||||
|
||||
moveToThread(thread_);
|
||||
@ -97,6 +100,7 @@ void Organise::Start() {
|
||||
void Organise::ProcessSomeFiles() {
|
||||
|
||||
if (!started_) {
|
||||
transcode_temp_name_.setFileTemplate(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/transcoder");
|
||||
#ifdef HAVE_GSTREAMER
|
||||
transcode_temp_name_.open();
|
||||
#endif
|
||||
@ -127,7 +131,7 @@ void Organise::ProcessSomeFiles() {
|
||||
|
||||
task_manager_->SetTaskFinished(task_id_);
|
||||
|
||||
emit Finished(files_with_errors_);
|
||||
emit Finished(files_with_errors_, log_);
|
||||
|
||||
// Move back to the original thread so deleteLater() can get called in the main thread's event loop
|
||||
moveToThread(original_thread_);
|
||||
@ -151,6 +155,10 @@ void Organise::ProcessSomeFiles() {
|
||||
Song song = task.song_info_.song_;
|
||||
if (!song.is_valid()) continue;
|
||||
|
||||
// Get embedded album cover
|
||||
QImage cover = TagReaderClient::Instance()->LoadEmbeddedArtBlocking(task.song_info_.song_.url().toLocalFile());
|
||||
if (!cover.isNull()) song.set_image(cover);
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
// Maybe this file is one that's been transcoded already?
|
||||
if (!task.transcoded_filename_.isEmpty()) {
|
||||
@ -202,7 +210,8 @@ void Organise::ProcessSomeFiles() {
|
||||
|
||||
if (!destination_->CopyToStorage(job)) {
|
||||
files_with_errors_ << task.song_info_.song_.basefilename();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (job.mark_as_listened_) {
|
||||
emit FileCopied(job.metadata_.id());
|
||||
}
|
||||
@ -320,3 +329,9 @@ void Organise::timerEvent(QTimerEvent *e) {
|
||||
|
||||
}
|
||||
|
||||
void Organise::LogLine(const QString message) {
|
||||
|
||||
QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
|
||||
log_.append(QString("%1: %2").arg(date, message));
|
||||
|
||||
}
|
||||
|
@ -28,14 +28,14 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QTemporaryFile>
|
||||
#include <QBasicTimer>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "organiseformat.h"
|
||||
@ -68,8 +68,8 @@ class Organise : public QObject {
|
||||
|
||||
void Start();
|
||||
|
||||
signals:
|
||||
void Finished(const QStringList &files_with_errors);
|
||||
signals:
|
||||
void Finished(const QStringList &files_with_errors, QStringList);
|
||||
void FileCopied(int database_id);
|
||||
|
||||
protected:
|
||||
@ -80,6 +80,7 @@ signals:
|
||||
#ifdef HAVE_GSTREAMER
|
||||
void FileTranscoded(const QString &input, const QString &output, bool success);
|
||||
#endif
|
||||
void LogLine(const QString message);
|
||||
|
||||
private:
|
||||
void SetSongProgress(float progress, bool transcoded = false);
|
||||
@ -136,6 +137,7 @@ signals:
|
||||
int current_copy_progress_;
|
||||
|
||||
QStringList files_with_errors_;
|
||||
QStringList log_;
|
||||
};
|
||||
|
||||
#endif // ORGANISE_H
|
||||
|
@ -383,18 +383,18 @@ void OrganiseDialog::accept() {
|
||||
// It deletes itself when it's finished.
|
||||
const bool copy = ui_->aftercopying->currentIndex() == 0;
|
||||
Organise *organise = new Organise(task_manager_, storage, format_, copy, ui_->overwrite->isChecked(), ui_->mark_as_listened->isChecked(), new_songs_info_, ui_->eject_after->isChecked());
|
||||
connect(organise, SIGNAL(Finished(QStringList)), SLOT(OrganiseFinished(QStringList)));
|
||||
connect(organise, SIGNAL(Finished(QStringList, QStringList)), SLOT(OrganiseFinished(QStringList, QStringList)));
|
||||
connect(organise, SIGNAL(FileCopied(int)), this, SIGNAL(FileCopied(int)));
|
||||
organise->Start();
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void OrganiseDialog::OrganiseFinished(const QStringList &files_with_errors) {
|
||||
void OrganiseDialog::OrganiseFinished(const QStringList files_with_errors, const QStringList log) {
|
||||
if (files_with_errors.isEmpty()) return;
|
||||
|
||||
error_dialog_.reset(new OrganiseErrorDialog);
|
||||
error_dialog_->Show(OrganiseErrorDialog::Type_Copy, files_with_errors);
|
||||
error_dialog_->Show(OrganiseErrorDialog::Type_Copy, files_with_errors, log);
|
||||
}
|
||||
|
||||
void OrganiseDialog::resizeEvent(QResizeEvent *e) {
|
||||
|
@ -88,7 +88,7 @@ class OrganiseDialog : public QDialog {
|
||||
void InsertTag(const QString &tag);
|
||||
void UpdatePreviews();
|
||||
|
||||
void OrganiseFinished(const QStringList &files_with_errors);
|
||||
void OrganiseFinished(const QStringList files_with_errors, const QStringList log);
|
||||
|
||||
private:
|
||||
SongList LoadSongsBlocking(const QStringList &filenames);
|
||||
|
@ -52,17 +52,17 @@ OrganiseErrorDialog::~OrganiseErrorDialog() {
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void OrganiseErrorDialog::Show(OperationType type, const SongList &songs_with_errors) {
|
||||
void OrganiseErrorDialog::Show(OperationType type, const SongList &songs_with_errors, const QStringList &log) {
|
||||
|
||||
QStringList files;
|
||||
for (const Song &song : songs_with_errors) {
|
||||
files << song.url().toLocalFile();
|
||||
}
|
||||
Show(type, files);
|
||||
Show(type, files, log);
|
||||
|
||||
}
|
||||
|
||||
void OrganiseErrorDialog::Show(OperationType type, const QStringList &files_with_errors) {
|
||||
void OrganiseErrorDialog::Show(OperationType type, const QStringList &files_with_errors, const QStringList &log) {
|
||||
|
||||
QStringList sorted_files = files_with_errors;
|
||||
std::stable_sort(sorted_files.begin(), sorted_files.end());
|
||||
@ -79,7 +79,8 @@ void OrganiseErrorDialog::Show(OperationType type, const QStringList &files_with
|
||||
break;
|
||||
}
|
||||
|
||||
ui_->list->addItems(sorted_files);
|
||||
ui_->files->addItems(sorted_files);
|
||||
ui_->log->addItems(log);
|
||||
|
||||
show();
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ class OrganiseErrorDialog : public QDialog {
|
||||
Type_Delete,
|
||||
};
|
||||
|
||||
void Show(OperationType type, const SongList& songs_with_errors);
|
||||
void Show(OperationType type, const QStringList &files_with_errors);
|
||||
void Show(OperationType type, const SongList &songs_with_errors, const QStringList &log = QStringList());
|
||||
void Show(OperationType type, const QStringList &files_with_errors, const QStringList &log = QStringList());
|
||||
|
||||
private:
|
||||
Ui_OrganiseErrorDialog *ui_;
|
||||
|
@ -12,12 +12,12 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="layout_left">
|
||||
<item>
|
||||
<widget class="QLabel" name="icon"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<spacer name="spacer_left">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@ -32,12 +32,28 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="layout_centre">
|
||||
<item>
|
||||
<widget class="QLabel" name="label"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="list"/>
|
||||
<widget class="QListWidget" name="files"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="log"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_bottom">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
|
@ -303,7 +303,7 @@ void TranscodeDialog::SetFilenames(const QStringList &filenames) {
|
||||
|
||||
void TranscodeDialog::Remove() { qDeleteAll(ui_->files->selectedItems()); }
|
||||
|
||||
void TranscodeDialog::LogLine(const QString &message) {
|
||||
void TranscodeDialog::LogLine(const QString message) {
|
||||
|
||||
QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
|
||||
log_ui_->log->appendPlainText(QString("%1: %2").arg(date, message));
|
||||
|
@ -62,8 +62,8 @@ class TranscodeDialog : public QDialog {
|
||||
void Start();
|
||||
void Cancel();
|
||||
void JobComplete(const QString &input, const QString &output, bool success);
|
||||
void LogLine(const QString &message);
|
||||
void AllJobsComplete();
|
||||
void LogLine(const QString message);
|
||||
void Options();
|
||||
void AddDestination();
|
||||
|
||||
|
@ -75,7 +75,7 @@ class Transcoder : public QObject {
|
||||
void Start();
|
||||
void Cancel();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void JobComplete(const QString &input, const QString &output, bool success);
|
||||
void LogLine(const QString &message);
|
||||
void AllJobsComplete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user