CuteLogger
Fast and simple logging solution for Qt based applications
screencapturejob.h
1/*
2 * Copyright (c) 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 SCREENCAPTUREJOB_H
19#define SCREENCAPTUREJOB_H
20
21#include "abstractjob.h"
22
23#include <QRect>
24#include <QTimer>
25#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
26#include <QDBusConnection>
27#endif
28
29class ScreenCaptureJob : public AbstractJob
30{
31 Q_OBJECT
32public:
33 ScreenCaptureJob(const QString &name,
34 const QString &filename,
35 const QRect &captureRect,
36 bool recordAudio = true);
37 virtual ~ScreenCaptureJob();
38 void start() override;
39 void stop() override;
40
41private slots:
42 void onOpenTriggered();
43 void onFinished(int exitCode, QProcess::ExitStatus exitStatus) override;
44#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
45 void onDBusRecordingTaken(const QString &fileName);
46 void onDBusRecordingFailed();
47#endif
48
49private:
50#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
51 enum DBusService { None, GNOME, KDE };
52 bool startWaylandRecording();
53 bool startGnomeScreencast();
54 bool startKdeSpectacle();
55#endif
56 QString m_filename;
57 QString m_actualFilename;
58 QRect m_rect;
59 bool m_isAutoOpen;
60 bool m_recordAudio;
61 QTimer m_progressTimer;
62#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
63 DBusService m_dbusService = DBusService::None;
64#endif
65};
66
67#endif // SCREENCAPTUREJOB_H