┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinremoveaction.h
blob: 645359da08511f99148874ba5b5e87c236e16783 (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
/*
 * 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