File indexing completed on 2024-05-12 16:02:28

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISACTIONSSNAPSHOT_H
0008 #define KISACTIONSSNAPSHOT_H
0009 
0010 #include <kritawidgetutils_export.h>
0011 
0012 #include <QScopedPointer>
0013 #include <QMap>
0014 
0015 class QAction;
0016 class KisKActionCollection;
0017 
0018 
0019 /**
0020  * @brief The KisActionsSnapshot class
0021  */
0022 class KRITAWIDGETUTILS_EXPORT KisActionsSnapshot
0023 {
0024 public:
0025     KisActionsSnapshot();
0026     ~KisActionsSnapshot();
0027 
0028     /**
0029      * @brief registers the action in the snapshot and sorts it into a proper
0030      *        category. The action is *not* owned by the snapshot.
0031      *
0032      * @param name id string of the action
0033      * @param action the action itself
0034      */
0035     void addAction(const QString &name, QAction *action);
0036 
0037     /**
0038      * Returns all action collections of the current snapshot
0039      *
0040      * WARNING: the collections are owned by the snapshot! Don't destroy
0041      *          the snapshot before you are done with the collections!
0042      */
0043     QMap<QString, KisKActionCollection*> actionCollections();
0044 
0045 private:
0046     struct Private;
0047     const QScopedPointer<Private> m_d;
0048 };
0049 
0050 #endif // KISACTIONSSNAPSHOT_H