CuteLogger
Fast and simple logging solution for Qt based applications
colorpickeritem.h
1 /*
2  * Copyright (c) 2014 Meltytech, LLC
3  * Author: Brian Matherly <pez4brian@yahoo.com>
4  * Author: Dan Dennedy <dan@dennedy.org>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef COLORPICKERITEM_H
21 #define COLORPICKERITEM_H
22 
23 #include <QObject>
24 #include <QColor>
25 #include <QFrame>
26 
27 class EventFilter;
28 
29 class ScreenSelector : public QFrame
30 {
31  Q_OBJECT
32 public:
33  ScreenSelector(QWidget* parent = 0);
34 
35 public slots:
36  void startSelection();
37 
38 signals:
39  void screenSelected(QRect);
40  void colorPicked(const QColor &color);
41 
42 public:
43  bool onMousePressEvent(QMouseEvent *event);
44  bool onMouseMoveEvent(QMouseEvent *event);
45  bool onMouseReleaseEvent(QMouseEvent *event);
46  bool onKeyPressEvent(QKeyEvent *event);
47 
48 private:
49  bool m_selectionInProgress;
50  QRect m_selectionRect;
51  EventFilter* m_eventFilter;
52 
53  void release();
54 
55 private slots:
56  void grabColor();
57 };
58 
59 class ColorPickerItem : public QObject
60 {
61  Q_OBJECT
62 public:
63  explicit ColorPickerItem(QObject* parent = 0);
64 
65 signals:
66  void pickColor();
67  void colorPicked(const QColor &color);
68 
69 private:
70  ScreenSelector m_selector;
71 };
72 
73 #endif // COLORPICKERITEM_H