Skip to content

Commit

Permalink
main application: initialize wallet, display balance
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg033 committed Jun 15, 2016
1 parent 2151f13 commit 3ddd9be
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 25 deletions.
3 changes: 3 additions & 0 deletions BasicPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Rectangle {
color: "#F0EEEE"
border.width: 1
border.color: "#DBDBDB"
property alias balanceText : balanceText.text;
property alias unlockedBalanceText : availableBalanceText.text;

Rectangle {
id: header
Expand Down Expand Up @@ -63,6 +65,7 @@ Rectangle {
columns: 3

Text {

width: 116
height: 20
font.family: "Arial"
Expand Down
14 changes: 10 additions & 4 deletions LeftPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import "components"

Rectangle {
id: panel

property alias unlockedBalanceText: unlockedBalanceText.text
property alias balanceText: balanceText.text

signal dashboardClicked()
signal historyClicked()
signal transferClicked()
Expand Down Expand Up @@ -90,7 +94,7 @@ Rectangle {
spacing: 6

Label {
text: qsTr("Locked balance")
text: qsTr("Balance")
anchors.left: parent.left
anchors.leftMargin: 50
tipText: qsTr("Test tip 1<br/><br/>line 2")
Expand All @@ -109,11 +113,12 @@ Rectangle {
}

Text {
id: balanceText
anchors.verticalCenter: parent.verticalCenter
font.family: "Arial"
font.pixelSize: 26
color: "#000000"
text: "78.9239845"
text: "78.9245"
}
}

Expand All @@ -124,19 +129,20 @@ Rectangle {
}

Label {
text: qsTr("Unlocked")
text: qsTr("Unlocked balance")
anchors.left: parent.left
anchors.leftMargin: 50
tipText: qsTr("Test tip 2<br/><br/>line 2")
}

Text {
id: unlockedBalanceText
anchors.left: parent.left
anchors.leftMargin: 50
font.family: "Arial"
font.pixelSize: 18
color: "#000000"
text: "2324.9239845"
text: "2324.9245"
}
}

Expand Down
58 changes: 56 additions & 2 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import QtQuick 2.2
import QtQuick.Window 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1

import Qt.labs.settings 1.0
import Bitmonero.Wallet 1.0

import "components"
import "wizard"
Expand All @@ -43,12 +44,16 @@ ApplicationWindow {
property bool ctrlPressed: false
property bool rightPanelExpanded: true
property bool osx: false
property alias persistentSettings : persistentSettings
property var wallet;

function altKeyReleased() { ctrlPressed = false; }

function showPageRequest(page) {
middlePanel.state = page
leftPanel.selectItem(page)
}

function sequencePressed(obj, seq) {
if(seq === undefined)
return
Expand Down Expand Up @@ -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() {
var wallets = walletManager.findWallets(moneroAccountsDir);
if (wallets.length === 0) {
Expand All @@ -133,6 +169,21 @@ ApplicationWindow {
y = (Screen.height - height) / 2
//
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 {
Expand Down Expand Up @@ -344,7 +395,10 @@ ApplicationWindow {
WizardMain {
id: wizard
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
Expand Down
37 changes: 19 additions & 18 deletions wizard/WizardMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,33 @@ Rectangle {
settings['wallet_filename'] = new_wallet_filename;

// persist settings
persistentSettings.language = settings.language
persistentSettings.account_name = settings.account_name
persistentSettings.wallet_path = settings.wallet_path
persistentSettings.allow_background_mining = settings.allow_background_mining
persistentSettings.auto_donations_enabled = settings.auto_donations_enabled
persistentSettings.auto_donations_amount = settings.auto_donations_amount
appWindow.persistentSettings.language = settings.language
appWindow.persistentSettings.account_name = settings.account_name
appWindow.persistentSettings.wallet_path = settings.wallet_path
appWindow.persistentSettings.allow_background_mining = settings.allow_background_mining
appWindow.persistentSettings.auto_donations_enabled = settings.auto_donations_enabled
appWindow.persistentSettings.auto_donations_amount = settings.auto_donations_amount
}

// reading settings from persistent storage
Component.onCompleted: {
settings['allow_background_mining'] = persistentSettings.allow_background_mining
settings['auto_donations_enabled'] = persistentSettings.auto_donations_enabled
settings['auto_donations_amount'] = persistentSettings.auto_donations_amount
console.log("rootItem: ", appWindow);
settings['allow_background_mining'] = appWindow.persistentSettings.allow_background_mining
settings['auto_donations_enabled'] = appWindow.persistentSettings.auto_donations_enabled
settings['auto_donations_amount'] = appWindow.persistentSettings.auto_donations_amount
}


Settings {
id: 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 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
// }

Rectangle {
id: nextButton
Expand Down
4 changes: 3 additions & 1 deletion wizard/WizardPassword.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Item {
onOpacityChanged: visible = opacity !== 0

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
}

Expand Down

0 comments on commit 3ddd9be

Please sign in to comment.