quicksettings: Fix crash when stop record

This commit is contained in:
Florian RICHER 2024-06-30 21:42:33 +00:00
parent 3d4b31c26b
commit 11af97b83e
2 changed files with 13 additions and 2 deletions

View file

@ -17,6 +17,6 @@ add_subdirectory(flashlight)
add_subdirectory(nightcolor)
add_subdirectory(powermenu)
# TODO: Disable screen recording quick setting, as it does not work properly
# add_subdirectory(record)
add_subdirectory(record)
add_subdirectory(screenshot)
add_subdirectory(screenrotation)

View file

@ -30,10 +30,21 @@ QS.QuickSetting {
}
icon: "media-record"
enabled: false
available: record.encoder != PWRec.PipeWireRecord.NoEncoder
function toggle() {
if (!record.active) {
record.output = RecordUtil.videoLocation("screen-recording.mp4");
// See this https://invent.kde.org/plasma/kpipewire/-/blob/eb21912e7e0ce5a70c6f906c6e5a20f56cc6783e/src/pipewirerecord.cpp#L82
switch (record.encoder) {
case PWRec.PipeWireRecord.H264Main:
case PWRec.PipeWireRecord.H264Baseline:
record.output = RecordUtil.videoLocation("screen-recording.mp4");
break;
case PWRec.PipeWireRecord.VP8:
case PWRec.PipeWireRecord.VP9:
record.output = RecordUtil.videoLocation("screen-recording.webm");
break;
}
} else {
RecordUtil.showNotification(i18n("New Screen Recording"), i18n("New Screen Recording saved in %1", record.output), record.output);
}