File indexing completed on 2024-12-01 04:59:11

0001 /*
0002     SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDBusObjectPath>
0010 #include <QObject>
0011 #include <QRect>
0012 #include <screencasting.h>
0013 
0014 class QQmlApplicationEngine;
0015 class QTimer;
0016 class QScreen;
0017 class Screencasting;
0018 
0019 namespace KWayland {
0020     namespace Client {
0021         class Registry;
0022         class PlasmaWindowManagement;
0023         class Output;
0024         class XdgOutputManager;
0025     }
0026 }
0027 class ScreencastingStream;
0028 class OrgFreedesktopPortalScreenCastInterface;
0029 
0030 class PlasmaRecordMe : public QObject
0031 {
0032     Q_OBJECT
0033     Q_PROPERTY(QRect region READ region NOTIFY regionChanged)
0034 public:
0035     PlasmaRecordMe(Screencasting::CursorMode cursorMode, const QStringList &sources, bool doSelection, QObject *parent = nullptr);
0036     ~PlasmaRecordMe() override;
0037 
0038     void setDuration(int duration);
0039 
0040     QRect region() const;
0041     Q_SCRIPTABLE void addWindow(const QVariantList &uuid, const QString &appId);
0042     Q_SCRIPTABLE void createVirtualMonitor();
0043     Q_SCRIPTABLE void requestSelection();
0044     Q_SCRIPTABLE void setRegionPressed(const QString &screen, int x, int y);
0045     Q_SCRIPTABLE void setRegionMoved(const QString &screen, int x, int y);
0046     Q_SCRIPTABLE void setRegionReleased(const QString &screen, int x, int y);
0047 
0048 Q_SIGNALS:
0049     void cursorModeChanged(Screencasting::CursorMode cursorMode);
0050     void workspaceChanged();
0051     void regionFinal(const QRect &region);
0052     void regionChanged(const QRect &region);
0053 
0054 private:
0055     void startNode(int node);
0056     void start(ScreencastingStream *stream, bool allowDmaBuf);
0057     void addScreen(QScreen *screen);
0058     void addStream(int nodeid, const QString &displayText, int fd, bool allowDmaBuf);
0059     bool matches(const QString &source);
0060 
0061     const Screencasting::CursorMode m_cursorMode;
0062     QTimer* const m_durationTimer;
0063     const QStringList m_sources;
0064     KWayland::Client::PlasmaWindowManagement* m_management = nullptr;
0065     Screencasting* m_screencasting = nullptr;
0066     QQmlApplicationEngine* m_engine;
0067     QList<ScreencastingStream *> m_workspaceStreams;
0068     QList<ScreencastingStream *> m_regionStreams;
0069     QRect m_workspace;
0070 
0071     QRect m_region;
0072 };