From 70809e0647c9dd87e15a47bb47fde666811d4afc Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 3 Apr 2024 21:37:20 +0200 Subject: [PATCH] MainWindow: Add error dialog when file deletion fails Fixes #1384 --- src/core/mainwindow.cpp | 14 +++++++++++++- src/core/mainwindow.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 0195f2c0..5130cdff 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -204,6 +204,8 @@ #include "smartplaylists/smartplaylistsviewcontainer.h" +#include "organize/organizeerrordialog.h" + #ifdef Q_OS_WIN # include "windows7thumbbar.h" #endif @@ -3239,11 +3241,21 @@ void MainWindow::PlaylistDelete() { SharedPtr storage = make_shared(Song::Source::LocalFile, "/"); DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true); - //QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFinished); + QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFilesFinished); delete_files->Start(selected_songs); } +void MainWindow::DeleteFilesFinished(const SongList &songs_with_errors) { + + if (songs_with_errors.isEmpty()) return; + + OrganizeErrorDialog *dialog = new OrganizeErrorDialog(this); + dialog->Show(OrganizeErrorDialog::OperationType::Delete, songs_with_errors); + // It deletes itself when the user closes it + +} + void MainWindow::FocusSearchField() { if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(collection_view_) && !collection_view_->filter_widget()->SearchFieldHasFocus()) { diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 6053f92e..05bda24b 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -270,6 +270,8 @@ class MainWindow : public QMainWindow, public PlatformInterface { void FocusSearchField(); + void DeleteFilesFinished(const SongList &songs_with_errors); + public slots: void CommandlineOptionsReceived(const QByteArray &string_options); void Raise();