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 "color_wheel.hpp"
7 #include <QWidget>
8 
9 class QVBoxLayout;
10 class QPushButton;
11 class QLabel;
12 class QColorPickingEventFilter;
13 class QSlider;
14 
15 class SidePanelWidget : public QWidget
16 {
17     Q_OBJECT
18 
19     friend class QColorPickingEventFilter;
20 
21 public:
22     explicit SidePanelWidget(QPixmap* p, QWidget* parent = nullptr);
23 
24 signals:
25     void colorChanged(const QColor& c);
26     void thicknessChanged(int t);
27     void togglePanel();
28 
29 public slots:
30     void updateColor(const QColor& c);
31     void updateThickness(const int& t);
32 
33 private slots:
34     void updateColorNoWheel(const QColor& c);
35     void updateCurrentThickness(int value);
36 
37 private slots:
38     void colorGrabberActivated();
39     void releaseColorGrab();
40 
41 private:
42     QColor grabPixmapColor(const QPoint& p);
43 
44     bool handleKeyPress(QKeyEvent* e);
45     bool handleMouseButtonPressed(QMouseEvent* e);
46     bool handleMouseMove(QMouseEvent* e);
47 
48     void updateGrabButton(const bool activated);
49 
50     QVBoxLayout* m_layout;
51     QPushButton* m_colorGrabButton;
52     color_widgets::ColorWheel* m_colorWheel;
53     QLabel* m_colorLabel;
54     QPixmap* m_pixmap;
55     QColor m_colorBackup;
56     QColor m_color;
57     QSlider* m_thicknessSlider;
58     int m_thickness;
59     QColorPickingEventFilter* m_eventFilter;
60 };
61