CuteLogger
Fast and simple logging solution for Qt based applications
screenselector.h
1 /*
2  * Copyright (c) 2014-2025 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef SCREENSELECTOR_H
19 #define SCREENSELECTOR_H
20 
21 #include <QFrame>
22 
23 class ScreenSelector : public QFrame
24 {
25  Q_OBJECT
26 public:
27  ScreenSelector(QWidget *parent = 0);
28  void setFixedSize(const QSize &size);
29  void setBoundingRect(const QRect &rect);
30  void setSelectedRect(const QRect &rect);
31  bool useDBus() const { return m_useDBus; }
32 
33 public slots:
34  void startSelection(QPoint initialPos = QPoint(-1, -1));
35 
36 signals:
37  void screenSelected(const QRect &);
38  void pointSelected(const QPoint &);
39  void cancelled();
40 
41 public:
42  bool onMousePressEvent(QMouseEvent *event);
43  bool onMouseMoveEvent(QMouseEvent *event);
44  bool onMouseReleaseEvent(QMouseEvent *event);
45  bool onKeyPressEvent(QKeyEvent *event);
46 
47 protected:
48  bool eventFilter(QObject *, QEvent *event);
49 
50 private:
51  void lockGeometry(const QRect &rect);
52  void release();
53 
54  bool m_selectionInProgress;
55  QRect m_selectionRect;
56  QPoint m_selectionPoint;
57  QSize m_fixedSize;
58  QRect m_boundingRect;
59  bool m_useDBus;
60 };
61 
62 #endif // SCREENSELECTOR_H