2021-11-21 00:29:55 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2026-02-11 20:24:41 +01:00
|
|
|
* Copyright (C) 2022-2026 Tom Zander <tom@flowee.org>
|
2021-11-21 00:29:55 +01:00
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2022-11-10 16:41:39 +01:00
|
|
|
import QtQuick
|
2025-06-18 17:48:29 +02:00
|
|
|
import QtQuick.Controls.Basic as QQC2
|
2022-11-10 16:41:39 +01:00
|
|
|
import QtQuick.Layouts
|
2022-11-14 21:19:31 +01:00
|
|
|
import "../ControlColors.js" as ControlColors
|
2023-06-30 22:27:27 +02:00
|
|
|
import "../Flowee" as Flowee
|
2026-02-11 20:24:41 +01:00
|
|
|
import Flowee.org.pay
|
2021-11-21 00:29:55 +01:00
|
|
|
|
2025-02-09 23:31:57 +01:00
|
|
|
|
|
|
|
|
QQC2.ApplicationWindow {
|
2021-11-21 00:29:55 +01:00
|
|
|
id: mainWindow
|
|
|
|
|
title: "Flowee Pay"
|
|
|
|
|
width: 360
|
|
|
|
|
height: 720
|
2023-05-17 14:28:24 +02:00
|
|
|
minimumWidth: 300
|
|
|
|
|
minimumHeight: 400
|
2021-11-21 00:29:55 +01:00
|
|
|
visible: true
|
2026-02-11 20:24:41 +01:00
|
|
|
onVisibleChanged: if (visible) ControlColors.applySkin(mainWindow)
|
2021-11-21 00:29:55 +01:00
|
|
|
|
2026-02-11 20:24:41 +01:00
|
|
|
property bool isLoading: typeof net === "undefined"
|
2022-11-14 21:19:31 +01:00
|
|
|
onIsLoadingChanged: {
|
2022-11-17 23:07:15 +01:00
|
|
|
// only load our UI when the p2p layer is loaded and all
|
|
|
|
|
// variables are available.
|
2023-02-09 18:25:10 +01:00
|
|
|
if (!isLoading) {
|
2026-02-11 20:24:41 +01:00
|
|
|
portfolio.limitedArchiveView = true
|
|
|
|
|
thePile.replace("./MainView.qml")
|
2026-01-14 17:05:33 +01:00
|
|
|
if (isNaN(portfolio.current.firstMinedTransaction.getTime()))
|
2026-02-11 20:24:41 +01:00
|
|
|
thePile.pushSpecialPage("./StartupScreen.qml")
|
2024-10-25 11:33:11 +02:00
|
|
|
else {
|
|
|
|
|
// find if there is any fullscreen plugin enabled
|
|
|
|
|
for (var mod of ModuleManager.registeredModules) {
|
|
|
|
|
for (var section of mod.sections) {
|
|
|
|
|
if (section.isStartScreenType && section.enabled) {
|
2024-10-27 21:06:21 +01:00
|
|
|
thePile.pushSpecialPage(section.qml)
|
2026-02-11 20:24:41 +01:00
|
|
|
return
|
2024-10-25 11:33:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-09 18:25:10 +01:00
|
|
|
}
|
2022-11-17 23:07:15 +01:00
|
|
|
}
|
2026-02-11 20:24:41 +01:00
|
|
|
Component.onCompleted: {
|
|
|
|
|
updateFontSize()
|
|
|
|
|
rootFocusScope.forceActiveFocus()
|
|
|
|
|
}
|
2022-12-15 12:37:21 +01:00
|
|
|
function updateFontSize() {
|
|
|
|
|
// 75% = > 14.25, 100% => 19, 200% => 28
|
|
|
|
|
mainWindow.font.pixelSize = 17 + (11 * (Pay.fontScaling-100) / 100)
|
|
|
|
|
}
|
|
|
|
|
Connections {
|
|
|
|
|
target: Pay
|
2026-02-11 20:24:41 +01:00
|
|
|
function onFontScalingChanged() { updateFontSize() }
|
|
|
|
|
function onUseDarkSkinChanged() { ControlColors.applySkin(mainWindow) }
|
2022-11-14 21:19:31 +01:00
|
|
|
}
|
2024-10-27 21:06:21 +01:00
|
|
|
Connections {
|
2025-09-10 13:57:13 +02:00
|
|
|
target: intent
|
2024-10-27 21:06:21 +01:00
|
|
|
function onPaymentUrlChanged() {
|
2025-09-10 13:57:13 +02:00
|
|
|
if (intent.paymentUrl !== "") {
|
2024-12-22 22:44:38 +01:00
|
|
|
let page = thePile.pushSpecialPage("./PayWithQR.qml", true)
|
2026-02-11 20:24:41 +01:00
|
|
|
page.start(intent.paymentUrl)
|
2024-12-22 22:44:38 +01:00
|
|
|
}
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
|
|
|
|
function onSweepKeyChanged() {
|
2025-09-10 13:57:13 +02:00
|
|
|
if (intent.sweepKey !== "") {
|
2026-02-11 20:24:41 +01:00
|
|
|
var s = ModuleManager.sectionOnPlugin("sendSweepModule", "main")
|
2024-12-22 22:44:38 +01:00
|
|
|
if (s) {
|
2026-02-11 20:24:41 +01:00
|
|
|
let page = thePile.pushSpecialPage(s.qml, true)
|
|
|
|
|
page.secret = intent.paymentUrl
|
2024-12-22 22:44:38 +01:00
|
|
|
}
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-31 12:09:19 +01:00
|
|
|
function onStartPaymentScannerChanged() {
|
2025-09-10 13:57:13 +02:00
|
|
|
if (intent.startPaymentScanner) {
|
2026-02-11 20:24:41 +01:00
|
|
|
intent.startPaymentScanner = false
|
2024-12-22 22:44:38 +01:00
|
|
|
thePile.pushSpecialPage("./ScanQRPage.qml", false)
|
2024-10-31 12:09:19 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
2025-10-27 18:39:43 +01:00
|
|
|
Connections {
|
|
|
|
|
target: ModuleManager
|
|
|
|
|
function onAddPage(url, pageData) {
|
|
|
|
|
thePile.pushSpecialPage(url, false, pageData)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-21 00:29:55 +01:00
|
|
|
|
|
|
|
|
property color floweeSalmon: "#ff9d94"
|
|
|
|
|
property color floweeBlue: "#0b1088"
|
|
|
|
|
property color floweeGreen: "#90e4b5"
|
2023-04-18 21:54:43 +02:00
|
|
|
property color errorRed: Pay.useDarkSkin ? "#ff6568" : "#940000"
|
|
|
|
|
property color errorRedBg: Pay.useDarkSkin ? "#671314" : "#9f1d1f"
|
2021-11-21 00:29:55 +01:00
|
|
|
|
2023-11-06 15:55:10 +01:00
|
|
|
FocusScope {
|
|
|
|
|
id: rootFocusScope
|
2022-11-15 15:19:35 +01:00
|
|
|
anchors.fill: parent
|
2023-11-06 15:55:10 +01:00
|
|
|
|
2024-12-22 14:41:46 +01:00
|
|
|
QQC2.StackView {
|
2023-11-06 15:55:10 +01:00
|
|
|
id: thePile
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
initialItem: "./Loading.qml"
|
2026-02-11 20:24:41 +01:00
|
|
|
onCurrentItemChanged: if (currentItem != null) currentItem.takeFocus()
|
2023-11-06 15:55:10 +01:00
|
|
|
enabled: !menuOverlay.open
|
2024-10-27 21:06:21 +01:00
|
|
|
property int tempPageIndex: -1
|
|
|
|
|
property bool exitAfterPopTemp: false
|
|
|
|
|
onDepthChanged: {
|
|
|
|
|
if (tempPageIndex > depth) {
|
2026-02-11 20:24:41 +01:00
|
|
|
tempPageIndex = -1
|
2024-10-27 21:06:21 +01:00
|
|
|
if (exitAfterPopTemp)
|
2026-02-11 20:24:41 +01:00
|
|
|
mainWindow.close()
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// the idea behind 'special' pages are that there can be no more than one
|
|
|
|
|
// so pushing a second just replaces the previous one.
|
2025-10-27 18:39:43 +01:00
|
|
|
// Argument 'exitAfter', when it is set to true will cause the application
|
2024-10-27 21:06:21 +01:00
|
|
|
// to close after the page is removed. Which is expected behavior on Android
|
|
|
|
|
// activities.
|
2025-10-27 18:39:43 +01:00
|
|
|
function pushSpecialPage(item, exitAfter, pageData) {
|
2026-02-11 20:24:41 +01:00
|
|
|
exitAfterPopTemp = false
|
2024-10-27 21:06:21 +01:00
|
|
|
while (tempPageIndex >= 0 && depth >= tempPageIndex) {
|
2026-02-11 20:24:41 +01:00
|
|
|
pop()
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
|
|
|
|
|
2025-10-27 18:39:43 +01:00
|
|
|
if (pageData === null || typeof(pageData) == "undefined") {
|
2026-02-11 20:24:41 +01:00
|
|
|
var newPage = thePile.push(item)
|
2025-10-27 18:39:43 +01:00
|
|
|
} else {
|
2026-02-11 20:24:41 +01:00
|
|
|
newPage = thePile.push(item, { "pageData": pageData })
|
|
|
|
|
ModuleManager.markChild(newPage, pageData) // avoid memory leak
|
2025-10-27 18:39:43 +01:00
|
|
|
}
|
2026-02-11 20:24:41 +01:00
|
|
|
tempPageIndex = depth
|
2024-10-27 21:06:21 +01:00
|
|
|
if (typeof(exitAfter) === "boolean")
|
2026-02-11 20:24:41 +01:00
|
|
|
exitAfterPopTemp = exitAfter
|
|
|
|
|
return newPage
|
2024-10-27 21:06:21 +01:00
|
|
|
}
|
|
|
|
|
|
2023-11-06 15:55:10 +01:00
|
|
|
Keys.onPressed: (event)=> {
|
|
|
|
|
if (depth > 1
|
|
|
|
|
&& (event.key === Qt.Key_Escape || event.key === Qt.Key_Back)) {
|
2026-02-11 20:24:41 +01:00
|
|
|
pop()
|
|
|
|
|
event.accepted = true
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-30 10:39:01 +02:00
|
|
|
|
2023-11-06 15:55:10 +01:00
|
|
|
MenuOverlay {
|
|
|
|
|
id: menuOverlay
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
2024-05-07 15:40:36 +02:00
|
|
|
Flowee.QRScanner {
|
2023-11-06 15:55:10 +01:00
|
|
|
id: scannerOverlay
|
|
|
|
|
anchors.fill: parent
|
2026-01-14 18:58:29 +01:00
|
|
|
anchors.leftMargin: Pay.screenInsets.x
|
|
|
|
|
anchors.rightMargin: Pay.screenInsets.width
|
|
|
|
|
anchors.topMargin: Pay.screenInsets.y
|
|
|
|
|
anchors.bottomMargin: Pay.screenInsets.height
|
2024-05-07 15:40:36 +02:00
|
|
|
showCloseButton: true
|
2026-01-14 18:58:29 +01:00
|
|
|
Rectangle {
|
|
|
|
|
id: header // for setups with screen insets and dark theme
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.bottom: parent.top
|
|
|
|
|
height: Pay.screenInsets.y
|
|
|
|
|
color: mainWindow.floweeBlue
|
|
|
|
|
}
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
Loader {
|
|
|
|
|
source: Pay.appProtection === FloweePay.AppPassword ? "./UnlockApplication.qml" : ""
|
|
|
|
|
anchors.fill: parent
|
2026-02-11 20:24:41 +01:00
|
|
|
onLoaded: item.forceActiveFocus()
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Keys.onPressed: (event)=> {
|
|
|
|
|
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back) {
|
2026-02-11 20:24:41 +01:00
|
|
|
event.accepted = true
|
2023-11-06 15:55:10 +01:00
|
|
|
// Aborting the camera will simply close its user page.
|
|
|
|
|
if (scannerOverlay.visible) {
|
2026-02-11 20:24:41 +01:00
|
|
|
CameraController.abort()
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
// the 'menu' can be closed on back.
|
|
|
|
|
else if (menuOverlay.open) {
|
2026-02-11 20:24:41 +01:00
|
|
|
menuOverlay.open = false
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2026-02-11 20:24:41 +01:00
|
|
|
mainWindow.close()
|
2023-11-06 15:55:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-15 15:19:35 +01:00
|
|
|
}
|
2022-12-03 13:44:21 +01:00
|
|
|
|
2025-06-19 14:47:19 +02:00
|
|
|
Flowee.Popup {
|
2023-06-30 22:27:27 +02:00
|
|
|
id: notificationPopup
|
|
|
|
|
y: 110
|
|
|
|
|
x: 25
|
|
|
|
|
width: mainWindow.contentItem.width - 50
|
|
|
|
|
height: label.implicitHeight * 3
|
|
|
|
|
property alias text: label.text
|
2025-02-10 20:17:31 +01:00
|
|
|
property QtObject notification: Pay.notification
|
|
|
|
|
property int timeout: 600
|
|
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
|
if (!visible) {
|
2026-02-11 20:24:41 +01:00
|
|
|
label.text = ""
|
|
|
|
|
Pay.notification = null
|
2025-02-10 20:17:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onNotificationChanged: if (notification) show(notification.message)
|
2023-06-30 22:27:27 +02:00
|
|
|
|
|
|
|
|
function show(message) {
|
|
|
|
|
if (message === "")
|
2026-02-11 20:24:41 +01:00
|
|
|
return
|
|
|
|
|
text = message
|
|
|
|
|
visible = true
|
|
|
|
|
timeout = 600
|
2023-06-30 22:27:27 +02:00
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
id: label
|
|
|
|
|
width: parent.width - 12
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: timeoutBar
|
|
|
|
|
width: 5
|
2025-02-10 20:17:31 +01:00
|
|
|
height: {
|
2026-02-11 20:24:41 +01:00
|
|
|
var max = parent.height - 12
|
|
|
|
|
return max - (notificationPopup.timeout / 600 * max)
|
2025-02-10 20:17:31 +01:00
|
|
|
}
|
2023-06-30 22:27:27 +02:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 6
|
|
|
|
|
color: palette.highlight
|
|
|
|
|
|
2025-02-10 20:17:31 +01:00
|
|
|
Behavior on height { NumberAnimation { duration: 100 } }
|
2023-06-30 22:27:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
color: palette.light
|
|
|
|
|
border.color: palette.midlight
|
|
|
|
|
border.width: 1
|
|
|
|
|
radius: 5
|
|
|
|
|
}
|
2025-02-09 23:31:57 +01:00
|
|
|
QQC2.Overlay.modeless: Rectangle {
|
2023-06-30 22:27:27 +02:00
|
|
|
color: Pay.useDarkSkin ? "#33000000" : "#33ffffff"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
|
id: notificationPopupTimer
|
2026-02-11 20:24:41 +01:00
|
|
|
running: parent.visible && notificationPopup.timeout > 0
|
2025-02-10 20:17:31 +01:00
|
|
|
interval: 100
|
|
|
|
|
onTriggered: {
|
2026-02-11 20:24:41 +01:00
|
|
|
var t = notificationPopup.timeout
|
|
|
|
|
t -= 10
|
|
|
|
|
notificationPopup.timeout = t
|
2025-02-10 20:17:31 +01:00
|
|
|
if (t <= 0)
|
2026-02-11 20:24:41 +01:00
|
|
|
notificationPopup.visible = false
|
2025-02-10 20:17:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-06-30 22:27:27 +02:00
|
|
|
|
2025-02-10 20:17:31 +01:00
|
|
|
}
|
|
|
|
|
Item { // slide to hide for the notification popup
|
|
|
|
|
width: notificationPopup.width
|
|
|
|
|
height: notificationPopup.height
|
|
|
|
|
x: notificationPopup.x
|
|
|
|
|
y: notificationPopup.y
|
|
|
|
|
visible: notificationPopup.visible
|
|
|
|
|
onXChanged: {
|
2026-02-11 20:24:41 +01:00
|
|
|
notificationPopup.x = x
|
2025-02-10 20:17:31 +01:00
|
|
|
if (x < -175 || x > 225)
|
2026-02-11 20:24:41 +01:00
|
|
|
notificationPopup.visible = false
|
2025-02-10 20:17:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DragHandler {
|
|
|
|
|
yAxis.enabled: false
|
|
|
|
|
xAxis.enabled: true
|
|
|
|
|
margin: 15
|
2026-02-11 20:24:41 +01:00
|
|
|
onActiveChanged: if (!active) parent.x = 25
|
2023-06-30 22:27:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-21 00:29:55 +01:00
|
|
|
}
|