Dim values of unset settings (that are showing the default)
Add a reset option.
This commit is contained in:
parent
0f890337d3
commit
9246d385b0
10 changed files with 111 additions and 15 deletions
|
@ -5,20 +5,35 @@ 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:
|
||||
{
|
||||
choice = value;
|
||||
if(!suppressChange)
|
||||
{
|
||||
choice = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
IconButton
|
||||
|
|
|
@ -6,29 +6,47 @@ 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(choice_high < choice_low)
|
||||
if(!suppressChange)
|
||||
{
|
||||
low_slider.value = choice_high > 0 ? choice_high : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
update_choice()
|
||||
if(choice_high < choice_low)
|
||||
{
|
||||
low_slider.value = choice_high > 0 ? choice_high : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
update_choice()
|
||||
}
|
||||
}
|
||||
}
|
||||
onChoice_lowChanged: {
|
||||
if(choice_low > choice_high)
|
||||
if(!suppressChange)
|
||||
{
|
||||
high_slider.value = choice_low
|
||||
if(choice_low > choice_high)
|
||||
{
|
||||
high_slider.value = choice_low
|
||||
}
|
||||
else
|
||||
{
|
||||
update_choice()
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
onChoiceChanged: {
|
||||
if(choice == undefined)
|
||||
{
|
||||
update_choice()
|
||||
console.log("choice unset");
|
||||
suppressChange = true;
|
||||
low_slider.value = low_slider.minimumValue;
|
||||
high_slider.value = high_slider.minimumValue;
|
||||
suppressChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue