--- a/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidget.cpp Fri Apr 16 14:58:25 2010 +0300
+++ b/phoneplugins/infowidgetplugin/infowidgetprovider/infowidget/src/infowidget.cpp Mon May 03 12:31:11 2010 +0300
@@ -28,6 +28,8 @@
#include <hbpushbutton.h>
#include <hbevent.h>
#include <hbcolorscheme.h>
+#include <hbmessagebox.h>
+#include <hbframedrawer.h>
#include <QPainter>
#include <QPainterPath>
#include <QBrush>
@@ -40,10 +42,25 @@
#include "infowidgetlayoutmanager.h"
#include "infowidgetpreferences.h"
-const int INFOWIDGET_LINE_WIDTH = 0;
-const int INFOWIDGET_MARGIN = 5;
const int INFOWIDGET_ROUNDING = 15;
+const int INFOWIDGET_DEFAULT_HEIGHT = 100;
+const int INFOWIDGET_DEFAULT_WIDTH = 100;
+const char *TS_FILE_OPERATOR_WIDGET = "operator_widget";
+const char *TS_FILE_COMMON = "common";
+const char *BACKGROUND_COLOR_GROUP_ID = "qtc_default_popup_normal";
+const char *BACKGROUND_FRAME_NAME = "qtg_fr_hswidget_normal";
+/*!
+ \class InfoWidget
+ \brief Operator info widget main class.
+
+ Implements HomeScreen specific slots and
+ graphical representation of the
+ Operator Info widget.
+
+ Derived from HbWidget.
+
+*/
/*!
InfoWidget::InfoWidget()
@@ -54,55 +71,54 @@
m_preferences(NULL),
m_layoutManager(NULL),
m_layout(NULL),
+ m_frameDrawer(NULL),
m_layoutChanging(false),
- m_isDragEvent(false)
+ m_dragEvent(false),
+ m_initialized(false)
{
INSTALL_TRACE_MSG_HANDLER;
DPRINT << ": IN";
// Localization file loading
- QTranslator translator;
- QString lang = QLocale::system().name();
- QString path = "z:/resource/qt/translations/";
- DPRINT << ": loading translation: " << QString(path + "operator_widget_" + lang);
- bool translatorLoaded = translator.load(path + "operator_widget_" + lang);
- DPRINT << ": translator loaded: " << translatorLoaded;
- if (translatorLoaded) {
- qApp->installTranslator(&translator);
- DPRINT << ": translator installed";
- }
+ installTranslator(TS_FILE_OPERATOR_WIDGET);
+ installTranslator(TS_FILE_COMMON);
m_layoutManager = new InfoWidgetLayoutManager(this);
Q_ASSERT(m_layoutManager);
- // Create network engine
m_engine = new InfoWidgetEngine(this);
-
- // Create widget preference handler
+ Q_ASSERT(m_engine);
+
m_preferences = new InfoWidgetPreferences(this);
-
- DPRINT << ": reading preferences from meta-object properties";
- initializePreferences();
-
- // Create widget main layout
+ Q_ASSERT(m_preferences);
+
+ QObject::connect( m_preferences, SIGNAL(prefChanged(int,int)),
+ m_engine, SLOT(preferenceChanged(int,int)));
+
+ // Setup widget main layout
m_layout = new QGraphicsLinearLayout;
m_layout->setSpacing(0);
m_layout->setContentsMargins(0,0,0,0);
-
- // Layout info display
- layoutInfoDisplay();
-
setLayout(m_layout);
- // Read initial data from model
- updateInfoDisplay();
+ // Read color definitions
+ m_backGroundColor = HbColorScheme::color(
+ BACKGROUND_COLOR_GROUP_ID);
+ if (!m_backGroundColor.isValid()) {
+ m_backGroundColor = Qt::black;
+ }
- QObject::connect(m_engine, SIGNAL(modelChanged()),
- this, SLOT(readModel()));
+ // Create background frame drawer
+ m_frameDrawer = new HbFrameDrawer(
+ BACKGROUND_FRAME_NAME,
+ HbFrameDrawer::NinePieces);
+ Q_ASSERT(m_frameDrawer);
- m_backGroundColor = HbColorScheme::color("popupbackground");
-
+ // Set widget initial size
+ resize(INFOWIDGET_DEFAULT_WIDTH,
+ INFOWIDGET_DEFAULT_HEIGHT);
+
DPRINT << ": OUT";
}
@@ -120,34 +136,156 @@
m_layout->removeAt(i);
}
+ if (m_frameDrawer) {
+ delete m_frameDrawer;
+ m_frameDrawer = NULL;
+ }
+
+ // Remove and delete language translators
+ removeTranslators();
+
DPRINT << ": OUT";
UNINSTALL_TRACE_MSG_HANDLER;
}
/*!
+ InfoWidget::onInitialize()
+
+ Called by HS framework, saved preference data
+ is available when onInitialize() is called and
+ meta-object data reading should be done here
+*/
+void InfoWidget::onInitialize()
+{
+ DPRINT << ": IN";
+
+ m_initialized = true;
+
+ // Initialize preferences from meta-object data
+ if (!readPersistentPreferences()) {
+
+ // Reading failed, initialize default values
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn,
+ DISPLAY_SETTING_ON);
+ m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn,
+ DISPLAY_SETTING_ON);
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText,
+ DISPLAY_SETTING_ON);
+ }
+ m_preferences->storePreferences();
+
+ // Layout components
+ layoutInfoDisplay();
+ m_layout->activate();
+
+ // Read initial data from model
+ updateInfoDisplay();
+
+ // Listen for model changes
+ QObject::connect(m_engine, SIGNAL(modelChanged()),
+ this, SLOT(readModel()));
+
+ DPRINT << ": OUT";
+}
+
+/*!
+ InfoWidget::onUninitialize()
+*/
+void InfoWidget::onUninitialize()
+{
+ DPRINT;
+ m_initialized = false;
+ m_engine->suspend();
+}
+
+/*!
+ InfoWidget::onShow()
+*/
+void InfoWidget::onShow()
+{
+ DPRINT;
+ m_engine->resume();
+}
+
+/*!
+ InfoWidget::onHide()
+*/
+void InfoWidget::onHide()
+{
+ DPRINT;
+ m_engine->suspend();
+}
+
+/*!
+ InfoWidget::installTranslator() const
+*/
+bool InfoWidget::installTranslator(QString translationFile)
+{
+ DPRINT << ": IN";
+
+ QString lang = QLocale::system().name();
+ QString path = "z:/resource/qt/translations/";
+ bool translatorLoaded(false);
+
+ QTranslator* widgetTranslator = new QTranslator;
+ translatorLoaded = widgetTranslator->load(
+ path + translationFile + "_" + lang);
+ if (translatorLoaded) {
+ qApp->installTranslator(widgetTranslator);
+ m_translators.append(widgetTranslator);
+ DPRINT << ": translator installed: " << translationFile;
+ } else {
+ delete widgetTranslator;
+ widgetTranslator = NULL;
+ }
+
+ DPRINT << ": OUT";
+ return translatorLoaded;
+}
+
+/*!
+ InfoWidget::removeTranslators() const
+*/
+void InfoWidget::removeTranslators()
+{
+ DPRINT << ": IN";
+
+ foreach (QTranslator *translator, m_translators) {
+ qApp->removeTranslator(translator);
+ }
+ qDeleteAll(m_translators);
+ m_translators.clear();
+
+ DPRINT << ": OUT";
+}
+
+/*!
InfoWidget::boundingRect() const
*/
QRectF InfoWidget::boundingRect() const
-{
- DPRINT;
-
- QRectF rectF = rect();
- rectF.adjust(-INFOWIDGET_MARGIN, -INFOWIDGET_MARGIN,
- INFOWIDGET_MARGIN, INFOWIDGET_MARGIN);
-
- return rectF;
+{
+ return rect();
}
/*!
InfoWidget::shape() const
- Return shape
+
+ Return Operator widget's shape
+ according to currect display
*/
QPainterPath InfoWidget::shape() const
{
DPRINT;
QPainterPath path;
- path.addRoundRect(boundingRect(), INFOWIDGET_ROUNDING, INFOWIDGET_ROUNDING);
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::InfoDisplay) {
+ path.addRoundRect(boundingRect(),
+ INFOWIDGET_ROUNDING,
+ INFOWIDGET_ROUNDING);
+ } else {
+ path.addRect(boundingRect());
+ }
return path;
}
@@ -159,24 +297,32 @@
Q_UNUSED(which);
Q_UNUSED(constraint);
- QSizeF requiredSize(70,160);
+ QSizeF requiredSize(
+ INFOWIDGET_DEFAULT_WIDTH,
+ INFOWIDGET_DEFAULT_HEIGHT);
- // Try to get size hint from docml content, if not found use default
- // size preference
- if (m_layoutManager->currentDisplayRole() ==
- InfoWidgetLayoutManager::InfoDisplay) {
- if (m_layoutManager->contentWidget()) {
- requiredSize = m_layoutManager->contentWidget()->minimumSize();
+ if (m_initialized) {
+ // Read size hint from docml content
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::InfoDisplay) {
+ if (m_layoutManager->contentWidget()) {
+ requiredSize = m_layoutManager->contentWidget()->minimumSize();
+ // Height according number of rows, if 0 or 1 row use minimum size
+ int rowCount = m_preferences->visibleItemCount();
+ if (1 < rowCount) {
+ requiredSize.rheight() += (rowCount-1)*
+ m_layoutManager->rowHeight();
+ }
}
- }
- else if (m_layoutManager->currentDisplayRole() ==
- InfoWidgetLayoutManager::SettingsDisplay) {
- requiredSize = QSizeF(250,250);
- if (m_layoutManager->contentWidget()) {
- requiredSize = m_layoutManager->contentWidget()->preferredSize();
- }
+ }
+ else if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::SettingsDisplay) {
+ if (m_layoutManager->contentWidget()) {
+ requiredSize= m_layoutManager->contentWidget()->size();
+ }
+ }
}
-
+
DPRINT << ": returning size: " << requiredSize;
return requiredSize;
}
@@ -187,49 +333,9 @@
QSizePolicy InfoWidget::sizePolicy () const
{
DPRINT;
-
- // Size tells the exact size for the widget
- return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-}
-
-/*!
- InfoWidget::onInitialize()
-*/
-void InfoWidget::onInitialize()
-{
- DPRINT << ": IN";
-
- // Initialize preferences from meta-object data
- // set by homescreen framework. Homescreen framework
- // has restored the properties before calling onInitialize
- DPRINT << ": reading preferences from meta-object properties";
- initializePreferences();
-
- DPRINT << ": OUT";
-}
-
-/*!
- InfoWidget::onUninitialize()
-*/
-void InfoWidget::onUninitialize()
-{
- DPRINT;
-}
-
-/*!
- InfoWidget::onShow()
-*/
-void InfoWidget::onShow()
-{
- DPRINT;
-}
-
-/*!
- InfoWidget::onHide()
-*/
-void InfoWidget::onHide()
-{
- DPRINT;
+ return QSizePolicy(
+ QSizePolicy::Fixed,
+ QSizePolicy::Fixed);
}
/*!
@@ -242,37 +348,28 @@
QList<QGraphicsWidget *> widgetsToHide;
// Update layout according to item visibility settings
- // 1. read visible items
- if (m_preferences->preference(InfoWidgetPreferences::DisplayHomeZone).compare(
+ if (m_preferences->preference(InfoWidgetPreferences::DisplaySpn).compare(
DISPLAY_SETTING_ON) == 0) {
layoutRows++;
} else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) {
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleHomeZoneLabel);
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleHomeZoneIcon);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnLabel);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnIcon);
}
-
+
if (m_preferences->preference(InfoWidgetPreferences::DisplayMcn).compare(
DISPLAY_SETTING_ON) == 0) {
layoutRows++;
} else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) {
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleMcnMarqueeItem);
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleMcnIcon);
- }
-
- if (m_preferences->preference(InfoWidgetPreferences::DisplayActiveLine).compare(
- DISPLAY_SETTING_ON) == 0) {
- layoutRows++;
- } else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) {
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleActiveLineLabel);
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleActiveLineIcon);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnMarqueeItem);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnIcon);
}
if (m_preferences->preference(InfoWidgetPreferences::DisplaySatText).compare(
DISPLAY_SETTING_ON) == 0) {
layoutRows++;
} else if (m_layoutManager->currentDisplayRole() != InfoWidgetLayoutManager::SettingsDisplay) {
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleSatTextLabel);
- m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleSatTextIcon);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatMarqueeItem);
+ m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatTextIcon);
}
DPRINT << ": visible layout rows count: " << layoutRows;
@@ -307,14 +404,15 @@
// Add content widget to main layout
m_layout->addItem(contentWidget);
-
- resize(contentWidget->preferredSize());
}
}
m_layoutManager->showAll();
updateItemsVisibility();
+ m_layout->invalidate();
+ m_layout->activate();
+
endChanges();
DPRINT << ": OUT";
@@ -348,8 +446,6 @@
// Add content widget to main layout
m_layout->addItem(contentWidget);
-
- resize(contentWidget->preferredSize());
}
// Connect settings display widget signals
@@ -357,7 +453,6 @@
}
m_layoutManager->showAll();
-
endChanges();
DPRINT << ": OUT";
@@ -384,52 +479,39 @@
HbPushButton *okButton = qobject_cast<HbPushButton *>(m_layoutManager->getWidget(
InfoWidgetLayoutManager::RoleOkButton));
if (okButton) {
- DPRINT << ": okButton has been returned from layout manager, connecting signal";
QObject::connect(okButton, SIGNAL(clicked()),
- this, SLOT(settingsEditingFinished()));
+ this, SLOT(settingsEditingFinished()), Qt::UniqueConnection);
}
// Connect display setting check boxes
- HbCheckBox *homeZoneBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleHomeZoneCheckBox));
- if (homeZoneBox) {
- DPRINT << ": homeZoneBox has been returned from layout manager, initializing";
- // Make checkable when home zone display is supported
- homeZoneBox->setCheckable(false);
- QObject::connect(homeZoneBox, SIGNAL(stateChanged(int)),
- this, SLOT(homeZoneDisplaySettingChanged(int)));
+ HbCheckBox *spnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleSpnCheckBox));
+ if (spnCheckBox) {
+ spnCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplaySpn));
+
+ QObject::connect(spnCheckBox, SIGNAL(stateChanged(int)),
+ this, SLOT(spnDisplaySettingChanged(int)), Qt::UniqueConnection);
}
HbCheckBox *mcnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
InfoWidgetLayoutManager::RoleMcnCheckBox));
if (mcnCheckBox) {
- mcnCheckBox->setChecked(true);
+ mcnCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplayMcn));
- DPRINT << ": mcnCheckBox has been returned from layout manager, connecting signal";
QObject::connect(mcnCheckBox, SIGNAL(stateChanged(int)),
- this, SLOT(mcnDisplaySettingChanged(int)));
- }
-
- HbCheckBox *activeLineCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleActiveLineCheckBox));
- if (activeLineCheckBox) {
- // Make checkable when active line display is supported
- activeLineCheckBox->setCheckable(false);
-
- DPRINT << ": activeLineCheckBox has been returned from layout manager, connecting signal";
- QObject::connect(activeLineCheckBox, SIGNAL(stateChanged(int)),
- this, SLOT(activeLineDisplaySettingChanged(int)));
+ this, SLOT(mcnDisplaySettingChanged(int)), Qt::UniqueConnection);
}
HbCheckBox *satTextCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
InfoWidgetLayoutManager::RoleSatTextCheckBox));
if (satTextCheckBox) {
- // Make checkable when sat text display is supported
- satTextCheckBox->setCheckable(false);
-
- DPRINT << ": satTextCheckBox has been returned from layout manager, connecting signal";
+ satTextCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplaySatText));
+
QObject::connect(satTextCheckBox, SIGNAL(stateChanged(int)),
- this, SLOT(satDisplaySettingChanged(int)));
+ this, SLOT(satDisplaySettingChanged(int)), Qt::UniqueConnection);
}
DPRINT << ": OUT";
@@ -440,30 +522,32 @@
*/
void InfoWidget::updateInfoDisplay()
{
- DPRINT;
+ DPRINT << ": IN";
+
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::InfoDisplay )
+ {
+ QString text;
+ InfoWidgetEngine::ModelData modelData = m_engine->modelData();
- QString text;
- InfoWidgetEngine::ModelData modelData = m_engine->modelData();
-
- HbLabel *homeZoneLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleHomeZoneLabel));
- if (homeZoneLabel &&
- m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) {
- text = modelData.homeZoneTextTag();
- homeZoneLabel->setPlainText(text);
- }
-
- HbMarqueeItem *mcnMarqueeItem = qobject_cast<HbMarqueeItem *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleMcnMarqueeItem));
- if (mcnMarqueeItem &&
- m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) {
- text = modelData.mcnName();
- if (text.length()) {
+ HbLabel *spnLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleSpnLabel));
+ if (spnLabel) {
+ if (m_engine->modelData().serviceProviderNameDisplayRequired()) {
+ text = modelData.serviceProviderName();
+ spnLabel->setPlainText(text);
+ }
+ }
+
+ HbMarqueeItem *mcnMarqueeItem = qobject_cast<HbMarqueeItem *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleMcnMarqueeItem));
+ if (mcnMarqueeItem) {
+ text = modelData.mcnName();
mcnMarqueeItem->setText(text);
-
+
// Set marquee animation looping mode to infinite
mcnMarqueeItem->setLoopCount(-1);
-
+
// Finally, start marquee animation
DPRINT << ": mcnMarqueeItem->isAnimating()";
if (!mcnMarqueeItem->isAnimating()) {
@@ -471,32 +555,25 @@
mcnMarqueeItem->startAnimation();
}
}
- }
-
- HbLabel *activeLineLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleActiveLineLabel));
- if (activeLineLabel &&
- m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) {
- text.setNum(modelData.activeLine());
- text.insert(0, hbTrId("Line: "));
+
+ HbMarqueeItem *satMarqueeItem = qobject_cast<HbMarqueeItem *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleSatMarqueeItem));
+ if (satMarqueeItem) {
+ text = modelData.satDisplayText();
- if (text.length()) {
- activeLineLabel->setPlainText(text);
+ satMarqueeItem->setText(text);
+
+ // Set marquee animation looping mode to infinite
+ satMarqueeItem->setLoopCount(-1);
+
+ // Finally, start marquee animation
+ DPRINT << ": satMarqueeItem->isAnimating()";
+ if (!satMarqueeItem->isAnimating()) {
+ DPRINT << ": mcnMarqueeItem->startAnimation()";
+ satMarqueeItem->startAnimation();
+ }
}
- }
-
- HbLabel *satTextLabel = qobject_cast<HbLabel *>(m_layoutManager->getWidget(
- InfoWidgetLayoutManager::RoleSatTextLabel));
- if (satTextLabel &&
- m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) {
-
- text = modelData.satDisplayText();
-
- if (text.length()) {
- satTextLabel->setPlainText(text);
- }
- }
-
+ }
}
/*!
@@ -508,7 +585,8 @@
{
DPRINT << ": IN";
- if (m_layoutManager->currentDisplayRole() == InfoWidgetLayoutManager::InfoDisplay) {
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::InfoDisplay) {
updateInfoDisplay();
}
DPRINT << ": OUT";
@@ -529,26 +607,31 @@
/*!
InfoWidget::paint()
*/
-void InfoWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+void InfoWidget::paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
DPRINT;
if (!m_layoutChanging) {
- QBrush brush(Qt::white);
- if (m_backGroundColor.isValid()) {
- brush.setColor(m_backGroundColor);
+ painter->save();
+
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::InfoDisplay) {
+ if (m_frameDrawer) {
+ m_frameDrawer->paint(painter,boundingRect());
+ }
+ } else {
+ QBrush brush(Qt::black);
+ QPainterPath path;
+ path.addRoundRect(boundingRect(),
+ INFOWIDGET_ROUNDING,
+ INFOWIDGET_ROUNDING);
+ painter->fillPath(path, brush);
}
- QRectF drawRect = boundingRect();
- drawRect.adjust( INFOWIDGET_LINE_WIDTH, INFOWIDGET_LINE_WIDTH,
- -INFOWIDGET_LINE_WIDTH, -INFOWIDGET_LINE_WIDTH );
- QPainterPath path;
- path.addRoundRect(drawRect, INFOWIDGET_ROUNDING, INFOWIDGET_ROUNDING);
-
- painter->save();
- painter->fillPath(path, brush);
painter->restore();
}
}
@@ -556,16 +639,12 @@
/*!
InfoWidget::mousePressEvent()
*/
-
void InfoWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
- DPRINT;
- // Initialize flag
- m_isDragEvent = false;
-
- DPRINT;
+ // Clear flag
+ m_dragEvent = false;
}
/*!
@@ -577,14 +656,15 @@
// If in info display and widget wasn't dragged
// change to settings display
- if ((!m_isDragEvent) &&
+ if ((!m_dragEvent) &&
m_layoutManager->currentDisplayRole() ==
InfoWidgetLayoutManager::InfoDisplay) {
DPRINT << ": layout settings display";
layoutSettingsDisplay();
}
- m_isDragEvent = false;
+ // Clear flag
+ m_dragEvent = false;
}
/*!
@@ -594,20 +674,21 @@
{
Q_UNUSED(event);
- // Mouse is moving after mouse press event
- m_isDragEvent = true;
+ // Mouse is moving
+ // after mouse press event
+ m_dragEvent = true;
}
/*!
- InfoWidget::homeZoneDisplaySettingChanged()
+ InfoWidget::spnDisplaySettingChanged()
*/
-void InfoWidget::homeZoneDisplaySettingChanged(int state)
+void InfoWidget::spnDisplaySettingChanged(int state)
{
DPRINT << ": state: " << state;
if (state == Qt::Checked){
- m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, DISPLAY_SETTING_ON);
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn, DISPLAY_SETTING_ON);
} else {
- m_preferences->setPreference(InfoWidgetPreferences::DisplayHomeZone, DISPLAY_SETTING_OFF);
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn, DISPLAY_SETTING_OFF);
}
}
@@ -625,19 +706,6 @@
}
/*!
- InfoWidget::activeLineDisplaySettingChanged()
-*/
-void InfoWidget::activeLineDisplaySettingChanged(int state)
-{
- DPRINT << ": state: " << state;
- if (state == Qt::Checked){
- m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, DISPLAY_SETTING_ON);
- } else {
- m_preferences->setPreference(InfoWidgetPreferences::DisplayActiveLine, DISPLAY_SETTING_OFF);
- }
-}
-
-/*!
InfoWidget::satDisplaySettingChanged()
*/
void InfoWidget::satDisplaySettingChanged(int state)
@@ -739,14 +807,38 @@
}
/*!
- InfoWidget::initializePreferences()
+ InfoWidget::spnDisplay()
+
+ Getter function for Meta-object property "spnDisplay"
+*/
+QString InfoWidget::spnDisplay()
+{
+ DPRINT;
+ return m_preferences->preference(InfoWidgetPreferences::DisplaySpn);
+}
+
+/*!
+ InfoWidget::setSpnDisplay()
- Read initial Meta-object properties and store to preference handler.
+ Setter function for Meta-object property "spnDisplay"
+*/
+void InfoWidget::setSpnDisplay(QString value)
+{
+ DPRINT;
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn, value);
+}
+
+/*!
+ InfoWidget::readPersistentPreferences()
+
+ Read Meta-object properties and store to preference handler.
Restores preferences from previous session.
*/
-void InfoWidget::initializePreferences()
+bool InfoWidget::readPersistentPreferences()
{
DPRINT << ": IN";
+ bool changed(false);
+
QString propertyValue;
propertyValue = QObject::property("homeZoneDisplay").toString();
@@ -765,12 +857,46 @@
m_preferences->setPreference(InfoWidgetPreferences::DisplaySatText,
propertyValue);
- // Check that at least one item is set visible. If not
- // set default item(s) visible. TBD which items and how selected.
- if (m_preferences->visibleItemCount() == 0) {
- DPRINT << ": no visible items initially, setting MCN on by default";
- m_preferences->setPreference(InfoWidgetPreferences::DisplayMcn,
- DISPLAY_SETTING_ON);
+ propertyValue = QObject::property("spnDisplay").toString();
+ m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn,
+ propertyValue);
+
+ // Check that at least one item is set visible and
+ // store preferences if true
+ if (m_preferences->validate()) {
+ changed = m_preferences->storePreferences();
+ }
+
+ DPRINT << ": OUT";
+ return changed;
+}
+
+/*!
+ InfoWidget::initializeCheckBoxStates()
+*/
+void InfoWidget::initializeCheckBoxStates()
+{
+ DPRINT << ": IN";
+
+ HbCheckBox *spnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleSpnCheckBox));
+ if (spnCheckBox) {
+ spnCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplaySpn));
+ }
+
+ HbCheckBox *mcnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleMcnCheckBox));
+ if (mcnCheckBox) {
+ mcnCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplayMcn));
+ }
+
+ HbCheckBox *satTextCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget(
+ InfoWidgetLayoutManager::RoleSatTextCheckBox));
+ if (satTextCheckBox) {
+ satTextCheckBox->setChecked(m_preferences->isPreferenceSet(
+ InfoWidgetPreferences::DisplaySatText));
}
DPRINT << ": OUT";
@@ -783,9 +909,33 @@
{
DPRINT << ": IN";
- layoutInfoDisplay();
-
- updateInfoDisplay();
+ // Save settings data if validation succeeds
+ if (m_preferences->validate()) {
+ DPRINT << ": switching to info display";
+
+ // Store preferences if changed
+ if (m_preferences->storePreferences()) {
+ // Signal Homescreen FW
+ emit setPreferences(
+ m_preferences->preferenceNames());
+ }
+
+ // ToDo: do only if settings have really changed
+ m_layoutManager->reloadWidgets(
+ InfoWidgetLayoutManager::InfoDisplay);
+
+ // Switch to info display
+ layoutInfoDisplay();
+ updateInfoDisplay();
+
+ } else {
+ DPRINT << ": staying in settings display";
+ // Display warning note
+ settingsValidationFailed();
+
+ // Restore check box states
+ initializeCheckBoxStates();
+ }
DPRINT << ": OUT";
}
@@ -795,11 +945,8 @@
*/
void InfoWidget::startChanges()
{
- DPRINT << ": IN";
-
- m_layoutChanging = true;
-
- DPRINT << ": OUT";
+ DPRINT;
+ m_layoutChanging = true;
}
/*!
@@ -807,11 +954,8 @@
*/
void InfoWidget::endChanges()
{
- DPRINT << ": IN";
-
- m_layoutChanging = false;
-
- DPRINT << ": OUT";
+ DPRINT;
+ m_layoutChanging = false;
}
/*!
@@ -822,12 +966,34 @@
DPRINT << ": IN";
if (event->type() == HbEvent::ThemeChanged) {
- m_backGroundColor = HbColorScheme::color("popupbackground");
+ DPRINT << ": HbEvent::ThemeChanged";
+ m_backGroundColor = HbColorScheme::color(
+ BACKGROUND_COLOR_GROUP_ID);
+ if (!m_backGroundColor.isValid()) {
+ m_backGroundColor = Qt::black;
+ }
}
- HbWidget::changeEvent( event );
+ HbWidget::changeEvent(event);
DPRINT << ": OUT";
}
+/*!
+ InfoWidget::settingsValidationFailed()
+*/
+void InfoWidget::settingsValidationFailed()
+{
+ DPRINT << ": IN";
+
+ if (m_layoutManager->currentDisplayRole() ==
+ InfoWidgetLayoutManager::SettingsDisplay) {
+ HbMessageBox::warning(
+ hbTrId("txt_operatorwidget_info_select_one"));
+ }
+
+ DPRINT << ": OUT";
+}
+
+
// End of File.