diff --git a/qml/components/IntegerSetting.qml b/qml/components/IntegerSetting.qml index c45df93..eeb4bc4 100644 --- a/qml/components/IntegerSetting.qml +++ b/qml/components/IntegerSetting.qml @@ -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 diff --git a/qml/components/RangeSetting.qml b/qml/components/RangeSetting.qml index ed27b63..5b62873 100644 --- a/qml/components/RangeSetting.qml +++ b/qml/components/RangeSetting.qml @@ -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; diff --git a/qml/components/Setting.qml b/qml/components/Setting.qml index 622332c..dc5dcee 100644 --- a/qml/components/Setting.qml +++ b/qml/components/Setting.qml @@ -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 + } + } + } diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 937d689..1981adb 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -450,6 +450,13 @@ Alle + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index a611d4f..9f545fb 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -450,6 +450,13 @@ + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 330ee75..ab52335 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -450,6 +450,13 @@ + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint-nl.ts b/translations/harbour-seaprint-nl.ts index 5b46ef1..921cef4 100644 --- a/translations/harbour-seaprint-nl.ts +++ b/translations/harbour-seaprint-nl.ts @@ -450,6 +450,13 @@ alles + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts index 2728142..d1062bf 100644 --- a/translations/harbour-seaprint-pl.ts +++ b/translations/harbour-seaprint-pl.ts @@ -450,6 +450,13 @@ + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 8974cbe..2318ca9 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -450,6 +450,13 @@ 全部 + + Setting + + Reset + + + SettingsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index f7c7b28..a16b923 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -450,6 +450,13 @@ + + Setting + + Reset + + + SettingsPage