Files
pay/guis/mobile/BackgroundSyncConfig.qml
T

123 lines
4.2 KiB
QML
Raw Permalink Normal View History

2025-03-02 19:35:00 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2025 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import "../Flowee" as Flowee
Page {
2025-03-04 13:01:11 +01:00
headerText: qsTr("Background Synchronization")
2025-03-02 19:35:00 +01:00
id: root
Column {
width: parent.width
spacing: 10
Flowee.Label {
width: parent.width
2025-03-04 13:01:11 +01:00
text: qsTr("Without background synchronization your wallets will not see new transactions until you open Flowee Pay")
2025-03-02 19:35:00 +01:00
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
Flowee.CheckBox {
id: checkbox
2025-03-04 13:01:11 +01:00
text: qsTr("Allow Background Synchronization")
2025-03-02 19:35:00 +01:00
checked: Pay.backgroundUpdates
onCheckedChanged: Pay.backgroundUpdates = checked
}
Item { width: 1; height: 10 } // spacer
QQC2.Slider {
id: slider
2025-04-02 10:50:58 +02:00
value: {
var ts = Pay.backgroundUpdateInterval
if (ts > 6) {
let s = 3;
while (ts > 6) {
s -= 1;
ts /= 2;
}
slider.value = s;
}
else {
slider.value = 6 - (ts - 3);
}
}
2025-03-02 19:35:00 +01:00
property int timeSpan: {
var i = slider.value;
if (i < 4) {
for (var h = 48; i > 0; --i) {
h = h / 2;
}
return h;
}
return 6 - (i - 3);
}
2025-04-02 10:50:58 +02:00
onTimeSpanChanged: Pay.backgroundUpdateInterval = timeSpan
2025-03-02 19:35:00 +01:00
visible: checkbox.checked
width: parent.width
stepSize: 1
from: 0
to: 8
snapMode: QQC2.Slider.SnapAlways
2025-03-03 17:38:38 +01:00
background: Rectangle {
x: slider.leftPadding
y: slider.topPadding + slider.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 4
width: slider.availableWidth
height: implicitHeight
radius: 2
color: palette.button
Repeater {
id: repeater
model: slider.to - slider.from - 1
Rectangle {
width: 1.8
height: 10
color: palette.button
x: {
var offset = slider.handle.implicitWidth
var totalWidth = slider.width - slider.leftPadding - slider.rightPadding - offset;
var unit = totalWidth / (slider.to - slider.from);
return offset / 2 + unit + unit * modelData
}
y: 10
}
}
}
handle: Rectangle {
x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
y: slider.topPadding + slider.availableHeight / 2 - height / 2
implicitWidth: slider.font.pixelSize
implicitHeight: implicitWidth
radius: implicitWidth / 2
color: Pay.useDarkSkin ? slider.palette.windowText : slider.palette.highlight
}
2025-03-02 19:35:00 +01:00
}
Flowee.Label {
visible: checkbox.checked
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Every %1 hours").arg(slider.timeSpan)
}
}
}