diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b052c9c292d2babf72e15158af8ff0ead5049a0..47f2e82186d7883c55fa67a58034d0554d2d602f 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/actiondrawer/quicksettings/QuickSettingsTest.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsTest.qml new file mode 100644 index 0000000000000000000000000000000000000000..52489493bce8e4c7af3ad764a8ab4d3016517f7a --- /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(); + } + } + } +} diff --git a/components/mobileshell/qml/taskswitcher/Task.qml b/components/mobileshell/qml/taskswitcher/Task.qml index 241fd61aeed84e76e90581f28fe91be623a1cc08..83c63485fa5c4d2a5dda9d9317e75100cbf81fe9 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 94e1b655aee829b7bbcc42f9a63fa8ef26d2ee7c..2235920d7e4f5797293457e024a7b189ef0f6cdc 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: "" } diff --git a/components/mobileshell/shellutil.cpp b/components/mobileshell/shellutil.cpp index 4438f99a36d0931fda651470536bc12c8571b7a8..dfdffe4e6b9ce95dc705689e340b482c27b1eab9 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 5ee3cf4e8f213f36b5aa76e9b10e80c2910a3d4e..3efa593af16e29c7a6b387de2fb6370b6af5ace4 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 e4be46491623056b9fac2a65b60812cd8c0b11b5..9cc20d5432745882efd1b4b6d5dec28b8dbb9014 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 0000000000000000000000000000000000000000..0491322152cbe482fe3553489c400e9c037ce28f --- /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 0000000000000000000000000000000000000000..625014a9fe3755daefe8e646a4bab5592a05059b --- /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+