Files
pay/desktop/main.qml
T

192 lines
5.7 KiB
QML
Raw Permalink Normal View History

2020-05-24 13:20:03 +02:00
/*
* This file is part of the Flowee project
* Copyright (C) 2020 Tom Zander <tomz@freedommail.ch>
*
* 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 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import Flowee.org.pay 1.0
2020-10-14 15:12:33 +02:00
import "./ControlColors.js" as ControlColors
2020-05-24 13:20:03 +02:00
ApplicationWindow {
2020-10-14 18:29:10 +02:00
id: mainWindow
2020-05-24 13:20:03 +02:00
visible: true
2020-10-16 18:17:56 +02:00
width: Flowee.windowWidth === -1 ? 600 : Flowee.windowWidth
height: Flowee.windowHeight === -1 ? 400 : Flowee.windowHeight
2020-10-14 15:12:33 +02:00
minimumWidth: 300
minimumHeight: 200
2020-05-24 13:20:03 +02:00
title: "Flowee Pay"
2020-06-11 17:56:06 +02:00
onWidthChanged: Flowee.windowWidth = width
onHeightChanged: Flowee.windowHeight = height
2020-10-14 18:29:10 +02:00
onVisibleChanged: if (visible) ControlColors.applySkin(mainWindow)
2020-10-16 18:17:56 +02:00
property bool isLoading: typeof portfolio === "undefined";
2020-06-11 17:56:06 +02:00
2020-10-14 15:12:33 +02:00
menuBar: MenuBar {
Menu {
2020-10-16 18:17:56 +02:00
title: qsTr("Flowee &Pay")
Action {
text: qsTr("Create / Import...")
onTriggered: newAccountDiag.source = "./NewAccountDialog.qml"
}
2020-10-14 15:12:33 +02:00
Action {
text: qsTr("&Quit")
shortcut: StandardKey.Quit
2020-10-14 18:29:10 +02:00
onTriggered: mainWindow.close()
2020-10-14 15:12:33 +02:00
}
}
Menu {
2020-10-14 18:29:10 +02:00
title: qsTr("&View")
2020-10-14 15:12:33 +02:00
Action {
text: qsTr("&Account List")
onTriggered: portfolio.current = null
}
2020-10-14 15:12:33 +02:00
Action {
checkable: true
checked: Flowee.useDarkSkin
text: qsTr("&Dark Mode")
onTriggered: {
Flowee.useDarkSkin = checked
2020-10-14 18:29:10 +02:00
ControlColors.applySkin(mainWindow)
}
}
Action {
enabled: !mainWindow.isLoading
text: qsTr("Network Status")
onTriggered: {
netView.source = "NetView.qml"
netView.item.show();
2020-10-14 15:12:33 +02:00
}
}
2020-10-15 20:04:10 +02:00
MenuSeparator { }
Menu {
title: qsTr("Unit Indicator")
Action {
text: "BCH"
checkable: true
checked: Flowee.unit === Pay.BCH
onTriggered: Flowee.unit = Pay.BCH
}
Action {
2020-10-15 20:49:50 +02:00
text: "mBCH"
2020-10-15 20:04:10 +02:00
checkable: true
2020-10-15 20:49:50 +02:00
checked: Flowee.unit === Pay.MilliBCH
onTriggered: Flowee.unit = Pay.MilliBCH
2020-10-15 20:04:10 +02:00
}
Action {
text: "Bits"
checkable: true
checked: Flowee.unit === Pay.Bits
onTriggered: Flowee.unit = Pay.Bits
}
2020-10-15 20:49:50 +02:00
Action {
text: "µBCH"
checkable: true
checked: Flowee.unit === Pay.MicroBCH
onTriggered: Flowee.unit = Pay.MicroBCH
}
2020-10-15 20:04:10 +02:00
Action {
text: "Satoshis"
checkable: true
checked: Flowee.unit === Pay.Satoshis
onTriggered: Flowee.unit = Pay.Satoshis
}
}
2020-10-14 15:12:33 +02:00
}
}
2020-10-14 18:29:10 +02:00
AccountSelectionPage {
id: accountSelectionPage
anchors.fill: parent
2020-10-16 18:17:56 +02:00
visible: !isLoading && portfolio.current === null
2020-10-14 18:29:10 +02:00
}
2020-10-15 19:18:54 +02:00
AccountPage {
2020-10-17 20:26:36 +02:00
anchors.fill: parent
2020-10-15 19:18:54 +02:00
}
// NetView (reachable from menu)
2020-10-14 18:29:10 +02:00
Loader {
id: netView
onLoaded: {
ControlColors.applySkin(item)
netViewHandler.target = item
}
Connections {
id: netViewHandler
function onVisibleChanged() {
if (!netView.item.visible)
netView.source = ""
2020-10-14 15:12:33 +02:00
}
}
}
2020-10-16 18:17:56 +02:00
Loader {
id: newAccountDiag
onLoaded: {
ControlColors.applySkin(item)
newAccountHandler.target = item
}
Connections {
id: newAccountHandler
function onVisibleChanged() {
if (!newAccountDiag.item.visible) {
newAccountDiag.source = ""
}
}
}
}
2020-11-04 18:33:50 +01:00
Loader {
id: accountDetailsDialog
onLoaded: {
item.account = portfolio.current
ControlColors.applySkin(item)
accountDetailsHandler.target = item
}
Connections {
id: accountDetailsHandler
function onVisibleChanged() {
if (!accountDetailsDialog.item.visible) {
accountDetailsDialog.source = ""
}
}
}
}
2020-10-14 15:12:33 +02:00
footer: Pane {
contentWidth: parent.width
contentHeight: statusBar.height
Label {
id: statusBar
property string message: ""
text: {
2020-10-14 18:29:10 +02:00
if (mainWindow.isLoading)
2020-10-14 15:12:33 +02:00
return qsTr("Starting up...");
2020-10-16 18:17:56 +02:00
if (portfolio.current === null)
return qsTr("%1 Accounts").arg(portfolio.accounts.length);
2020-10-15 19:18:54 +02:00
if (message === "")
2020-10-16 18:17:56 +02:00
return portfolio.current.name
2020-10-14 15:12:33 +02:00
return message;
}
}
2020-10-14 18:29:10 +02:00
2020-10-14 15:12:33 +02:00
}
2020-05-24 13:20:03 +02:00
}