From e308985de4b355e5758c916ba683040f6f394603 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 3 Jun 2018 18:28:23 +0200 Subject: [PATCH] Fix scrolling to renamed file when using the rename dialog Summary: The `RenameDialog::slotResult()` slot is currently never called because the dialog is deleted first, due to the usage of the `WA_DeleteOnClose` attribute. This breaks the scroll-to-renamed-file feature when the inline renaming is disabled. Instead of deleting the dialog on close, we can use `deleteLater()` when we are sure the dialog has actually finished its job, which is when the KIO move job emits the `result` signal. Test Plan: - Disable inline renaming - Rename a file so that it goes out of the view - Check whether the view scrolls to the renamed file. Reviewers: #dolphin, emateli Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D13304 --- src/panels/folders/folderspanel.cpp | 1 - src/views/dolphinview.cpp | 2 -- src/views/renamedialog.cpp | 2 ++ src/views/renamedialog.h | 2 ++ 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 61417dc5ee..7a0b4b6b24 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -105,7 +105,6 @@ void FoldersPanel::rename(const KFileItem& item) m_controller->view()->editRole(index, "text"); } else { RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item); - dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); dialog->raise(); dialog->activateWindow(); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index acd66eb572..342c226382 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -634,10 +634,8 @@ void DolphinView::renameSelectedItems() this, &DolphinView::slotRoleEditingFinished); } else { RenameDialog* dialog = new RenameDialog(this, items); - connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished); - dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); dialog->raise(); dialog->activateWindow(); diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index e49f56e2de..c9f9c177b0 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -62,6 +62,7 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) : m_okButton->setShortcut(Qt::CTRL + Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &RenameDialog::slotAccepted); connect(buttonBox, &QDialogButtonBox::rejected, this, &RenameDialog::reject); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QObject::deleteLater); m_okButton->setDefault(true); KGuiItem::assign(m_okButton, KGuiItem(i18nc("@action:button", "&Rename"), QStringLiteral("dialog-ok-apply"))); @@ -178,6 +179,7 @@ void RenameDialog::slotAccepted() KIO::FileUndoManager::self()->recordJob(cmdType, srcList, parentUrl, job); connect(job, &KJob::result, this, &RenameDialog::slotResult); + connect(job, &KJob::result, this, &QObject::deleteLater); job->uiDelegate()->setAutoErrorHandlingEnabled(true); diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h index 5b04f857cf..08571cd9d2 100644 --- a/src/views/renamedialog.h +++ b/src/views/renamedialog.h @@ -33,6 +33,8 @@ class QPushButton; class KJob; /** * @brief Dialog for renaming a variable number of files. + * + * The dialog deletes itself when accepted or rejected. */ class DOLPHIN_EXPORT RenameDialog : public QDialog {