┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinremoveaction.cpp
diff options
context:
space:
mode:
authorDawit Alemayehu <[email protected]>2013-02-09 15:56:51 -0500
committerDawit Alemayehu <[email protected]>2013-05-14 08:37:21 -0400
commit01761798a93bc93f3e16f8fb68fe5739ab66d98b (patch)
treecfb05f25aec9e46dc37bf9ee74ea4a01764f3a3d /src/dolphinremoveaction.cpp
parent799641859e92acacb33d0dc7c9eb659b651b0a18 (diff)
- Factored out the Delete/Move To Trash action into own class.
- Updated both the Dolphin KPart and context menu to use the new DolphinRemoveAction class to manage "Delete/Move to Trash" actions. See also https://git.reviewboard.kde.org/r/107509/. REVIEW: 108802
Diffstat (limited to 'src/dolphinremoveaction.cpp')
-rw-r--r--src/dolphinremoveaction.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp
new file mode 100644
index 000000000..200fc407d
--- /dev/null
+++ b/src/dolphinremoveaction.cpp
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2013 by Dawit Alemayehu <[email protected] *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "dolphinremoveaction.h"
+
+#include <QApplication>
+
+#include <KLocalizedString>
+
+
+DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* collection) :
+ QAction(parent),
+ m_collection(collection)
+{
+ update();
+ connect(this, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
+}
+
+void DolphinRemoveAction::slotRemoveActionTriggered()
+{
+ if (m_action) {
+ m_action->trigger();
+ }
+}
+
+void DolphinRemoveAction::update()
+{
+ Q_ASSERT(m_collection);
+ // Using setText(action->text()) does not apply the &-shortcut.
+ // This is only done until the original action has been shown at least once. To
+ // bypass this issue, the text and &-shortcut is applied manually.
+ if (qApp->keyboardModifiers() & Qt::ShiftModifier) {
+ m_action = m_collection ? m_collection->action("delete") : 0;
+ setText(i18nc("@action:inmenu", "&Delete"));
+ } else {
+ m_action = m_collection ? m_collection->action("move_to_trash") : 0;
+ setText(i18nc("@action:inmenu", "&Move to Trash"));
+ }
+
+ if (m_action) {
+ setIcon(m_action->icon());
+ setShortcuts(m_action->shortcuts());
+ }
+}