+ m_disabledActionNotifier->setDisabledReason(duplicateAction,
+ i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder."));
+
+ if (enableMoveToTrash) {
+ moveToTrashAction->setEnabled(true);
+ deleteWithTrashShortcut->setEnabled(false);
+ m_disabledActionNotifier->clearDisabledReason(deleteWithTrashShortcut);
+ } else {
+ moveToTrashAction->setEnabled(false);
+ deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting());
+ m_disabledActionNotifier->setDisabledReason(deleteWithTrashShortcut,
+ i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
+ }
+ }
+
+ if (!m_tabWidget->currentTabPage()->splitViewEnabled()) {
+ // No need to set the disabled reason here, as it's obvious to the user that the reason is the split view being disabled.
+ copyToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->clearDisabledReason(copyToOtherViewAction);
+ moveToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->clearDisabledReason(moveToOtherViewAction);
+ } else if (list.isEmpty()) {
+ copyToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, i18nc("@info", "Cannot copy to other view: No files selected."));
+ moveToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, i18nc("@info", "Cannot move to other view: No files selected."));
+ } else {
+ DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+ KFileItem capabilitiesDestination;
+
+ if (tabPage->primaryViewActive()) {
+ capabilitiesDestination = tabPage->secondaryViewContainer()->rootItem();
+ } else {
+ capabilitiesDestination = tabPage->primaryViewContainer()->rootItem();
+ }
+
+ 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;
+ });
+
+ if (!allNotTargetOrigin) {
+ copyToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction,
+ i18nc("@info", "Cannot copy to other view: The other view already contains these items."));
+ moveToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction,
+ i18nc("@info", "Cannot move to other view: The other view already contains these items."));
+ } else if (!capabilitiesDestination.isWritable()) {
+ copyToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(
+ copyToOtherViewAction,
+ i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder."));
+ moveToOtherViewAction->setEnabled(false);
+ m_disabledActionNotifier->setDisabledReason(
+ moveToOtherViewAction,
+ i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder."));
+ } else {
+ copyToOtherViewAction->setEnabled(true);
+ moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving());
+ m_disabledActionNotifier->setDisabledReason(
+ moveToOtherViewAction,
+ i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder."));
+ }