@@ -39,18 +39,21 @@ ApplicationWindow {
39
39
40
40
id: app;
41
41
42
- property string fromCode: ' USD ' ;
43
- property string toCode: ' EUR ' ;
42
+ property string fromCode;
43
+ property string toCode;
44
44
45
45
// 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;
48
48
49
49
// The amount to multiply the quote with
50
- property int multiplier: 1 ;
50
+ property int multiplier;
51
51
52
52
// 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;
54
57
55
58
// The last result before multiplication
56
59
property string quote: ' 1' ;
@@ -72,12 +75,15 @@ ApplicationWindow {
72
75
}
73
76
74
77
Component .onCompleted : {
75
- console . log ( ' Ready ' );
78
+ setBusy ( true );
76
79
refreshInterval = settings .value (' refreshInterval' , 60 );
77
80
fromCode = settings .value (' currencyCodeFrom' , ' USD' );
78
81
toCode = settings .value (' currencyCodeTo' , ' EUR' );
79
82
multiplier = settings .value (' amount' , 1 );
83
+ numDecimals = settings .value (' numDecimals' , 4 );
80
84
quote = settings .value (' quote' , ' 1' );
85
+ console .log (' Ready' , fromCode, toCode);
86
+ setBusy (false );
81
87
// startUp();
82
88
getQuote ();
83
89
}
@@ -102,7 +108,7 @@ ApplicationWindow {
102
108
103
109
onMessage: {
104
110
if (messageObject .quote ) {
105
- result = Number (messageObject .quote * multiplier).toFixed (4 );
111
+ result = Number (messageObject .quote * multiplier).toFixed (numDecimals );
106
112
} else {
107
113
console .log (messageObject .error );
108
114
}
@@ -122,6 +128,10 @@ ApplicationWindow {
122
128
timer .restart ();
123
129
}
124
130
myWorker .sendMessage ({' quote' : fromCode + toCode});
131
+
132
+ settings .setValue (' currencyCodeFrom' , fromCode);
133
+ settings .setValue (' currencyCodeTo' , toCode);
134
+ settings .setValue (' amount' , multiplier);
125
135
}
126
136
127
137
function setBusy (state ) {
0 commit comments