1 | /* |
2 | Copyright (C) 2004 Bernd Brandstetter <bbrand@freenet.de> |
3 | Copyright (C) 2010, 2011 Pau Garcia i Quiles <pgquiles@elpauer.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or ( at your option ) any later version. |
9 | |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU General Public License |
16 | along with this library; see the file COPYING. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef WINDOWGRABBER_H |
22 | #define WINDOWGRABBER_H |
23 | |
24 | #include <QDialog> |
25 | #include <vector> |
26 | |
27 | class WindowGrabber : public QDialog |
28 | { |
29 | Q_OBJECT |
30 | |
31 | public: |
32 | WindowGrabber(); |
33 | ~WindowGrabber(); |
34 | |
35 | /* Grab a screenshot of the current window. x and y are set to the position of the window */ |
36 | static QPixmap grabCurrent( bool includeDecorations ); |
37 | static QString lastWindowTitle() { return WindowGrabber::title; } |
38 | static QString lastWindowClass() { return WindowGrabber::windowClass; } |
39 | static QPoint lastWindowPosition() { return WindowGrabber::windowPosition; } |
40 | |
41 | signals: |
42 | void windowGrabbed( const QPixmap & ); |
43 | |
44 | protected: |
45 | void mousePressEvent( QMouseEvent * ); |
46 | void mouseReleaseEvent( QMouseEvent * ); |
47 | void mouseMoveEvent( QMouseEvent * ); |
48 | void wheelEvent( QWheelEvent * ); |
49 | void paintEvent( QPaintEvent * ); |
50 | |
51 | private: |
52 | void increaseScope( const QPoint & ); |
53 | void decreaseScope( const QPoint & ); |
54 | int windowIndex( const QPoint & ) const; |
55 | std::vector<QRect> windows; |
56 | int current; |
57 | int yPos; |
58 | static QString title; |
59 | static QString windowClass; |
60 | static QPoint windowPosition; |
61 | }; |
62 | |
63 | #endif // WINDOWGRABBER_H |
64 | |