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); @@ -1377,11 +1409,27 @@ // (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"))); + 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 items from " + "the active view to the other split view.")); + moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); + 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")); 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(KFileItemList selection, QUrl destinationPanelUrl); + + /** + * Moves all selected items to the other view. + * Only available in Split View. + */ + void moveSelectedItemsToOtherSplitView(KFileItemList selection, 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,30 @@ QApplication::clipboard()->setMimeData(mimeData); } +void DolphinView::copySelectedItemsToOtherSplitView(KFileItemList selection, QUrl destinationPanelUrl) +{ + KIO::CopyJob* job = KIO::copy(selection.urlList(), destinationPanelUrl, KIO::DefaultFlags); + KJobWidgets::setWindow(job, this); + + QList newSelection; + if (job) { + newSelection << destinationPanelUrl; + KIO::FileUndoManager::self()->recordCopyJob(job); + } +} + +void DolphinView::moveSelectedItemsToOtherSplitView(KFileItemList selection, QUrl destinationPanelUrl) +{ + KIO::CopyJob* job = KIO::move(selection.urlList(), destinationPanelUrl, KIO::DefaultFlags); + KJobWidgets::setWindow(job, this); + + QList newSelection; + if (job) { + newSelection << destinationPanelUrl; + KIO::FileUndoManager::self()->recordCopyJob(job); + } +} + void DolphinView::paste() { pasteToUrl(url());