Skip to content

Commit

Permalink
feat(config): add option for specify click action
Browse files Browse the repository at this point in the history
Fix #12
  • Loading branch information
orblazer committed Dec 2, 2021
1 parent 082df08 commit ae2e9c6
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 9 deletions.
4 changes: 4 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<default>1.0</default>
</entry>

<entry name="actionService" type="String">
<default>org.kde.plasma-systemmonitor</default>
</entry>

<entry name="showCpuMonitor" type="Bool">
<default>true</default>
</entry>
Expand Down
Binary file not shown.
59 changes: 59 additions & 0 deletions package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,31 @@ QtLayouts.ColumnLayout {
spacing: Kirigami.Units.largeSpacing

property alias cfg_updateInterval: updateInterval.valueReal
property alias cfg_actionService: customActionService.text

property alias cfg_showCpuMonitor: showCpuMonitor.checked
property alias cfg_showClock: showClock.checked
property alias cfg_showRamMonitor: showRamMonitor.checked
property alias cfg_memoryInPercent: memoryInPercent.checked
property alias cfg_showNetMonitor: showNetMonitor.checked

// TODO: find way to use `.desktop` transltation for programs
readonly property var actionServiceOptions: [
{
"label": i18n("Custom"),
"value": ""
}, {
"label": i18n("Plasma System Monitor"),
"value": "org.kde.plasma-systemmonitor"
}, {
"label": "KSysGuard",
"value": "org.kde.ksysguard"
}, {
"label": i18n("System Monitor"),
"value": "org.kde.systemmonitor"
}
]


Kirigami.FormLayout {
wideMode: true
Expand All @@ -36,6 +54,47 @@ QtLayouts.ColumnLayout {
return i18n("%1 seconds", valueToText(value))
}
}

// click action
PlasmaComponents.Label {
text: i18n("Click action")
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.2
}

QtControls.ComboBox {
id: actionService
Kirigami.FormData.label: i18n("Program:")
textRole: "label"
model: actionServiceOptions
QtLayouts.Layout.fillWidth: true

onCurrentIndexChanged: {
var current = model[currentIndex]
if (current && current.value !== "") {
customActionService.text = current.value
}
}

Component.onCompleted: {
for (var i = 0; i < model.length; i++) {
if (model[i]["value"] === plasmoid.configuration.actionService) {
actionService.currentIndex = i;
return
}
}

actionService.currentIndex = 0 // Custom
}
}
QtControls.TextField {
id: customActionService
Kirigami.FormData.label: i18n("Custom program:")
QtLayouts.Layout.fillWidth: true
visible: actionService.currentIndex === 0
}
PlasmaComponents.Label {
text: i18n("NOTE: The is name should same as filename\nin \"%1\"", "/usr/share/applications/")
}
}

// Charts
Expand Down
5 changes: 2 additions & 3 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Item {

// Settings properties
property bool verticalLayout: plasmoid.configuration.verticalLayout
property string actionService: plasmoid.configuration.actionService

property bool showCpuMonitor: plasmoid.configuration.showCpuMonitor
property bool showClock: plasmoid.configuration.showClock
Expand Down Expand Up @@ -220,9 +221,7 @@ Item {
id: mouseArea
anchors.fill: parent
onClicked: {
if (!kRun.openService("org.kde.plasma-systemmonitor")) {
kRun.openService("org.kde.ksysguard")
}
kRun.openService(actionService)
}
}

Expand Down
4 changes: 2 additions & 2 deletions package/translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Or if you know how to make a pull request

| Locale | Lines | % Done|
|----------|---------|-------|
| Template | 58 | |
| fr | 58/58 | 100% |
| Template | 64 | |
| fr | 64/64 | 100% |
33 changes: 31 additions & 2 deletions package/translate/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: resourcesMonitor-fork\n"
"Report-Msgid-Bugs-To: https://github.com/orblazer/plasma-applet-resources-monitor\n"
"POT-Creation-Date: 2021-12-02 12:57+0100\n"
"POT-Creation-Date: 2021-12-02 13:42+0100\n"
"PO-Revision-Date: 2021-12-02 13:01+0100\n"
"Last-Translator: orblazer\n"
"Language: fr\n"
Expand Down Expand Up @@ -152,7 +152,7 @@ msgstr "Couleur du traffic sortant :"
msgid "Choose network sending graph color"
msgstr "Choisissez la couleur du graphique du traffic sortant"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigData.qml
#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigData.qml /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Custom"
msgstr "Personnalisée"

Expand Down Expand Up @@ -196,6 +196,14 @@ msgstr "Vitesse d'envoi maximale :"
msgid "Custom max sending speed:"
msgstr "Vitesse d'envoi maximale personnalisée"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Plasma System Monitor"
msgstr "Surveillance du système Plasma"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "System Monitor"
msgstr "Surveillance du système"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Update interval:"
msgstr "Intervalle d'actualisation :"
Expand All @@ -204,6 +212,27 @@ msgstr "Intervalle d'actualisation :"
msgid "%1 seconds"
msgstr "%1 secondes"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Click action"
msgstr "Action du clique"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Program:"
msgstr "Programme"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Custom program:"
msgstr "Programme personnalisé"

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid ""
"NOTE: The is name should same as filename\n"
"in \"%1\""
msgstr ""
"NOTE: Le nom est doit être le même\n"
"que celui du fichier dans\n"
"\"%1\""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Charts"
msgstr "Graphiques"
Expand Down
30 changes: 28 additions & 2 deletions package/translate/template.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: resourcesMonitor-fork\n"
"Report-Msgid-Bugs-To: https://github.com/orblazer/plasma-applet-resources-monitor\n"
"POT-Creation-Date: 2021-12-02 12:57+0100\n"
"POT-Creation-Date: 2021-12-02 13:42+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -153,7 +153,7 @@ msgstr ""
msgid "Choose network sending graph color"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigData.qml
#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigData.qml /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Custom"
msgstr ""

Expand Down Expand Up @@ -197,6 +197,14 @@ msgstr ""
msgid "Custom max sending speed:"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Plasma System Monitor"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "System Monitor"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Update interval:"
msgstr ""
Expand All @@ -205,6 +213,24 @@ msgstr ""
msgid "%1 seconds"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Click action"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Program:"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Custom program:"
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid ""
"NOTE: The is name should same as\n"
"filename in \"%1\""
msgstr ""

#: /home/orblazer/dev/kde/plasma-applet-resources-monitor/package/contents/ui/config/ConfigGeneral.qml
msgid "Charts"
msgstr ""
Expand Down

0 comments on commit ae2e9c6

Please sign in to comment.