File: upstream_b63c01d0_videoplatform-Add-RecordingState-property.patch

package info (click to toggle)
kde-spectacle 4%3A6.3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,912 kB
  • sloc: cpp: 13,087; xml: 746; sh: 10; makefile: 3
file content (122 lines) | stat: -rw-r--r-- 3,927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
From b63c01d08fe870e876ac9425083093bcc6d78ff1 Mon Sep 17 00:00:00 2001
From: Arjen Hiemstra <ahiemstra@heimr.nl>
Date: Tue, 8 Oct 2024 14:53:51 +0200
Subject: [PATCH] videoplatform: Add RecordingState property

This indicates what state the video platform is in currently and allows
other bits of the UI to react accordingly.

Most importantly this adds a "Rendering" state that corresponds to
KPipeWire's Rendering state, which indicates we're finishing the
recording process but haven't fully finished yet.
---
 src/Platforms/VideoPlatform.cpp | 17 +++++++++++++++++
 src/Platforms/VideoPlatform.h   | 14 ++++++++++++++
 2 files changed, 31 insertions(+)

--- a/src/Platforms/VideoPlatform.cpp
+++ b/src/Platforms/VideoPlatform.cpp
@@ -26,9 +26,11 @@
     }
 
     if (recording) {
+        setRecordingState(RecordingState::Recording);
         m_elapsedTimer.start();
         m_basicTimer.start(1000, Qt::PreciseTimer, this);
     } else {
+        setRecordingState(RecordingState::Finished);
         m_elapsedTimer.invalidate();
         m_basicTimer.stop();
     }
@@ -80,4 +82,19 @@
     return formatForExtension(path.mid(path.lastIndexOf(u'.') + 1));
 }
 
+VideoPlatform::RecordingState VideoPlatform::recordingState() const
+{
+    return m_recordingState;
+}
+
+void VideoPlatform::setRecordingState(RecordingState state)
+{
+    if (state == m_recordingState) {
+        return;
+    }
+
+    m_recordingState = state;
+    Q_EMIT recordingStateChanged(state);
+}
+
 #include "moc_VideoPlatform.cpp"
--- a/src/Platforms/VideoPlatform.h
+++ b/src/Platforms/VideoPlatform.h
@@ -27,6 +27,7 @@
     Q_PROPERTY(Formats supportedFormats READ supportedFormats NOTIFY supportedFormatsChanged)
     Q_PROPERTY(bool isRecording READ isRecording NOTIFY recordingChanged)
     Q_PROPERTY(qint64 recordedTime READ recordedTime NOTIFY recordedTimeChanged)
+    Q_PROPERTY(RecordingState recordingState READ recordingState NOTIFY recordingStateChanged)
 
 public:
     explicit VideoPlatform(QObject *parent = nullptr);
@@ -41,6 +42,14 @@
     Q_FLAG(RecordingMode)
     Q_DECLARE_FLAGS(RecordingModes, RecordingMode)
 
+    enum class RecordingState : char {
+        NotRecording, //< Not recording anything
+        Recording, //< Actively recording
+        Rendering, //< Finishing the recording, no longer actively receiving frames but still processing to do.
+        Finished //< Recording finished completely.
+    };
+    Q_ENUM(RecordingState)
+
     /**
      * Video formats supported by this class's APIs.
      *
@@ -118,8 +127,11 @@
     bool isRecording() const;
     qint64 recordedTime() const;
 
+    RecordingState recordingState() const;
+
 protected:
     void setRecording(bool recording);
+    void setRecordingState(RecordingState state);
     void timerEvent(QTimerEvent *event) override;
 
 public Q_SLOTS:
@@ -137,6 +149,7 @@
     void recordingFailed(const QString &message);
     void recordingCanceled(const QString &message);
     void recordedTimeChanged();
+    void recordingStateChanged(RecordingState state);
 
     /// Request a region from the platform agnostic selection editor
     void regionRequested();
@@ -144,6 +157,7 @@
 private:
     QElapsedTimer m_elapsedTimer;
     QBasicTimer m_basicTimer;
+    RecordingState m_recordingState = RecordingState::NotRecording;
 };
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(VideoPlatform::RecordingModes)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@
 
 # minimum requirements
 set(PROJECT_DEP_VERSION "6.3.4")
+set(KPIPEWIRE_DEP_VERSION "6.3.5")
 set(QT_MIN_VERSION "6.7.0")
 set(KF6_MIN_VERSION "6.10.0")
 
@@ -83,7 +84,7 @@
 find_package(Wayland REQUIRED COMPONENTS Client)
 find_package(PlasmaWaylandProtocols REQUIRED)
 find_package(LayerShellQt REQUIRED)
-find_package(KPipeWire)
+find_package(KPipeWire ${KPIPEWIRE_DEP_VERSION})
 find_package(OpenCV REQUIRED core imgproc)
 
 set_package_properties(KPipeWire PROPERTIES DESCRIPTION