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
23class ScreenSelector : public QFrame
24{
25 Q_OBJECT
26public:
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
32 {
33 return m_useDBus;
34 }
35
36public slots:
37 void startSelection(QPoint initialPos = QPoint(-1, -1));
38
39signals:
40 void screenSelected(const QRect &);
41 void pointSelected(const QPoint &);
42 void cancelled();
43
44public:
45 bool onMousePressEvent(QMouseEvent *event);
46 bool onMouseMoveEvent(QMouseEvent *event);
47 bool onMouseReleaseEvent(QMouseEvent *event);
48 bool onKeyPressEvent(QKeyEvent *event);
49
50protected:
51 bool eventFilter(QObject *, QEvent *event);
52
53private:
54 void lockGeometry(const QRect &rect);
55 void release();
56
57 bool m_selectionInProgress;
58 QRect m_selectionRect;
59 QPoint m_selectionPoint;
60 QSize m_fixedSize;
61 QRect m_boundingRect;
62 bool m_useDBus;
63};
64
65#endif // SCREENSELECTOR_H