| 1 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 |
// Copyright 2019 Juan Palacios <[email protected]> |
| 3 |
|
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 |
| 6 |
import CoreCtrl.UIComponents 1.0 |
| 7 |
import "Style.js" as Style |
| 8 |
|
| 9 |
AMD_PM_FIXED { |
| 10 |
id: pmFixed |
| 11 |
objectName: "AMD_PM_FIXED" |
| 12 |
|
| 13 |
width: contents.width |
| 14 |
height: contents.height |
| 15 |
|
| 16 |
Component { |
| 17 |
id: modeButton |
| 18 |
|
| 19 |
Button { |
| 20 |
property string mode; |
| 21 |
checkable: true; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
onModesChanged: modes => { |
| 26 |
for (var i = 0; i < modes.length; i+=2) { |
| 27 |
var button = modeButton.createObject(btnContainer); |
| 28 |
button.mode = modes[i] |
| 29 |
button.text = modes[i + 1] |
| 30 |
} |
| 31 |
btnContainer.forceLayout() |
| 32 |
} |
| 33 |
|
| 34 |
onModeChanged: mode => { |
| 35 |
// check the button specified by mode |
| 36 |
var buttons = btnContainer.children |
| 37 |
for (var i = 0; i < buttons.length; i++) { |
| 38 |
if (buttons[i].mode === mode) { |
| 39 |
buttons[i].checked = true |
| 40 |
btnGroup.lastChecked = buttons[i] |
| 41 |
break; |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
ButtonGroup { |
| 47 |
id: btnGroup |
| 48 |
property var lastChecked |
| 49 |
buttons: btnContainer.children |
| 50 |
|
| 51 |
onClicked: button => { |
| 52 |
if (lastChecked !== button) { |
| 53 |
lastChecked = button |
| 54 |
pmFixed.changeMode(button.mode) |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
CPane { |
| 60 |
id: contents |
| 61 |
|
| 62 |
Row { |
| 63 |
id: btnContainer |
| 64 |
spacing: 8 |
| 65 |
} |
| 66 |
} |
| 67 |
} |