mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-22 02:34:36 +00:00
main application: initialize wallet, display balance
This commit is contained in:
parent
2151f1395c
commit
3ddd9bed72
5 changed files with 91 additions and 25 deletions
|
@ -35,6 +35,8 @@ Rectangle {
|
||||||
color: "#F0EEEE"
|
color: "#F0EEEE"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: "#DBDBDB"
|
border.color: "#DBDBDB"
|
||||||
|
property alias balanceText : balanceText.text;
|
||||||
|
property alias unlockedBalanceText : availableBalanceText.text;
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: header
|
id: header
|
||||||
|
@ -63,6 +65,7 @@ Rectangle {
|
||||||
columns: 3
|
columns: 3
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|
||||||
width: 116
|
width: 116
|
||||||
height: 20
|
height: 20
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
|
|
|
@ -31,6 +31,10 @@ import "components"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: panel
|
id: panel
|
||||||
|
|
||||||
|
property alias unlockedBalanceText: unlockedBalanceText.text
|
||||||
|
property alias balanceText: balanceText.text
|
||||||
|
|
||||||
signal dashboardClicked()
|
signal dashboardClicked()
|
||||||
signal historyClicked()
|
signal historyClicked()
|
||||||
signal transferClicked()
|
signal transferClicked()
|
||||||
|
@ -90,7 +94,7 @@ Rectangle {
|
||||||
spacing: 6
|
spacing: 6
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Locked balance")
|
text: qsTr("Balance")
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 50
|
anchors.leftMargin: 50
|
||||||
tipText: qsTr("Test tip 1<br/><br/>line 2")
|
tipText: qsTr("Test tip 1<br/><br/>line 2")
|
||||||
|
@ -109,11 +113,12 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
id: balanceText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 26
|
font.pixelSize: 26
|
||||||
color: "#000000"
|
color: "#000000"
|
||||||
text: "78.9239845"
|
text: "78.9245"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,19 +129,20 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Unlocked")
|
text: qsTr("Unlocked balance")
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 50
|
anchors.leftMargin: 50
|
||||||
tipText: qsTr("Test tip 2<br/><br/>line 2")
|
tipText: qsTr("Test tip 2<br/><br/>line 2")
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
id: unlockedBalanceText
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 50
|
anchors.leftMargin: 50
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 18
|
font.pixelSize: 18
|
||||||
color: "#000000"
|
color: "#000000"
|
||||||
text: "2324.9239845"
|
text: "2324.9245"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
main.qml
58
main.qml
|
@ -30,7 +30,8 @@ import QtQuick 2.2
|
||||||
import QtQuick.Window 2.0
|
import QtQuick.Window 2.0
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
import QtQuick.Controls.Styles 1.1
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import Qt.labs.settings 1.0
|
||||||
|
import Bitmonero.Wallet 1.0
|
||||||
|
|
||||||
import "components"
|
import "components"
|
||||||
import "wizard"
|
import "wizard"
|
||||||
|
@ -43,12 +44,16 @@ ApplicationWindow {
|
||||||
property bool ctrlPressed: false
|
property bool ctrlPressed: false
|
||||||
property bool rightPanelExpanded: true
|
property bool rightPanelExpanded: true
|
||||||
property bool osx: false
|
property bool osx: false
|
||||||
|
property alias persistentSettings : persistentSettings
|
||||||
|
property var wallet;
|
||||||
|
|
||||||
function altKeyReleased() { ctrlPressed = false; }
|
function altKeyReleased() { ctrlPressed = false; }
|
||||||
|
|
||||||
function showPageRequest(page) {
|
function showPageRequest(page) {
|
||||||
middlePanel.state = page
|
middlePanel.state = page
|
||||||
leftPanel.selectItem(page)
|
leftPanel.selectItem(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
function sequencePressed(obj, seq) {
|
function sequencePressed(obj, seq) {
|
||||||
if(seq === undefined)
|
if(seq === undefined)
|
||||||
return
|
return
|
||||||
|
@ -112,6 +117,37 @@ ApplicationWindow {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
|
||||||
|
if (typeof wizard.settings['wallet'] !== 'undefined') {
|
||||||
|
wallet = wizard.settings['wallet'];
|
||||||
|
} else {
|
||||||
|
var wallet_path = persistentSettings.wallet_path + "/" + persistentSettings.account_name + "/"
|
||||||
|
+ persistentSettings.account_name;
|
||||||
|
console.log("opening wallet at: ", wallet_path);
|
||||||
|
// TODO: wallet password dialog
|
||||||
|
wallet = walletManager.openWallet(wallet_path, "", persistentSettings.testnet);
|
||||||
|
if (wallet.status !== Wallet.Status_Ok) {
|
||||||
|
console.log("Error opening wallet: ", wallet.errorString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("Wallet opened successfully: ", wallet.errorString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wallet.init(persistentSettings.daemon_address, 0)) {
|
||||||
|
console.log("Error initialize wallet: ", wallet.errorString);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO: refresh asynchronously without blocking UI, implement signal(s)
|
||||||
|
wallet.refresh();
|
||||||
|
|
||||||
|
console.log("wallet balance: ", wallet.balance)
|
||||||
|
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
||||||
|
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function walletsFound() {
|
function walletsFound() {
|
||||||
var wallets = walletManager.findWallets(moneroAccountsDir);
|
var wallets = walletManager.findWallets(moneroAccountsDir);
|
||||||
if (wallets.length === 0) {
|
if (wallets.length === 0) {
|
||||||
|
@ -133,6 +169,21 @@ ApplicationWindow {
|
||||||
y = (Screen.height - height) / 2
|
y = (Screen.height - height) / 2
|
||||||
//
|
//
|
||||||
rootItem.state = walletsFound() ? "normal" : "wizard";
|
rootItem.state = walletsFound() ? "normal" : "wizard";
|
||||||
|
if (rootItem.state === "normal") {
|
||||||
|
initialize(persistentSettings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings {
|
||||||
|
id: persistentSettings
|
||||||
|
property string language
|
||||||
|
property string account_name
|
||||||
|
property string wallet_path
|
||||||
|
property bool auto_donations_enabled : true
|
||||||
|
property int auto_donations_amount : 50
|
||||||
|
property bool allow_background_mining : true
|
||||||
|
property bool testnet: true
|
||||||
|
property string daemon_address: "localhost:38081"
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -344,7 +395,10 @@ ApplicationWindow {
|
||||||
WizardMain {
|
WizardMain {
|
||||||
id: wizard
|
id: wizard
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onUseMoneroClicked: rootItem.state = "normal"
|
onUseMoneroClicked: {
|
||||||
|
rootItem.state = "normal" // TODO: listen for this state change in appWindow;
|
||||||
|
appWindow.initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property int maxWidth: leftPanel.width + 655 + rightPanel.width
|
property int maxWidth: leftPanel.width + 655 + rightPanel.width
|
||||||
|
|
|
@ -146,32 +146,33 @@ Rectangle {
|
||||||
settings['wallet_filename'] = new_wallet_filename;
|
settings['wallet_filename'] = new_wallet_filename;
|
||||||
|
|
||||||
// persist settings
|
// persist settings
|
||||||
persistentSettings.language = settings.language
|
appWindow.persistentSettings.language = settings.language
|
||||||
persistentSettings.account_name = settings.account_name
|
appWindow.persistentSettings.account_name = settings.account_name
|
||||||
persistentSettings.wallet_path = settings.wallet_path
|
appWindow.persistentSettings.wallet_path = settings.wallet_path
|
||||||
persistentSettings.allow_background_mining = settings.allow_background_mining
|
appWindow.persistentSettings.allow_background_mining = settings.allow_background_mining
|
||||||
persistentSettings.auto_donations_enabled = settings.auto_donations_enabled
|
appWindow.persistentSettings.auto_donations_enabled = settings.auto_donations_enabled
|
||||||
persistentSettings.auto_donations_amount = settings.auto_donations_amount
|
appWindow.persistentSettings.auto_donations_amount = settings.auto_donations_amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading settings from persistent storage
|
// reading settings from persistent storage
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
settings['allow_background_mining'] = persistentSettings.allow_background_mining
|
console.log("rootItem: ", appWindow);
|
||||||
settings['auto_donations_enabled'] = persistentSettings.auto_donations_enabled
|
settings['allow_background_mining'] = appWindow.persistentSettings.allow_background_mining
|
||||||
settings['auto_donations_amount'] = persistentSettings.auto_donations_amount
|
settings['auto_donations_enabled'] = appWindow.persistentSettings.auto_donations_enabled
|
||||||
|
settings['auto_donations_amount'] = appWindow.persistentSettings.auto_donations_amount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Settings {
|
// Settings {
|
||||||
id: persistentSettings
|
// id: persistentSettings
|
||||||
|
|
||||||
property string language
|
// property string language
|
||||||
property string account_name
|
// property string account_name
|
||||||
property string wallet_path
|
// property string wallet_path
|
||||||
property bool auto_donations_enabled : true
|
// property bool auto_donations_enabled : true
|
||||||
property int auto_donations_amount : 50
|
// property int auto_donations_amount : 50
|
||||||
property bool allow_background_mining : true
|
// property bool allow_background_mining : true
|
||||||
}
|
// }
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: nextButton
|
id: nextButton
|
||||||
|
|
|
@ -44,7 +44,9 @@ Item {
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function onPageClosed(settingsObject) {
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject.wallet.setPassword(passwordItem.password)
|
// TODO: set password on the final page
|
||||||
|
// settingsObject.wallet.setPassword(passwordItem.password)
|
||||||
|
settingsObject['wallet_password'] = passwordItem.password
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue