Prevent copying/moving to same folder as origin when copying/moving to inactive split view
BUG: 356436
m_copyToMenu.addActionsTo(this);
}
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"));
// insert 'Properties...' entry
addSeparator();
QAction *propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
#include <QTimer>
#include <QToolButton>
#include <QTimer>
#include <QToolButton>
namespace
{
// Used for GeneralSettings::version() to determine whether
namespace
{
// Used for GeneralSettings::version() to determine whether
+bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const
+{
+ return m_tabWidget->currentTabPage()->splitViewEnabled();
+}
+
void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
{
openFiles(QUrl::fromStringList(files), splitView);
void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
{
openFiles(QUrl::fromStringList(files), splitView);
+ cutCopyPastePara);
QAction *copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
+ 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."));
copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy",
"This copies the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView);
QAction *moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
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."));
moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move",
"This moves the selected items from "
"the <emphasis>active</emphasis> view to the inactive split view."));
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}
- if (m_tabWidget->currentTabPage()->splitViewEnabled()) {
+ if (m_tabWidget->currentTabPage()->splitViewEnabled() && !list.isEmpty()) {
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
KFileItem capabilitiesDestination;
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
KFileItem capabilitiesDestination;
capabilitiesDestination = tabPage->primaryViewContainer()->rootItem();
}
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);
} else {
copyToOtherViewAction->setEnabled(false);
moveToOtherViewAction->setEnabled(false);
bool isFoldersPanelEnabled() const;
bool isInformationPanelEnabled() const;
bool isFoldersPanelEnabled() const;
bool isInformationPanelEnabled() const;
+ bool isSplitViewEnabledInCurrentTab() const;
return ContextMenuSettings::showDuplicateHere();
} else if (id == "open_terminal_here") {
return ContextMenuSettings::showOpenTerminal();
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();
ContextMenuSettings::setShowDuplicateHere(visible);
} else if (id == "open_terminal_here") {
ContextMenuSettings::setShowOpenTerminal(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);
<label>Show 'Open Terminal' in context menu.</label>
<default>true</default>
</entry>
<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>
QStringLiteral("open_in_new_window"),
QStringLiteral("copy_location"),
QStringLiteral("duplicate"),
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);
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);