2022-11-15 11:38:28 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2023-02-14 14:56:18 +01:00
|
|
|
* Copyright (C) 2022-2023 Tom Zander <tom@flowee.org>
|
2022-11-15 11:38:28 +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-26 10:44:52 +01:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
|
import QtQuick.Layouts
|
2022-11-15 15:19:35 +01:00
|
|
|
import "../Flowee" as Flowee
|
2022-11-15 11:38:28 +01:00
|
|
|
|
|
|
|
|
QQC2.Control {
|
|
|
|
|
id: root
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: parent.height
|
|
|
|
|
|
2023-02-14 14:56:18 +01:00
|
|
|
background: Rectangle {
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.light
|
2023-02-14 14:56:18 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-17 00:12:17 +01:00
|
|
|
// This trick means any child items are actually added to the 'stack' item's children.
|
2022-11-15 11:38:28 +01:00
|
|
|
default property alias content: stack.children
|
|
|
|
|
property int currentIndex: 0
|
|
|
|
|
onCurrentIndexChanged: setOpacities()
|
|
|
|
|
Component.onCompleted: setOpacities()
|
|
|
|
|
|
|
|
|
|
function setOpacities() {
|
|
|
|
|
for (let i = 0; i < stack.children.length; ++i) {
|
|
|
|
|
let on = i === currentIndex;
|
|
|
|
|
let child = stack.children[i];
|
|
|
|
|
child.visible = on;
|
|
|
|
|
}
|
2022-11-23 10:35:31 +01:00
|
|
|
takeFocus();
|
|
|
|
|
}
|
2022-12-08 13:00:19 +01:00
|
|
|
function switchToTab(index) {
|
|
|
|
|
currentIndex = index
|
|
|
|
|
}
|
2022-11-15 11:38:28 +01:00
|
|
|
|
2022-11-23 10:35:31 +01:00
|
|
|
// called from main when this page becomes active, as well as when we change tabs
|
|
|
|
|
function takeFocus() {
|
2022-11-15 11:38:28 +01:00
|
|
|
// try to make sure the current tab gets keyboard focus properly.
|
|
|
|
|
// We do some extra work in case the tab itself is a loader.
|
|
|
|
|
forceActiveFocus();
|
2022-11-23 10:35:31 +01:00
|
|
|
let visibleChild = stack.children[currentIndex];
|
2022-11-15 11:38:28 +01:00
|
|
|
visibleChild.focus = true
|
|
|
|
|
if (visibleChild instanceof Loader) {
|
|
|
|
|
var child = visibleChild.item;
|
|
|
|
|
if (child !== null)
|
|
|
|
|
child.focus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: header
|
|
|
|
|
width: parent.width
|
2022-11-23 16:06:37 +01:00
|
|
|
height: 50
|
2023-02-21 16:40:46 +01:00
|
|
|
color: Pay.useDarkSkin ? palette.window : mainWindow.floweeBlue
|
2022-11-15 11:38:28 +01:00
|
|
|
|
2023-02-06 19:44:53 +01:00
|
|
|
Flowee.HamburgerMenu {
|
2022-11-15 11:38:28 +01:00
|
|
|
id: menuButton
|
2022-12-15 15:03:43 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-02-14 14:56:18 +01:00
|
|
|
color: "white"
|
2023-02-06 19:44:53 +01:00
|
|
|
wide: true
|
2022-12-15 15:03:43 +01:00
|
|
|
x: 8
|
2022-11-15 11:38:28 +01:00
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: menuButton
|
2023-03-15 13:35:03 +01:00
|
|
|
// make the touch area a lot bigger, its safe as its limited to the 'header' area anyway.
|
|
|
|
|
anchors.margins: -60
|
2022-11-15 11:38:28 +01:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: menuOverlay.open = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-15 15:03:43 +01:00
|
|
|
QQC2.Control {
|
|
|
|
|
id: logo
|
2022-11-17 00:12:17 +01:00
|
|
|
// Here we just want the text part. So clip that out.
|
|
|
|
|
clip: true
|
2022-12-15 15:03:43 +01:00
|
|
|
y: 17
|
|
|
|
|
x: 20
|
2022-11-17 00:12:17 +01:00
|
|
|
width: 122
|
|
|
|
|
height: 21
|
2022-12-15 15:03:43 +01:00
|
|
|
baselineOffset: 16
|
2022-11-17 00:12:17 +01:00
|
|
|
Image {
|
2022-11-17 23:07:15 +01:00
|
|
|
source: "qrc:/FloweePay.svg"
|
2022-11-17 00:12:17 +01:00
|
|
|
// ratio: 449 / 77
|
|
|
|
|
width: 150
|
|
|
|
|
height: 26
|
|
|
|
|
x: -28
|
|
|
|
|
y: -5
|
|
|
|
|
}
|
2022-11-15 11:38:28 +01:00
|
|
|
}
|
2022-12-15 15:03:43 +01:00
|
|
|
|
|
|
|
|
QQC2.Label {
|
|
|
|
|
id: currentWalletName
|
2023-02-24 23:48:26 +01:00
|
|
|
visible: !portfolio.singleAccountSetup
|
2022-12-15 15:03:43 +01:00
|
|
|
text: portfolio.current.name
|
|
|
|
|
color: "#fcfcfc"
|
|
|
|
|
clip: true
|
|
|
|
|
anchors.left: logo.right
|
|
|
|
|
anchors.right: searchIcon.left
|
|
|
|
|
anchors.margins: 12
|
|
|
|
|
anchors.baseline: logo.baseline
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2023-05-18 21:52:51 +02:00
|
|
|
onClicked: {
|
|
|
|
|
if (accountSelector.visible)
|
|
|
|
|
accountSelector.close();
|
|
|
|
|
else
|
|
|
|
|
accountSelector.open();
|
|
|
|
|
}
|
2022-12-15 15:03:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QQC2.Label {
|
|
|
|
|
id: searchIcon
|
|
|
|
|
color: "#fcfcfc"
|
|
|
|
|
text: "" // placeholder for the magnifying glass search feature to be done in future
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
anchors.baseline: logo.baseline
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 10:32:12 +01:00
|
|
|
AccountSelectorPopup {
|
2022-12-15 15:03:43 +01:00
|
|
|
id: accountSelector
|
|
|
|
|
width: root.width
|
2023-02-06 20:29:03 +01:00
|
|
|
y: header.height
|
2023-02-06 21:55:54 +01:00
|
|
|
|
|
|
|
|
onSelectedAccountChanged: portfolio.current = selectedAccount
|
2022-12-15 15:03:43 +01:00
|
|
|
}
|
2022-11-15 11:38:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: stack
|
|
|
|
|
width: root.width
|
|
|
|
|
anchors.top: header.bottom; anchors.bottom: tabbar.top
|
|
|
|
|
}
|
2023-02-14 18:44:53 +01:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: tabbar
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.window
|
2023-02-14 18:44:53 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-15 11:38:28 +01:00
|
|
|
Row {
|
|
|
|
|
id: tabbar
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
model: stack.children.length
|
2023-02-14 18:44:53 +01:00
|
|
|
delegate: Item {
|
2023-07-05 12:24:31 +02:00
|
|
|
height: 65
|
2022-11-15 11:38:28 +01:00
|
|
|
width: root.width / stack.children.length;
|
2023-02-14 18:44:53 +01:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
x: 5
|
|
|
|
|
height: 4
|
|
|
|
|
width: parent.width - 10
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.highlight
|
2023-02-14 18:44:53 +01:00
|
|
|
visible: modelData === root.currentIndex
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.highlight
|
2023-02-14 18:44:53 +01:00
|
|
|
visible: modelData === root.currentIndex
|
|
|
|
|
opacity: 0.15
|
2022-11-18 13:43:04 +01:00
|
|
|
}
|
|
|
|
|
Image {
|
|
|
|
|
source: stack.children[modelData].icon
|
2023-07-05 12:24:31 +02:00
|
|
|
width: 30
|
|
|
|
|
height: 30
|
2022-12-08 11:34:10 +01:00
|
|
|
smooth: true
|
2022-12-15 15:03:43 +01:00
|
|
|
y: 8
|
2022-11-18 13:43:04 +01:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
}
|
2022-11-15 15:19:35 +01:00
|
|
|
Flowee.Label {
|
2022-11-18 13:43:04 +01:00
|
|
|
text: stack.children[modelData].title
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
anchors.bottom: parent.bottom
|
2022-12-15 15:03:43 +01:00
|
|
|
anchors.bottomMargin: 2
|
|
|
|
|
font.pixelSize: 14
|
2022-11-15 11:38:28 +01:00
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: root.currentIndex = modelData
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-27 18:57:50 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fully encrypted wallet are useless to inspect or use until they are opened.
|
|
|
|
|
* This is an overlay that covers the entire screen except for the header to make
|
|
|
|
|
* unlocking a "modal" dialogue.
|
|
|
|
|
*/
|
|
|
|
|
Rectangle {
|
|
|
|
|
color: palette.window
|
|
|
|
|
anchors.top: header.bottom
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: parent.width
|
|
|
|
|
visible: portfolio.current.needsPinToOpen && !portfolio.current.isDecrypted
|
|
|
|
|
|
|
|
|
|
// eat all taps / clicks.
|
|
|
|
|
MouseArea { anchors.fill: parent }
|
|
|
|
|
|
|
|
|
|
// to avoid using resources in the 99% of the time the user is not unlocking his wallet,
|
|
|
|
|
// we use a loader for the unlocking screen.
|
|
|
|
|
Loader {
|
|
|
|
|
id: unlockWalletWidget
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
source: parent.visible ? "./UnlockWalletPanel.qml" : ""
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-15 11:38:28 +01:00
|
|
|
}
|