2 * SPDX-FileCopyrightText: 2013 Dawit Alemayehu <adawit@kde.org>
3 * SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
8 #include "dolphinremoveaction.h"
10 #include <QApplication>
12 DolphinRemoveAction::DolphinRemoveAction(QObject
*parent
, KActionCollection
*collection
)
14 , m_collection(collection
)
17 connect(this, &DolphinRemoveAction::triggered
, this, &DolphinRemoveAction::slotRemoveActionTriggered
);
20 void DolphinRemoveAction::slotRemoveActionTriggered()
27 void DolphinRemoveAction::update(ShiftState shiftState
)
34 if (shiftState
== ShiftState::Unknown
) {
35 shiftState
= QGuiApplication::keyboardModifiers() & Qt::ShiftModifier
? ShiftState::Pressed
: ShiftState::Released
;
39 case ShiftState::Pressed
: {
40 m_action
= m_collection
->action(KStandardAction::name(KStandardAction::DeleteFile
));
41 // Make sure we show Shift+Del in the context menu.
42 auto deleteShortcuts
= m_action
->shortcuts();
43 deleteShortcuts
.removeAll(Qt::SHIFT
| Qt::Key_Delete
);
44 deleteShortcuts
.prepend(Qt::SHIFT
| Qt::Key_Delete
);
45 m_collection
->setDefaultShortcuts(this, deleteShortcuts
);
48 case ShiftState::Released
: {
49 m_action
= m_collection
->action(KStandardAction::name(KStandardAction::MoveToTrash
));
50 // Make sure we show Del in the context menu.
51 auto trashShortcuts
= m_action
->shortcuts();
52 trashShortcuts
.removeAll(QKeySequence::Delete
);
53 trashShortcuts
.prepend(QKeySequence::Delete
);
54 m_collection
->setDefaultShortcuts(this, trashShortcuts
);
57 case ShiftState::Unknown
:
63 setText(m_action
->text());
64 setIcon(m_action
->icon());
65 setEnabled(m_action
->isEnabled());
69 #include "moc_dolphinremoveaction.cpp"