From 9ec96cefd76cb9df32d64fb459a51c17c7d1d9c6 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Jul 30 2024 10:49:29 +0000 Subject: OpenH264: Add initial page to install/uninstall codec --- diff --git a/usr/share/plasma/plasma-welcome/extra-pages/02-EnableOpenh264.qml b/usr/share/plasma/plasma-welcome/extra-pages/02-EnableOpenh264.qml new file mode 100644 index 0000000..7a40c2a --- /dev/null +++ b/usr/share/plasma/plasma-welcome/extra-pages/02-EnableOpenh264.qml @@ -0,0 +1,96 @@ +/* + * SPDX-FileCopyrightText: 2021 Felipe Kinoshita + * SPDX-FileCopyrightText: 2022 Nate Graham + * + * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + */ + +import QtQuick +import QtQuick.Controls as QQC2 +import QtQuick.Layouts +import org.kde.kirigami as Kirigami +import Qt5Compat.GraphicalEffects + +import org.kde.plasma.welcome + +GenericPage { + heading: i18nc("@info:window", "Install the OpenH264 codec") + description: xi18nc("@info:usagetip", "Cisco provides an OpenH264 codec (as a source and a binary), which is their of implementation of the H.264 codec, and they cover all licensing fees for all parties using their binary.") + id: root + topContent: [ + Kirigami.UrlButton { + id: thirdPartyInfoLink + Layout.topMargin: Kirigami.Units.largeSpacing + text: i18nc("@action:button", "Learn more about the OpenH264 codec in Fedora") + url: "https://docs.fedoraproject.org/en-US/quick-docs/openh264/" + }, + QQC2.Label { + id: ostreeWarning + Layout.fillWidth: true + text: "Note: Due to current limitations on Fedora Kinoite, installing the OpenH264 codec on the system will make applying updates slower." + wrapMode: Text.WordWrap + visible: false + Layout.topMargin: Kirigami.Units.largeSpacing + }, + QQC2.Button { + id: installOpenh264 + text: "Install the OpenH264 codec" + onClicked: { + if (root.isOstree) { + console.log('Installing openh264 via rpm-ostree'); + Controller.runCommand("pkexec rpm-ostree override remove noopenh264 --install openh264 --install mozilla-openh264"); + } else { + console.log('Installing openh264 via dnf'); + Controller.runCommand("pkexec dnf install -y openh264"); + } + showPassiveNotification(i18n("The OpenH264 codec is being installed in the background.")); + uninstallOpenh264.visible = true; + installOpenh264.visible = false; + } + Layout.topMargin: Kirigami.Units.largeSpacing + }, + QQC2.Button { + id: uninstallOpenh264 + text: "Uninstall the OpenH264 codec" + visible: false + onClicked: { + if (root.isOstree) { + console.log('Uninstalling openh264 via rpm-ostree'); + Controller.runCommand("pkexec rpm-ostree override reset noopenh264 --uninstall openh264 --uninstall mozilla-openh264"); + } else { + console.log('Uninstalling openh264 via dnf'); + Controller.runCommand("pkexec dnf remove -y openh264"); + } + showPassiveNotification(i18n("The OpenH264 codec is being uninstalled in the background.")); + uninstallOpenh264.visible = false; + installOpenh264.visible = true; + } + Layout.topMargin: Kirigami.Units.largeSpacing + } + ] + Component.onCompleted: { + Controller.runCommand("rpm -qi openh264", rpmCallback); + Controller.runCommand("test -f /run/ostree-booted", ostreeCallback); + } + property var rpmCallback: (returnStatus, outputText) => { + if (returnStatus == 0) { + uninstallOpenh264.visible = true; + installOpenh264.visible = false; + console.log('OpenH264 package is installed'); + } else { + uninstallOpenh264.visible = false; + installOpenh264.visible = true; + console.log('OpenH264 package is not installed'); + } + } + property var ostreeCallback: (returnStatus, outputText) => { + if (returnStatus == 0) { + ostreeWarning.visible = true; + root.isOstree = true; + console.log('Running on Kinoite'); + } else { + console.log('Not running on Kinoite'); + } + } + property var isOstree: false +}