You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
10 KiB
354 lines
10 KiB
3 years ago
|
import QtQuick 2.7
|
||
|
import QtQuick.Controls 2.0
|
||
|
import QtQuick.Layouts 1.2
|
||
|
import QtGraphicalEffects 1.0
|
||
|
import QtQuick.Window 2.0
|
||
|
import QtQuick.Controls.Styles 1.4
|
||
|
import QtQuick.Dialogs 1.2
|
||
|
|
||
|
import "."
|
||
|
import "mock/Windows.js" as Windows
|
||
|
import "mock/Version.js" as Version
|
||
|
import "mock/NetworkType.js" as NetworkType
|
||
|
import "mock/Settings.js" as Settings
|
||
|
import "mock"
|
||
|
|
||
|
import "qml/common"
|
||
|
import "qml/."
|
||
|
|
||
|
import wowlet.Wallet 1.0
|
||
|
import wowlet.WalletManager 1.0
|
||
|
|
||
|
Rectangle {
|
||
|
id: appWindow
|
||
|
width: 1600
|
||
|
height: 800
|
||
|
color: "#1b2939"
|
||
|
|
||
|
property var currentWallet;
|
||
|
property bool disconnected: currentWallet ? currentWallet.disconnected : false
|
||
|
property string walletTitle: "lol123"
|
||
|
property string walletPath: ""
|
||
|
property string statusText: "Idle"
|
||
|
property string balanceFormatted: "Balance: 25928.9543 WOW (+3902.32 WOW unconfirmed)"
|
||
|
property bool wsConnected: false
|
||
|
property int connectionStatus: Wallet.ConnectionStatus_Disconnected;
|
||
|
|
||
|
property var balance: 0.0
|
||
|
property var spendable: 0.0
|
||
|
|
||
|
property DashboardPage dashboardPage: DashboardPage {
|
||
|
visible: false
|
||
|
}
|
||
|
|
||
|
property AboutPage aboutPage: AboutPage {
|
||
|
visible: false
|
||
|
}
|
||
|
|
||
|
property WalletPage walletPage: WalletPage {
|
||
|
visible: false
|
||
|
}
|
||
|
|
||
|
MyDialogOkPopup {
|
||
|
id: messagePopup
|
||
|
function showMessage(title, text) {
|
||
|
dialogTitle = title
|
||
|
dialogText = text
|
||
|
open()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MyDialogOkCancelPopup {
|
||
|
id: enterPasswordDialog
|
||
|
dialogTitle: "Enter Password"
|
||
|
dialogWidth: 700
|
||
|
dialogHeight: 400
|
||
|
|
||
|
dialogContentItem: ColumnLayout {
|
||
|
RowLayout {
|
||
|
Layout.topMargin: 16
|
||
|
Layout.leftMargin: 16
|
||
|
Layout.rightMargin: 16
|
||
|
|
||
|
MyText {
|
||
|
text: "Password: "
|
||
|
}
|
||
|
|
||
|
MyTextField {
|
||
|
id: walletOpenPassword
|
||
|
keyBoardUID: 590
|
||
|
color: "#cccccc"
|
||
|
text: ""
|
||
|
Layout.fillWidth: true
|
||
|
font.pointSize: 20
|
||
|
function onInputEvent(input) {
|
||
|
walletOpenPassword.text = input
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onClosed: {
|
||
|
if (okClicked) {
|
||
|
if(walletOpenPassword.text === "")
|
||
|
return messagePopup.showMessage("Password empty", "Please fill in a password.");
|
||
|
|
||
|
ctx.onOpenWallet(appWindow.walletPath, walletOpenPassword.text);
|
||
|
}
|
||
|
}
|
||
|
function openPopup() {
|
||
|
open()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MyDialogOkCancelPopup {
|
||
|
id: createWalletDialog
|
||
|
dialogTitle: "Create New Wallet"
|
||
|
dialogWidth: 700
|
||
|
dialogHeight: 400
|
||
|
|
||
|
dialogContentItem: ColumnLayout {
|
||
|
RowLayout {
|
||
|
Layout.topMargin: 16
|
||
|
Layout.leftMargin: 16
|
||
|
Layout.rightMargin: 16
|
||
|
|
||
|
MyText {
|
||
|
text: "Name: "
|
||
|
}
|
||
|
|
||
|
MyTextField {
|
||
|
id: newWalletName
|
||
|
keyBoardUID: 590
|
||
|
color: "#cccccc"
|
||
|
text: ""
|
||
|
Layout.fillWidth: true
|
||
|
font.pointSize: 20
|
||
|
function onInputEvent(input) {
|
||
|
newWalletName.text = input
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
RowLayout {
|
||
|
Layout.topMargin: 16
|
||
|
Layout.leftMargin: 16
|
||
|
Layout.rightMargin: 16
|
||
|
|
||
|
MyText {
|
||
|
text: "Password: "
|
||
|
}
|
||
|
|
||
|
MyTextField {
|
||
|
id: newWalletPassword
|
||
|
keyBoardUID: 591
|
||
|
color: "#cccccc"
|
||
|
text: ""
|
||
|
Layout.fillWidth: true
|
||
|
font.pointSize: 20
|
||
|
function onInputEvent(input) {
|
||
|
newWalletPassword.text = input
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MyText {
|
||
|
fontSize: 16
|
||
|
text: "The password field is optional."
|
||
|
}
|
||
|
|
||
|
Item {
|
||
|
Layout.fillWidth: true
|
||
|
Layout.fillHeight: true
|
||
|
}
|
||
|
}
|
||
|
onClosed: {
|
||
|
if (okClicked) {
|
||
|
if(newWalletName.text === "")
|
||
|
return messagePopup.showMessage("Invalid name", "Please name the wallet.");
|
||
|
|
||
|
ctx.createWalletWithoutSpecifyingSeed(newWalletName.text, newWalletPassword.text);
|
||
|
}
|
||
|
}
|
||
|
function openPopup() {
|
||
|
open()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
StackView {
|
||
|
id: mainView
|
||
|
anchors.fill: parent
|
||
|
|
||
|
pushEnter: Transition {
|
||
|
PropertyAnimation {
|
||
|
property: "x"
|
||
|
from: mainView.width
|
||
|
to: 0
|
||
|
duration: 300
|
||
|
easing.type: Easing.OutCubic
|
||
|
}
|
||
|
}
|
||
|
pushExit: Transition {
|
||
|
PropertyAnimation {
|
||
|
property: "x"
|
||
|
from: 0
|
||
|
to: -mainView.width
|
||
|
duration: 300
|
||
|
easing.type: Easing.OutCubic
|
||
|
}
|
||
|
}
|
||
|
popEnter: Transition {
|
||
|
PropertyAnimation {
|
||
|
property: "x"
|
||
|
from: -mainView.width
|
||
|
to: 0
|
||
|
duration: 300
|
||
|
easing.type: Easing.OutCubic
|
||
|
}
|
||
|
}
|
||
|
popExit: Transition {
|
||
|
PropertyAnimation {
|
||
|
property: "x"
|
||
|
from: 0
|
||
|
to: mainView.width
|
||
|
duration: 300
|
||
|
easing.type: Easing.OutCubic
|
||
|
}
|
||
|
}
|
||
|
|
||
|
initialItem: dashboardPage
|
||
|
}
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
dashboardPage.onPageCompleted();
|
||
|
|
||
|
if(typeof ctx !== 'undefined') {
|
||
|
ctx.initTor();
|
||
|
ctx.initWS();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Connections {
|
||
|
target: ctx
|
||
|
|
||
|
function onWsConnected() {
|
||
|
console.log("onWsConnected")
|
||
|
appWindow.wsConnected = true;
|
||
|
}
|
||
|
|
||
|
function onWsDisconnected() {
|
||
|
console.log("onWsDisconnected")
|
||
|
appWindow.wsConnected = false;
|
||
|
}
|
||
|
|
||
|
function onWalletOpened(wallet) {
|
||
|
console.log("onWalletOpened()");
|
||
|
|
||
|
appWindow.currentWallet = wallet;
|
||
|
appWindow.walletTitle = ctx.walletName;
|
||
|
mainView.push(appWindow.walletPage);
|
||
|
appWindow.walletPage.onPageCompleted();
|
||
|
|
||
|
appWindow.currentWallet.connectionStatusChanged.connect(onConnectionStatusChanged);
|
||
|
}
|
||
|
|
||
|
// function onWalletOpened(Wallet *wallet) {
|
||
|
|
||
|
// currentWallet.heightRefreshed.connect(onHeightRefreshed);
|
||
|
// currentWallet.refreshed.connect(onWalletRefresh)
|
||
|
// currentWallet.updated.connect(onWalletUpdate)
|
||
|
// currentWallet.newBlock.connect(onWalletNewBlock)
|
||
|
// currentWallet.moneySpent.connect(onWalletMoneySent)
|
||
|
// currentWallet.moneyReceived.connect(onWalletMoneyReceived)
|
||
|
// currentWallet.unconfirmedMoneyReceived.connect(onWalletUnconfirmedMoneyReceived)
|
||
|
// currentWallet.transactionCreated.connect(onTransactionCreated)
|
||
|
// currentWallet.connectionStatusChanged.connect(onWalletConnectionStatusChanged)
|
||
|
// currentWallet.deviceButtonRequest.connect(onDeviceButtonRequest);
|
||
|
// currentWallet.deviceButtonPressed.connect(onDeviceButtonPressed);
|
||
|
// currentWallet.walletPassphraseNeeded.connect(onWalletPassphraseNeededWallet);
|
||
|
// currentWallet.transactionCommitted.connect(onTransactionCommitted);
|
||
|
|
||
|
// middlePanel.paymentClicked.connect(handlePayment);
|
||
|
// }
|
||
|
|
||
|
function onBlockchainSync(height, target) {
|
||
|
let blocks = (target > height) ? (target - height) : "?";
|
||
|
let heightText = "Blockchain sync: " + blocks + " blocks remaining";
|
||
|
appWindow.statusText = heightText;
|
||
|
}
|
||
|
|
||
|
function onRefreshSync(height, target) {
|
||
|
let blocks = (target >= height) ? (target - height) : "?";
|
||
|
let heightText = "Wallet sync: " + blocks + " blocks remaining";
|
||
|
appWindow.statusText = heightText;
|
||
|
}
|
||
|
|
||
|
function onWalletClosed() {
|
||
|
console.log("onWalletClosed");
|
||
|
|
||
|
appWindow.currentWallet.connectionStatusChanged.disconnect(onConnectionStatusChanged);
|
||
|
|
||
|
appWindow.walletTitle = "";
|
||
|
appWindow.balanceFormatted = "";
|
||
|
appWindow.balance = 0.0;
|
||
|
appWindow.spendable = 0.0;
|
||
|
appWindow.connectionStatus = Wallet.ConnectionStatus_Disconnected;
|
||
|
}
|
||
|
|
||
|
function onBalanceUpdatedFormatted(fmt) {
|
||
|
appWindow.balanceFormatted = fmt;
|
||
|
}
|
||
|
|
||
|
function onBalanceUpdated(balance, spendable) {
|
||
|
appWindow.balance = balance;
|
||
|
appWindow.spendable = spendable;
|
||
|
}
|
||
|
|
||
|
function onWalletOpenedError(err) {
|
||
|
messagePopup.showMessage("Error", err);
|
||
|
}
|
||
|
|
||
|
function onWalletCreatedError(err) {
|
||
|
messagePopup.showMessage("Error", err);
|
||
|
}
|
||
|
|
||
|
function onWalletCreated(wallet) {
|
||
|
console.log("walletCreated");
|
||
|
}
|
||
|
|
||
|
function onSynchronized() {
|
||
|
appWindow.statusText = "Synchronized";
|
||
|
|
||
|
appWindow.onConnectionStatusChanged(Wallet.ConnectionStatus_Connected);
|
||
|
console.log("onSynchronized");
|
||
|
}
|
||
|
|
||
|
function onWalletOpenPasswordNeeded(invalidPassword, path) { // bool, str
|
||
|
enterPasswordDialog.openPopup();
|
||
|
}
|
||
|
|
||
|
function onInitiateTransaction() {
|
||
|
console.log("transactionStarted");
|
||
|
}
|
||
|
|
||
|
function onCreateTransactionError(message) { // str
|
||
|
console.log("transactionError", message);
|
||
|
}
|
||
|
|
||
|
function onCreateTransactionSuccess(tx, address) { // PendingTransaction
|
||
|
// auto-commit all tx's
|
||
|
//m_ctx->currentWallet->commitTransactionAsync(tx);
|
||
|
console.log("onCreateTransactionSuccess", address)
|
||
|
}
|
||
|
|
||
|
function onTransactionCommitted(status, tx, txid) { // bool,PendingTransaction,stringlist
|
||
|
console.log("onTransactionCommitted", status)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onConnectionStatusChanged(status) {
|
||
|
console.log("onConnectionStatusChanged", status)
|
||
|
appWindow.connectionStatus = status;
|
||
|
}
|
||
|
}
|