File indexing completed on 2024-12-22 04:12:39

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KIS_ALTERNATE_INVOCATION_ACTION_H
0008 #define KIS_ALTERNATE_INVOCATION_ACTION_H
0009 
0010 #include "kis_abstract_input_action.h"
0011 #include <QScopedPointer>
0012 #include "kis_tool.h"
0013 
0014 /**
0015  * \brief Alternate Invocation implementation of KisAbstractInputAction.
0016  *
0017  * The Alternate Invocation action performs an alternate action with the
0018  * current tool. For example, using the brush tool it samples a color from
0019  * the canvas.
0020  */
0021 class KisAlternateInvocationAction : public KisAbstractInputAction
0022 {
0023 public:
0024     /**
0025      * The different behaviours for this action.
0026      */
0027     enum Shortcut {
0028         PrimaryAlternateModeShortcut, ///< Toggle Primary mode.
0029         SecondaryAlternateModeShortcut, ///< Toggle Secondary mode.
0030         SampleColorFgLayerModeShortcut,
0031         SampleColorBgLayerModeShortcut,
0032         SampleColorFgImageModeShortcut,
0033         SampleColorBgImageModeShortcut,
0034         TertiaryAlternateModeShortcut ///< Warning: don't reorder the items of this enum, it breaks user configs!
0035     };
0036 
0037     explicit KisAlternateInvocationAction();
0038     ~KisAlternateInvocationAction() override;
0039 
0040     void activate(int shortcut) override;
0041     void deactivate(int shortcut) override;
0042 
0043     int priority() const override;
0044 
0045     void begin(int shortcut, QEvent *event) override;
0046     void end(QEvent *event) override;
0047     void inputEvent(QEvent* event) override;
0048 
0049     bool supportsHiResInputEvents(int shortcut) const override;
0050 
0051 
0052 private:
0053     KisTool::ToolAction shortcutToToolAction(int shortcut) const;
0054 
0055 private:
0056     struct Private;
0057     const QScopedPointer<Private> m_d;
0058 };
0059 
0060 #endif // KIS_ALTERNATE_INVOCATION_ACTION_H