From 11af97b83eb48f877b4f6bc5f409a483e78d4bcf Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sun, 30 Jun 2024 21:42:33 +0000 Subject: [PATCH] quicksettings: Fix crash when stop record --- quicksettings/CMakeLists.txt | 2 +- quicksettings/record/package/contents/ui/main.qml | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/quicksettings/CMakeLists.txt b/quicksettings/CMakeLists.txt index ac0789d5..bf6bd8d7 100644 --- a/quicksettings/CMakeLists.txt +++ b/quicksettings/CMakeLists.txt @@ -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) diff --git a/quicksettings/record/package/contents/ui/main.qml b/quicksettings/record/package/contents/ui/main.qml index f7a1e7bc..2b2f2883 100644 --- a/quicksettings/record/package/contents/ui/main.qml +++ b/quicksettings/record/package/contents/ui/main.qml @@ -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); }