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 {
|
|
|
|
property int high
|
2020-08-01 21:18:47 +03:00
|
|
|
property int choice_low: 1
|
|
|
|
property int choice_high: 0
|
2022-08-13 17:30:13 +03:00
|
|
|
property bool acceptRangeList: false
|
2020-08-01 21:18:47 +03:00
|
|
|
|
2021-03-20 21:45:30 +03:00
|
|
|
property bool suppressChange: false
|
2020-08-01 21:18:47 +03:00
|
|
|
|
|
|
|
function update_choice() {
|
2021-03-21 00:45:58 +03:00
|
|
|
if (choice_high == 0)
|
|
|
|
{
|
|
|
|
choice = undefined;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
choice = new Object({low: choice_low, high: choice_high});
|
|
|
|
}
|
2020-08-01 21:18:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onChoice_highChanged: {
|
2021-03-20 21:45:30 +03:00
|
|
|
if(!suppressChange)
|
2020-08-01 21:18:47 +03:00
|
|
|
{
|
2021-03-20 21:45:30 +03:00
|
|
|
if(choice_high < choice_low)
|
|
|
|
{
|
|
|
|
low_slider.value = choice_high > 0 ? choice_high : 1;
|
|
|
|
}
|
2021-03-21 00:45:58 +03:00
|
|
|
update_choice()
|
2020-08-01 21:18:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
onChoice_lowChanged: {
|
2021-03-20 21:45:30 +03:00
|
|
|
if(!suppressChange)
|
2020-08-01 21:18:47 +03:00
|
|
|
{
|
2021-03-20 21:45:30 +03:00
|
|
|
if(choice_low > choice_high)
|
|
|
|
{
|
|
|
|
high_slider.value = choice_low
|
|
|
|
}
|
2021-03-21 00:45:58 +03:00
|
|
|
update_choice()
|
2020-08-01 21:18:47 +03:00
|
|
|
}
|
2021-03-20 21:45:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onChoiceChanged: {
|
2022-08-13 17:30:13 +03:00
|
|
|
if(choice == undefined || choice.constructor.name !== "Object")
|
2020-08-01 21:18:47 +03:00
|
|
|
{
|
2021-03-20 21:45:30 +03:00
|
|
|
suppressChange = true;
|
|
|
|
low_slider.value = low_slider.minimumValue;
|
|
|
|
high_slider.value = high_slider.minimumValue;
|
|
|
|
suppressChange = false;
|
2020-08-01 21:18:47 +03:00
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2022-08-13 17:30:13 +03:00
|
|
|
displayValue: prettify(choice)
|
|
|
|
|
|
|
|
function prettify(choice)
|
|
|
|
{
|
|
|
|
if(choice == undefined)
|
|
|
|
{
|
|
|
|
return qsTr("all");
|
|
|
|
}
|
|
|
|
else if(choice.constructor.name === "Object")
|
|
|
|
{
|
|
|
|
return (""+choice.low+" - "+choice.high)
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var ret = "";
|
|
|
|
for(var i = 0; i < choice.length; i++)
|
|
|
|
{
|
|
|
|
if(i!=0)
|
|
|
|
{
|
|
|
|
ret = ret+","
|
|
|
|
}
|
|
|
|
if(choice[i].low == choice[i].high)
|
|
|
|
{
|
|
|
|
ret=ret+choice[i].low
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret=ret+choice[i].low+"-"+choice[i].high
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
2020-11-23 22:29:59 +03:00
|
|
|
menu: ContextMenu {
|
2020-08-01 21:18:47 +03:00
|
|
|
MenuItem {
|
|
|
|
Slider
|
|
|
|
{
|
|
|
|
id: low_slider
|
|
|
|
minimumValue: 1
|
2021-12-05 15:23:14 +03:00
|
|
|
maximumValue: high > 50 ? 50 : high
|
2020-08-01 21:18:47 +03:00
|
|
|
width: parent.width
|
|
|
|
stepSize: 1
|
|
|
|
onValueChanged:
|
|
|
|
{
|
|
|
|
choice_low = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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: 1, max: high});
|
|
|
|
dialog.accepted.connect(function() {
|
|
|
|
choice_low = dialog.value;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
MenuItem {
|
2020-08-01 21:18:47 +03:00
|
|
|
Slider
|
|
|
|
{
|
|
|
|
id: high_slider
|
|
|
|
minimumValue: 0
|
2021-12-05 15:23:14 +03:00
|
|
|
maximumValue: high > 50 ? 50 : high
|
2020-08-01 21:18:47 +03:00
|
|
|
width: parent.width
|
|
|
|
stepSize: 1
|
|
|
|
onValueChanged:
|
|
|
|
{
|
|
|
|
choice_high = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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: 1, max: high});
|
|
|
|
dialog.accepted.connect(function() {
|
|
|
|
choice_high = dialog.value;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-13 17:30:13 +03:00
|
|
|
MenuItem {
|
|
|
|
visible: acceptRangeList
|
|
|
|
text: qsTr("Advanced")
|
|
|
|
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("RangeListInputDialog.qml"),
|
|
|
|
{value: choice, title: prettyName});
|
|
|
|
dialog.accepted.connect(function() {
|
|
|
|
choice = dialog.value;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|