┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinremoveaction.h
blob: 7c3b49279e2013b8e16abd2997edd03bb45c0d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * SPDX-FileCopyrightText: 2013 Dawit Alemayehu <[email protected]>
 * SPDX-FileCopyrightText: 2017 Elvis Angelaccio <[email protected]>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef DOLPHINREMOVEACTION_H
#define DOLPHINREMOVEACTION_H

#include "dolphin_export.h"

#include <KActionCollection>

#include <QAction>
#include <QPointer>

/**
 * A QAction that manages the delete based on the current state of
 * the Shift key or the parameter passed to update.
 *
 * This class expects the presence of both the KStandardAction::MoveToTrash and
 * KStandardAction::DeleteFile actions in @ref collection.
 */
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
  Q_OBJECT
public:

    enum class ShiftState {
        Unknown,
        Pressed,
        Released
    };

    DolphinRemoveAction(QObject* parent, KActionCollection* collection);

    /**
     * Updates this action key based on @p shiftState.
     * Default value is QueryShiftState, meaning it will query QGuiApplication::modifiers().
     */
    void update(ShiftState shiftState = ShiftState::Unknown);

private Q_SLOTS:
    void slotRemoveActionTriggered();

private:
    QPointer<KActionCollection> m_collection;
    QPointer<QAction> m_action;
};

#endif