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 opposite panel. */ + void copyToOppositePanel(); + + /** Moves all selected items to the opposite panel. */ + void moveToOppositePanel(); + /** 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 @@ -658,6 +658,38 @@ m_activeViewContainer->view()->paste(); } +void DolphinMainWindow::copyToOppositePanel() +{ + 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()->copySelectedItemsToOppositePanel(tabPage->secondaryViewContainer()->url()); + } else { + // copy from right panel to left + m_activeViewContainer->view()->copySelectedItemsToOppositePanel(tabPage->primaryViewContainer()->url()); + } +} + +void DolphinMainWindow::moveToOppositePanel() +{ + 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()->moveSelectedItemsToOppositePanel(tabPage->secondaryViewContainer()->url()); + } else { + // move from right panel to left + m_activeViewContainer->view()->moveSelectedItemsToOppositePanel(tabPage->primaryViewContainer()->url()); + } +} + void DolphinMainWindow::find() { m_activeViewContainer->setSearchModeEnabled(true); @@ -1373,6 +1405,22 @@ "If the items were added to the clipboard by the Cut " "action they are removed from their old location.") + cutCopyPastePara); + QAction* copyToOppositePanelAction = actionCollection()->addAction(QStringLiteral("copy_to_opposite_panel")); + copyToOppositePanelAction->setText(i18nc("@action:inmenu", "Copy to opposite panel")); + copyToOppositePanelAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the items from " + "the active panel to the inactive panel.")); + copyToOppositePanelAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + actionCollection()->setDefaultShortcut(copyToOppositePanelAction, Qt::CTRL + Qt::Key_F5 ); + connect(copyToOppositePanelAction, &QAction::triggered, this, &DolphinMainWindow::copyToOppositePanel); + + QAction* moveToOppositePanelAction = actionCollection()->addAction(QStringLiteral("move_to_opposite_panel")); + moveToOppositePanelAction->setText(i18nc("@action:inmenu", "Move to opposite panel")); + moveToOppositePanelAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the items from " + "the active panel to the inactive panel.")); + moveToOppositePanelAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); + actionCollection()->setDefaultShortcut(moveToOppositePanelAction, Qt::CTRL + Qt::Key_F6 ); + connect(moveToOppositePanelAction, &QAction::triggered, this, &DolphinMainWindow::moveToOppositePanel); + 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 opposite panel. + * Only available in Split View. + */ + void copySelectedItemsToOppositePanel(QUrl destinationPanelUrl); + + /** + * Moves all selected items to the opposite panel. + * Only available in Split View. + */ + void moveSelectedItemsToOppositePanel(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,18 @@ QApplication::clipboard()->setMimeData(mimeData); } +void DolphinView::copySelectedItemsToOppositePanel(QUrl destinationPanelUrl) +{ + copySelectedItems(); + pasteToUrl(destinationPanelUrl); +} + +void DolphinView::moveSelectedItemsToOppositePanel(QUrl destinationPanelUrl) +{ + cutSelectedItems(); + pasteToUrl(destinationPanelUrl); +} + void DolphinView::paste() { pasteToUrl(url());