| 1 | import QtQuick |
| 2 | import QtQuick.Layouts |
| 3 | |
| 4 | // envycontrol mode buttons with the two-click arm (SysPage, settings app > Power) |
| 5 | ColumnLayout { |
| 6 | id: root |
| 7 | // two-click arm before switching (needs a reboot to apply) |
| 8 | property string armedGpu: "" |
| 9 | Timer { id: disarm; interval: 3000; onTriggered: root.armedGpu = "" } |
| 10 | function gpuClick(m) { |
| 11 | if (Gpu.mode === m || Gpu.busy) return |
| 12 | if (armedGpu !== m) { armedGpu = m; disarm.restart(); return } |
| 13 | armedGpu = "" |
| 14 | Gpu.set(m) |
| 15 | } |
| 16 | visible: Gpu.mode !== "" |
| 17 | Layout.fillWidth: true |
| 18 | spacing: 8 |
| 19 | SectionLabel { text: "graphics · envycontrol" } |
| 20 | RowLayout { |
| 21 | Layout.fillWidth: true |
| 22 | spacing: 6 |
| 23 | Repeater { |
| 24 | model: ["integrated", "hybrid", "nvidia"] |
| 25 | delegate: IconBtn { |
| 26 | required property string modelData |
| 27 | Layout.fillWidth: true |
| 28 | icon: Theme.iGpu |
| 29 | label: root.armedGpu === modelData ? "sure?" : modelData |
| 30 | active: Gpu.mode === modelData |
| 31 | opacity: Gpu.busy ? 0.5 : 1 |
| 32 | onClicked: root.gpuClick(modelData) |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | Text { |
| 37 | visible: Gpu.pending !== "" || Gpu.message !== "" || Gpu.busy |
| 38 | Layout.fillWidth: true |
| 39 | wrapMode: Text.Wrap |
| 40 | color: Gpu.message !== "" ? Theme.err : Theme.accent |
| 41 | font.family: Theme.font |
| 42 | font.pixelSize: Theme.fontSize - 2 |
| 43 | text: Gpu.busy ? "switching…" : (Gpu.message !== "" ? Gpu.message : "queued: " + Gpu.pending + " · reboot to apply") |
| 44 | } |
| 45 | } |