From b2e83f506c04f965d73b931993383a89c7efb98f Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 13 Dec 2022 21:45:50 +0100 Subject: [PATCH] Improve and fix pluging modules - Fix call to removed get() method - Add PlaceHolderMessage in runcommand plugin - Simplify qml code when possible - Use latest qml import - Fix missing i18n call Signed-off-by: Carl Schwan --- .../clipboard/kdeconnect_clipboard_config.qml | 16 ++--- .../kdeconnect_findthisdevice_config.qml | 18 +++--- .../kdeconnect_pausemusic_config.qml | 28 ++++----- .../kdeconnect_runcommand_config.qml | 59 +++++++++++-------- plugins/share/kdeconnect_share_config.qml | 18 +++--- 5 files changed, 72 insertions(+), 67 deletions(-) diff --git a/plugins/clipboard/kdeconnect_clipboard_config.qml b/plugins/clipboard/kdeconnect_clipboard_config.qml index 9924333c8..fa2b937fd 100644 --- a/plugins/clipboard/kdeconnect_clipboard_config.qml +++ b/plugins/clipboard/kdeconnect_clipboard_config.qml @@ -4,10 +4,10 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.1 -import org.kde.kirigami 2.5 as Kirigami +import QtQuick 2.15 +import QtQuick.Controls 2.15 as QQC2 +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami import org.kde.kdeconnect 1.0 Kirigami.FormLayout { @@ -21,17 +21,17 @@ Kirigami.FormLayout { } Component.onCompleted: { - unknown.checked = config.get("sendUnknown", true) - password.checked = config.get("sendPassword", true) + unknown.checked = config.getBool("sendUnknown", true) + password.checked = config.getBool("sendPassword", true) } - CheckBox { + QQC2.CheckBox { id: password text: i18n("Passwords (as marked by password managers)") onClicked: config.set("sendPassword", checked) } - CheckBox { + QQC2.CheckBox { id: unknown text: i18n("Anything else") onClicked: config.set("sendUnknown", checked) diff --git a/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml b/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml index 79cfa0026..3479b05fc 100644 --- a/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml +++ b/plugins/findthisdevice/kdeconnect_findthisdevice_config.qml @@ -4,10 +4,10 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.1 -import org.kde.kirigami 2.5 as Kirigami +import QtQuick 2.15 +import QtQuick.Controls 2.15 as QQC2 +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami import Qt.labs.platform 1.1 import org.kde.kdeconnect 1.0 @@ -36,22 +36,20 @@ Kirigami.FormLayout { pluginName: "kdeconnect_findthisdevice" onConfigChanged: { - path.text = get("ringtone", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", "")) + path.text = getString("ringtone", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", "")) } } RowLayout { Kirigami.FormData.label: i18n("Sound to play:") - TextField { + QQC2.TextField { id: path } - Button { + QQC2.Button { icon.name: "document-open" - onClicked: { - fileDialog.open() - } + onClicked: fileDialog.open() } } } diff --git a/plugins/pausemusic/kdeconnect_pausemusic_config.qml b/plugins/pausemusic/kdeconnect_pausemusic_config.qml index 40394cc4a..9a347c825 100644 --- a/plugins/pausemusic/kdeconnect_pausemusic_config.qml +++ b/plugins/pausemusic/kdeconnect_pausemusic_config.qml @@ -4,14 +4,13 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.1 -import org.kde.kirigami 2.5 as Kirigami +import QtQuick 2.15 +import QtQuick.Controls 2.15 as QQC2 +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami import org.kde.kdeconnect 1.0 Kirigami.FormLayout { - property string device KdeConnectPluginConfig { @@ -21,39 +20,38 @@ Kirigami.FormLayout { } Component.onCompleted: { - talking.checked = config.get("conditionTalking", false) - mute.checked = config.get("actionMute", false) - pause.checked = config.get("actionPause", true) - resume.checked = config.get("actionResume", true) + talking.checked = config.getBool("conditionTalking", false) + mute.checked = config.getBool("actionMute", false) + pause.checked = config.getBool("actionPause", true) + resume.checked = config.getBool("actionResume", true) } - RadioButton { + QQC2.RadioButton { text: i18n("Pause as soon as phone rings") checked: !talking.checked } - RadioButton { + QQC2.RadioButton { id: talking onCheckedChanged: config.set("conditionTalking", checked) text: i18n("Pause only while talking") } - CheckBox { + QQC2.CheckBox { id: pause text: i18n("Pause media players") onClicked: config.set("actionPause", checked) } - CheckBox { + QQC2.CheckBox { id: mute text: i18n("Mute system sound") onClicked: config.set("actionMute", checked) } - CheckBox { + QQC2.CheckBox { id: resume text: i18n("Resume automatically when call ends") onClicked: config.set("actionResume", checked) } - } diff --git a/plugins/runcommand/kdeconnect_runcommand_config.qml b/plugins/runcommand/kdeconnect_runcommand_config.qml index 778af1b05..ea8a2ca23 100644 --- a/plugins/runcommand/kdeconnect_runcommand_config.qml +++ b/plugins/runcommand/kdeconnect_runcommand_config.qml @@ -4,18 +4,18 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -import QtQuick 2.2 -import QtQuick.Controls 2.5 -import org.kde.kirigami 2.4 as Kirigami +import QtQuick 2.15 +import QtQuick.Controls 2.15 as QQC2 +import org.kde.kirigami 2.20 as Kirigami import org.kde.kdeconnect 1.0 ListView { - + id: view Component.onCompleted: { - root.leftPadding = 0 - root.rightPadding = 0 - root.topPadding = 0 - root.bottomPadding = 0 + root.leftPadding = 0 + root.rightPadding = 0 + root.topPadding = 0 + root.bottomPadding = 0 } property string device @@ -32,38 +32,47 @@ ListView { } delegate: Kirigami.SwipeListItem { - width: parent.width - enabled: true + width: parent.width + enabled: true - Label { - text: i18n("%1
%2", name, command) - } - - actions: [ - Kirigami.Action { - icon.name: "delete" - onTriggered: commandModel.removeCommand(index) - } - ] + QQC2.Label { + text: i18n("%1
%2", name, command) } - Dialog { + actions: Kirigami.Action { + text: i18n("Delete") + icon.name: "delete" + onTriggered: commandModel.removeCommand(index) + } + } + + Kirigami.PlaceholderMessage { + icon.name: 'utilities-terminal' + anchors.centerIn: parent + visible: view.count === 0 + width: parent.width - Kirigami.Units.gridUnit * 4 + text: i18n("No Commands") + explanation: i18n("Add commands to run them remotely from other devices") + helpfulAction: view.action + } + + QQC2.Dialog { id: addDialog title: "Add command" - standardButtons: Dialog.Save | Dialog.Cancel + standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Cancel Kirigami.FormLayout { - TextField { + QQC2.TextField { id: nameField Kirigami.FormData.label: i18n("Name:") } - TextField { + QQC2.TextField { id: commandField Kirigami.FormData.label: i18n("Command:") } - ComboBox { + QQC2.ComboBox { Kirigami.FormData.label: i18n("Sample commands:") textRole: "name" model: ListModel { diff --git a/plugins/share/kdeconnect_share_config.qml b/plugins/share/kdeconnect_share_config.qml index fee7a8afe..44c6ba259 100644 --- a/plugins/share/kdeconnect_share_config.qml +++ b/plugins/share/kdeconnect_share_config.qml @@ -4,10 +4,10 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.1 -import org.kde.kirigami 2.5 as Kirigami +import QtQuick 2.15 +import QtQuick.Controls 2.15 as QQC2 +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami import Qt.labs.platform 1.1 import org.kde.kdeconnect 1.0 @@ -36,24 +36,24 @@ Kirigami.FormLayout { pluginName: "kdeconnect_share" onConfigChanged: { - path.text = get("incoming_path", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", "")) + path.text = getString("incoming_path", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", "")) } } RowLayout { Kirigami.FormData.label: i18n("Save files in:") - TextField { + QQC2.TextField { id: path } - Button { + QQC2.Button { icon.name: "document-open" onClicked: folderDialog.open() } } - Label { - text: "%1 in the path will be replaced with the specific device name" + QQC2.Label { + text: i18n("%1 in the path will be replaced with the specific device name") } }