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 <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-12-13 21:45:50 +01:00
parent c64ac4101a
commit b2e83f506c
5 changed files with 72 additions and 67 deletions

View file

@ -4,10 +4,10 @@
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 2.2 import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
Kirigami.FormLayout { Kirigami.FormLayout {
@ -21,17 +21,17 @@ Kirigami.FormLayout {
} }
Component.onCompleted: { Component.onCompleted: {
unknown.checked = config.get("sendUnknown", true) unknown.checked = config.getBool("sendUnknown", true)
password.checked = config.get("sendPassword", true) password.checked = config.getBool("sendPassword", true)
} }
CheckBox { QQC2.CheckBox {
id: password id: password
text: i18n("Passwords (as marked by password managers)") text: i18n("Passwords (as marked by password managers)")
onClicked: config.set("sendPassword", checked) onClicked: config.set("sendPassword", checked)
} }
CheckBox { QQC2.CheckBox {
id: unknown id: unknown
text: i18n("Anything else") text: i18n("Anything else")
onClicked: config.set("sendUnknown", checked) onClicked: config.set("sendUnknown", checked)

View file

@ -4,10 +4,10 @@
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 2.2 import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
@ -36,22 +36,20 @@ Kirigami.FormLayout {
pluginName: "kdeconnect_findthisdevice" pluginName: "kdeconnect_findthisdevice"
onConfigChanged: { onConfigChanged: {
path.text = get("ringtone", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", "")) path.text = getString("ringtone", StandardPaths.writableLocation(StandardPaths.DownloadsLocation).toString().replace("file://", ""))
} }
} }
RowLayout { RowLayout {
Kirigami.FormData.label: i18n("Sound to play:") Kirigami.FormData.label: i18n("Sound to play:")
TextField { QQC2.TextField {
id: path id: path
} }
Button { QQC2.Button {
icon.name: "document-open" icon.name: "document-open"
onClicked: { onClicked: fileDialog.open()
fileDialog.open()
}
} }
} }
} }

View file

@ -4,14 +4,13 @@
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 2.2 import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
Kirigami.FormLayout { Kirigami.FormLayout {
property string device property string device
KdeConnectPluginConfig { KdeConnectPluginConfig {
@ -21,39 +20,38 @@ Kirigami.FormLayout {
} }
Component.onCompleted: { Component.onCompleted: {
talking.checked = config.get("conditionTalking", false) talking.checked = config.getBool("conditionTalking", false)
mute.checked = config.get("actionMute", false) mute.checked = config.getBool("actionMute", false)
pause.checked = config.get("actionPause", true) pause.checked = config.getBool("actionPause", true)
resume.checked = config.get("actionResume", true) resume.checked = config.getBool("actionResume", true)
} }
RadioButton { QQC2.RadioButton {
text: i18n("Pause as soon as phone rings") text: i18n("Pause as soon as phone rings")
checked: !talking.checked checked: !talking.checked
} }
RadioButton { QQC2.RadioButton {
id: talking id: talking
onCheckedChanged: config.set("conditionTalking", checked) onCheckedChanged: config.set("conditionTalking", checked)
text: i18n("Pause only while talking") text: i18n("Pause only while talking")
} }
CheckBox { QQC2.CheckBox {
id: pause id: pause
text: i18n("Pause media players") text: i18n("Pause media players")
onClicked: config.set("actionPause", checked) onClicked: config.set("actionPause", checked)
} }
CheckBox { QQC2.CheckBox {
id: mute id: mute
text: i18n("Mute system sound") text: i18n("Mute system sound")
onClicked: config.set("actionMute", checked) onClicked: config.set("actionMute", checked)
} }
CheckBox { QQC2.CheckBox {
id: resume id: resume
text: i18n("Resume automatically when call ends") text: i18n("Resume automatically when call ends")
onClicked: config.set("actionResume", checked) onClicked: config.set("actionResume", checked)
} }
} }

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 2.5 import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.4 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
ListView { ListView {
id: view
Component.onCompleted: { Component.onCompleted: {
root.leftPadding = 0 root.leftPadding = 0
root.rightPadding = 0 root.rightPadding = 0
@ -35,35 +35,44 @@ ListView {
width: parent.width width: parent.width
enabled: true enabled: true
Label { QQC2.Label {
text: i18n("%1 <br> <i>%2</i>", name, command) text: i18n("%1 <br> <i>%2</i>", name, command)
} }
actions: [ actions: Kirigami.Action {
Kirigami.Action { text: i18n("Delete")
icon.name: "delete" icon.name: "delete"
onTriggered: commandModel.removeCommand(index) onTriggered: commandModel.removeCommand(index)
} }
]
} }
Dialog { 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 id: addDialog
title: "Add command" title: "Add command"
standardButtons: Dialog.Save | Dialog.Cancel standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Cancel
Kirigami.FormLayout { Kirigami.FormLayout {
TextField { QQC2.TextField {
id: nameField id: nameField
Kirigami.FormData.label: i18n("Name:") Kirigami.FormData.label: i18n("Name:")
} }
TextField { QQC2.TextField {
id: commandField id: commandField
Kirigami.FormData.label: i18n("Command:") Kirigami.FormData.label: i18n("Command:")
} }
ComboBox { QQC2.ComboBox {
Kirigami.FormData.label: i18n("Sample commands:") Kirigami.FormData.label: i18n("Sample commands:")
textRole: "name" textRole: "name"
model: ListModel { model: ListModel {

View file

@ -4,10 +4,10 @@
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/ */
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 2.2 import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.5 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
@ -36,24 +36,24 @@ Kirigami.FormLayout {
pluginName: "kdeconnect_share" pluginName: "kdeconnect_share"
onConfigChanged: { 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 { RowLayout {
Kirigami.FormData.label: i18n("Save files in:") Kirigami.FormData.label: i18n("Save files in:")
TextField { QQC2.TextField {
id: path id: path
} }
Button { QQC2.Button {
icon.name: "document-open" icon.name: "document-open"
onClicked: folderDialog.open() onClicked: folderDialog.open()
} }
} }
Label { QQC2.Label {
text: "%1 in the path will be replaced with the specific device name" text: i18n("%1 in the path will be replaced with the specific device name")
} }
} }