]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix scrolling to renamed file when using the rename dialog
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 3 Jun 2018 16:28:23 +0000 (18:28 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Tue, 5 Jun 2018 20:07:45 +0000 (22:07 +0200)
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
src/views/dolphinview.cpp
src/views/renamedialog.cpp
src/views/renamedialog.h

index 61417dc5ee4df1e27f56fb78a5369616eaf39cd8..7a0b4b6b245b88beb31ba1053eef49e23532dba4 100644 (file)
@@ -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();
index acd66eb572169ee8a2dbc83f0d413a872eefb2f5..342c226382ae561fef05fd1af3e14f619bc82ed7 100644 (file)
@@ -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();
index e49f56e2de6266b0ae92f445c7792c27f3fdfe52..c9f9c177b08db55972d383994e67d208da075783 100644 (file)
@@ -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);
 
index 5b04f857cfdcb398575efcb6aa652b66aee3ce3e..08571cd9d2ce57732dbbed626c7b952cacb521ad 100644 (file)
@@ -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
 {