From 6d47b5869d4b328614e5e95e97ef66d97009295e Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Wed, 15 Jun 2022 22:03:27 +0800 Subject: [PATCH] filewidgets: update location text after selected files are renamed Before this commit, the location text is not updated after the selected files are renamed. BUG: 455327 --- src/filewidgets/kdiroperator.cpp | 3 ++- src/filewidgets/kdiroperator.h | 9 +++++++++ src/filewidgets/kfilewidget.cpp | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/filewidgets/kdiroperator.cpp b/src/filewidgets/kdiroperator.cpp index c7a1c9350..adacfda60 100644 --- a/src/filewidgets/kdiroperator.cpp +++ b/src/filewidgets/kdiroperator.cpp @@ -889,8 +889,9 @@ void KDirOperator::renameSelected() } KIO::RenameFileDialog *dialog = new KIO::RenameFileDialog(items, this); - connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, [this]() { + connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, [this](const QList &urls) { d->assureVisibleSelection(); + Q_EMIT renamingFinished(urls); }); dialog->open(); diff --git a/src/filewidgets/kdiroperator.h b/src/filewidgets/kdiroperator.h index cb9668fb7..a15e90765 100644 --- a/src/filewidgets/kdiroperator.h +++ b/src/filewidgets/kdiroperator.h @@ -824,6 +824,7 @@ public Q_SLOTS: /** * Initiates a rename operation on the currently selected files/directories, * prompting the user to choose a new name(s) for the currently selected items + * @see renamingFinished * @since 5.67 */ void renameSelected(); @@ -991,6 +992,14 @@ Q_SIGNALS: */ void keyEnterReturnPressed(); + /** + * Emitted when renaming selected files has finished. + * + * @param urls URL list of the renamed files + * @since 5.96 + */ + void renamingFinished(const QList &urls); + private: friend class KDirOperatorPrivate; std::unique_ptr d; diff --git a/src/filewidgets/kfilewidget.cpp b/src/filewidgets/kfilewidget.cpp index 943c0cd93..d0825dfaa 100644 --- a/src/filewidgets/kfilewidget.cpp +++ b/src/filewidgets/kfilewidget.cpp @@ -1185,6 +1185,10 @@ void KFileWidgetPrivate::initDirOpWidgets() q->connect(m_ops, &KDirOperator::keyEnterReturnPressed, q, [this]() { slotViewKeyEnterReturnPressed(); }); + q->connect(m_ops, &KDirOperator::renamingFinished, q, [this](const QList &urls) { + // Update file names in location text field after renaming selected files + q->setSelectedUrls(urls); + }); m_ops->dirLister()->setAutoErrorHandlingEnabled(false); q->connect(m_ops->dirLister(), &KDirLister::jobError, q, [this](KIO::Job *job) { -- GitLab