Commit 6f3a4863 authored by Eike Hein's avatar Eike Hein

Swap Trash for Delete action when only one is enabled and the Shift modifier is pressed

Summary:
Now matches Dolphin behavior.

BUG:395155

Reviewers: broulik, davidedmundson, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D13508
parent 7909ca22
......@@ -273,12 +273,12 @@ FocusScope {
if (mouse.buttons & Qt.RightButton) {
clearPressState();
dir.openContextMenu();
dir.openContextMenu(null, mouse.modifiers);
mouse.accepted = true;
}
} else {
pressedItem = hoveredItem;
https://bugs.kde.org/show_bug.cgi?id=120008
var pos = mapToItem(hoveredItem.actionsOverlay, mouse.x, mouse.y);
if (!(pos.x <= hoveredItem.actionsOverlay.width && pos.y <= hoveredItem.actionsOverlay.height)) {
......@@ -309,7 +309,7 @@ FocusScope {
clearPressState();
dir.openContextMenu();
dir.openContextMenu(null, mouse.modifiers);
mouse.accepted = true;
}
}
......@@ -868,7 +868,7 @@ FocusScope {
Keys.onMenuPressed: {
if (currentIndex != -1 && dir.hasSelection() && currentItem) {
dir.setSelected(positioner.map(currentIndex));
dir.openContextMenu(currentItem.frame);
dir.openContextMenu(currentItem.frame, event.modifiers);
} else {
// Otherwise let the containment handle it.
event.accepted = false;
......
......@@ -1640,7 +1640,7 @@ void FolderModel::updateActions()
}
}
void FolderModel::openContextMenu(QQuickItem *visualParent)
void FolderModel::openContextMenu(QQuickItem *visualParent, Qt::KeyboardModifiers modifiers)
{
QModelIndexList indexes = m_selectionModel->selectedIndexes();
......@@ -1728,12 +1728,13 @@ void FolderModel::openContextMenu(QQuickItem *visualParent)
menu->addAction(emptyTrashAction);
}
} else {
if (!hasRemoteFiles && itemProperties.supportsMoving()) {
if (!modifiers.testFlag(Qt::ShiftModifier) && !hasRemoteFiles && itemProperties.supportsMoving()) {
menu->addAction(m_actionCollection.action(QStringLiteral("trash")));
} else {
showDeleteCommand = true;
}
}
if (showDeleteCommand && itemProperties.supportsDeleting()) {
menu->addAction(m_actionCollection.action(QStringLiteral("del")));
}
......
......@@ -225,7 +225,8 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
Q_INVOKABLE QAction* action(const QString& name) const;
QObject* newMenu() const;
Q_INVOKABLE void updateActions();
Q_INVOKABLE void openContextMenu(QQuickItem *visualParent = nullptr);
Q_INVOKABLE void openContextMenu(QQuickItem *visualParent = nullptr,
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
Q_INVOKABLE void linkHere(const QUrl &sourceUrl);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment