Skip to content

Commit

Permalink
fix(config): allow easier fix gpu index
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed Jul 22, 2024
1 parent 616c86e commit 675e308
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 84 deletions.
14 changes: 14 additions & 0 deletions package/contents/ui/config/AvailableGraphProxy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ ListModel {
return undefined;
}

function findAllType(type, excludeAllDevice) {
const results = [];
for (let i = 0; i < count; i++) {
const item = get(i);
if (item.type !== type) {
continue;
} else if (excludeAllDevice && item.device === "all") {
continue;
}
results.push(item);
}
return results;
}

// Sensor for retrieve GPU name
property var _gpuNameFetcher: Sensors.SensorDataModel {
readonly property var gpuNameRegex: /.*\[(.*)\]/
Expand Down
68 changes: 65 additions & 3 deletions package/contents/ui/config/ConfigGraph.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ KCM.ScrollViewKCM {
reuseItems: true

//? Use differrent array due to QML issue with deep object conversion
model: ListModel {
}
model: ListModel {}

delegate: Item {
// External item required to make Kirigami.ListItemDragHandle work
Expand All @@ -91,7 +90,8 @@ KCM.ScrollViewKCM {
icon: "unknown",
fallbackIcon: "unknown",
section: "unknown",
device: model.device ?? model.type
device: model.device ?? model.type,
fixable: model.type === "gpu" && model.device !== "all"
};
}
return info;
Expand Down Expand Up @@ -135,6 +135,17 @@ KCM.ScrollViewKCM {
}

// Actions
QQC2.Button {
id: fixButton
visible: graphInfo.fixable ?? false
text: i18n("Fix...")
QQC2.ToolTip.text: i18nc("@info:tooltip", "Edit \"%1\" graph", name.text)
QQC2.ToolTip.visible: hovered

onClicked: {
fixDialog.openFor(index, name.text);
}
}
DelegateButton {
icon.name: "edit-entry-symbolic"
text: i18nc("@info:tooltip", "Edit \"%1\" graph", name.text)
Expand Down Expand Up @@ -306,6 +317,57 @@ KCM.ScrollViewKCM {
}
}

// Fix dialog
Kirigami.Dialog {
id: fixDialog
width: graphsView.width - Kirigami.Units.gridUnit * 4
height: graphsView.height

title: i18nc("@title:window", "Edit graph: %1", graphName)
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel

property int graphIndex
property string graphName

onAccepted: {
const newGraph = graphs[graphIndex];
newGraph.device = newGpuIndexes.currentValue;
graphs[graphIndex] = newGraph;
graphsView.model.set(graphIndex, {
type: "gpu",
device: newGraph.device
});
saveGraphs();
}

Kirigami.FormLayout {
QQC2.ComboBox {
id: newGpuIndexes
Layout.fillWidth: true
Kirigami.FormData.label: i18n("New GPU:")

textRole: "name"
valueRole: "device"
}
}

/**
* Open edit modal for specific graph
* @param {number} index The graph index
* @param {string} name The graph name
*/
function openFor(index, name) {
if (typeof newGpuIndexes.model === "undefined") {
newGpuIndexes.model = availableGraphs.findAllType("gpu", true);
}

// Load settings page
graphIndex = index;
graphName = name;
fixDialog.open();
}
}

// Remove dialog
Kirigami.PromptDialog {
id: removePrompt
Expand Down
8 changes: 4 additions & 4 deletions package/translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Or if you're able to work with "github's" mechanics and "npm":

| Locale | Lines | % Done|
|----------|---------|-------|
| Template | 127 | |
| de | 127/127 | 100% |
| fr | 127/127 | 100% |
| nl | 127/127 | 100% |
| Template | 129 | |
| de | 129/129 | 100% |
| fr | 129/129 | 100% |
| nl | 129/129 | 100% |
49 changes: 29 additions & 20 deletions package/translate/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Copyright (C) 2024
# This file is distributed under the same license as the resources-monitor package.
# madeddy <saxony@earth.sol>, 2024.
# orblazer, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: resources-monitor\n"
"Report-Msgid-Bugs-To: https://github.com/orblazer/plasma-applet-resources-monitor\n"
"POT-Creation-Date: 2024-05-24 14:54+0200\n"
"PO-Revision-Date: 2024-05-24 14:55+0200\n"
"Last-Translator: madeddy <saxony@earth.sol>\n"
"POT-Creation-Date: 2024-07-22 14:04+0200\n"
"PO-Revision-Date: 2024-07-22 14:06+0200\n"
"Last-Translator: orblazer\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -48,27 +49,27 @@ msgctxt "Bytes per second unit symbol"
msgid "iB/s"
msgstr "iB/s"

#: ../contents/ui/code/graphs.js:196
#: ../contents/ui/code/graphs.js:201
msgctxt "Chart name"
msgid "CPU"
msgstr "CPU"

#: ../contents/ui/code/graphs.js:201
#: ../contents/ui/code/graphs.js:206
msgctxt "Chart name"
msgid "Memory"
msgstr "Speicher"

#: ../contents/ui/code/graphs.js:206
#: ../contents/ui/code/graphs.js:211
msgctxt "Chart name"
msgid "GPU [%1]"
msgstr "GPU [%1]"

#: ../contents/ui/code/graphs.js:211
#: ../contents/ui/code/graphs.js:216
msgctxt "Chart name"
msgid "Network"
msgstr "Netzwerk"

#: ../contents/ui/code/graphs.js:216
#: ../contents/ui/code/graphs.js:221
msgctxt "Chart name"
msgid "Disk I/O [%1]"
msgstr "Disk I/O [%1]"
Expand Down Expand Up @@ -123,7 +124,7 @@ msgctxt "Graph label"
msgid "Sending"
msgstr "Senden"

#: ../contents/ui/config/AvailableGraphProxy.qml:132
#: ../contents/ui/config/AvailableGraphProxy.qml:164
msgid "All"
msgstr "Alle"

Expand Down Expand Up @@ -257,55 +258,63 @@ msgstr "Kritisch:"
msgid "The graphs as been upgraded to new version, please save it."
msgstr "Die Diagramme wurden auf die neue Version aktualisiert. Bitte speichere sie."

#: ../contents/ui/config/ConfigGraph.qml:140
#: ../contents/ui/config/ConfigGraph.qml:141
msgid "Fix..."
msgstr "Fixieren..."

#: ../contents/ui/config/ConfigGraph.qml:142 ../contents/ui/config/ConfigGraph.qml:151
msgctxt "@info:tooltip"
msgid "Edit \"%1\" graph"
msgstr "Bearbeite \"%1\" Diagramm"

#: ../contents/ui/config/ConfigGraph.qml:148
#: ../contents/ui/config/ConfigGraph.qml:159
msgctxt "@info:tooltip"
msgid "Delete \"%1\" graph"
msgstr "Lösche \"%1\" Diagramm"

#: ../contents/ui/config/ConfigGraph.qml:174
#: ../contents/ui/config/ConfigGraph.qml:185
msgid "No graph selected"
msgstr "Kein Diagramm ausgewählt"

#: ../contents/ui/config/ConfigGraph.qml:175
#: ../contents/ui/config/ConfigGraph.qml:186
msgctxt "@info"
msgid "Click <i>%1</i> to get started"
msgstr "Wähle <i>%1</i> um zu beginnen"

#: ../contents/ui/config/ConfigGraph.qml:187
#: ../contents/ui/config/ConfigGraph.qml:198
msgid "Add graph…"
msgstr "Diagramm hinzufügen…"

#: ../contents/ui/config/ConfigGraph.qml:199
#: ../contents/ui/config/ConfigGraph.qml:210 ../contents/ui/config/ConfigGraph.qml:326
msgctxt "@title:window"
msgid "Edit graph: %1"
msgstr "Bearbeite Diagramm: %1"

#: ../contents/ui/config/ConfigGraph.qml:251
#: ../contents/ui/config/ConfigGraph.qml:262
msgctxt "@title:window"
msgid "Add graph"
msgstr "Diagramm hinzufügen"

#: ../contents/ui/config/ConfigGraph.qml:296
#: ../contents/ui/config/ConfigGraph.qml:307
msgctxt "@info:tooltip"
msgid "Add"
msgstr "Hinzufügen"

#: ../contents/ui/config/ConfigGraph.qml:316
#: ../contents/ui/config/ConfigGraph.qml:347
msgid "New GPU:"
msgstr "Neue GPU:"

#: ../contents/ui/config/ConfigGraph.qml:378
msgctxt "@title:window"
msgid "Remove graph"
msgstr "Entferne Diagramm"

#: ../contents/ui/config/ConfigGraph.qml:317
#: ../contents/ui/config/ConfigGraph.qml:379
msgctxt "%1 is an graph name"
msgid "Do you want remove graph \"%1\" ?"
msgstr "Möchten Sie das Diagramm \"%1\" entfernen?"

#: ../contents/ui/config/ConfigGraph.qml:322
#: ../contents/ui/config/ConfigGraph.qml:384
msgid "Delete"
msgstr "Löschen"

Expand Down
46 changes: 27 additions & 19 deletions package/translate/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: resources-monitor\n"
"Report-Msgid-Bugs-To: https://github.com/orblazer/plasma-applet-resources-monitor\n"
"POT-Creation-Date: 2024-05-24 14:54+0200\n"
"PO-Revision-Date: 2024-04-24 14:55+0200\n"
"POT-Creation-Date: 2024-07-22 14:04+0200\n"
"PO-Revision-Date: 2024-07-22 14:04+0200\n"
"Last-Translator: orblazer\n"
"Language-Team: \n"
"Language: fr\n"
Expand Down Expand Up @@ -48,27 +48,27 @@ msgctxt "Bytes per second unit symbol"
msgid "iB/s"
msgstr "io/s"

#: ../contents/ui/code/graphs.js:196
#: ../contents/ui/code/graphs.js:201
msgctxt "Chart name"
msgid "CPU"
msgstr "CPU"

#: ../contents/ui/code/graphs.js:201
#: ../contents/ui/code/graphs.js:206
msgctxt "Chart name"
msgid "Memory"
msgstr "Mémoire"

#: ../contents/ui/code/graphs.js:206
#: ../contents/ui/code/graphs.js:211
msgctxt "Chart name"
msgid "GPU [%1]"
msgstr "GPU [%1]"

#: ../contents/ui/code/graphs.js:211
#: ../contents/ui/code/graphs.js:216
msgctxt "Chart name"
msgid "Network"
msgstr "Réseau"

#: ../contents/ui/code/graphs.js:216
#: ../contents/ui/code/graphs.js:221
msgctxt "Chart name"
msgid "Disk I/O [%1]"
msgstr "Disque E/S [%1]"
Expand Down Expand Up @@ -123,7 +123,7 @@ msgctxt "Graph label"
msgid "Sending"
msgstr "Envoi"

#: ../contents/ui/config/AvailableGraphProxy.qml:132
#: ../contents/ui/config/AvailableGraphProxy.qml:164
msgid "All"
msgstr "Tous"

Expand Down Expand Up @@ -257,55 +257,63 @@ msgstr "Critique :"
msgid "The graphs as been upgraded to new version, please save it."
msgstr "Les graphiques ont été mis à jour, veuillez les sauvegarder."

#: ../contents/ui/config/ConfigGraph.qml:140
#: ../contents/ui/config/ConfigGraph.qml:141
msgid "Fix..."
msgstr "Fixer..."

#: ../contents/ui/config/ConfigGraph.qml:142 ../contents/ui/config/ConfigGraph.qml:151
msgctxt "@info:tooltip"
msgid "Edit \"%1\" graph"
msgstr "Modifier le graphique \"%1\""

#: ../contents/ui/config/ConfigGraph.qml:148
#: ../contents/ui/config/ConfigGraph.qml:159
msgctxt "@info:tooltip"
msgid "Delete \"%1\" graph"
msgstr "Supprimer le graphique \"%1\""

#: ../contents/ui/config/ConfigGraph.qml:174
#: ../contents/ui/config/ConfigGraph.qml:185
msgid "No graph selected"
msgstr "Aucun graphique sélectionné"

#: ../contents/ui/config/ConfigGraph.qml:175
#: ../contents/ui/config/ConfigGraph.qml:186
msgctxt "@info"
msgid "Click <i>%1</i> to get started"
msgstr "Cliquez sur <i>%1</i> pour commencer"

#: ../contents/ui/config/ConfigGraph.qml:187
#: ../contents/ui/config/ConfigGraph.qml:198
msgid "Add graph…"
msgstr "Ajouter un graphique..."

#: ../contents/ui/config/ConfigGraph.qml:199
#: ../contents/ui/config/ConfigGraph.qml:210 ../contents/ui/config/ConfigGraph.qml:326
msgctxt "@title:window"
msgid "Edit graph: %1"
msgstr "Édition du graphique : %1"

#: ../contents/ui/config/ConfigGraph.qml:251
#: ../contents/ui/config/ConfigGraph.qml:262
msgctxt "@title:window"
msgid "Add graph"
msgstr "Ajout d'un graphique"

#: ../contents/ui/config/ConfigGraph.qml:296
#: ../contents/ui/config/ConfigGraph.qml:307
msgctxt "@info:tooltip"
msgid "Add"
msgstr "Ajouter"

#: ../contents/ui/config/ConfigGraph.qml:316
#: ../contents/ui/config/ConfigGraph.qml:347
msgid "New GPU:"
msgstr "Nouveau GPU :"

#: ../contents/ui/config/ConfigGraph.qml:378
msgctxt "@title:window"
msgid "Remove graph"
msgstr "Supression du graphique"

#: ../contents/ui/config/ConfigGraph.qml:317
#: ../contents/ui/config/ConfigGraph.qml:379
msgctxt "%1 is an graph name"
msgid "Do you want remove graph \"%1\" ?"
msgstr "Voulez-vous supprimer le graphique \"%1\" ?"

#: ../contents/ui/config/ConfigGraph.qml:322
#: ../contents/ui/config/ConfigGraph.qml:384
msgid "Delete"
msgstr "Supprimer"

Expand Down
Loading

0 comments on commit 675e308

Please sign in to comment.