Dim values of unset settings (that are showing the default)

Add a reset option.
This commit is contained in:
Anton Thomasson 2021-03-20 19:45:30 +01:00
parent 0f890337d3
commit 9246d385b0
10 changed files with 111 additions and 15 deletions

View file

@ -5,22 +5,37 @@ Setting {
property int low
property int high
property bool suppressChange: false
displayValue: choice ? choice : default_choice
onChoiceChanged: {
if(choice == undefined)
{
console.log("choice unset");
suppressChange = true;
slider.value = slider.minimumValue;
suppressChange = false;
}
}
menu: ContextMenu {
MenuItem {
Slider
{
id: slider
minimumValue: low
maximumValue: high < 100 ? high : 100
width: parent.width
stepSize: 1
value: choice ? choice : default_choice
onValueChanged:
{
if(!suppressChange)
{
choice = value;
}
}
}
IconButton
{
anchors.right: parent.right

View file

@ -6,12 +6,15 @@ Setting {
property int choice_low: 1
property int choice_high: 0
property bool suppressChange: false
function update_choice() {
choice = new Object({low: choice_low, high: choice_high});
}
onChoice_highChanged: {
if(!suppressChange)
{
if(choice_high < choice_low)
{
low_slider.value = choice_high > 0 ? choice_high : 1;
@ -21,7 +24,10 @@ Setting {
update_choice()
}
}
}
onChoice_lowChanged: {
if(!suppressChange)
{
if(choice_low > choice_high)
{
high_slider.value = choice_low
@ -31,6 +37,18 @@ Setting {
update_choice()
}
}
}
onChoiceChanged: {
if(choice == undefined)
{
console.log("choice unset");
suppressChange = true;
low_slider.value = low_slider.minimumValue;
high_slider.value = high_slider.minimumValue;
suppressChange = false;
}
}
displayValue: choice_high==0 ? qsTr("all") : ""+choice_low+" - "+choice_high
@ -43,7 +61,6 @@ Setting {
maximumValue: high > 100 ? 100 : high
width: parent.width
stepSize: 1
value: choice_low
onValueChanged:
{
choice_low = value;
@ -72,7 +89,6 @@ Setting {
maximumValue: high > 100 ? 100 : high
width: parent.width
stepSize: 1
value: choice_high
onValueChanged:
{
choice_high = value;

View file

@ -2,7 +2,7 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
Item {
height: button.height + (menu != undefined ? menu.height : 0)
height: button.height + (menu != undefined ? menu.height : 0) + resetMenu.height
width: parent.width
property string name
@ -21,6 +21,11 @@ Item {
}
}
signal pressAndHold()
onPressAndHold: {
resetMenu.open(this)
}
property alias displayValue: button.value
ValueButton {
@ -28,9 +33,20 @@ Item {
enabled: valid
label: prettyName
onClicked: parent.clicked()
onPressAndHold: parent.pressAndHold()
valueColor: choice != undefined ? Theme.highlightColor : Theme.secondaryHighlightColor
}
property var menu
property bool hasMenu: true
ContextMenu {
id: resetMenu
MenuItem {
text: qsTr("Reset")
onClicked: choice = undefined
}
}
}

View file

@ -450,6 +450,13 @@
<translation>Alle</translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation>alles</translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation></translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>

View file

@ -450,6 +450,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Setting</name>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>
<message>