Settings page
This commit is contained in:
parent
ad275cf1fb
commit
ab4dfc611b
6 changed files with 184 additions and 8 deletions
|
@ -77,6 +77,16 @@ Python {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setConfig(key, value) {
|
||||||
|
py.call('main.set_config_value', [key, value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig(key, callback) {
|
||||||
|
py.call('main.get_config_value', [key], function (result) {
|
||||||
|
callback(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onReceived: {
|
onReceived: {
|
||||||
console.log('unhandled message: ' + data);
|
console.log('unhandled message: ' + data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ Item {
|
||||||
property real value
|
property real value
|
||||||
property real min: 0.0
|
property real min: 0.0
|
||||||
property real max: 1.0
|
property real max: 1.0
|
||||||
|
property real step: 0.0
|
||||||
property color color: Constants.colors.highlight
|
property color color: Constants.colors.highlight
|
||||||
|
|
||||||
property real displayedValue: mouseArea.pressed ? temporaryValue : value
|
property real displayedValue: mouseArea.pressed ? temporaryValue : value
|
||||||
|
@ -42,13 +43,22 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: slider.valueChangeRequested(min + (max - min) * (mouse.x / width))
|
function updateValue(x) {
|
||||||
onPressed: {
|
if (x > width) {
|
||||||
slider.temporaryValue = (min + (max - min) * (mouse.x / width));
|
x = width;
|
||||||
}
|
} else if (x < 0) {
|
||||||
onPositionChanged: {
|
x = 0;
|
||||||
slider.temporaryValue = (min + (max - min) * (mouse.x / width));
|
}
|
||||||
|
var v = (max - min) * (x / width);
|
||||||
|
if (slider.step > 0.0) {
|
||||||
|
v = slider.step * parseInt(0.5 + v / slider.step);
|
||||||
|
}
|
||||||
|
slider.temporaryValue = min + v;
|
||||||
|
return slider.temporaryValue;
|
||||||
}
|
}
|
||||||
|
onClicked: slider.valueChangeRequested(updateValue(mouse.x));
|
||||||
|
onPressed: updateValue(mouse.x);
|
||||||
|
onPositionChanged: updateValue(mouse.x);
|
||||||
preventStealing: true
|
preventStealing: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,4 +78,14 @@ Item {
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: slider.step ? ((slider.max - slider.min) / slider.step - 1) : 0
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: Math.max(1, 1 * pgst.scalef)
|
||||||
|
height: parent.height
|
||||||
|
color: Constants.colors.area
|
||||||
|
x: parent.width * ((slider.step * (1 + index)) / (slider.max - slider.min));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ Item {
|
||||||
right: clipboardIcon.left
|
right: clipboardIcon.left
|
||||||
margins: 5 * pgst.scalef
|
margins: 5 * pgst.scalef
|
||||||
}
|
}
|
||||||
|
clip: true
|
||||||
|
|
||||||
inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ SlidePage {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'About',
|
label: 'Settings',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
pgst.loadPage('AboutPage.qml');
|
pgst.loadPage('SettingsPage.qml');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
32
touch/SettingsLabel.qml
Normal file
32
touch/SettingsLabel.qml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* gPodder QML UI Reference Implementation
|
||||||
|
* Copyright (c) 2015, Thomas Perl <m@thp.io>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
import 'common/constants.js' as Constants
|
||||||
|
|
||||||
|
PLabel {
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
margins: Constants.layout.padding * pgst.scalef
|
||||||
|
}
|
||||||
|
color: Constants.colors.secondaryHighlight
|
||||||
|
}
|
113
touch/SettingsPage.qml
Normal file
113
touch/SettingsPage.qml
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* gPodder QML UI Reference Implementation
|
||||||
|
* Copyright (c) 2015, Thomas Perl <m@thp.io>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
import 'common/constants.js' as Constants
|
||||||
|
|
||||||
|
SlidePage {
|
||||||
|
id: page
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
py.getConfig('plugins.youtube.api_key_v3', function (value) {
|
||||||
|
youtube_api_key_v3.text = value;
|
||||||
|
});
|
||||||
|
py.getConfig('limit.episodes', function (value) {
|
||||||
|
limit_episodes.value = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
py.setConfig('plugins.youtube.api_key_v3', youtube_api_key_v3.text);
|
||||||
|
py.setConfig('limit.episodes', parseInt(limit_episodes.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
Flickable {
|
||||||
|
id: flickable
|
||||||
|
anchors.fill: parent
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
|
contentWidth: detailColumn.width
|
||||||
|
contentHeight: detailColumn.height + detailColumn.spacing
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: detailColumn
|
||||||
|
|
||||||
|
width: page.width
|
||||||
|
spacing: 15 * pgst.scalef
|
||||||
|
|
||||||
|
SlidePageHeader { title: 'Settings' }
|
||||||
|
|
||||||
|
SectionHeader { text: 'YouTube' }
|
||||||
|
|
||||||
|
SettingsLabel { text: 'API Key (v3)' }
|
||||||
|
|
||||||
|
PTextField {
|
||||||
|
id: youtube_api_key_v3
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
margins: Constants.layout.padding * pgst.scalef
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionHeader { text: 'Limits' }
|
||||||
|
|
||||||
|
SettingsLabel { text: 'Maximum episodes per feed' }
|
||||||
|
|
||||||
|
PSlider {
|
||||||
|
id: limit_episodes
|
||||||
|
min: 100
|
||||||
|
step: 100
|
||||||
|
max: 1000
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
margins: Constants.layout.padding * pgst.scalef
|
||||||
|
}
|
||||||
|
onValueChangeRequested: { value = newValue; }
|
||||||
|
}
|
||||||
|
|
||||||
|
PLabel {
|
||||||
|
text: parseInt(limit_episodes.displayedValue)
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
margins: Constants.layout.padding * pgst.scalef
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionHeader { text: 'About' }
|
||||||
|
|
||||||
|
ButtonArea {
|
||||||
|
width: parent.width
|
||||||
|
height: Constants.layout.item.height * pgst.scalef
|
||||||
|
PLabel {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: 'About gPodder ' + py.uiversion
|
||||||
|
}
|
||||||
|
onClicked: pgst.loadPage('AboutPage.qml')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PScrollDecorator { flickable: flickable }
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue