harbour-seaprint/qml/components/IntegerSetting.qml

58 lines
1.6 KiB
QML
Raw Normal View History

2021-07-11 15:27:03 +03:00
import QtQuick 2.6
2019-12-01 22:27:00 +03:00
import Sailfish.Silica 1.0
Setting {
2021-03-21 16:01:19 +03:00
property int low: valid ? parent.printer.attrs[name+"-supported"].value.low : 0
property int high: valid ? parent.printer.attrs[name+"-supported"].value.high : 0
2019-12-01 22:27:00 +03:00
property bool suppressChange: false
2021-07-31 13:36:04 +03:00
displayValue: choice != undefined ? choice : default_choice
2019-12-01 22:27:00 +03:00
onChoiceChanged: {
if(choice == undefined)
{
console.log("choice unset");
suppressChange = true;
slider.value = slider.minimumValue;
suppressChange = false;
}
}
2020-11-23 22:29:59 +03:00
menu: ContextMenu {
2019-12-01 22:27:00 +03:00
MenuItem {
Slider
{
id: slider
2019-12-01 22:27:00 +03:00
minimumValue: low
maximumValue: high < 100 ? high : 100
width: parent.width
stepSize: 1
onValueChanged:
{
if(!suppressChange)
{
choice = value;
}
2019-12-01 22:27:00 +03:00
}
}
IconButton
{
anchors.right: parent.right
icon.source: "image://theme/icon-s-edit"
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("IntegerInputDialog.qml"),
{value: choice, title: prettyName,
min: low, max: high});
dialog.accepted.connect(function() {
choice = dialog.value;
})
}
}
}
}
}