CuteLogger
Fast and simple logging solution for Qt based applications
screenselector.h
1/*
2 * Copyright (c) 2014-2019 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
32public slots:
33 void startSelection(QPoint initialPos = QPoint(-1, -1));
34
35signals:
36 void screenSelected(const QRect &);
37 void pointSelected(const QPoint &);
38 void cancelled();
39
40public:
41 bool onMousePressEvent(QMouseEvent *event);
42 bool onMouseMoveEvent(QMouseEvent *event);
43 bool onMouseReleaseEvent(QMouseEvent *event);
44 bool onKeyPressEvent(QKeyEvent *event);
45
46protected:
47 bool eventFilter(QObject *, QEvent *event);
48
49private:
50 void lockGeometry(const QRect &rect);
51 void release();
52
53 bool m_selectionInProgress;
54 QRect m_selectionRect;
55 QPoint m_selectionPoint;
56 QSize m_fixedSize;
57 QRect m_boundingRect;
58};
59
60#endif // SCREENSELECTOR_H