tanghus / currency-converter-qml Goto Github PK
View Code? Open in Web Editor NEWCurrency Converter for SailfishOS
License: Other
Currency Converter for SailfishOS
License: Other
You have to select new currencies or switch currencies before they show up.
The ts files are empty/corrupted. Sync with transifex.
Translate .desktop file
All currency names must be translated more systematically:
Use QT_TR_NOOP()
Generate a dummy .qml
file based on currencies.json or currencies.csv. https://stackoverflow.com/questions/7771011/how-to-parse-data-in-json
//: <currency.name>
//~ Context Currency name
QT_TR_NOOP("code_ <currency.code>")
Where <currency.code>
is NOT a variable, but the actual currency code: code_EUR
.
In the actual list element, use something like text: qsTr("code_" + model.code)
Or don't use Transifex for currency names.
Always let response contain 'result'
and 'status'
and an optional 'message'
'result'
being the result of the request, e.g. [{'this':'that'},{'now':'then'}]
{
'status':'success',
'result':[{},{},{}...]
}
or
{
'status':'error',
'message':'Oops',
'error:'' // Optional. "Title" of the error
}
This implementation apparently doesn't support setTimeout/onTimeOut
https://stackoverflow.com/questions/26598404/timeout-xmlhttprequest-in-qml
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort
Changed from an option in settings, to a menu item on front page to force refresh of current from currency. That way there is no risk of "loosing" available currencies, and it's more intuitive. I hope.
There is an option to delete cache. Maybe just automatically reload. No need to ask user?
Also because if you delete cache it will work until you close the app. Either re-download automatically or make sure it's done properly on startup. Well both actually.
I am writing a currency converter for SailfishOS, and have to display the currency symbols like £, $, €. Since RTL languages messes around with my editor (and because I tried to remedy the error), they are UTF-8 encoded. All is fine, except for some currencies (USD JPY BGN CZK DKK GBP HUF PLN RON SEK CHF ISK NOK HRK RUB TRY AUD BRL CAD CNY HKD IDR ILS INR KRW MXN MYR NZD PHP SGD THB ZAR and maybe more). When using them in the UI, they completely corrupt the graphics; slows down the app, hides elements and some times makes the backgound flash red, cyan, green.
I tried using encodeURIComponent
and it has had some effect; now the app doesn't completely freeze, but can't exactly be shipped ;)
Examples from currencies.json
:
"CNY": {
"symbol": "\u00a5", // This is OK
"num": 156,
"name": "Chinese Yuan"
},
"DKK": {
"symbol": "\u006b\u0072", // This is OK
"num": 208,
"name": "Danish Krone"
},
"EUR": {
"symbol": "\u20AC", // This is OK
"num": 978,
"name": "Euro"
},
{
"AUD": {
"symbol": "\u0024", // This breaks it
"num": 36,
"name": "Australian Dollar"
},
"IDR": {
"symbol": "\u0052\u0070", // This breaks it
"num": 360,
"name": "Indonesian Rupiah"
},
"ILS": {
"symbol": "\u20aa", // This breaks it
"num": 376,
"name": "New Israeli Shekel"
},
"NOK": {
"symbol": "\u006b\u0072", // This breaks it
"num": 578,
"name": "Norwegian Krone"
},
"TRY": {
"symbol": "\u20a4", // This is OK
"num": 949,
"name": "Turkish Lira"
},
"USD": {
"symbol": "\u0024", // This breaks it
"num": 840,
"name": "US Dollar"
},
}
I have tried various ways of using the symbol in the UI; all of them boils down to something like this:
ListModel {
id: currencyModel
var allCurrencies = Currencies.all // loaded from currencies.json
for(var currency in allCurrencies) {
allCurrencies[currency].symbol = encodeURIComponent(allCurrencies[currency].symbol)
append(allCurrencies[currency])
}
}
Using it in the UI:
Label {
text: decodeURIComponent(currency.symbol)
}
I'm sure there is something I have overlooked, but I can't figure out what.
"All" errors are caught but relevant error messages must be shown to the user.
Test with #5
The title used to be "Crash when no network!", but I can't reproduce the crash.
The app needs to be usable without network, as long as the currency pairs needed are cached.
Outstanding issues:
Save quotes to DB and add an offline option to menu.
The selected currencies aren't remembered when you activate the combobox again.
Please change the Name of the Ukrainian currency. Hryvnia (UAH) is wrong.
It should be Hryvna (UAH) or better:
Ukrainian Hryvna (UAH).
Might not be needed if available are saved in separate table.
To be decided.
UI to add profile for using a different currency exchange web service:
Perhaps have some example profiles. Make a field for setting API key.
https://www.programmableweb.com/category/all/apis?keyword=currency
Currently:
TODO:
Pros:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.