diff --git a/doc/index.docbook b/doc/index.docbook
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1729,6 +1729,29 @@
+
+
+
+&Ctrl;F5
+
+Edit
+Copy to inactive split view
+
+Copies the currently selected item(s) from the active split view to the inactive split view.
+
+
+
+
+
+&Ctrl;F6
+
+Edit
+Move to inactive split 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.cpp b/src/dolphinmainwindow.cpp
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1149,6 +1149,8 @@
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
+ addActionToMenu(ac->action(QStringLiteral("copy_to_inactive_split_view")), menu) |
+ addActionToMenu(ac->action(QStringLiteral("move_to_inactive_split_view")), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu);
@@ -1382,6 +1384,24 @@
"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_inactive_split_view"));
+ copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to inactive split view"));
+ copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
+ "the active view to the inactive split view."));
+ copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
+ copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to inactive split view"));
+ actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT + Qt::Key_F5 );
+ connect(copyToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::copyToInactiveSplitView);
+
+ QAction* moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
+ moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to inactive split view"));
+ moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
+ "the active view to the inactive split view."));
+ moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
+ moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to inactive split view"));
+ actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT + Qt::Key_F6 );
+ connect(moveToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::moveToInactiveSplitView);
+
QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
searchAction->setText(i18n("Search..."));
searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
@@ -1907,12 +1927,18 @@
{
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
const KActionCollection* col = actionCollection();
+ KFileItemListProperties capabilitiesSource(list);
+
QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places"));
+ QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
+ QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_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,16 +1956,32 @@
addToPlacesAction->setEnabled(false);
}
- KFileItemListProperties capabilities(list);
- const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
+ if (m_tabWidget->currentTabPage()->splitViewEnabled()) {
+ DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
+ KFileItem capabilitiesDestination;
+
+ if (tabPage->primaryViewActive()) {
+ capabilitiesDestination = tabPage->secondaryViewContainer()->url();
+ } else {
+ capabilitiesDestination = tabPage->primaryViewContainer()->url();
+ }
+
+ copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable());
+ moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving() && capabilitiesDestination.isWritable());
+ } else {
+ copyToOtherViewAction->setEnabled(false);
+ moveToOtherViewAction->setEnabled(false);
+ }
+
+ const bool enableMoveToTrash = capabilitiesSource.isLocal() && capabilitiesSource.supportsMoving();
- renameAction->setEnabled(capabilities.supportsMoving());
+ renameAction->setEnabled(capabilitiesSource.supportsMoving());
moveToTrashAction->setEnabled(enableMoveToTrash);
- deleteAction->setEnabled(capabilities.supportsDeleting());
- deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
- cutAction->setEnabled(capabilities.supportsMoving());
+ deleteAction->setEnabled(capabilitiesSource.supportsDeleting());
+ deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash);
+ cutAction->setEnabled(capabilitiesSource.supportsMoving());
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
- duplicateAction->setEnabled(capabilities.supportsWriting());
+ duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}
}
diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h
--- a/src/dolphintabwidget.h
+++ b/src/dolphintabwidget.h
@@ -189,6 +189,12 @@
*/
void restoreClosedTab(const QByteArray& state);
+ /** Copies all selected items to the inactive view. */
+ void copyToInactiveSplitView();
+
+ /** Moves all selected items to the inactive view. */
+ void moveToInactiveSplitView();
+
private slots:
/**
* Opens the tab with the index \a index in a new Dolphin instance and closes
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -320,6 +320,40 @@
currentTabPage()->restoreState(state);
}
+void DolphinTabWidget::copyToInactiveSplitView()
+{
+ const DolphinTabPage* tabPage = tabPageAt(currentIndex());
+ DolphinViewContainer* activeViewContainer = currentTabPage()->activeViewContainer();
+ if (!tabPage->splitViewEnabled() || activeViewContainer->view()->selectedItems().isEmpty()) {
+ return;
+ }
+
+ if (tabPage->primaryViewActive()) {
+ // copy from left panel to right
+ activeViewContainer->view()->copySelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+ } else {
+ // copy from right panel to left
+ activeViewContainer->view()->copySelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+ }
+}
+
+void DolphinTabWidget::moveToInactiveSplitView()
+{
+ const DolphinTabPage* tabPage = tabPageAt(currentIndex());
+ DolphinViewContainer* activeViewContainer = currentTabPage()->activeViewContainer();
+ if (!tabPage->splitViewEnabled() || activeViewContainer->view()->selectedItems().isEmpty()) {
+ return;
+ }
+
+ if (tabPage->primaryViewActive()) {
+ // move from left panel to right
+ activeViewContainer->view()->moveSelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+ } else {
+ // move from right panel to left
+ activeViewContainer->view()->moveSelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+ }
+}
+
void DolphinTabWidget::detachTab(int index)
{
Q_ASSERT(index >= 0);
diff --git a/src/dolphinui.rc b/src/dolphinui.rc
--- a/src/dolphinui.rc
+++ b/src/dolphinui.rc
@@ -1,5 +1,5 @@
-
+
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -370,6 +370,18 @@
/** Copies all selected items to the clipboard. */
void copySelectedItemsToClipboard();
+ /**
+ * Copies all selected items to the inactive split view.
+ * Only used in Split View.
+ */
+ void copySelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl);
+
+ /**
+ * Moves all selected items to the inactive split view.
+ * Only used in Split View.
+ */
+ void moveSelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl);
+
/** Pastes the clipboard data to this view. */
void paste();
@@ -608,15 +620,16 @@
void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
void slotRenameDialogRenamingFinished(const QList& urls);
void slotSelectedItemTextPressed(int index);
+ void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to);
/*
* Is called when new items get pasted or dropped.
*/
void slotItemCreated(const QUrl &url);
/*
* Is called after all pasted or dropped items have been copied to destination.
*/
- void slotPasteJobResult(KJob *job);
+ void slotJobResult(KJob *job);
/**
* Emits the signal \a selectionChanged() with a small delay. This is
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,27 @@
QApplication::clipboard()->setMimeData(mimeData);
}
+void DolphinView::copySelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl)
+{
+ KIO::CopyJob* job = KIO::copy(selection.urlList(), destinationUrl, KIO::DefaultFlags);
+ KJobWidgets::setWindow(job, this);
+
+ connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotCopyingDone);
+ KIO::FileUndoManager::self()->recordCopyJob(job);
+}
+
+void DolphinView::moveSelectedItemsToInactiveSplitView(const KFileItemList &selection, const QUrl &destinationUrl)
+{
+ KIO::CopyJob* job = KIO::move(selection.urlList(), destinationUrl, KIO::DefaultFlags);
+ KJobWidgets::setWindow(job, this);
+
+ connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotCopyingDone);
+ KIO::FileUndoManager::self()->recordCopyJob(job);
+
+}
+
void DolphinView::paste()
{
pasteToUrl(url());
@@ -1132,7 +1153,7 @@
KIO::DropJob* job = DragAndDropHelper::dropUrls(destUrl, dropEvent, dropWidget);
if (job) {
- connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult);
+ connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
if (destUrl == url()) {
// Mark the dropped urls as selected.
@@ -1185,6 +1206,11 @@
}
}
+void DolphinView::slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to)
+{
+ slotItemCreated(to);
+}
+
void DolphinView::slotItemCreated(const QUrl& url)
{
if (m_markFirstNewlySelectedItemAsCurrent) {
@@ -1194,7 +1220,7 @@
m_selectedUrls << url;
}
-void DolphinView::slotPasteJobResult(KJob *job)
+void DolphinView::slotJobResult(KJob *job)
{
if (job->error()) {
emit errorMessage(job->errorString());
@@ -1845,7 +1871,7 @@
m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true;
connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
- connect(job, &KIO::PasteJob::result, this, &DolphinView::slotPasteJobResult);
+ connect(job, &KIO::PasteJob::result, this, &DolphinView::slotJobResult);
}
QList DolphinView::simplifiedSelectedUrls() const