Skip to content

Commit 128ddbe

Browse files
committed
Several fixes for v.0.2
1 parent 40aa37d commit 128ddbe

File tree

7 files changed

+57
-24
lines changed

7 files changed

+57
-24
lines changed

TODO

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Currency Converter TODO:
22

33
- Rewrite CurrencyModel inheriting QAbstractListModel and use
44
QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
5-
to get complete list.
5+
to get complete list.
6+
Update: Qlocale doesn't have as good support as KLocale, so this won't be implemented.
67
- Better error checking and reporting. Use native notifications.
78
- Cache latest N exchange rates. Useful for when travelling with no internet connection.

harbour-currencyconverter.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ OTHER_FILES += \
5353
qml/components/CurrencyCombo.qml \
5454
qml/harbour-currencyconverter.qml \
5555
transifex.sh \
56-
.travis.yml
56+
.travis.yml \
57+
Changelog \
58+
TODO
5759

5860
lupdate_only {
5961
SOURCES += $${QML_FILES}

qml/components/CurrencyCombo.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ComboBox {
4949

5050
for(var i = 0; i < currencies.length; i++ ) {
5151
if(currencies[i].code === currentCurrency) {
52-
currentIndex = i;
52+
currentItem = currencies[i];
5353
return;
5454
}
5555
}

qml/harbour-currencyconverter.qml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,21 @@ ApplicationWindow {
3939

4040
id: app;
4141

42-
property string fromCode: 'USD';
43-
property string toCode: 'EUR';
42+
property string fromCode;
43+
property string toCode;
4444

4545
// Usually the same as above, but can be e.g. £ or $
46-
property string fromSymbol: '$';
47-
property string toSymbol: '';
46+
property string fromSymbol;
47+
property string toSymbol;
4848

4949
// The amount to multiply the quote with
50-
property int multiplier: 1;
50+
property int multiplier;
5151

5252
// Refresh interval in minutes
53-
property int refreshInterval: 60;
53+
property int refreshInterval;
54+
55+
// The number of decimals to show the result with
56+
property int numDecimals;
5457

5558
// The last result before multiplication
5659
property string quote: '1';
@@ -72,12 +75,15 @@ ApplicationWindow {
7275
}
7376

7477
Component.onCompleted: {
75-
console.log('Ready');
78+
setBusy(true);
7679
refreshInterval = settings.value('refreshInterval', 60);
7780
fromCode = settings.value('currencyCodeFrom', 'USD');
7881
toCode = settings.value('currencyCodeTo', 'EUR');
7982
multiplier = settings.value('amount', 1);
83+
numDecimals = settings.value('numDecimals', 4);
8084
quote = settings.value('quote', '1');
85+
console.log('Ready', fromCode, toCode);
86+
setBusy(false);
8187
//startUp();
8288
getQuote();
8389
}
@@ -102,7 +108,7 @@ ApplicationWindow {
102108

103109
onMessage: {
104110
if(messageObject.quote) {
105-
result = Number(messageObject.quote * multiplier).toFixed(4);
111+
result = Number(messageObject.quote * multiplier).toFixed(numDecimals);
106112
} else {
107113
console.log(messageObject.error);
108114
}
@@ -122,6 +128,10 @@ ApplicationWindow {
122128
timer.restart();
123129
}
124130
myWorker.sendMessage({'quote': fromCode + toCode});
131+
132+
settings.setValue('currencyCodeFrom', fromCode);
133+
settings.setValue('currencyCodeTo', toCode);
134+
settings.setValue('amount', multiplier);
125135
}
126136

127137
function setBusy(state) {

qml/pages/FrontPage.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Page {
114114
label: qsTr('From');
115115
currentCurrency: fromCode;
116116
onActivated: {
117+
console.log('fromCombo', currency.code);
117118
fromCode = currency.code;
118119
fromSymbol = currency.getSymbol();
119120
getQuote();
@@ -124,6 +125,7 @@ Page {
124125
label: qsTr('To');
125126
currentCurrency: toCode;
126127
onActivated: {
128+
console.log('toCombo', currency.code);
127129
toCode = currency.code;
128130
toSymbol = currency.getSymbol();
129131
getQuote();

qml/pages/SettingsPage.qml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ Dialog {
6666
}
6767
}
6868
}
69+
Row {
70+
id: decimals;
71+
Label {
72+
text: qsTr('Number of decimals');
73+
}
74+
TextField {
75+
id: decimalsValue;
76+
text: numDecimals;
77+
horizontalAlignment: TextInput.AlignRight;
78+
inputMethodHints: Qt.ImhFormattedNumbersOnly;
79+
validator: IntValidator {
80+
bottom: 0;
81+
}
82+
}
83+
}
6984
}
7085
onDone: {
7186
if(result == DialogResult.Accepted) {
@@ -74,6 +89,9 @@ Dialog {
7489
timer.start()
7590
}
7691

92+
numDecimals = parseInt(decimalsValue.text);
93+
94+
settings.setValue('numDecimals', numDecimals);
7795
settings.setValue('refreshInterval', refreshInterval);
7896
}
7997
}

rpm/harbour-currencyconverter.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: harbour-currencyconverter
22
Summary: Currency Converter
3-
Version: 0.1
3+
Version: 0.2
44
Release: 1
55
Group: Qt/Qt
66
License: "BSD"
@@ -14,21 +14,21 @@ Builder: qtc5
1414
QMakeOptions:
1515
- VERSION=%{version}
1616
PkgConfigBR:
17-
- sailfishapp
18-
- Qt5Quick
19-
- Qt5Qml
2017
- Qt5Core
18+
- Qt5Qml
19+
- Qt5Quick
20+
- sailfishapp
2121
Requires:
2222
- sailfishsilica-qt5
2323
Files:
24-
- '%{_bindir}'
25-
- '%{_bindir}/%{name}'
26-
- '%{_datadir}'
27-
- '%{_datadir}/%{name}'
28-
- '%{_datadir}/%{name}/qml'
29-
- '%{_datadir}/%{name}/translations'
30-
- '%{_datadir}/applications/%{name}.desktop'
31-
- '%{_datadir}/applications'
32-
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
3324
- '%{_datadir}/icons/hicolor/86x86/apps'
25+
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
26+
- '%{_datadir}/applications'
27+
- '%{_datadir}/applications/%{name}.desktop'
28+
- '%{_datadir}/%{name}/translations'
29+
- '%{_datadir}/%{name}/qml'
30+
- '%{_datadir}/%{name}'
31+
- '%{_datadir}'
32+
- '%{_bindir}/%{name}'
33+
- '%{_bindir}'
3434
PkgBR: []

0 commit comments

Comments
 (0)