2019-12-01 22:27:00 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
|
|
|
Item {
|
2021-03-20 21:45:30 +03:00
|
|
|
height: button.height + (menu != undefined ? menu.height : 0) + resetMenu.height
|
2020-11-23 20:34:38 +03:00
|
|
|
width: parent.width
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
property string name
|
|
|
|
property string prettyName
|
|
|
|
property int tag
|
2021-07-09 20:17:45 +03:00
|
|
|
property string subkey: ""
|
2021-03-21 16:01:19 +03:00
|
|
|
property bool _valid: parent.isValid(name)
|
|
|
|
property bool valid: _valid
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
property var choice
|
2021-03-21 16:01:19 +03:00
|
|
|
property var default_choice: parent.getDefaultChoice(name)
|
|
|
|
|
|
|
|
Component.onCompleted: parent.setInitialChoice(this)
|
|
|
|
|
|
|
|
onChoiceChanged: parent.choiceMade(this)
|
2020-11-23 22:29:59 +03:00
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
signal clicked()
|
2021-01-02 19:39:06 +03:00
|
|
|
onClicked: {
|
|
|
|
if (hasMenu)
|
|
|
|
{
|
|
|
|
menu.open(this)
|
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2021-03-20 21:45:30 +03:00
|
|
|
signal pressAndHold()
|
|
|
|
onPressAndHold: {
|
|
|
|
resetMenu.open(this)
|
|
|
|
}
|
|
|
|
|
2020-11-23 22:57:02 +03:00
|
|
|
property alias displayValue: button.value
|
|
|
|
|
|
|
|
ValueButton {
|
|
|
|
id: button
|
|
|
|
enabled: valid
|
|
|
|
label: prettyName
|
|
|
|
onClicked: parent.clicked()
|
2021-03-20 21:45:30 +03:00
|
|
|
onPressAndHold: parent.pressAndHold()
|
|
|
|
valueColor: choice != undefined ? Theme.highlightColor : Theme.secondaryHighlightColor
|
2020-11-23 22:57:02 +03:00
|
|
|
}
|
2021-01-02 19:39:06 +03:00
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
property var menu
|
2021-01-02 19:39:06 +03:00
|
|
|
property bool hasMenu: true
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2021-03-20 21:45:30 +03:00
|
|
|
ContextMenu {
|
|
|
|
id: resetMenu
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Reset")
|
|
|
|
onClicked: choice = undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|