┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2023-04-02 07:22:07 +0000
committerMéven Car <[email protected]>2023-04-02 07:22:07 +0000
commit9061b22a0d0bc6bd7b9a1c31a5296bd00af60d0b (patch)
tree8ff98a07139bb83353313600ffa033008adb68a2 /src
parentcdf56e761de86caca644c07a52de28163d430127 (diff)
Context menu: allow to show copy to/move to inactive split view
Prevent copying/moving to same folder as origin when copying/moving to inactive split view BUG: 356436
Diffstat (limited to 'src')
-rw-r--r--src/dolphincontextmenu.cpp10
-rw-r--r--src/dolphinmainwindow.cpp27
-rw-r--r--src/dolphinmainwindow.h1
-rw-r--r--src/settings/contextmenu/contextmenusettingspage.cpp8
-rw-r--r--src/settings/dolphin_contextmenusettings.kcfg8
-rw-r--r--src/settings/dolphinsettingsdialog.cpp4
6 files changed, 50 insertions, 8 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index 94fed1872..a5b033c71 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -257,6 +257,16 @@ void DolphinContextMenu::addItemContextMenu()
m_copyToMenu.addActionsTo(this);
}
+ if (m_mainWindow->isSplitViewEnabledInCurrentTab()) {
+ if (ContextMenuSettings::showCopyToOtherSplitView()) {
+ addAction(m_mainWindow->actionCollection()->action(QStringLiteral("copy_to_inactive_split_view")));
+ }
+
+ if (ContextMenuSettings::showMoveToOtherSplitView()) {
+ addAction(m_mainWindow->actionCollection()->action(QStringLiteral("move_to_inactive_split_view")));
+ }
+ }
+
// insert 'Properties...' entry
addSeparator();
QAction *propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 9c3d9862b..5061a10af 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -88,6 +88,8 @@
#include <QTimer>
#include <QToolButton>
+#include <algorithm>
+
namespace
{
// Used for GeneralSettings::version() to determine whether
@@ -265,6 +267,11 @@ bool DolphinMainWindow::isInformationPanelEnabled() const
#endif
}
+bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const
+{
+ return m_tabWidget->currentTabPage()->splitViewEnabled();
+}
+
void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
{
openFiles(QUrl::fromStringList(files), splitView);
@@ -1609,8 +1616,8 @@ void DolphinMainWindow::setupActions()
+ cutCopyPastePara);
QAction *copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
- copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
- m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Inactive Split View…"));
+ copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Other View"));
+ m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Other View…"));
copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy",
"This copies the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
@@ -1620,8 +1627,8 @@ void DolphinMainWindow::setupActions()
connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView);
QAction *moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
- moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
- m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Inactive Split View…"));
+ moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Other View"));
+ m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Other View…"));
moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move",
"This moves the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
@@ -2280,7 +2287,7 @@ void DolphinMainWindow::updateFileAndEditActions()
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}
- if (m_tabWidget->currentTabPage()->splitViewEnabled()) {
+ if (m_tabWidget->currentTabPage()->splitViewEnabled() && !list.isEmpty()) {
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
KFileItem capabilitiesDestination;
@@ -2290,8 +2297,14 @@ void DolphinMainWindow::updateFileAndEditActions()
capabilitiesDestination = tabPage->primaryViewContainer()->rootItem();
}
- copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable());
- moveToOtherViewAction->setEnabled((list.isEmpty() || capabilitiesSource.supportsMoving()) && capabilitiesDestination.isWritable());
+ const auto destUrl = capabilitiesDestination.url();
+ const bool allNotTargetOrigin = std::all_of(list.cbegin(), list.cend(), [destUrl](const KFileItem &item) {
+ return item.url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash) != destUrl;
+ });
+
+ copyToOtherViewAction->setEnabled(capabilitiesDestination.isWritable() && allNotTargetOrigin);
+ moveToOtherViewAction->setEnabled((list.isEmpty() || capabilitiesSource.supportsMoving()) && capabilitiesDestination.isWritable()
+ && allNotTargetOrigin);
} else {
copyToOtherViewAction->setEnabled(false);
moveToOtherViewAction->setEnabled(false);
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 3a97f557c..2c6874966 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -118,6 +118,7 @@ public:
bool isFoldersPanelEnabled() const;
bool isInformationPanelEnabled() const;
+ bool isSplitViewEnabledInCurrentTab() const;
public Q_SLOTS:
/**
diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp
index 2205fadd0..c363914d0 100644
--- a/src/settings/contextmenu/contextmenusettingspage.cpp
+++ b/src/settings/contextmenu/contextmenusettingspage.cpp
@@ -129,6 +129,10 @@ bool ContextMenuSettingsPage::entryVisible(const QString &id)
return ContextMenuSettings::showDuplicateHere();
} else if (id == "open_terminal_here") {
return ContextMenuSettings::showOpenTerminal();
+ } else if (id == "copy_to_inactive_split_view") {
+ return ContextMenuSettings::showCopyToOtherSplitView();
+ } else if (id == "move_to_inactive_split_view") {
+ return ContextMenuSettings::showMoveToOtherSplitView();
}
return false;
}
@@ -151,6 +155,10 @@ void ContextMenuSettingsPage::setEntryVisible(const QString &id, bool visible)
ContextMenuSettings::setShowDuplicateHere(visible);
} else if (id == "open_terminal_here") {
ContextMenuSettings::setShowOpenTerminal(visible);
+ } else if (id == "copy_to_inactive_split_view") {
+ ContextMenuSettings::setShowCopyToOtherSplitView(visible);
+ } else if (id == "move_to_inactive_split_view") {
+ ContextMenuSettings::setShowMoveToOtherSplitView(visible);
}
}
diff --git a/src/settings/dolphin_contextmenusettings.kcfg b/src/settings/dolphin_contextmenusettings.kcfg
index 44fd83513..63ca079af 100644
--- a/src/settings/dolphin_contextmenusettings.kcfg
+++ b/src/settings/dolphin_contextmenusettings.kcfg
@@ -42,5 +42,13 @@
<label>Show 'Open Terminal' in context menu.</label>
<default>true</default>
</entry>
+ <entry name="ShowCopyToOtherSplitView" type="Bool">
+ <label>Show 'Copy to other split view' in context menu.</label>
+ <default>true</default>
+ </entry>
+ <entry name="ShowMoveToOtherSplitView" type="Bool">
+ <label>Show 'Move to other split view' in context menu.</label>
+ <default>true</default>
+ </entry>
</group>
</kcfg>
diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp
index ec92cb635..af3dbc865 100644
--- a/src/settings/dolphinsettingsdialog.cpp
+++ b/src/settings/dolphinsettingsdialog.cpp
@@ -84,7 +84,9 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K
QStringLiteral("open_in_new_window"),
QStringLiteral("copy_location"),
QStringLiteral("duplicate"),
- QStringLiteral("open_terminal_here")});
+ QStringLiteral("open_terminal_here"),
+ QStringLiteral("copy_to_inactive_split_view"),
+ QStringLiteral("move_to_inactive_split_view")});
KPageWidgetItem *contextMenuSettingsFrame = addPage(contextMenuSettingsPage, i18nc("@title:group", "Context Menu"));
contextMenuSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-menu-edit")));
connect(contextMenuSettingsPage, &ContextMenuSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);