|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "infowidget.h" |
|
19 |
|
20 #include <hbanchorlayout.h> |
|
21 #include <hbiconitem.h> |
|
22 #include <hbmarqueeitem.h> |
|
23 #include <hbfontspec.h> |
|
24 #include <hbdialog.h> |
|
25 #include <hblabel.h> |
|
26 #include <hbaction.h> |
|
27 #include <hbcheckbox.h> |
|
28 #include <hbpushbutton.h> |
|
29 #include <hbevent.h> |
|
30 #include <hbcolorscheme.h> |
|
31 #include <QPainter> |
|
32 #include <QPainterPath> |
|
33 #include <QBrush> |
|
34 #include <QGraphicsLinearLayout> |
|
35 #include <QApplication> |
|
36 #include <QLocale> |
|
37 #include <QTranslator> |
|
38 #include "infowidgetlogging.h" |
|
39 #include "infowidgetengine.h" |
|
40 #include "infowidgetlayoutmanager.h" |
|
41 #include "infowidgetpreferences.h" |
|
42 |
|
43 const int INFOWIDGET_LINE_WIDTH = 0; |
|
44 const int INFOWIDGET_MARGIN = 5; |
|
45 const int INFOWIDGET_ROUNDING = 15; |
|
46 |
|
47 |
|
48 /*! |
|
49 InfoWidget::InfoWidget() |
|
50 */ |
|
51 InfoWidget::InfoWidget(QGraphicsItem* parent, Qt::WindowFlags flags) |
|
52 : HbWidget(parent, flags), |
|
53 m_engine(NULL), |
|
54 m_preferences(NULL), |
|
55 m_layoutManager(NULL), |
|
56 m_layout(NULL), |
|
57 m_layoutChanging(false), |
|
58 m_isDragEvent(false) |
|
59 { |
|
60 INSTALL_TRACE_MSG_HANDLER; |
|
61 |
|
62 DPRINT << ": IN"; |
|
63 |
|
64 // Localization file loading |
|
65 QTranslator translator; |
|
66 QString lang = QLocale::system().name(); |
|
67 QString path = "z:/resource/qt/translations/"; |
|
68 DPRINT << ": loading translation: " << QString(path + "operator_widget_" + lang); |
|
69 bool translatorLoaded = translator.load(path + "operator_widget_" + lang); |
|
70 DPRINT << ": translator loaded: " << translatorLoaded; |
|
71 if (translatorLoaded) { |
|
72 qApp->installTranslator(&translator); |
|
73 DPRINT << ": translator installed"; |
|
74 } |
|
75 |
|
76 m_layoutManager = new InfoWidgetLayoutManager(this); |
|
77 Q_ASSERT(m_layoutManager); |
|
78 |
|
79 // Create network engine |
|
80 m_engine = new InfoWidgetEngine(this); |
|
81 |
|
82 // Create widget preference handler |
|
83 m_preferences = new InfoWidgetPreferences(this); |
|
84 |
|
85 DPRINT << ": reading preferences from meta-object properties"; |
|
86 initializePreferences(); |
|
87 |
|
88 // Create widget main layout |
|
89 m_layout = new QGraphicsLinearLayout; |
|
90 m_layout->setSpacing(0); |
|
91 m_layout->setContentsMargins(0,0,0,0); |
|
92 |
|
93 // Layout info display |
|
94 layoutInfoDisplay(); |
|
95 |
|
96 setLayout(m_layout); |
|
97 |
|
98 // Read initial data from model |
|
99 updateInfoDisplay(); |
|
100 |
|
101 QObject::connect(m_engine, SIGNAL(modelChanged()), |
|
102 this, SLOT(readModel())); |
|
103 |
|
104 m_backGroundColor = HbColorScheme::color("popupbackground"); |
|
105 |
|
106 DPRINT << ": OUT"; |
|
107 } |
|
108 |
|
109 /*! |
|
110 InfoWidget::~InfoWidget() |
|
111 */ |
|
112 InfoWidget::~InfoWidget() |
|
113 { |
|
114 DPRINT << ": IN"; |
|
115 |
|
116 // Clean layout container, |
|
117 // layout manager handles layout item cleanup |
|
118 for (int i=0; i < m_layout->count(); i++) { |
|
119 DPRINT << ": item(" << i << ") removed from layout"; |
|
120 m_layout->removeAt(i); |
|
121 } |
|
122 |
|
123 DPRINT << ": OUT"; |
|
124 UNINSTALL_TRACE_MSG_HANDLER; |
|
125 } |
|
126 |
|
127 /*! |
|
128 InfoWidget::boundingRect() const |
|
129 */ |
|
130 QRectF InfoWidget::boundingRect() const |
|
131 { |
|
132 DPRINT; |
|
133 |
|
134 QRectF rectF = rect(); |
|
135 rectF.adjust(-INFOWIDGET_MARGIN, -INFOWIDGET_MARGIN, |
|
136 INFOWIDGET_MARGIN, INFOWIDGET_MARGIN); |
|
137 |
|
138 return rectF; |
|
139 } |
|
140 |
|
141 /*! |
|
142 InfoWidget::shape() const |
|
143 Return shape |
|
144 */ |
|
145 QPainterPath InfoWidget::shape() const |
|
146 { |
|
147 DPRINT; |
|
148 |
|
149 QPainterPath path; |
|
150 path.addRoundRect(boundingRect(), INFOWIDGET_ROUNDING, INFOWIDGET_ROUNDING); |
|
151 return path; |
|
152 } |
|
153 |
|
154 /*! |
|
155 InfoWidget::sizeHint() |
|
156 */ |
|
157 QSizeF InfoWidget::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const |
|
158 { |
|
159 Q_UNUSED(which); |
|
160 Q_UNUSED(constraint); |
|
161 |
|
162 QSizeF requiredSize(70,160); |
|
163 |
|
164 // Try to get size hint from docml content, if not found use default |
|
165 // size preference |
|
166 if (m_layoutManager->currentDisplayRole() == |
|
167 InfoWidgetLayoutManager::InfoDisplay) { |
|
168 if (m_layoutManager->contentWidget()) { |
|
169 requiredSize = m_layoutManager->contentWidget()->minimumSize(); |
|
170 } |
|
171 } |
|
172 else if (m_layoutManager->currentDisplayRole() == |
|
173 InfoWidgetLayoutManager::SettingsDisplay) { |
|
174 requiredSize = QSizeF(250,250); |
|
175 if (m_layoutManager->contentWidget()) { |
|
176 requiredSize = m_layoutManager->contentWidget()->preferredSize(); |
|
177 } |
|
178 } |
|
179 |
|
180 DPRINT << ": returning size: " << requiredSize; |
|
181 return requiredSize; |
|
182 } |
|
183 |
|
184 /*! |
|
185 InfoWidget::sizePolicy() |
|
186 */ |
|
187 QSizePolicy InfoWidget::sizePolicy () const |
|
188 { |
|
189 DPRINT; |
|
190 |
|
191 // Size tells the exact size for the widget |
|
192 return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
193 } |
|
194 |
|
195 /*! |
|
196 InfoWidget::onInitialize() |
|
197 */ |
|
198 void InfoWidget::onInitialize() |
|
199 { |
|
200 DPRINT << ": IN"; |
|
201 |
|
202 // Initialize preferences from meta-object data |
|
203 // set by homescreen framework. Homescreen framework |
|
204 // has restored the properties before calling onInitialize |
|
205 DPRINT << ": reading preferences from meta-object properties"; |
|
206 initializePreferences(); |
|
207 |
|
208 DPRINT << ": OUT"; |
|
209 } |
|
210 |
|
211 /*! |
|
212 InfoWidget::onUninitialize() |
|
213 */ |
|
214 void InfoWidget::onUninitialize() |
|
215 { |
|
216 DPRINT; |
|
217 } |
|
218 |
|
219 /*! |
|
220 InfoWidget::onShow() |
|
221 */ |
|
222 void InfoWidget::onShow() |
|
223 { |
|
224 DPRINT; |
|
225 } |
|
226 |
|
227 /*! |
|
228 InfoWidget::onHide() |
|
229 */ |
|
230 void InfoWidget::onHide() |
|
231 { |
|
232 DPRINT; |
|
233 } |
|
234 |
|
235 /*! |
|
236 InfoWidget::updateItemsVisibility() |
|
237 */ |
|
238 void InfoWidget::updateItemsVisibility() |
|
239 { |
|
240 DPRINT <<": IN"; |
|
241 int layoutRows = 0; |
|
242 QList<QGraphicsWidget *> widgetsToHide; |
|
243 |
|
244 // Update layout according to item visibility settings |
|
245 // 1. read visible items |
|
246 if (m_preferences->preference(InfoWidgetPreferences::DisplayHomeZone).compare( |
|
247 DISPLAY_SETTING_ON) == 0) { |
|
248 layoutRows++; |
|
249 } else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) { |
|
250 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleHomeZoneLabel); |
|
251 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleHomeZoneIcon); |
|
252 } |
|
253 |
|
254 if (m_preferences->preference(InfoWidgetPreferences::DisplayMcn).compare( |
|
255 DISPLAY_SETTING_ON) == 0) { |
|
256 layoutRows++; |
|
257 } else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) { |
|
258 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleMcnMarqueeItem); |
|
259 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleMcnIcon); |
|
260 } |
|
261 |
|
262 if (m_preferences->preference(InfoWidgetPreferences::DisplayActiveLine).compare( |
|
263 DISPLAY_SETTING_ON) == 0) { |
|
264 layoutRows++; |
|
265 } else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) { |
|
266 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleActiveLineLabel); |
|
267 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleActiveLineIcon); |
|
268 } |
|
269 |
|
270 if (m_preferences->preference(InfoWidgetPreferences::DisplaySatText).compare( |
|
271 DISPLAY_SETTING_ON) == 0) { |
|
272 layoutRows++; |
|
273 } else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) { |
|
274 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleSatTextLabel); |
|
275 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleSatTextIcon); |
|
276 } |
|
277 |
|
278 DPRINT << ": visible layout rows count: " << layoutRows; |
|
279 m_layoutManager->setLayoutRows(layoutRows); |
|
280 } |
|
281 |
|
282 /*! |
|
283 InfoWidget::layoutInfoDisplay() |
|
284 |
|
285 Layout info display |
|
286 */ |
|
287 void InfoWidget::layoutInfoDisplay() |
|
288 { |
|
289 startChanges(); |
|
290 |
|
291 QGraphicsLayout *infoDisplayLayout = |
|
292 m_layoutManager->layoutInfoDisplay(); |
|
293 |
|
294 DPRINT << ": IN"; |
|
295 if (infoDisplayLayout) { |
|
296 DPRINT << ": infoDisplayLayout has been returned from layout manager"; |
|
297 |
|
298 QGraphicsWidget *contentWidget = m_layoutManager->contentWidget(); |
|
299 if (contentWidget) { |
|
300 DPRINT << ": contentWidget has been returned from layout manager"; |
|
301 |
|
302 // Remove old data from layout. |
|
303 for (int i=0; i < m_layout->count(); i++) { |
|
304 DPRINT << ": item(" << i << ") removed from layout"; |
|
305 m_layout->removeAt(i); |
|
306 } |
|
307 |
|
308 // Add content widget to main layout |
|
309 m_layout->addItem(contentWidget); |
|
310 |
|
311 resize(contentWidget->preferredSize()); |
|
312 } |
|
313 } |
|
314 |
|
315 m_layoutManager->showAll(); |
|
316 updateItemsVisibility(); |
|
317 |
|
318 endChanges(); |
|
319 |
|
320 DPRINT << ": OUT"; |
|
321 } |
|
322 |
|
323 /*! |
|
324 InfoWidget::layoutSettingsDisplay() |
|
325 |
|
326 Switch to settings display layout |
|
327 */ |
|
328 void InfoWidget::layoutSettingsDisplay() |
|
329 { |
|
330 startChanges(); |
|
331 |
|
332 QGraphicsLayout *settingDisplayLayout = |
|
333 m_layoutManager->layoutSettingsDisplay(); |
|
334 |
|
335 DPRINT << ": IN"; |
|
336 if (settingDisplayLayout) { |
|
337 DPRINT << ": settingDisplayLayout has been returned from layout manager"; |
|
338 |
|
339 QGraphicsWidget *contentWidget = m_layoutManager->contentWidget(); |
|
340 if (contentWidget) { |
|
341 DPRINT << ": contentWidget has been returned from layout manager"; |
|
342 |
|
343 // Remove old data from layout. |
|
344 for (int i=0; i < m_layout->count(); i++) { |
|
345 DPRINT << ": item(" << i << ") removed from layout"; |
|
346 m_layout->removeAt(i); |
|
347 } |
|
348 |
|
349 // Add content widget to main layout |
|
350 m_layout->addItem(contentWidget); |
|
351 |
|
352 resize(contentWidget->preferredSize()); |
|
353 } |
|
354 |
|
355 // Connect settings display widget signals |
|
356 initializeSettingsDisplayItems(); |
|
357 } |
|
358 |
|
359 m_layoutManager->showAll(); |
|
360 |
|
361 endChanges(); |
|
362 |
|
363 DPRINT << ": OUT"; |
|
364 } |
|
365 |
|
366 /*! |
|
367 InfoWidget::initializeInfoDisplayItems() |
|
368 */ |
|
369 void InfoWidget::initializeInfoDisplayItems() |
|
370 { |
|
371 DPRINT; |
|
372 } |
|
373 |
|
374 /*! |
|
375 InfoWidget::initializeSettingsDisplayItems() |
|
376 |
|
377 Set up initial check box states, lock check boxes |
|
378 if needed and connect signals to local slots |
|
379 */ |
|
380 void InfoWidget::initializeSettingsDisplayItems() |
|
381 { |
|
382 DPRINT << ": IN"; |
|
383 |
|
384 HbPushButton *okButton = qobject_cast<HbPushButton *>(m_layoutManager->getWidget( |
|
385 InfoWidgetLayoutManager::RoleOkButton)); |
|
386 if (okButton) { |
|
387 DPRINT << ": okButton has been returned from layout manager, connecting signal"; |
|
388 QObject::connect(okButton, SIGNAL(clicked()), |
|
389 this, SLOT(settingsEditingFinished())); |
|
390 } |
|
391 |
|
392 // Connect display setting check boxes |
|
393 HbCheckBox *homeZoneBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
|
394 InfoWidgetLayoutManager::RoleHomeZoneCheckBox)); |
|
395 if (homeZoneBox) { |
|
396 DPRINT << ": homeZoneBox has been returned from layout manager, initializing"; |
|
397 // Make checkable when home zone display is supported |
|
398 homeZoneBox->setCheckable(false); |
|
399 QObject::connect(homeZoneBox, SIGNAL(stateChanged(int)), |
|
400 this, SLOT(homeZoneDisplaySettingChanged(int))); |
|
401 } |
|
402 |
|
403 HbCheckBox *mcnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
|
404 InfoWidgetLayoutManager::RoleMcnCheckBox)); |
|
405 if (mcnCheckBox) { |
|
406 mcnCheckBox->setChecked(true); |
|
407 |
|
408 DPRINT << ": mcnCheckBox has been returned from layout manager, connecting signal"; |
|
409 QObject::connect(mcnCheckBox, SIGNAL(stateChanged(int)), |
|
410 this, SLOT(mcnDisplaySettingChanged(int))); |
|
411 } |
|
412 |
|
413 HbCheckBox *activeLineCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
|
414 InfoWidgetLayoutManager::RoleActiveLineCheckBox)); |
|
415 if (activeLineCheckBox) { |
|
416 // Make checkable when active line display is supported |
|
417 activeLineCheckBox->setCheckable(false); |
|
418 |
|
419 DPRINT << ": activeLineCheckBox has been returned from layout manager, connecting signal"; |
|
420 QObject::connect(activeLineCheckBox, SIGNAL(stateChanged(int)), |
|
421 this, SLOT(activeLineDisplaySettingChanged(int))); |
|
422 } |
|
423 |
|
424 HbCheckBox *satTextCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
|
425 InfoWidgetLayoutManager::RoleSatTextCheckBox)); |
|
426 if (satTextCheckBox) { |
|
427 // Make checkable when sat text display is supported |
|
428 satTextCheckBox->setCheckable(false); |
|
429 |
|
430 DPRINT << ": satTextCheckBox has been returned from layout manager, connecting signal"; |
|
431 QObject::connect(satTextCheckBox, SIGNAL(stateChanged(int)), |
|
432 this, SLOT(satDisplaySettingChanged(int))); |
|
433 } |
|
434 |
|
435 DPRINT << ": OUT"; |
|
436 } |
|
437 |
|
438 /*! |
|
439 InfoWidget::updateInfoDisplay() |
|
440 */ |
|
441 void InfoWidget::updateInfoDisplay() |
|
442 { |
|
443 DPRINT; |
|
444 |
|
445 QString text; |
|
446 InfoWidgetEngine::ModelData modelData = m_engine->modelData(); |
|
447 |
|
448 HbLabel *homeZoneLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget( |
|
449 InfoWidgetLayoutManager::RoleHomeZoneLabel)); |
|
450 if (homeZoneLabel && |
|
451 m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) { |
|
452 text = modelData.homeZoneTextTag(); |
|
453 homeZoneLabel->setPlainText(text); |
|
454 } |
|
455 |
|
456 HbMarqueeItem *mcnMarqueeItem = qobject_cast<HbMarqueeItem *>(m_layoutManager->getWidget( |
|
457 InfoWidgetLayoutManager::RoleMcnMarqueeItem)); |
|
458 if (mcnMarqueeItem && |
|
459 m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) { |
|
460 text = modelData.mcnName(); |
|
461 if (text.length()) { |
|
462 mcnMarqueeItem->setText(text); |
|
463 |
|
464 // Set marquee animation looping mode to infinite |
|
465 mcnMarqueeItem->setLoopCount(-1); |
|
466 |
|
467 // Finally, start marquee animation |
|
468 DPRINT << ": mcnMarqueeItem->isAnimating()"; |
|
469 if (!mcnMarqueeItem->isAnimating()) { |
|
470 DPRINT << ": mcnMarqueeItem->startAnimation()"; |
|
471 mcnMarqueeItem->startAnimation(); |
|
472 } |
|
473 } |
|
474 } |
|
475 |
|
476 HbLabel *activeLineLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget( |
|
477 InfoWidgetLayoutManager::RoleActiveLineLabel)); |
|
478 if (activeLineLabel && |
|
479 m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) { |
|
480 text.setNum(modelData.activeLine()); |
|
481 text.insert(0, hbTrId("Line: ")); |
|
482 |
|
483 if (text.length()) { |
|
484 activeLineLabel->setPlainText(text); |
|
485 } |
|
486 } |
|
487 |
|
488 HbLabel *satTextLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget( |
|
489 InfoWidgetLayoutManager::RoleSatTextLabel)); |
|
490 if (satTextLabel && |
|
491 m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) { |
|
492 |
|
493 text = modelData.satDisplayText(); |
|
494 |
|
495 if (text.length()) { |
|
496 satTextLabel->setPlainText(text); |
|
497 } |
|
498 } |
|
499 |
|
500 } |
|
501 |
|
502 /*! |
|
503 InfoWidget::readModel() |
|
504 |
|
505 Read model data. Model's modelChanged - signal is connected to this slot. |
|
506 */ |
|
507 void InfoWidget::readModel() |
|
508 { |
|
509 DPRINT << ": IN"; |
|
510 |
|
511 if (m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) { |
|
512 updateInfoDisplay(); |
|
513 } |
|
514 DPRINT << ": OUT"; |
|
515 } |
|
516 |
|
517 /*! |
|
518 InfoWidget::handleModelError() |
|
519 |
|
520 Model error signal is connected to this slot |
|
521 */ |
|
522 void InfoWidget::handleModelError(int operation,int errorCode) |
|
523 { |
|
524 Q_UNUSED(operation); |
|
525 Q_UNUSED(errorCode); |
|
526 DPRINT; |
|
527 } |
|
528 |
|
529 /*! |
|
530 InfoWidget::paint() |
|
531 */ |
|
532 void InfoWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
533 { |
|
534 Q_UNUSED(option); |
|
535 Q_UNUSED(widget); |
|
536 DPRINT; |
|
537 |
|
538 if (!m_layoutChanging) { |
|
539 QBrush brush(Qt::white); |
|
540 if (m_backGroundColor.isValid()) { |
|
541 brush.setColor(m_backGroundColor); |
|
542 } |
|
543 QRectF drawRect = boundingRect(); |
|
544 drawRect.adjust( INFOWIDGET_LINE_WIDTH, INFOWIDGET_LINE_WIDTH, |
|
545 -INFOWIDGET_LINE_WIDTH, -INFOWIDGET_LINE_WIDTH ); |
|
546 |
|
547 QPainterPath path; |
|
548 path.addRoundRect(drawRect, INFOWIDGET_ROUNDING, INFOWIDGET_ROUNDING); |
|
549 |
|
550 painter->save(); |
|
551 painter->fillPath(path, brush); |
|
552 painter->restore(); |
|
553 } |
|
554 } |
|
555 |
|
556 /*! |
|
557 InfoWidget::mousePressEvent() |
|
558 */ |
|
559 |
|
560 void InfoWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
561 { |
|
562 Q_UNUSED(event); |
|
563 DPRINT; |
|
564 |
|
565 // Initialize flag |
|
566 m_isDragEvent = false; |
|
567 |
|
568 DPRINT; |
|
569 } |
|
570 |
|
571 /*! |
|
572 InfoWidget::mouseReleaseEvent() |
|
573 */ |
|
574 void InfoWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
575 { |
|
576 Q_UNUSED(event); |
|
577 |
|
578 // If in info display and widget wasn't dragged |
|
579 // change to settings display |
|
580 if ((!m_isDragEvent) && |
|
581 m_layoutManager->currentDisplayRole() == |
|
582 InfoWidgetLayoutManager::InfoDisplay) { |
|
583 DPRINT << ": layout settings display"; |
|
584 layoutSettingsDisplay(); |
|
585 } |
|
586 |
|
587 m_isDragEvent = false; |
|
588 } |
|
589 |
|
590 /*! |
|
591 InfoWidget::mouseMoveEvent() |
|
592 */ |
|
593 void InfoWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
594 { |
|
595 Q_UNUSED(event); |
|
596 |
|
597 // Mouse is moving after mouse press event |
|
598 m_isDragEvent = true; |
|
599 } |
|
600 |
|
601 /*! |
|
602 InfoWidget::homeZoneDisplaySettingChanged() |
|
603 */ |
|
604 void InfoWidget::homeZoneDisplaySettingChanged(int state) |
|
605 { |
|
606 DPRINT << ": state: " << state; |
|
607 if (state == Qt::Checked){ |
|
608 m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, DISPLAY_SETTING_ON); |
|
609 } else { |
|
610 m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, DISPLAY_SETTING_OFF); |
|
611 } |
|
612 } |
|
613 |
|
614 /*! |
|
615 InfoWidget::mcnDisplaySettingChanged() |
|
616 */ |
|
617 void InfoWidget::mcnDisplaySettingChanged(int state) |
|
618 { |
|
619 DPRINT << ": state: " << state; |
|
620 if (state == Qt::Checked){ |
|
621 m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn, DISPLAY_SETTING_ON); |
|
622 } else { |
|
623 m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn, DISPLAY_SETTING_OFF); |
|
624 } |
|
625 } |
|
626 |
|
627 /*! |
|
628 InfoWidget::activeLineDisplaySettingChanged() |
|
629 */ |
|
630 void InfoWidget::activeLineDisplaySettingChanged(int state) |
|
631 { |
|
632 DPRINT << ": state: " << state; |
|
633 if (state == Qt::Checked){ |
|
634 m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, DISPLAY_SETTING_ON); |
|
635 } else { |
|
636 m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, DISPLAY_SETTING_OFF); |
|
637 } |
|
638 } |
|
639 |
|
640 /*! |
|
641 InfoWidget::satDisplaySettingChanged() |
|
642 */ |
|
643 void InfoWidget::satDisplaySettingChanged(int state) |
|
644 { |
|
645 DPRINT << ": state: " << state; |
|
646 if (state == Qt::Checked){ |
|
647 m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText, DISPLAY_SETTING_ON); |
|
648 } else { |
|
649 m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText, DISPLAY_SETTING_OFF); |
|
650 } |
|
651 } |
|
652 |
|
653 /*! |
|
654 InfoWidget::mcnDisplay() |
|
655 |
|
656 Getter function for Meta-object property "mcnDisplay" |
|
657 */ |
|
658 QString InfoWidget::mcnDisplay() |
|
659 { |
|
660 DPRINT; |
|
661 return m_preferences->preference(InfoWidgetPreferences::DisplayMcn); |
|
662 } |
|
663 |
|
664 /*! |
|
665 InfoWidget::setMcnDisplay() |
|
666 |
|
667 Setter function for Meta-object property "mcnDisplay" |
|
668 */ |
|
669 void InfoWidget::setMcnDisplay(QString value) |
|
670 { |
|
671 DPRINT; |
|
672 m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn, value); |
|
673 } |
|
674 |
|
675 /*! |
|
676 InfoWidget::homeZoneDisplay() |
|
677 |
|
678 Getter function for Meta-object property "homeZoneDisplay" |
|
679 */ |
|
680 QString InfoWidget::homeZoneDisplay() |
|
681 { |
|
682 DPRINT; |
|
683 return m_preferences->preference(InfoWidgetPreferences::DisplayHomeZone); |
|
684 } |
|
685 |
|
686 /*! |
|
687 InfoWidget::setHomeZoneDisplay() |
|
688 |
|
689 Setter function for Meta-object property "homeZoneDisplay" |
|
690 */ |
|
691 void InfoWidget::setHomeZoneDisplay(QString value) |
|
692 { |
|
693 DPRINT; |
|
694 m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, value); |
|
695 } |
|
696 |
|
697 /*! |
|
698 InfoWidget::activeLineDisplay() |
|
699 |
|
700 Getter function for Meta-object property "activeLineDisplay" |
|
701 */ |
|
702 QString InfoWidget::activeLineDisplay() |
|
703 { |
|
704 DPRINT; |
|
705 return m_preferences->preference(InfoWidgetPreferences::DisplayActiveLine); |
|
706 } |
|
707 |
|
708 /*! |
|
709 InfoWidget::setActiveLineDisplay() |
|
710 |
|
711 Setter function for Meta-object property "activeLineDisplay" |
|
712 */ |
|
713 void InfoWidget::setActiveLineDisplay(QString value) |
|
714 { |
|
715 DPRINT; |
|
716 m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, value); |
|
717 } |
|
718 |
|
719 /*! |
|
720 InfoWidget::satDisplay() |
|
721 |
|
722 Getter function for Meta-object property "satDisplay" |
|
723 */ |
|
724 QString InfoWidget::satDisplay() |
|
725 { |
|
726 DPRINT; |
|
727 return m_preferences->preference(InfoWidgetPreferences::DisplaySatText); |
|
728 } |
|
729 |
|
730 /*! |
|
731 InfoWidget::setSatDisplay() |
|
732 |
|
733 Setter function for Meta-object property "satDisplay" |
|
734 */ |
|
735 void InfoWidget::setSatDisplay(QString value) |
|
736 { |
|
737 DPRINT; |
|
738 m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText, value); |
|
739 } |
|
740 |
|
741 /*! |
|
742 InfoWidget::initializePreferences() |
|
743 |
|
744 Read initial Meta-object properties and store to preference handler. |
|
745 Restores preferences from previous session. |
|
746 */ |
|
747 void InfoWidget::initializePreferences() |
|
748 { |
|
749 DPRINT << ": IN"; |
|
750 QString propertyValue; |
|
751 |
|
752 propertyValue = QObject::property("homeZoneDisplay").toString(); |
|
753 m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, |
|
754 propertyValue); |
|
755 |
|
756 propertyValue = QObject::property("mcnDisplay").toString(); |
|
757 m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn, |
|
758 propertyValue); |
|
759 |
|
760 propertyValue = QObject::property("activeLineDisplay").toString(); |
|
761 m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, |
|
762 propertyValue); |
|
763 |
|
764 propertyValue = QObject::property("satDisplay").toString(); |
|
765 m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText, |
|
766 propertyValue); |
|
767 |
|
768 // Check that at least one item is set visible. If not |
|
769 // set default item(s) visible. TBD which items and how selected. |
|
770 if (m_preferences->visibleItemCount() == 0) { |
|
771 DPRINT << ": no visible items initially, setting MCN on by default"; |
|
772 m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn, |
|
773 DISPLAY_SETTING_ON); |
|
774 } |
|
775 |
|
776 DPRINT << ": OUT"; |
|
777 } |
|
778 |
|
779 /*! |
|
780 InfoWidget::settingsEditingFinished() |
|
781 */ |
|
782 void InfoWidget::settingsEditingFinished() |
|
783 { |
|
784 DPRINT << ": IN"; |
|
785 |
|
786 layoutInfoDisplay(); |
|
787 |
|
788 updateInfoDisplay(); |
|
789 |
|
790 DPRINT << ": OUT"; |
|
791 } |
|
792 |
|
793 /*! |
|
794 InfoWidget::startChanges() |
|
795 */ |
|
796 void InfoWidget::startChanges() |
|
797 { |
|
798 DPRINT << ": IN"; |
|
799 |
|
800 m_layoutChanging = true; |
|
801 |
|
802 DPRINT << ": OUT"; |
|
803 } |
|
804 |
|
805 /*! |
|
806 InfoWidget::endChanges() |
|
807 */ |
|
808 void InfoWidget::endChanges() |
|
809 { |
|
810 DPRINT << ": IN"; |
|
811 |
|
812 m_layoutChanging = false; |
|
813 |
|
814 DPRINT << ": OUT"; |
|
815 } |
|
816 |
|
817 /*! |
|
818 \reimp |
|
819 */ |
|
820 void InfoWidget::changeEvent(QEvent *event) |
|
821 { |
|
822 DPRINT << ": IN"; |
|
823 |
|
824 if (event->type() == HbEvent::ThemeChanged) { |
|
825 m_backGroundColor = HbColorScheme::color("popupbackground"); |
|
826 } |
|
827 HbWidget::changeEvent( event ); |
|
828 |
|
829 DPRINT << ": OUT"; |
|
830 } |
|
831 |
|
832 // End of File. |
|
833 |