File indexing completed on 2024-04-14 15:49:28

0001 /*
0002  * SPDX-FileCopyrightText: 2013 Dawit Alemayehu <adawit@kde.org>
0003  * SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef DOLPHINREMOVEACTION_H
0009 #define DOLPHINREMOVEACTION_H
0010 
0011 #include "dolphin_export.h"
0012 
0013 #include <KActionCollection>
0014 
0015 #include <QAction>
0016 #include <QPointer>
0017 
0018 /**
0019  * A QAction that manages the delete based on the current state of
0020  * the Shift key or the parameter passed to update.
0021  *
0022  * This class expects the presence of both the KStandardAction::MoveToTrash and
0023  * KStandardAction::DeleteFile actions in @ref collection.
0024  */
0025 class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
0026 {
0027     Q_OBJECT
0028 public:
0029     enum class ShiftState { Unknown, Pressed, Released };
0030 
0031     DolphinRemoveAction(QObject *parent, KActionCollection *collection);
0032 
0033     /**
0034      * Updates this action key based on @p shiftState.
0035      * Default value is QueryShiftState, meaning it will query QGuiApplication::modifiers().
0036      */
0037     void update(ShiftState shiftState = ShiftState::Unknown);
0038 
0039 private Q_SLOTS:
0040     void slotRemoveActionTriggered();
0041 
0042 private:
0043     QPointer<KActionCollection> m_collection;
0044     QPointer<QAction> m_action;
0045 };
0046 
0047 #endif