Debian Codegraph @

src/backend/imageGrabber/AbstractImageGrabber.cpp

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 #include "AbstractImageGrabber.h"
21
22 AbstractImageGrabber::AbstractImageGrabber(const QSharedPointer<IConfig> &config) :
23 mConfig(config),
24 mIsCaptureCursorEnabled(false),
25 mCaptureDelay(0),
26 mCaptureMode(CaptureModes::FullScreen),
27 mImplicitCaptureDelay(mConfig->implicitCaptureDelay())
28 {
29 }
30
31 bool AbstractImageGrabber::isCaptureModeSupported(CaptureModes captureMode) const
32 {
33 return mSupportedCaptureModes.contains(captureMode);
34 }
35
36 QList<CaptureModes> AbstractImageGrabber::supportedCaptureModes() const
37 {
38 return mSupportedCaptureModes;
39 }
40
41 void AbstractImageGrabber::grabImage(CaptureModes captureMode, bool captureCursor, int delay)
42 {
43 setIsCaptureCursorEnabled(captureCursor);
44 setCaptureDelay(delay);
45 setCaptureMode(captureMode);
46
47 QTimer::singleShot(captureDelay(), this, &AbstractImageGrabber::grab);
48 }
49
50 void AbstractImageGrabber::addSupportedCaptureMode(CaptureModes captureMode)
51 {
52 mSupportedCaptureModes.append(captureMode);
53 }
54
55 void AbstractImageGrabber::setCaptureDelay(int delay)
56 {
57 mCaptureDelay = delay;
58 }
59
60 int AbstractImageGrabber::captureDelay() const
61 {
62 return mCaptureDelay;
63 }
64
65 CaptureModes AbstractImageGrabber::captureMode() const
66 {
67 return mCaptureMode;
68 }
69
70 void AbstractImageGrabber::setCaptureMode(CaptureModes captureMode)
71 {
72 if (isCaptureModeSupported(captureMode)) {
73 mCaptureMode = captureMode;
74 } else {
75 qWarning("Unsupported Capture Mode selected, falling back to full screen.");
76 mCaptureMode = CaptureModes::FullScreen;
77 }
78 }
79
80 bool AbstractImageGrabber::isCaptureDelayBelowMin() const
81 {
82 return mCaptureDelay <= mImplicitCaptureDelay;
83 }
84
85 bool AbstractImageGrabber::isCaptureCursorEnabled() const
86 {
87 return mIsCaptureCursorEnabled;
88 }
89
90 void AbstractImageGrabber::setIsCaptureCursorEnabled(bool enabled)
91 {
92 mIsCaptureCursorEnabled = enabled;
93 }
94
95 void AbstractImageGrabber::delayChanged()
96 {
97 mImplicitCaptureDelay = mConfig->implicitCaptureDelay();
98 }