From 128ddbea1c796fa8cad6552f2ea310734e920f73 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 7 Feb 2014 22:46:31 +0100 Subject: [PATCH] Several fixes for v.0.2 --- TODO | 3 ++- harbour-currencyconverter.pro | 4 +++- qml/components/CurrencyCombo.qml | 2 +- qml/harbour-currencyconverter.qml | 26 ++++++++++++++++++-------- qml/pages/FrontPage.qml | 2 ++ qml/pages/SettingsPage.qml | 18 ++++++++++++++++++ rpm/harbour-currencyconverter.yaml | 26 +++++++++++++------------- 7 files changed, 57 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index de231ba..f8f8ce8 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,7 @@ Currency Converter TODO: - Rewrite CurrencyModel inheriting QAbstractListModel and use QList 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. diff --git a/harbour-currencyconverter.pro b/harbour-currencyconverter.pro index 2324050..2e6e053 100644 --- a/harbour-currencyconverter.pro +++ b/harbour-currencyconverter.pro @@ -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} diff --git a/qml/components/CurrencyCombo.qml b/qml/components/CurrencyCombo.qml index 197194c..fa813a1 100644 --- a/qml/components/CurrencyCombo.qml +++ b/qml/components/CurrencyCombo.qml @@ -49,7 +49,7 @@ ComboBox { for(var i = 0; i < currencies.length; i++ ) { if(currencies[i].code === currentCurrency) { - currentIndex = i; + currentItem = currencies[i]; return; } } diff --git a/qml/harbour-currencyconverter.qml b/qml/harbour-currencyconverter.qml index 0228315..30c4be1 100644 --- a/qml/harbour-currencyconverter.qml +++ b/qml/harbour-currencyconverter.qml @@ -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'; @@ -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(); } @@ -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); } @@ -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) { diff --git a/qml/pages/FrontPage.qml b/qml/pages/FrontPage.qml index 442298f..315217c 100644 --- a/qml/pages/FrontPage.qml +++ b/qml/pages/FrontPage.qml @@ -114,6 +114,7 @@ Page { label: qsTr('From'); currentCurrency: fromCode; onActivated: { + console.log('fromCombo', currency.code); fromCode = currency.code; fromSymbol = currency.getSymbol(); getQuote(); @@ -124,6 +125,7 @@ Page { label: qsTr('To'); currentCurrency: toCode; onActivated: { + console.log('toCombo', currency.code); toCode = currency.code; toSymbol = currency.getSymbol(); getQuote(); diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 084b3f5..8c01a75 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -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) { @@ -74,6 +89,9 @@ Dialog { timer.start() } + numDecimals = parseInt(decimalsValue.text); + + settings.setValue('numDecimals', numDecimals); settings.setValue('refreshInterval', refreshInterval); } } diff --git a/rpm/harbour-currencyconverter.yaml b/rpm/harbour-currencyconverter.yaml index bbc7661..fb810bf 100644 --- a/rpm/harbour-currencyconverter.yaml +++ b/rpm/harbour-currencyconverter.yaml @@ -1,6 +1,6 @@ Name: harbour-currencyconverter Summary: Currency Converter -Version: 0.1 +Version: 0.2 Release: 1 Group: Qt/Qt License: "BSD" @@ -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: []