diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1725,6 +1725,29 @@ + + + +&Ctrl;F5 + +Edit +Copy selection to the other view + +Copies the currently selected item(s) from the active split view to the inactive split view. + + + + + +&Ctrl;F6 + +Edit +Move selection to the other view + +Moves the currently selected item(s) from the active split view to the inactive split view. +Is disabled if the current user does not have write permission on the selected item(s). + + diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -254,6 +254,12 @@ /** Pastes the clipboard data to the active view. */ void paste(); + /** Copies all selected items to the other view. */ + void copyToOtherView(); + + /** Moves all selected items to the other view. */ + void moveToOtherView(); + /** Replaces the URL navigator by a search box to find files. */ void find(); diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -667,6 +667,38 @@ m_activeViewContainer->view()->paste(); } +void DolphinMainWindow::copyToOtherView() +{ + const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); + if (!tabPage->splitViewEnabled() || m_activeViewContainer->view()->selectedItems().isEmpty()) { + return; + } + + if (tabPage->primaryViewActive()) { + // copy from left panel to right + m_activeViewContainer->view()->copySelectedItemsToOtherSplitView(m_activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url()); + } else { + // copy from right panel to left + m_activeViewContainer->view()->copySelectedItemsToOtherSplitView(m_activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url()); + } +} + +void DolphinMainWindow::moveToOtherView() +{ + const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); + if (!tabPage->splitViewEnabled() || m_activeViewContainer->view()->selectedItems().isEmpty()) { + return; + } + + if (tabPage->primaryViewActive()) { + // move from left panel to right + m_activeViewContainer->view()->moveSelectedItemsToOtherSplitView(m_activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url()); + } else { + // move from right panel to left + m_activeViewContainer->view()->moveSelectedItemsToOtherSplitView(m_activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url()); + } +} + void DolphinMainWindow::find() { m_activeViewContainer->setSearchModeEnabled(true); @@ -1149,6 +1181,8 @@ // Add "Edit" actions bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) | + addActionToMenu(ac->action(QStringLiteral("copy_to_other_split_view")), menu) | + addActionToMenu(ac->action(QStringLiteral("move_to_other_split_view")), menu) | addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) | addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu); @@ -1377,11 +1411,29 @@ // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes // due to the long text, the text "Paste" is used: paste->setIconText(i18nc("@action:inmenu Edit", "Paste")); - paste->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from " + paste->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the selected items from " "your clipboard to the currently viewed folder." "If the items were added to the clipboard by the Cut " "action they are removed from their old location.") + cutCopyPastePara); + QAction* copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_other_split_view")); + copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy selection to the other view")); + copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from " + "the active view to the other split view.")); + copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to other view")); + actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::CTRL + Qt::Key_F5 ); + connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToOtherView); + + QAction* moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_other_split_view")); + moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move selection to the other view")); + moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from " + "the active view to the other split view.")); + moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); + moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to other view")); + actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::CTRL + Qt::Key_F6 ); + connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToOtherView); + QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); searchAction->setText(i18n("Search...")); searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders")); @@ -1907,12 +1959,18 @@ { const KFileItemList list = m_activeViewContainer->view()->selectedItems(); const KActionCollection* col = actionCollection(); + KFileItemListProperties capabilities(list); + QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); + QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_other_split_view")); + QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_other_split_view")); if (list.isEmpty()) { stateChanged(QStringLiteral("has_no_selection")); addToPlacesAction->setEnabled(true); + copyToOtherViewAction->setEnabled(false); + moveToOtherViewAction->setEnabled(false); } else { stateChanged(QStringLiteral("has_selection")); @@ -1930,7 +1988,14 @@ addToPlacesAction->setEnabled(false); } - KFileItemListProperties capabilities(list); + if (m_tabWidget->currentTabPage()->splitViewEnabled()) { + copyToOtherViewAction->setEnabled(true); + moveToOtherViewAction->setEnabled(capabilities.supportsMoving()); + } else { + copyToOtherViewAction->setEnabled(false); + moveToOtherViewAction->setEnabled(false); + } + const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); renameAction->setEnabled(capabilities.supportsMoving()); diff --git a/src/dolphinui.rc b/src/dolphinui.rc --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -1,5 +1,5 @@ - + @@ -20,6 +20,8 @@ + + diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -364,6 +364,18 @@ /** Copies all selected items to the clipboard. */ void copySelectedItems(); + /** + * Copies all selected items to the other view. + * Only available in Split View. + */ + void copySelectedItemsToOtherSplitView(const KFileItemList &selection, const QUrl &destinationPanelUrl); + + /** + * Moves all selected items to the other view. + * Only available in Split View. + */ + void moveSelectedItemsToOtherSplitView(const KFileItemList &selection, const QUrl &destinationPanelUrl); + /** Pastes the clipboard data to this view. */ void paste(); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -692,6 +692,25 @@ QApplication::clipboard()->setMimeData(mimeData); } +void DolphinView::copySelectedItemsToOtherSplitView(const KFileItemList &selection, const QUrl &destinationPanelUrl) +{ + KIO::CopyJob* job = KIO::copy(selection.urlList(), destinationPanelUrl, KIO::DefaultFlags); + KJobWidgets::setWindow(job, this); + + KIO::FileUndoManager::self()->recordCopyJob(job); +} + +void DolphinView::moveSelectedItemsToOtherSplitView(const KFileItemList &selection, const QUrl &destinationPanelUrl) +{ + KIO::CopyJob* job = KIO::move(selection.urlList(), destinationPanelUrl, KIO::DefaultFlags); + KJobWidgets::setWindow(job, this); + + connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult); + + KIO::FileUndoManager::self()->recordCopyJob(job); + +} + void DolphinView::paste() { pasteToUrl(url());