Files
pay/guis/mobile/UnlockApplication.qml
T

151 lines
4.7 KiB
QML
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
2025-03-03 15:55:44 +01:00
* Copyright (C) 2023-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
2025-06-18 17:48:29 +02:00
import QtQuick.Controls.Basic as QQC2
2025-02-05 20:52:38 +01:00
import "../Flowee" as Flowee
2026-03-14 21:14:42 +01:00
import Flowee.org.pay
FocusScope {
2025-03-03 15:55:44 +01:00
id: root
Rectangle {
anchors.fill: parent
color: palette.window
}
MouseArea { // eat all mouse events.
anchors.fill: parent
}
2025-02-05 20:52:38 +01:00
Image {
source: "qrc:/background.jpg"
width: parent.width
height: {
if (Pay.unlockingKeyboard === FloweePay.FullKeyboard)
2026-03-14 21:14:42 +01:00
return parent.height
2025-02-05 20:52:38 +01:00
if (Pay.unlockingKeyboard === FloweePay.SmallNumbersKeyboard)
2026-03-14 21:14:42 +01:00
return parent.height - 225
return 0
2025-02-05 20:52:38 +01:00
}
}
UnlockWidget {
anchors.fill: parent
2025-09-05 12:22:40 +02:00
anchors.topMargin: Pay.screenInsets.y
anchors.leftMargin: 10 + Pay.screenInsets.x
anchors.rightMargin: 10 + Pay.screenInsets.width
2026-03-14 21:14:42 +01:00
onPasswordEntered: if (!Pay.checkAppPassword(password)) passwordIncorrect()
2025-02-07 00:18:44 +01:00
// the above background means the widget should prefer white text
assumeDarkBackground: Pay.unlockingKeyboard !== FloweePay.BigNumbersKeyboard
}
Keys.onPressed: (event)=> {
2026-03-14 21:14:42 +01:00
event.accepted = true
2025-03-03 15:55:44 +01:00
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back)
2026-03-14 21:14:42 +01:00
mainWindow.close() // exit app on 'back'.
}
2025-02-05 20:52:38 +01:00
Column {
id: quickReceive
2025-09-05 12:22:40 +02:00
x: 60 + Pay.screenInsets.x
2025-02-05 20:52:38 +01:00
y: {
2026-03-14 21:14:42 +01:00
var uk = Pay.unlockingKeyboard
2025-02-05 20:52:38 +01:00
if (uk === FloweePay.BigNumbersKeyboard)
2026-03-14 21:14:42 +01:00
return parent.height + 10
2025-02-05 20:52:38 +01:00
if (uk === FloweePay.FullKeyboard)
2026-03-14 21:14:42 +01:00
return 300
2025-02-05 20:52:38 +01:00
if (uk === FloweePay.SmallNumbersKeyboard)
2025-02-10 20:46:35 +01:00
return parent.height - 270 - height
2025-02-05 20:52:38 +01:00
}
spacing: 6
2025-02-10 20:58:54 +01:00
opacity: 0
2026-03-14 21:14:42 +01:00
property bool havePortfolio: typeof portfolio !== "undefined"
2025-02-10 20:58:54 +01:00
onHavePortfolioChanged: opacity = portfolio.current.isSingleAddressAccount ? 0 : 1
2025-09-05 12:22:40 +02:00
visible: opacity > 0
2025-02-10 20:58:54 +01:00
Behavior on opacity { NumberAnimation { } }
2025-02-05 20:52:38 +01:00
Image {
source: "qrc:/back-arrow"
rotation: 270
width: 30
height: 30
}
Flowee.Label {
color: "white"
text: qsTr("Quick Receive")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Qt.AlignHCenter
x: 15 - width / 2
width: 90
}
}
MouseArea {
2025-03-03 15:55:44 +01:00
id: quickReceiveButton
focus: true
enabled: quickReceive.visible
2025-02-05 20:52:38 +01:00
anchors.fill: quickReceive
onClicked: myLittleStack.push(receive)
}
FocusScope {
anchors.fill: parent
Rectangle {
2025-02-09 22:57:14 +01:00
id: background
2025-02-05 20:52:38 +01:00
anchors.fill: parent
color: palette.window
visible: myLittleStack.depth > 0
2025-02-09 22:57:14 +01:00
MouseArea { anchors.fill: parent; acceptedButtons: Qt.AllButtons } // catch all
2025-02-05 20:52:38 +01:00
QQC2.StackView {
id: myLittleStack
anchors.fill: parent
2026-03-14 21:14:42 +01:00
onCurrentItemChanged: if (currentItem != null) currentItem.takeFocus()
2025-09-05 12:22:40 +02:00
2025-02-05 20:52:38 +01:00
}
}
Keys.onPressed: (event)=> {
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back) {
2025-03-03 15:55:44 +01:00
if (myLittleStack.depth <= 1) {
2026-03-14 21:14:42 +01:00
myLittleStack.clear()
quickReceiveButton.forceActiveFocus()
2025-03-03 15:55:44 +01:00
}
2025-02-05 20:52:38 +01:00
else
2026-03-14 21:14:42 +01:00
myLittleStack.pop()
event.accepted = true
2025-02-05 20:52:38 +01:00
}
}
}
Component {
id: receive
Page {
function takeFocus() {
2026-03-14 21:14:42 +01:00
receiveTab.verticalTab = 1 // the money input
receiveTab.forceActiveFocus()
}
2025-02-05 20:52:38 +01:00
backHandler: function handler() { myLittleStack.clear() }
2025-02-09 22:57:14 +01:00
headerText: receiveTab.title
2025-02-10 16:04:45 +01:00
function switchToTab(tab) {
2026-03-14 21:14:42 +01:00
myLittleStack.clear()
2025-02-10 16:04:45 +01:00
}
2025-02-05 20:52:38 +01:00
ReceiveTab {
id: receiveTab
anchors.fill: parent
2025-02-09 22:57:14 +01:00
showInstructions: false
2025-02-05 20:52:38 +01:00
}
}
}
}