|
| 1 | +import QtQuick |
| 2 | +import QtQuick.Layouts |
| 3 | +import qs.Commons |
| 4 | +import qs.Widgets |
| 5 | + |
| 6 | +ColumnLayout { |
| 7 | + id: root |
| 8 | + |
| 9 | + property var pluginApi: null |
| 10 | + |
| 11 | + property var cfg: pluginApi?.pluginSettings || ({}) |
| 12 | + property var defaults: pluginApi?.manifest?.metadata?.defaultSettings || ({}) |
| 13 | + |
| 14 | + property string editBackend: cfg.backend ?? defaults.backend ?? "auto" |
| 15 | + property bool editHideWhenUnavailable: cfg.hideWhenUnavailable ?? defaults.hideWhenUnavailable ?? false |
| 16 | + property bool editDisableHoverIcon: cfg.disableHoverIcon ?? defaults.disableHoverIcon ?? false |
| 17 | + property string editWvkbdBin: cfg.wvkbdBin ?? defaults.wvkbdBin ?? "wvkbd-mobintl" |
| 18 | + |
| 19 | + readonly property bool showWvkbdBin: editBackend === "wvkbd" || editBackend === "auto" |
| 20 | + |
| 21 | + spacing: Style.marginL |
| 22 | + |
| 23 | + NComboBox { |
| 24 | + Layout.fillWidth: true |
| 25 | + label: pluginApi?.tr("settings.backend.label") |
| 26 | + description: pluginApi?.tr("settings.backend.desc") |
| 27 | + model: [ |
| 28 | + { key: "auto", name: pluginApi?.tr("settings.backend.option.auto") }, |
| 29 | + { key: "squeekboard", name: pluginApi?.tr("settings.backend.option.squeekboard") }, |
| 30 | + { key: "wvkbd", name: pluginApi?.tr("settings.backend.option.wvkbd") } |
| 31 | + ] |
| 32 | + currentKey: root.editBackend |
| 33 | + onSelected: key => { |
| 34 | + root.editBackend = key |
| 35 | + root.saveSettings() |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + NToggle { |
| 40 | + Layout.fillWidth: true |
| 41 | + label: pluginApi?.tr("settings.hideWhenUnavailable.label") |
| 42 | + description: pluginApi?.tr("settings.hideWhenUnavailable.desc") |
| 43 | + checked: root.editHideWhenUnavailable |
| 44 | + onToggled: checked => { |
| 45 | + root.editHideWhenUnavailable = checked |
| 46 | + root.saveSettings() |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + NToggle { |
| 51 | + Layout.fillWidth: true |
| 52 | + label: pluginApi?.tr("settings.disableHoverIcon.label") |
| 53 | + description: pluginApi?.tr("settings.disableHoverIcon.desc") |
| 54 | + checked: root.editDisableHoverIcon |
| 55 | + onToggled: checked => { |
| 56 | + root.editDisableHoverIcon = checked |
| 57 | + root.saveSettings() |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + NTextInput { |
| 62 | + Layout.fillWidth: true |
| 63 | + visible: root.showWvkbdBin |
| 64 | + label: pluginApi?.tr("settings.wvkbdBin.label") |
| 65 | + description: pluginApi?.tr("settings.wvkbdBin.desc") |
| 66 | + text: root.editWvkbdBin |
| 67 | + onEditingFinished: { |
| 68 | + root.editWvkbdBin = text |
| 69 | + root.saveSettings() |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + RowLayout { |
| 74 | + Layout.fillWidth: true |
| 75 | + |
| 76 | + NLabel { |
| 77 | + Layout.fillWidth: true |
| 78 | + label: pluginApi?.tr("settings.recheck.desc") |
| 79 | + } |
| 80 | + |
| 81 | + NButton { |
| 82 | + text: recheckDone ? pluginApi?.tr("settings.recheck.done") : pluginApi?.tr("settings.recheck.label") |
| 83 | + property bool recheckDone: false |
| 84 | + onClicked: { |
| 85 | + pluginApi?.mainInstance?.recheckState() |
| 86 | + recheckDone = true |
| 87 | + recheckTimer.restart() |
| 88 | + } |
| 89 | + Timer { |
| 90 | + id: recheckTimer |
| 91 | + interval: 1500 |
| 92 | + onTriggered: parent.recheckDone = false |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + function saveSettings() { |
| 98 | + if (!pluginApi) return |
| 99 | + pluginApi.pluginSettings.backend = root.editBackend |
| 100 | + pluginApi.pluginSettings.hideWhenUnavailable = root.editHideWhenUnavailable |
| 101 | + pluginApi.pluginSettings.disableHoverIcon = root.editDisableHoverIcon |
| 102 | + pluginApi.pluginSettings.wvkbdBin = root.editWvkbdBin |
| 103 | + pluginApi.saveSettings() |
| 104 | + } |
| 105 | +} |
0 commit comments