Harmattan font changes completed
[marketstoday] / src / qml / ConfigParametersComponent.qml
1 /*
2 @version: 0.5
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5 */
6
7 import Qt 4.7
8 import "Library/js/DBUtility.js" as DBUtility
9
10 Item {
11     id: configParametersComponent
12     property bool updateFreqEnabled
13     property string  updateFreqMin
14     property bool updateWeekdaysOnly
15     property int fontSizeMed: 24
16     property int fontSizeSmall: 20
17
18     //property bool updateOnSavedNetworksOnly
19     property string  rssURL: "http://finance.yahoo.com/rss/topfinstories"
20     signal logRequest(string strMessage)
21
22     Rectangle {
23         id: updateConfig
24         anchors.fill: parent
25         color:"#343434"
26
27         Component.onCompleted: {
28                 DBUtility.initialize();
29                 loadSettings();
30         }
31
32         Component.onDestruction:{
33             logRequest("Saving settings");
34             saveSettings();
35         }
36
37         function loadSettings(){
38             var value;
39             value  = DBUtility.getSetting("UpdateFreqency");
40             if (!value || value === "0.0" || value === "" || isNaN(value)){
41                 configParametersComponent.updateFreqEnabled = false;
42             }
43             else{
44                 configParametersComponent.updateFreqEnabled = true;
45                 configParametersComponent.updateFreqMin = parseInt(value);
46             }
47             value  = DBUtility.getSetting("UpdateWeekdaysOnly");
48             if (!value || value === "0.0" || value === ""|| !configParametersComponent.updateFreqEnabled){
49                 configParametersComponent.updateWeekdaysOnly = false;
50             }
51             else{
52                 configParametersComponent.updateWeekdaysOnly = true;
53             }
54
55 /*
56             value  = DBUtility.getSetting("UpdateOnSavedNetworksOnly");
57             if (!value || value == "0.0" || value === ""){
58                 configParametersComponent.updateOnSavedNetworksOnly = false;
59             }
60             else{
61                 configParametersComponent.updateOnSavedNetworksOnly = true;
62             }
63 */
64
65             value  = DBUtility.getSetting("RSSURL");
66             if (!value || value === "Unknown" || value === ""){
67                 //configParametersComponent.rssURL = configParametersComponent.defaultRSSFeed;
68             }
69             else{
70                 configParametersComponent.rssURL = value;
71             }
72         }
73
74         function saveSettings(){
75             if (isNaN(configParametersComponent.updateFreqMin))
76                 DBUtility.setSetting("UpdateFreqency","");
77             else
78                 DBUtility.setSetting("UpdateFreqency",configParametersComponent.updateFreqMin);
79
80             DBUtility.setSetting("UpdateWeekdaysOnly",(configParametersComponent.updateWeekdaysOnly?1:0));
81             //DBUtility.setSetting("UpdateOnSavedNetworksOnly",(configParametersComponent.updateOnSavedNetworksOnly?1:0));
82             DBUtility.setSetting("RSSURL",configParametersComponent.rssURL);
83         }
84
85         Text {
86             id: newsSectionLabel
87             anchors.top: parent.top
88             anchors.left: parent.left
89             anchors.leftMargin: 35
90             height: 50
91             horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
92             font.pixelSize: fontSizeMed; font.bold: true; elide: Text.ElideRight; color: "#B8B8B8"; style: Text.Raised; styleColor: "black"
93             text: "News Feed"
94         }
95
96         Rectangle {
97             id: newsSection
98             border.width: 1
99             border.color: "#BFBFBF"
100             color:"#2E2E2E"
101             anchors.top: newsSectionLabel.bottom
102             anchors.topMargin: 10
103             anchors.left: parent.left
104             anchors.leftMargin: 30
105             anchors.right: parent.right
106             anchors.rightMargin: 30
107             height: 60
108             radius: 15
109
110             Row {
111                 id: rowRSSURL
112                 //anchors.top: parent.top
113                 //anchors.topMargin: 5
114                 anchors.verticalCenter: parent.verticalCenter
115                 anchors.left: parent.left
116                 anchors.leftMargin: 5
117                 anchors.right: parent.right
118                 height: 50
119                 spacing: 5
120
121                 Text{
122                     height:parent.height
123                     horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
124                     font.pixelSize: fontSizeSmall; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black"
125                     text: "RSS URL: "
126                     color: "#ffffff";
127                 }
128
129                 Item {
130                     height: 40
131                     //updateConfig.width > updateConfig.height?
132                     width:  parent.width*3/4
133                     BorderImage { source: "Library/images/lineedit.sci"; anchors.fill: parent }
134                     TextInput{
135                         id: txtRSSURL
136                         height: parent.height
137                         anchors.left: parent.left
138                         anchors.leftMargin: 10
139                         anchors.right: parent.right
140                         anchors.verticalCenter: parent.verticalCenter
141                         focus: true
142                         text: configParametersComponent.rssURL
143                         horizontalAlignment: Text.AlignLeft
144                         font.pixelSize: 18
145                         inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase
146                         onTextChanged: {
147                             configParametersComponent.rssURL = txtRSSURL.text;
148                         }
149                     }
150                 }
151             }
152         }
153
154         Text {
155             id: autoUpdateSectionLabel
156             anchors.top: newsSection.bottom
157             anchors.topMargin: 20
158             anchors.left: parent.left
159             anchors.leftMargin: 35
160             height: 50
161             horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
162             font.pixelSize: fontSizeMed; font.bold: true; elide: Text.ElideRight; color: "#B8B8B8"; style: Text.Raised; styleColor: "black"
163             text: "Auto-Update *"
164         }
165
166         Rectangle {
167             id: autoUpdateSection
168             border.width: 1
169             border.color: "#BFBFBF"
170             color:"#2E2E2E"
171             anchors.top: autoUpdateSectionLabel.bottom
172             anchors.topMargin: 10
173             anchors.left: parent.left
174             anchors.leftMargin: 30
175             anchors.right: parent.right
176             anchors.rightMargin: 30
177             height: 120
178             radius: 15
179
180             Row {
181                 id: rowUpdateFreq
182                 anchors.top: parent.top
183                 anchors.topMargin: 5
184                 anchors.left: parent.left
185                 anchors.leftMargin: 5
186                 anchors.right: parent.right
187                 height: 50
188                 spacing: 5
189
190                 Image {
191                     id: checkboxUpdateFreqImg
192                     source: configParametersComponent.updateFreqEnabled? "Library/images/checkbox_checked.png":"Library/images/checkbox_unchecked.png"
193                     width: 32; height: 32
194                     MouseArea {
195                         anchors.fill: parent;
196                         onClicked: {
197                             configParametersComponent.updateFreqEnabled = !configParametersComponent.updateFreqEnabled;
198                             if (!configParametersComponent.updateFreqEnabled){
199                                 txtUpdateFreqMin.text = "";
200                                 configParametersComponent.updateWeekdaysOnly = false;
201                             }
202                         }
203                     }
204                 }
205
206                 Text{
207                     height:parent.height
208                     horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
209                     font.pixelSize: fontSizeSmall; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black"
210                     text: "Every "
211                     color: configParametersComponent.updateFreqEnabled? "#ffffff" :"#B8B8B8";
212                 }
213                 Item {
214                     height: 40
215                     width: 80
216                     BorderImage { source: "Library/images/lineedit.sci"; anchors.fill: parent }
217                     TextInput{                        
218                         id: txtUpdateFreqMin
219                         anchors.fill: parent
220                         focus: true
221                         text: configParametersComponent.updateFreqMin
222                         horizontalAlignment: Text.AlignHCenter
223                         font.pixelSize: 18
224                         inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
225                         onTextChanged: {
226                             configParametersComponent.updateFreqMin = txtUpdateFreqMin.text;
227                         }
228                     }
229                 }
230                 Text{
231                     height:parent.height
232                     horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
233                     font.pixelSize: fontSizeSmall; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black"
234                     text: " minutes"
235                     color: configParametersComponent.updateFreqEnabled? "#ffffff" :"#B8B8B8";
236                 }
237             }
238             Row {
239                 id: rowUpdateDays
240                 anchors.top: rowUpdateFreq.bottom
241                 anchors.topMargin: 5
242                 anchors.left: parent.left
243                 anchors.leftMargin: 5
244                 anchors.right: parent.right
245                 height: 50
246                 spacing: 5
247
248                 Image {
249                     id: checkboxUpdateWeekdays
250                     source: configParametersComponent.updateWeekdaysOnly? "Library/images/checkbox_checked.png":"Library/images/checkbox_unchecked.png"
251                     width: 32; height: 32
252                     MouseArea {
253                         anchors.fill: parent;
254                         onClicked: {
255                             configParametersComponent.updateWeekdaysOnly = !configParametersComponent.updateWeekdaysOnly;
256                         }
257                     }
258                 }
259
260                 Text{
261                     height:parent.height
262                     horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
263                     font.pixelSize: fontSizeSmall; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black"
264                     text: "Only on weekdays"
265                     color: configParametersComponent.updateWeekdaysOnly? "#ffffff" :"#B8B8B8";
266                 }
267             }
268 /*
269             Row {
270                 id: rowUpdateConnections
271                 anchors.top: rowUpdateDays.bottom
272                 anchors.topMargin: 5
273                 anchors.left: parent.left
274                 anchors.leftMargin: 5
275                 anchors.right: parent.right
276                 height: 50
277                 spacing: 5
278
279                 Image {
280                     id: checkboxUpdateKnownConnections
281                     source: configParametersComponent.updateOnSavedNetworksOnly? "Library/images/checkbox_checked.png":"Library/images/checkbox_unchecked.png"
282                     width: 32; height: 32
283                     MouseArea {
284                         anchors.fill: parent;
285                         onClicked: {
286                             configParametersComponent.updateOnSavedNetworksOnly = !configParametersComponent.updateOnSavedNetworksOnly;
287                         }
288                     }
289                 }
290
291                 Text{
292                     height:parent.height
293                     horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
294                     font.pixelSize: fontSizeSmall; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black"
295                     text: "Only on saved Wifi connections"
296                     color: configParametersComponent.updateOnSavedNetworksOnly? "#ffffff" :"#B8B8B8";
297                 }
298             }
299 */
300         }
301
302         Rectangle{
303             id: footerText
304             width: parent.width
305             height: 25
306             color: "#343434"
307             anchors.bottom: parent.bottom
308             Text {
309                 id: footerMessage
310                 anchors.fill: parent
311                 text: "* Quotes will be auto-updated only when the application/widget is running."
312                 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
313                 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
314                 color: "#cccccc"
315                 style: Text.Raised; styleColor: "black"
316             }
317         }
318     }
319 }