1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors
3 
4 #pragma once
5 
6 #include "capturebutton.h"
7 #include <QMap>
8 #include <QVector>
9 
10 class QWidget;
11 class QPropertyAnimation;
12 class CaptureTool;
13 
14 class CaptureToolButton : public CaptureButton
15 {
16     Q_OBJECT
17 
18 public:
19     // Don't forget to add the new types to CaptureButton::iterableButtonTypes
20     // in the .cpp and the order value in the private array buttonTypeOrder
21     enum ButtonType
22     {
23         TYPE_PENCIL = 0,
24         TYPE_DRAWER = 1,
25         TYPE_ARROW = 2,
26         TYPE_SELECTION = 3,
27         TYPE_RECTANGLE = 4,
28         TYPE_CIRCLE = 5,
29         TYPE_MARKER = 6,
30         TYPE_SELECTIONINDICATOR = 7,
31         TYPE_MOVESELECTION = 8,
32         TYPE_UNDO = 9,
33         TYPE_COPY = 10,
34         TYPE_SAVE = 11,
35         TYPE_EXIT = 12,
36         TYPE_IMAGEUPLOADER = 13,
37         TYPE_OPEN_APP = 14,
38         TYPE_PIXELATE = 15,
39         TYPE_REDO = 16,
40         TYPE_PIN = 17,
41         TYPE_TEXT = 18,
42         TYPE_CIRCLECOUNT = 19,
43         TYPE_SIZEINCREASE = 20,
44         TYPE_SIZEDECREASE = 21,
45     };
46     Q_ENUM(ButtonType)
47 
48     explicit CaptureToolButton(const ButtonType, QWidget* parent = nullptr);
49     ~CaptureToolButton();
50 
51     static QVector<CaptureToolButton::ButtonType> getIterableButtonTypes();
52     static int getPriorityByButton(CaptureToolButton::ButtonType);
53 
54     QString name() const;
55     QString description() const;
56     QIcon icon() const;
57     CaptureTool* tool() const;
58 
59     void setColor(const QColor& c);
60     void animatedShow();
61 
62 protected:
63     void mousePressEvent(QMouseEvent* e) override;
64     static QVector<ButtonType> iterableButtonTypes;
65 
66     CaptureTool* m_tool;
67 
68 signals:
69     void pressedButton(CaptureToolButton*);
70 
71 private:
72     CaptureToolButton(QWidget* parent = nullptr);
73     ButtonType m_buttonType;
74 
75     QPropertyAnimation* m_emergeAnimation;
76 
77     static QColor m_mainColor;
78 
79     void initButton();
80     void updateIcon();
81 };
82