]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinremoveaction.h
Merge branch 'Applications/17.08'
[dolphin.git] / src / dolphinremoveaction.h
1 /***************************************************************************
2 * Copyright (C) 2013 by Dawit Alemayehu <adawit@kde.org> *
3 * Copyright (C) 2017 by Elvis Angelaccio <elvis.angelaccio@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef DOLPHINREMOVEACTION_H
22 #define DOLPHINREMOVEACTION_H
23
24 #include "dolphin_export.h"
25
26 #include <QAction>
27 #include <QPointer>
28
29 #include <KActionCollection>
30
31 /**
32 * A QAction that manages the delete based on the current state of
33 * the Shift key or the parameter passed to update.
34 *
35 * This class expects the presence of both the KStandardAction::MoveToTrash and
36 * KStandardAction::DeleteFile actions in @ref collection.
37 */
38 class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
39 {
40 Q_OBJECT
41 public:
42
43 enum class ShiftState {
44 Unknown,
45 Pressed,
46 Released
47 };
48
49 DolphinRemoveAction(QObject* parent, KActionCollection* collection);
50
51 /**
52 * Updates this action key based on @p shiftState.
53 * Default value is QueryShiftState, meaning it will query QGuiApplication::modifiers().
54 */
55 void update(ShiftState shiftState = ShiftState::Unknown);
56
57 private Q_SLOTS:
58 void slotRemoveActionTriggered();
59
60 private:
61 QPointer<KActionCollection> m_collection;
62 QPointer<QAction> m_action;
63 };
64
65 #endif