From 0006e9997e86f5522375dc082d890e0c5710a0a2 Mon Sep 17 00:00:00 2001 From: Ben Cooksley Date: Tue, 12 Sep 2017 07:25:25 +1200 Subject: Qt 5 Porting: Q_WS_WIN -> Q_OS_WIN (cherry picked from commit 4c1df50d522a09577274e19a8fe66bd865f3a2da) --- src/kitemviews/private/kdirectorycontentscounterworker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.cpp b/src/kitemviews/private/kdirectorycontentscounterworker.cpp index e649c20e1..47fbb5dd5 100644 --- a/src/kitemviews/private/kdirectorycontentscounterworker.cpp +++ b/src/kitemviews/private/kdirectorycontentscounterworker.cpp @@ -21,7 +21,7 @@ #include "kdirectorycontentscounterworker.h" // Required includes for subItemsCount(): -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #else #include @@ -39,7 +39,7 @@ int KDirectoryContentsCounterWorker::subItemsCount(const QString& path, Options const bool countHiddenFiles = options & CountHiddenFiles; const bool countDirectoriesOnly = options & CountDirectoriesOnly; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QDir dir(path); QDir::Filters filters = QDir::NoDotAndDotDot | QDir::System; if (countHiddenFiles) { -- cgit v1.3 From cdd002c57cde0480e6e02c7942e9b92af9d0a3e7 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sat, 2 Sep 2017 16:28:49 +0200 Subject: Make sure we always have Shift+Del as shortcut After commit 68bb0ec22a the shortcut for the Delete action is not necessarily Shift+Del, but whatever the user set in System Setting. However DolphinRemoveAction assumes/hardcodes Shift+Del, so we should always make sure we have this shortcut around, for consistency. We just need to add it (if necessary) to the list of shortcuts of the action. However: * for the actual Delete action, we need to append it (if we'd prepend it, it would override a custom primary shortcut in the 'Configure Shortcuts' dialog). * for DolphinRemoveAction, we need to prepend it in order to have Shift+Del (rather than the custom primary shortcut) in the context menu. Differential Revision: https://phabricator.kde.org/D7655 --- src/dolphinremoveaction.cpp | 7 ++++++- src/views/dolphinviewactionhandler.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp index ad00f6286..79d6bed60 100644 --- a/src/dolphinremoveaction.cpp +++ b/src/dolphinremoveaction.cpp @@ -48,14 +48,19 @@ void DolphinRemoveAction::update() if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) { m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)) : 0; setText(i18nc("@action:inmenu", "&Delete")); + // Make sure we show Shift+Del in the context menu. + auto deleteShortcuts = m_action->shortcuts(); + deleteShortcuts.removeAll(Qt::SHIFT | Qt::Key_Delete); + deleteShortcuts.prepend(Qt::SHIFT | Qt::Key_Delete); + m_collection->setDefaultShortcuts(this, deleteShortcuts); } else { m_action = m_collection ? m_collection->action(QStringLiteral("move_to_trash")) : 0; setText(i18nc("@action:inmenu", "&Move to Trash")); + m_collection->setDefaultShortcuts(this, m_action->shortcuts()); } if (m_action) { setIcon(m_action->icon()); - m_collection->setDefaultShortcuts(this, m_action->shortcuts()); setEnabled(m_action->isEnabled()); } } diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 7e52d5b28..f4104d9cf 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -120,7 +120,12 @@ void DolphinViewActionHandler::createActions() connect(moveToTrash, &QAction::triggered, this, &DolphinViewActionHandler::slotTrashActivated); - KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection); + auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection); + auto deleteShortcuts = deleteAction->shortcuts(); + if (!deleteShortcuts.contains(Qt::SHIFT | Qt::Key_Delete)) { + deleteShortcuts.append(Qt::SHIFT | Qt::Key_Delete); + m_actionCollection->setDefaultShortcuts(deleteAction, deleteShortcuts); + } // This action is useful for being enabled when "move_to_trash" should be // disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del -- cgit v1.3 From 478f404b8abf924a0e3e21bbf1dd49aefbe47672 Mon Sep 17 00:00:00 2001 From: Emirald Mateli Date: Sun, 17 Sep 2017 11:07:44 +0200 Subject: Keep renamed file(s) in view When renaming a file, if its new name causes it to scroll out of view, Dolphin will not scroll to the location of the new file. This patch aims to address that. This affects all view modes. CCBUG: 354330 Test Plan: 1. Have many files in a directory (or several files, just zoom in a lot) 2. Rename a file so that it will move out of view Differential Revision: https://phabricator.kde.org/D6312 --- src/views/dolphinview.cpp | 22 +++++++++++++++++++--- src/views/dolphinview.h | 9 +++++++++ src/views/renamedialog.cpp | 9 +++++++++ src/views/renamedialog.h | 4 ++++ 4 files changed, 41 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 5fcec9241..2ca51f52d 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -635,6 +635,9 @@ 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(); @@ -1308,9 +1311,7 @@ QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh void DolphinView::observeCreatedItem(const QUrl& url) { if (m_active) { - clearSelection(); - markUrlAsCurrent(url); - markUrlsAsSelected({url}); + forceUrlsSelection(url, {url}); } } @@ -1541,6 +1542,8 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); job->uiDelegate()->setAutoErrorHandlingEnabled(true); + forceUrlsSelection(newUrl, {newUrl}); + if (!newNameExistsAlready) { // Only connect the result signal if there is no item with the new name // in the model yet, see bug 328262. @@ -1747,3 +1750,16 @@ QUrl DolphinView::viewPropertiesUrl() const url.setPath(m_viewPropertiesContext); return url; } + +void DolphinView::slotRenameDialogRenamingFinished(const QList& urls) +{ + forceUrlsSelection(urls.first(), urls); +} + +void DolphinView::forceUrlsSelection(const QUrl& current, const QList& selected) +{ + clearSelection(); + m_clearSelectionBeforeSelectingNewItems = true; + markUrlAsCurrent(current); + markUrlsAsSelected(selected); +} diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 5c832efd1..911103b5d 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -576,6 +576,7 @@ private slots: void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); void slotModelChanged(KItemModelBase* current, KItemModelBase* previous); void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); + void slotRenameDialogRenamingFinished(const QList& urls); /* * Is called when new items get pasted or dropped. @@ -760,6 +761,14 @@ private: */ QUrl viewPropertiesUrl() const; + /** + * Clears the selection and updates current item and selection according to the parameters + * + * @param current URL to be set as current + * @param selected list of selected items + */ + void forceUrlsSelection(const QUrl& current, const QList& selected); + private: void updatePalette(); diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index df4827b3a..6309bfbdf 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -162,6 +162,11 @@ void RenameDialog::renameItem(const KFileItem &item, const QString& newName) KIO::Job * job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo); KJobWidgets::setWindow(job, widget); KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); + + if (!job->error()) { + m_renamedItems << newUrl; + } + job->uiDelegate()->setAutoErrorHandlingEnabled(true); } @@ -223,6 +228,10 @@ void RenameDialog::renameItems() renameItem(item, newName); } } + + if (!m_items.empty()) { + emit renamingFinished(m_renamedItems); + } } QString RenameDialog::indexedName(const QString& name, int index, const QChar& indexPlaceHolder) diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h index 3964c0a5c..7ead0ca9f 100644 --- a/src/views/renamedialog.h +++ b/src/views/renamedialog.h @@ -41,6 +41,9 @@ public: explicit RenameDialog(QWidget* parent, const KFileItemList& items); virtual ~RenameDialog(); +signals: + void renamingFinished(const QList& urls); + private slots: void slotAccepted(); void slotTextChanged(const QString& newName); @@ -63,6 +66,7 @@ private: private: bool m_renameOneItem; + QList m_renamedItems; QString m_newName; QLineEdit* m_lineEdit; KFileItemList m_items; -- cgit v1.3