Debian Codegraph @

src/backend/imageGrabber/AbstractRectAreaImageGrabber.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 Damir Porobic <[email protected]>
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 2 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, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef KSNIP_ABSTRACTRECTAREAIMAGEGRABBER_H
21 #define KSNIP_ABSTRACTRECTAREAIMAGEGRABBER_H
22
23 #include <QPainter>
24 #include <QScreen>
25
26 #include "AbstractImageGrabber.h"
27 #include "src/gui/snippingArea/AbstractSnippingArea.h"
28
29 class AbstractRectAreaImageGrabber : public AbstractImageGrabber
30 {
31 Q_OBJECT
32 public:
33 explicit AbstractRectAreaImageGrabber(AbstractSnippingArea *snippingArea, const QSharedPointer<IConfig> &config);
34 ~AbstractRectAreaImageGrabber() override;
35 void grabImage(CaptureModes captureMode, bool captureCursor, int delay) override;
36 virtual QRect currentScreenRect() const;
37 virtual QRect fullScreenRect() const = 0;
38 virtual QRect activeWindowRect() const = 0;
39 virtual QRect lastRectArea() const;
40
41 protected:
42 QRect mCaptureRect;
43 CursorDto mStoredCursorImageWithPosition;
44
45 void openSnippingAreaWithoutBackground();
46 void openSnippingAreaWithBackground(const QPixmap &background);
47 QRect selectedSnippingAreaRect() const;
48 QPixmap snippingAreaBackground() const;
49 QPixmap getScreenshotFromRect(const QRect &rect) const;
50 QPixmap getScreenshot() const;
51 virtual QPixmap getScreenshotFromBackground() const;
52 void setCaptureRectFromCorrectSource();
53 virtual bool isSnippingAreaBackgroundTransparent() const;
54 virtual CursorDto getCursorWithPosition() const = 0;
55
56 protected slots:
57 void prepareGrab();
58 void grab() override;
59
60 private:
61 AbstractSnippingArea* mSnippingArea;
62 bool mFreezeImageWhileSnipping;
63
64 void openSnippingArea();
65 void connectSnippingAreaCancel();
66 void connectSnippingAreaFinish();
67 void disconnectSnippingAreaFinish();
68 bool shouldCaptureCursor() const;
69 CursorDto getCursorImageWithPositionFromCorrectSource() const;
70 bool isRectAreaCaptureWithBackground() const;
71 bool isRectAreaCaptureWithoutBackground() const;
72 CursorDto getCursorRelativeToScreenshot() const;
73 void storeCursorForPostProcessing(const QRect &screenRect);
74 };
75
76 #endif // KSNIP_ABSTRACTRECTAREAIMAGEGRABBER_H