]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Allow to copy or move selection to the other split view
[dolphin.git] / src / dolphinmainwindow.cpp
index 77937790aa08ea286f991b27b568966ea19f7812..668f511ee0eedca94e4648b7a883ed3057f191fb 100644 (file)
@@ -654,12 +654,12 @@ void DolphinMainWindow::undo()
 
 void DolphinMainWindow::cut()
 {
-    m_activeViewContainer->view()->cutSelectedItems();
+    m_activeViewContainer->view()->cutSelectedItemsToClipboard();
 }
 
 void DolphinMainWindow::copy()
 {
-    m_activeViewContainer->view()->copySelectedItems();
+    m_activeViewContainer->view()->copySelectedItemsToClipboard();
 }
 
 void DolphinMainWindow::paste()
@@ -1149,6 +1149,8 @@ void DolphinMainWindow::updateControlMenu()
 
     // 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 @@ void DolphinMainWindow::setupActions()
         "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
         "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 <emphasis>active</emphasis> 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 <emphasis>active</emphasis> 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 @@ void DolphinMainWindow::updateFileAndEditActions()
 {
     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 @@ void DolphinMainWindow::updateFileAndEditActions()
             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());
     }
 }