Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Commit

Permalink
Add fiat currency conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit HERVIER committed Apr 8, 2013
1 parent a7613a5 commit 5994315
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 46 deletions.
1 change: 1 addition & 0 deletions bitpurse/qml/AddressPage.qml
Expand Up @@ -56,6 +56,7 @@ Page {
horizontalCenter: parent.horizontalCenter
}
text: WalletController.currentBalance
subtext: WalletController.currentFiatBalance
}
}

Expand Down
1 change: 1 addition & 0 deletions bitpurse/qml/BitCoinField.qml
Expand Up @@ -10,6 +10,7 @@ TextField {
sourceSize.width: 24
sourceSize.height: 24
anchors.rightMargin: 10
anchors.leftMargin: 10
anchors.right: parent.right
source: Qt.resolvedUrl('bitcoin.svg')
}
Expand Down
58 changes: 37 additions & 21 deletions bitpurse/qml/BitCoinLabel.qml
Expand Up @@ -2,28 +2,44 @@ import QtQuick 1.1
import com.nokia.meego 1.0

Item {
property alias text: label.text
height: label.height
width: label.width + bitcoinLogo.width + 20
Text {
id: label
text : '<b>00.00</b>000000'
font.pixelSize: 40
height: paintedHeight
width: paintedWidth
anchors.verticalCenter: parent.verticalCenter
}
property alias text: label.text
property alias subtext: fiatLabel.text

height: bitcoinLabel.height + fiatLabel.height
width: bitcoinLabel.width
Row {
id: bitcoinLabel
width: label.width + bitcoinLogo.width + 20
height: label.height
spacing: 10
Text {
id: label
text : '<b>00.00</b>000000'
font.pixelSize: 40
height: paintedHeight
width: paintedWidth
anchors.verticalCenter: parent.verticalCenter
}

Image {
id: bitcoinLogo
anchors.verticalCenter: parent.verticalCenter
anchors.left: label.right
anchors.leftMargin: 10
sourceSize.width: 32
sourceSize.height: 32
source: Qt.resolvedUrl('bitcoin.svg')
width: 32
height: 32
Image {
id: bitcoinLogo
anchors.verticalCenter: parent.verticalCenter
//anchors.left: label.right
//anchors.leftMargin: 10
sourceSize.width: 32
sourceSize.height: 32
source: Qt.resolvedUrl('bitcoin.svg')
width: 32
height: 32
}
}
Text {
id: fiatLabel
text: ''
font.pixelSize: 16
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
}


}
1 change: 1 addition & 0 deletions bitpurse/qml/SendPage.qml
Expand Up @@ -59,6 +59,7 @@ Page {
id: summary
anchors.horizontalCenter: parent.horizontalCenter
text: WalletController.currentBalance
subtext: WalletController.currentFiatBalance
}

Label {
Expand Down
134 changes: 132 additions & 2 deletions bitpurse/qml/SettingsPage.qml
@@ -1,10 +1,13 @@
import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.0

Page {
tools: backTools
id: settingsPage

property string fiatCurrency : Settings.fiatCurrency

Header{
id:header
source: Qt.resolvedUrl('bitpurse.svg')
Expand Down Expand Up @@ -79,7 +82,26 @@ Page {
}
}
}

TitleLabel {
text: qsTr("Fiat Currency")
}

Label {
text: "Currency"
width: parent.width
height: fiatButton.height
verticalAlignment: Text.AlignVCenter

TumblerButton {
id: fiatButton
text: "EUR"
anchors.right: parent.right
onClicked: fiatSelectionDialog.open()
}
}


TitleLabel {
text: qsTr("Import Blockchain.info MyWallet")
}
Expand Down Expand Up @@ -261,6 +283,114 @@ Page {
ScrollDecorator {
flickableItem: flick
platformStyle: ScrollDecoratorStyle {
}}
}
}

WorkingSelectionDialog {
id: fiatSelectionDialog
titleText: "Fiat Currency"
searchFieldVisible: false

model: ListModel {

}
// This function is what interprets the selection when the user selects a color
function interpretValue() {
var item = fiatListModel.get(fiatSelectionDialog.selectedIndex);
fiatCurrency = item.value
fiatButton.text = item.name
}

id: fiatListModel
ListElement {
name: "EUR (Default)"
value: "EUR"
}
ListElement {
name: "USD"
value: "USD"
}
ListElement {
name: "CNY"
value: "CNY"
}
ListElement {
name: "JPY"
value: "JPY"
}
ListElement {
name: "SGD"
value: "SGD"
}
ListElement {
name: "HKD"
value: "HKD"
}
ListElement {
name: "CAD"
value: "CAD"
}
ListElement {
name: "AUD"
value: "AUD"
}
ListElement {
name: "NZD"
value: "NZD"
}
ListElement {
name: "GBP"
value: "GBP"
}
ListElement {
name: "DKK"
value: "DKK"
}
ListElement {
name: "SEK"
value: "SEK"
}
ListElement {
name: "BRL"
value: "BRL"
}
ListElement {
name: "CHF"
value: "CHF"
}
ListElement {
name: "RUB"
value: "RUB"
}
ListElement {
name: "SLL"
value: "SLL"
}
ListElement {
name: "PLN"
value: "PLN"
}
ListElement {
name: "THB"
value: "THB"
}

}
onAccepted: fiatListModel.interpretValue()
}
// This event handler will set the dialog and the tumbler button to the name of the selected color
Component.onCompleted: {
for (var i = 0; i < fiatListModel.count; i++) {
var item = fiatListModel.get(i)
if (item.value === Settings.fiatCurrency) {
fiatSelectionDialog.selectedIndex = i
fiatListModel.interpretValue();
break;
}
}
}
Binding {
target: Settings
property: "fiatCurrency"
value: fiatCurrency
}
}
5 changes: 3 additions & 2 deletions bitpurse/qml/WalletPage.qml
Expand Up @@ -21,7 +21,8 @@ Page {
top: header.bottom
horizontalCenter: parent.horizontalCenter
}
text: WalletController.balance
text: WalletController.balance
subtext: WalletController.fiatBalance
}

ListModel {
Expand Down Expand Up @@ -208,4 +209,4 @@ Page {
onClicked: (mainMenu.status === DialogStatus.Closed) ? mainMenu.open() : mainMenu.close()
}
}
}
}
11 changes: 11 additions & 0 deletions bitpurse/settings.py
Expand Up @@ -140,16 +140,27 @@ def _set_useDoubleEncryption(self, b):
self._set('useDoubleEncryption', 'true' if b else 'false')
self.on_useDoubleEncryption.emit()

def _set_fiatCurrency(self, value):
self._set('fiatCurrency', value)
self.on_fiatCurrency.emit()

def _get_fiatCurrency(self):
return self.get('fiatCurrency')

on_storePassKey = Signal()
on_passKey = Signal()
on_useDoubleEncryption = Signal()
on_numberOfLaunch = Signal()
on_fiatCurrency = Signal()

numberOfLaunch = Property(int, _get_numberOfLaunch, _set_numberOfLaunch,
notify=on_numberOfLaunch)
storePassKey = Property(bool, _get_storePassKey, _set_storePassKey,
notify=on_storePassKey)
passKey = Property(unicode, _get_passKey,
_set_passKey, notify=on_passKey)
fiatCurrency = Property(unicode, _get_fiatCurrency,
_set_fiatCurrency, notify=on_fiatCurrency)
useDoubleEncryption = Property(bool,
_get_useDoubleEncryption,
_set_useDoubleEncryption,
Expand Down

0 comments on commit 5994315

Please sign in to comment.