Skip to content

Commit

Permalink
Several fixes for v.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghus committed Feb 7, 2014
1 parent 40aa37d commit 128ddbe
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 24 deletions.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Currency Converter TODO:

- Rewrite CurrencyModel inheriting QAbstractListModel and use
QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
to get complete list.
to get complete list.
Update: Qlocale doesn't have as good support as KLocale, so this won't be implemented.
- Better error checking and reporting. Use native notifications.
- Cache latest N exchange rates. Useful for when travelling with no internet connection.
4 changes: 3 additions & 1 deletion harbour-currencyconverter.pro
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ OTHER_FILES += \
qml/components/CurrencyCombo.qml \
qml/harbour-currencyconverter.qml \
transifex.sh \
.travis.yml
.travis.yml \
Changelog \
TODO

lupdate_only {
SOURCES += $${QML_FILES}
Expand Down
2 changes: 1 addition & 1 deletion qml/components/CurrencyCombo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ComboBox {

for(var i = 0; i < currencies.length; i++ ) {
if(currencies[i].code === currentCurrency) {
currentIndex = i;
currentItem = currencies[i];
return;
}
}
Expand Down
26 changes: 18 additions & 8 deletions qml/harbour-currencyconverter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ ApplicationWindow {

id: app;

property string fromCode: 'USD';
property string toCode: 'EUR';
property string fromCode;
property string toCode;

// Usually the same as above, but can be e.g. £ or $
property string fromSymbol: '$';
property string toSymbol: '';
property string fromSymbol;
property string toSymbol;

// The amount to multiply the quote with
property int multiplier: 1;
property int multiplier;

// Refresh interval in minutes
property int refreshInterval: 60;
property int refreshInterval;

// The number of decimals to show the result with
property int numDecimals;

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

Component.onCompleted: {
console.log('Ready');
setBusy(true);
refreshInterval = settings.value('refreshInterval', 60);
fromCode = settings.value('currencyCodeFrom', 'USD');
toCode = settings.value('currencyCodeTo', 'EUR');
multiplier = settings.value('amount', 1);
numDecimals = settings.value('numDecimals', 4);
quote = settings.value('quote', '1');
console.log('Ready', fromCode, toCode);
setBusy(false);
//startUp();
getQuote();
}
Expand All @@ -102,7 +108,7 @@ ApplicationWindow {

onMessage: {
if(messageObject.quote) {
result = Number(messageObject.quote * multiplier).toFixed(4);
result = Number(messageObject.quote * multiplier).toFixed(numDecimals);
} else {
console.log(messageObject.error);
}
Expand All @@ -122,6 +128,10 @@ ApplicationWindow {
timer.restart();
}
myWorker.sendMessage({'quote': fromCode + toCode});

settings.setValue('currencyCodeFrom', fromCode);
settings.setValue('currencyCodeTo', toCode);
settings.setValue('amount', multiplier);
}

function setBusy(state) {
Expand Down
2 changes: 2 additions & 0 deletions qml/pages/FrontPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Page {
label: qsTr('From');
currentCurrency: fromCode;
onActivated: {
console.log('fromCombo', currency.code);
fromCode = currency.code;
fromSymbol = currency.getSymbol();
getQuote();
Expand All @@ -124,6 +125,7 @@ Page {
label: qsTr('To');
currentCurrency: toCode;
onActivated: {
console.log('toCombo', currency.code);
toCode = currency.code;
toSymbol = currency.getSymbol();
getQuote();
Expand Down
18 changes: 18 additions & 0 deletions qml/pages/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ Dialog {
}
}
}
Row {
id: decimals;
Label {
text: qsTr('Number of decimals');
}
TextField {
id: decimalsValue;
text: numDecimals;
horizontalAlignment: TextInput.AlignRight;
inputMethodHints: Qt.ImhFormattedNumbersOnly;
validator: IntValidator {
bottom: 0;
}
}
}
}
onDone: {
if(result == DialogResult.Accepted) {
Expand All @@ -74,6 +89,9 @@ Dialog {
timer.start()
}

numDecimals = parseInt(decimalsValue.text);

settings.setValue('numDecimals', numDecimals);
settings.setValue('refreshInterval', refreshInterval);
}
}
Expand Down
26 changes: 13 additions & 13 deletions rpm/harbour-currencyconverter.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: harbour-currencyconverter
Summary: Currency Converter
Version: 0.1
Version: 0.2
Release: 1
Group: Qt/Qt
License: "BSD"
Expand All @@ -14,21 +14,21 @@ Builder: qtc5
QMakeOptions:
- VERSION=%{version}
PkgConfigBR:
- sailfishapp
- Qt5Quick
- Qt5Qml
- Qt5Core
- Qt5Qml
- Qt5Quick
- sailfishapp
Requires:
- sailfishsilica-qt5
Files:
- '%{_bindir}'
- '%{_bindir}/%{name}'
- '%{_datadir}'
- '%{_datadir}/%{name}'
- '%{_datadir}/%{name}/qml'
- '%{_datadir}/%{name}/translations'
- '%{_datadir}/applications/%{name}.desktop'
- '%{_datadir}/applications'
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
- '%{_datadir}/icons/hicolor/86x86/apps'
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
- '%{_datadir}/applications'
- '%{_datadir}/applications/%{name}.desktop'
- '%{_datadir}/%{name}/translations'
- '%{_datadir}/%{name}/qml'
- '%{_datadir}/%{name}'
- '%{_datadir}'
- '%{_bindir}/%{name}'
- '%{_bindir}'
PkgBR: []

0 comments on commit 128ddbe

Please sign in to comment.