Skip to content

Commit

Permalink
organise: Update the song preview when the selected destination's dat…
Browse files Browse the repository at this point in the history
…a changes

This will cause the file exensions to change when transcode options are changed.
  • Loading branch information
jbroadus authored and hatstand committed Jun 7, 2020
1 parent 4dd3233 commit c299c19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/ui/organisedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ void OrganiseDialog::SetDestinationModel(QAbstractItemModel* model,
ui_->destination->setModel(model);

ui_->eject_after->setVisible(devices);

// In case this is called more than once, disconnect old model.
if (model_connection_) disconnect(model_connection_);
// If a device changes, transcoding options may have changed.
model_connection_ =
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(DestDataChanged(QModelIndex, QModelIndex)));
}

bool OrganiseDialog::SetSongs(const SongList& songs) {
Expand Down Expand Up @@ -306,6 +313,16 @@ void OrganiseDialog::UpdatePreviews() {
}
}

void OrganiseDialog::DestDataChanged(const QModelIndex& begin,
const QModelIndex& end) {
const QModelIndex destination =
ui_->destination->model()->index(ui_->destination->currentIndex(), 0);
if (QItemSelection(begin, end).contains(destination)) {
qLog(Debug) << "Destination data changed";
UpdatePreviews();
}
}

QSize OrganiseDialog::sizeHint() const { return QSize(650, 0); }

void OrganiseDialog::Reset() {
Expand Down
6 changes: 5 additions & 1 deletion src/ui/organisedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OrganiseDialog : public QDialog {

void SetCopy(bool copy);

signals:
signals:
void FileCopied(int);

public slots:
Expand All @@ -80,6 +80,8 @@ class OrganiseDialog : public QDialog {
void InsertTag(const QString& tag);
void UpdatePreviews();

void DestDataChanged(const QModelIndex& begin, const QModelIndex& end);

void OrganiseFinished(const QStringList& files_with_errors);

private:
Expand All @@ -93,6 +95,8 @@ class OrganiseDialog : public QDialog {
TaskManager* task_manager_;
LibraryBackend* backend_;

QMetaObject::Connection model_connection_;

OrganiseFormat format_;

QFuture<SongList> songs_future_;
Expand Down

0 comments on commit c299c19

Please sign in to comment.