From b0e2065a631b24c080faa4dc3d87c7006d08b130 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 20 May 2022 01:34:03 +0200 Subject: [PATCH 1/3] PipeWireThumbnail: Port to KPipeWire It's the same components just in a different place. No need to do much porting. --- CMakeLists.txt | 3 +++ components/mobileshell/qml/taskswitcher/Task.qml | 1 - components/mobileshell/qml/taskswitcher/Thumbnail.qml | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b052c9c2..47f2e8218 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(ECMQMLModules) include(ECMGenerateQmlTypes) +include(ECMFindQmlModule) include(GenerateExportHeader) include(KDEGitCommitHooks) include(KDEClangFormat) @@ -74,6 +75,8 @@ set_package_properties(KWinDBusInterface PROPERTIES DESCRIPTION "KWin DBus inter include(CheckIncludeFiles) +ecm_find_qmlmodule(org.kde.pipewire 0.1) + plasma_install_package(look-and-feel org.kde.plasma.phone look-and-feel) plasma_install_package(shell org.kde.plasma.phoneshell shells) diff --git a/components/mobileshell/qml/taskswitcher/Task.qml b/components/mobileshell/qml/taskswitcher/Task.qml index 241fd61ae..83c63485f 100644 --- a/components/mobileshell/qml/taskswitcher/Task.qml +++ b/components/mobileshell/qml/taskswitcher/Task.qml @@ -10,7 +10,6 @@ import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 as QQC2 -import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell diff --git a/components/mobileshell/qml/taskswitcher/Thumbnail.qml b/components/mobileshell/qml/taskswitcher/Thumbnail.qml index 94e1b655a..2235920d7 100644 --- a/components/mobileshell/qml/taskswitcher/Thumbnail.qml +++ b/components/mobileshell/qml/taskswitcher/Thumbnail.qml @@ -8,9 +8,9 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 -import org.kde.taskmanager 0.1 as TaskManager +import org.kde.pipewire 0.1 as PipeWire -TaskManager.PipeWireSourceItem { +PipeWire.PipeWireSourceItem { id: root visible: nodeId > 0 nodeId: waylandItem.nodeId @@ -23,7 +23,7 @@ TaskManager.PipeWireSourceItem { } } - TaskManager.ScreencastingRequest { + PipeWire.ScreencastingRequest { id: waylandItem uuid: "" } -- GitLab From ecd1515217a7bcaa97491d9a0b19695494dca0b4 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 20 May 2022 01:59:30 +0200 Subject: [PATCH 2/3] Add a Record QuickSetting Allows to record the current output conveniently from the drop-down. --- components/mobileshell/shellutil.cpp | 21 +++++++++ components/mobileshell/shellutil.h | 13 ++++++ quicksettings/CMakeLists.txt | 1 + quicksettings/record/contents/ui/main.qml | 52 +++++++++++++++++++++++ quicksettings/record/metadata.desktop | 16 +++++++ 5 files changed, 103 insertions(+) create mode 100644 quicksettings/record/contents/ui/main.qml create mode 100644 quicksettings/record/metadata.desktop diff --git a/components/mobileshell/shellutil.cpp b/components/mobileshell/shellutil.cpp index 4438f99a3..dfdffe4e6 100644 --- a/components/mobileshell/shellutil.cpp +++ b/components/mobileshell/shellutil.cpp @@ -9,6 +9,7 @@ #include "shellutil.h" #include +#include #include #include #include @@ -86,3 +87,23 @@ void ShellUtil::launchApp(const QString &app) auto job = new KIO::ApplicationLauncherJob(appService, this); job->start(); } + +QString ShellUtil::videoLocation(const QString &name) +{ + QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation); + QString newPath(path + '/' + name); + if (QFile::exists(newPath)) { + newPath = path + '/' + KFileUtils::suggestName(QUrl::fromLocalFile(newPath), name); + } + return newPath; +} + +void ShellUtil::showNotification(const QString &title, const QString &text, const QString &filePath) +{ + KNotification *notif = new KNotification("captured"); + notif->setComponentName(QStringLiteral("plasma_phone_components")); + notif->setTitle(title); + notif->setUrls({QUrl::fromLocalFile(filePath)}); + notif->setText(text); + notif->sendEvent(); +} diff --git a/components/mobileshell/shellutil.h b/components/mobileshell/shellutil.h index 5ee3cf4e8..3efa593af 100644 --- a/components/mobileshell/shellutil.h +++ b/components/mobileshell/shellutil.h @@ -62,6 +62,19 @@ public: */ Q_INVOKABLE bool isSystem24HourFormat(); + /** + * Allows us to get a filename in the standard videos directory (~/Videos by default) + * with a name that starts with @p name + * + * @returns a non-existing path that can be written into + * + * @see QStandardPaths::writableLocation() + * @see KFileUtil::suggestName() + */ + Q_INVOKABLE QString videoLocation(const QString &name); + + Q_INVOKABLE void showNotification(const QString &title, const QString &text, const QString &filePath); + Q_SIGNALS: void isSystem24HourFormatChanged(); diff --git a/quicksettings/CMakeLists.txt b/quicksettings/CMakeLists.txt index e4be46491..9cc20d543 100644 --- a/quicksettings/CMakeLists.txt +++ b/quicksettings/CMakeLists.txt @@ -9,6 +9,7 @@ plasma_install_package(caffeine org.kde.plasma.quicksetting.caffeine quicksettin plasma_install_package(keyboardtoggle org.kde.plasma.quicksetting.keyboardtoggle quicksettings) plasma_install_package(location org.kde.plasma.quicksetting.location quicksettings) plasma_install_package(mobiledata org.kde.plasma.quicksetting.mobiledata quicksettings) +plasma_install_package(record org.kde.plasma.quicksetting.record quicksettings) plasma_install_package(settingsapp org.kde.plasma.quicksetting.settingsapp quicksettings) plasma_install_package(wifi org.kde.plasma.quicksetting.wifi quicksettings) add_subdirectory(flashlight) diff --git a/quicksettings/record/contents/ui/main.qml b/quicksettings/record/contents/ui/main.qml new file mode 100644 index 000000000..049132215 --- /dev/null +++ b/quicksettings/record/contents/ui/main.qml @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: 2022 Devin Lin +// SPDX-License-Identifier: LGPL-2.0-or-later + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.pipewire 0.1 as PipeWire +import org.kde.pipewire.record 0.1 as PWRec + +MobileShell.QuickSetting { + id: root + text: switch(record.state) { + case PWRec.PipeWireRecord.Idle: + return i18n("Record") + case PWRec.PipeWireRecord.Recording: + return i18n("Recording...") + case PWRec.PipeWireRecord.Rendering: + i18n("Writing...") + } + status: switch(record.state) { + case PWRec.PipeWireRecord.Idle: + return i18n("Start Recording") + case PWRec.PipeWireRecord.Recording: + return i18n("Action! 📽️") + case PWRec.PipeWireRecord.Rendering: + i18n("Please wait...") + } + icon: "media-record" + enabled: false + + function toggle() { + if (!record.active) { + record.output = MobileShell.ShellUtil.videoLocation("screen-recording.mp4") + } else { + MobileShell.ShellUtil.showNotification(i18n("New Screen Recording"), i18n("New Screen Recording saved in %1", record.output), record.output); + } + enabled = !enabled + MobileShell.TopPanelControls.closeActionDrawer(); + } + + PWRec.PipeWireRecord { + id: record + nodeId: waylandItem.nodeId + active: root.enabled + + } + PipeWire.ScreencastingRequest { + id: waylandItem + outputName: root.enabled ? Screen.name : "" + } +} diff --git a/quicksettings/record/metadata.desktop b/quicksettings/record/metadata.desktop new file mode 100644 index 000000000..625014a9f --- /dev/null +++ b/quicksettings/record/metadata.desktop @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Aleix Pol +# SPDX-License-Identifier: GPL-2.0-or-later + +[Desktop Entry] +Name=Screenshot +Icon=spectacle + +Type=Service +X-KDE-ServiceTypes=KPackage/GenericQML + +X-KDE-PluginInfo-Author=Aleix Pol i Gonzalez +X-KDE-PluginInfo-Email=aleixpol@kde.org +X-KDE-PluginInfo-Name=org.kde.plasma.quicksetting.record +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=https://kde.org +X-KDE-PluginInfo-License=GPL-2.0+ -- GitLab From 55eadf0377ce83e434f120792ead0c147d5f7f89 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 20 May 2022 02:02:50 +0200 Subject: [PATCH 3/3] QuickSettings: Provide a small test app to run QuickSettings It's useful to limit what you are testing. --- .../quicksettings/QuickSettingsTest.qml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsTest.qml diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsTest.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsTest.qml new file mode 100644 index 000000000..52489493b --- /dev/null +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsTest.qml @@ -0,0 +1,52 @@ +/* + * SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + * + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +import QtQuick 2.15 + +import org.kde.plasma.components 3.0 as PlasmaComponents +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import "../../components" as Components + +// This is a test app to conveniently test the Quick Settings that are available +// on the system without having to load a full Plasma Mobile shell. +// +// Do not expect changes in this file to change the plasma UX. Do not install. +// +// This can be executed by running `qml QuickSettingsTest.qml` + +GridView { + model: MobileShell.QuickSettingsModel {} + + PlasmaComponents.Button { + id: restrictedButton + checkable: true + text: "Restricted" + } + delegate: Components.BaseItem { + required property var modelData + + implicitHeight: 150 + implicitWidth: 150 + horizontalPadding: (width - PlasmaCore.Units.gridUnit * 3) / 2 + verticalPadding: (height - PlasmaCore.Units.gridUnit * 3) / 2 + + contentItem: QuickSettingsFullDelegate { + restrictedPermissions: restrictedButton.checked + + text: modelData.text + status: modelData.status + icon: modelData.icon + enabled: modelData.enabled + settingsCommand: modelData.settingsCommand + toggleFunction: modelData.toggle + + onCloseRequested: { + actionDrawer.close(); + } + } + } +} -- GitLab