# HG changeset patch
# User hgs
# Date 1285726198 -28800
# Node ID 593f946f4fec9abdb54e5da0e3b5c2644790eb86
# Parent a5692c68d7722745e91ff44798070a4126f42b72
201037_2
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/aboutplugin.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/aboutplugin.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: controlpanel - about
+#
+
+HEADERS += src/cpaboutview.h \
+ src/cpaboutplugin.h \
+ src/cpaboututils.h \
+ src/cpaboutthirdpartyview.h \
+ src/cpaboutopensourceview.h
+
+
+
+SOURCES += src/cpaboutview.cpp \
+ src/cpaboutplugin.cpp \
+ src/cpaboututils.cpp \
+ src/cpaboutthirdpartyview.cpp \
+ src/cpaboutopensourceview.cpp
+
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/aboutplugin.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/aboutplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = lib
+TARGET = cpaboutplugin
+
+LIBS += -lcpframework
+
+symbian {
+ LIBS += -lsysversioninfo \
+ -lsysutil \
+ -lxqutils
+}
+
+TRANSLATIONS = control_panel.ts
+CONFIG += hb plugin
+
+include (aboutplugin.pri)
+include (rom/aboutplugin_rom.pri)
+
+CONFIG += debug_and_release
+MOC_DIR = moc
+OBJECT_DIR = obj
+RCC_DIR = rcc
+# On win32 and mac, debug and release libraries are named differently.
+# We must follow the debug and release settings Qt was compiled with:
+# build debug iff Qt built debug, build release iff Qt built release.
+
+win32|mac {
+ !contains(QT_CONFIG,debug)|!contains(QT_CONFIG,release) {
+ CONFIG -= debug_and_release debug release
+ contains(QT_CONFIG,debug): CONFIG+=debug
+ contains(QT_CONFIG,release):CONFIG+=release
+ }
+}
+
+CONFIG(debug, debug|release) {
+ SUBDIRPART = debug
+} else {
+ SUBDIRPART = release
+}
+
+win32 {
+ DESTDIR = C:/ControlPanel/$$SUBDIRPART/bin
+ OBJECTS_DIR = $$PWD/$$SUBDIRPART/tmp/$$TARGET
+ # add platfrom API for windows
+ INCLUDEPATH += $$PWD/../../../controlpanel_plat/inc
+}
+
+# Add the output dirs to the link path too
+LIBS += -L$$DESTDIR
+symbian {
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += $$MOC_DIR
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.UID3 = 0X2002873B
+}
+
+symbian: plugin { # copy qtstub and manifest
+
+ PLUGIN_STUB_PATH = /resource/qt/plugins/controlpanel
+
+ deploy.path = C:
+ pluginstub.sources = $${TARGET}.dll
+ pluginstub.path = $$PLUGIN_STUB_PATH
+ DEPLOYMENT += pluginstub
+
+ qtplugins.path = $$PLUGIN_STUB_PATH
+ qtplugins.sources += qmakepluginstubs/$${TARGET}.qtplugin
+
+ for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)"
+}
+symbian:MMP_RULES += SMPSAFE
+# End of file --Don't remove this.
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/layers.sysdef.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/layers.sysdef.xml Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,14 @@
+
+
+]>
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/rom/aboutplugin.iby
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/rom/aboutplugin.iby Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __ABOUTPLUGIN_IBY__
+#define __ABOUTPLUGIN_IBY__
+
+#include
+#include
+
+file=ABI_DIR\BUILD_DIR\cpaboutplugin.dll SHARED_LIB_DIR\cpaboutplugin.dll
+
+data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpaboutplugin.qtplugin resource\qt\plugins\controlpanel\cpaboutplugin.qtplugin
+
+#endif
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/rom/aboutplugin_rom.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/rom/aboutplugin_rom.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+symbian {
+ BLD_INF_RULES.prj_exports += \
+ "$${LITERAL_HASH}include" \
+ "rom/aboutplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(aboutplugin.iby)"
+}
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpabout_global.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpabout_global.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef CPABOUT_GLOBAL_H
+#define CPABOUT_GLOBAL_H
+
+#ifndef ABOUT_TEST
+ #define ABOUT_TEST_FRIEND_CLASS(aClassName)
+#else
+ #define ABOUT_TEST_FRIEND_CLASS(aClassName) friend class aClassName;
+#endif //ABOUT_TEST
+
+#endif // CPABOUT_GLOBAL_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutopensourceview.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutopensourceview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include "cpaboutopensourceview.h"
+#include "cpaboututils.h"
+#include
+#include
+#include
+/*!
+ \class CpAboutOpenSourceView
+*/
+
+/*!
+ Constructor
+*/
+CpAboutOpenSourceView::CpAboutOpenSourceView(QGraphicsItem *parent)
+: HbView(parent)
+{
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+ layout->setContentsMargins(0, 0, 0, 0);
+ //view title
+ HbGroupBox *label = new HbGroupBox();
+ label->setHeading(hbTrId("txt_cp_subhead_open_source_software_notices"));
+ layout->addItem(label);
+ for (int i=1; i <=2; ++i) {
+ HbTextEdit *edit = CpAboutUtils::createTextEdit();
+ QString str(CpAboutUtils::contentString(hbTrId("txt_cp_open_source_software_notices_"), i));
+ edit->setHtml(CpAboutUtils::preprocessText(str));
+ layout->addItem(edit);
+ }
+ HbScrollArea* scrollArea = new HbScrollArea();
+ QGraphicsWidget* content = new QGraphicsWidget();
+ content->setLayout(layout);
+ scrollArea->setContentWidget(content);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ setWidget(scrollArea);
+}
+
+/*!
+ Destructor
+*/
+CpAboutOpenSourceView::~CpAboutOpenSourceView()
+{
+}
+
+
+
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutopensourceview.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutopensourceview.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef CPABOUTOPENSOURCEVIEW_H
+#define CPABOUTOPENSOURCEVIEW_H
+
+#include "cpabout_global.h"
+#include
+
+class CpAboutOpenSourceView : public HbView
+{
+ Q_OBJECT
+public:
+ explicit CpAboutOpenSourceView(QGraphicsItem *parent = 0);
+ virtual ~CpAboutOpenSourceView();
+
+private:
+ ABOUT_TEST_FRIEND_CLASS(TestAboutPlugin)
+};
+#endif //CPABOUTOPENSOURCEVIEW_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutplugin.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include "cpaboutplugin.h"
+#include "cpaboutview.h"
+#include
+
+/*!
+ \class CpAboutPlugin
+*/
+
+/*!
+ Constructor
+*/
+CpAboutPlugin::CpAboutPlugin()
+{
+}
+
+/*!
+ Destructor
+*/
+CpAboutPlugin::~CpAboutPlugin()
+{
+}
+
+/*!
+ Creates setting form item data
+*/
+QList CpAboutPlugin::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
+{
+ const QString aboutIconName = "qtg_large_info";
+ return QList()
+ << new CpSettingFormEntryItemDataImpl(
+ itemDataHelper,
+ hbTrId("txt_cp_list_about"),
+ QString(), // shows two liner in list
+ HbIcon(aboutIconName));
+}
+
+Q_EXPORT_PLUGIN2(cpaboutplugin, CpAboutPlugin);
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutplugin.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutplugin.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef CPABOUTPLUGIN_H
+#define CPABOUTPLUGIN_H
+
+#include
+#include
+
+#include "cpabout_global.h"
+
+class CpAboutPlugin : public QObject, public CpPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(CpPluginInterface)
+
+public:
+ CpAboutPlugin();
+ virtual ~CpAboutPlugin();
+ virtual QList createSettingFormItemData(CpItemDataHelper &itemDataHelper) const;
+
+ ABOUT_TEST_FRIEND_CLASS(TestAboutPlugin)
+};
+
+#endif //CPABOUTPLUGIN_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutthirdpartyview.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutthirdpartyview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include "cpaboutthirdpartyview.h"
+#include "cpaboututils.h"
+#include
+#include
+#include
+#include
+#include
+/*!
+ \class CpAboutThirdPartyView
+*/
+
+/*!
+ Constructor
+*/
+CpAboutThirdPartyView::CpAboutThirdPartyView(QGraphicsItem *parent)
+: HbView(parent)
+{
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ //view titile
+ HbGroupBox *label = new HbGroupBox();
+ label->setHeading(hbTrId("txt_cp_subhead_3rd_party_notices"));
+ layout->addItem(label);
+ //the first text edit contains the icon.
+ HbTextEdit *firstEdit = new HbTextEdit();//CpAboutUtils::createTextEdit();
+ QImage image("c:\\data\\qgn_graf_mup2_visualizer_image.svg");
+ QTextCursor cursor(firstEdit->textCursor());
+ cursor.insertImage(image);
+ QString str = CpAboutUtils::contentString("txt_cp_3rd_party_notices_",1 );
+ str.insert(0, doubleHtmlLineBreak);
+ cursor.insertHtml(str);
+ firstEdit->setTextCursor(cursor);
+ layout->addItem(firstEdit);
+ //2-14 logic string's text edit.
+ for (int i = 2; i<=14; i++ ) {
+ QString content(CpAboutUtils::findAndReplaceWithLink(\
+ CpAboutUtils::contentString("txt_cp_3rd_party_notices_", i)));
+ HbTextEdit *edit = CpAboutUtils::createTextEdit();
+ edit->setHtml(content);
+ connect(edit, SIGNAL(anchorTapped(QString)), this, SLOT(handleLinkClicked(QString)));
+ layout->addItem(edit);
+ }
+
+ HbScrollArea* scrollArea = new HbScrollArea();
+ QGraphicsWidget* contentWidget = new QGraphicsWidget();
+ contentWidget->setLayout(layout);
+ scrollArea->setContentWidget(contentWidget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ setWidget(scrollArea);
+}
+
+/*!
+ Destructor
+*/
+CpAboutThirdPartyView::~CpAboutThirdPartyView()
+{
+}
+
+/*!
+ Responds to link clicked signal.
+*/
+void CpAboutThirdPartyView::handleLinkClicked(const QString &anchor)
+{
+ if (!anchor.isEmpty() &&
+ !QDesktopServices::openUrl(QUrl(anchor))) {
+ return;
+ }
+}
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutthirdpartyview.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutthirdpartyview.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef CPABOUTTHIRDPARTYVIEW_H
+#define CPABOUTTHIRDPARTYVIEW_H
+
+#include "cpabout_global.h"
+#include
+
+class CpAboutThirdPartyView : public HbView
+{
+ Q_OBJECT
+
+public:
+ explicit CpAboutThirdPartyView(QGraphicsItem *parent = 0);
+ virtual ~CpAboutThirdPartyView();
+
+private slots:
+ void handleLinkClicked(const QString &anchor);
+
+private:
+
+ ABOUT_TEST_FRIEND_CLASS(TestAboutPlugin)
+};
+#endif //CPABOUTTHIRDPARTYVIEW_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboututils.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboututils.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "CpAboutUtils.h"
+#include
+#include
+
+#include
+#include
+
+/*!
+ Create the readonly text edit.
+*/
+HbTextEdit *CpAboutUtils::createTextEdit()
+{
+ HbTextEdit *edit = new HbTextEdit();
+ edit->setReadOnly(true);
+ edit->setCursorVisibility(Hb::TextCursorHidden);
+ edit->clearContextMenuFlag(Hb::ShowTextContextMenuOnSelectionClicked);
+ edit->clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
+ return edit;
+}
+
+/*!
+ Return the localized string by logic string connecting \a prefixString and
+ \a index
+*/
+QString CpAboutUtils::contentString(const QString &prefixString, int index)
+{
+ QString contentString;
+ QString localization(prefixString);
+ localization.append(QString::number(index));
+ contentString.append(QString(hbTrId(localization.toAscii().constData())));
+ contentString.replace(lineBreak, htmlLineBreak);
+ return contentString;
+}
+
+/*!
+ Returns html link for \a textContent with content text.
+*/
+QString CpAboutUtils::linkHtmlContent(const QString &textContent)
+{
+ QString link(htmlLinkStart);
+ link.append(textContent);
+ link.append(htmlLinkEnd);
+ return link;
+}
+
+/*!
+ Trim the html address \a string, also replace \n with
+ */
+QString CpAboutUtils::preprocessText(const QString &string)
+{
+ QString str(string.trimmed());
+ str.replace(lineBreak, htmlLineBreak);
+ return str;
+}
+
+/*!
+ Replace html link in \a stringwith anchor.
+ */
+QString CpAboutUtils::findAndReplaceWithLink(const QString &string)
+{
+ //stands for the web address.
+ QRegExp regExp("[a-zA-z]+://[^\\s]*");
+
+ QString str(string);
+ if (string.indexOf(regExp) != KErrNotFound) {
+ foreach(const QString &match, regExp.capturedTexts()) {
+ QString originalString(match.trimmed());
+ if (originalString.endsWith('.')) {
+ originalString = originalString.left(originalString.length()-1);
+ }
+ QString replaceString(""+ originalString + "");
+ str.replace(originalString, replaceString);
+ }
+ }
+ return str;
+}
+
+/*!
+ Returns the phone's model.
+*/
+QString CpAboutUtils::getPhoneModel()
+{
+ TBuf<100> phoneName;
+ TInt error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EModelVersion, phoneName);
+ QString model;
+ if (error == KErrNone) {
+ if (phoneName.Length() > 0) {
+ model = XQConversions::s60DescToQString(phoneName);
+
+ }
+ }
+ return model;
+}
+
+/*!
+ Returns the produce release.
+*/
+QString CpAboutUtils::getProductRelease()
+{
+
+ TBuf productRelease;
+ productRelease.Zero();
+ QString release;
+ if (SysUtil::GetPRInformation(productRelease) == KErrNone) {
+ release = XQConversions::s60DescToQString(productRelease);
+ }
+ return release;
+}
+
+/*!
+ Returns the software version.
+*/
+QString CpAboutUtils::getSoftwareVersion()
+{
+ TBuf swVersion;
+ TBuf version;
+ swVersion.Zero();
+ version.Zero();
+ QString versionText;
+ if (SysUtil::GetSWVersion(version) == KErrNone) {
+ TInt len = version.Length();
+ TInt pos1 = version.Find(KEol);
+ if (pos1 != KErrNotFound && len > pos1) {
+ TBuf version1;
+ version1.Zero();
+ swVersion.Append(version.Left(pos1));
+ versionText = XQConversions::s60DescToQString(swVersion);
+ }
+ }
+ return versionText;
+}
+
+/*!
+ Returns the phone type.
+*/
+QString CpAboutUtils::getPhoneType()
+{
+ TBuf swVersion;
+ TBuf swVersionDate;
+ TBuf typeDesignator;
+ TBuf version;
+ swVersion.Zero();
+ version.Zero();
+ typeDesignator.Zero();
+ swVersionDate.Zero();
+ QString type;
+ if (SysUtil::GetSWVersion(version) == KErrNone) {
+ TInt len = version.Length();
+ TInt pos1 = version.Find(KEol);
+ if (pos1 != KErrNotFound && len > pos1) {
+ TBuf version1;
+ version1.Zero();
+ swVersion.Append(version.Left(pos1));
+ version1.Append(version.Right(len - pos1 - 1));
+ len = version1.Length();
+ pos1 = version1.Find(KEol);
+ if (pos1 != KErrNotFound && len > pos1) {
+ swVersionDate.Append(version1.Left(pos1));
+ version.Zero();
+ version.Append(version1.Right(len - pos1 - 1));
+ len= version.Length();
+ pos1 = version.Find(KEol);
+ if (pos1 != KErrNotFound && len > pos1 ) {
+ typeDesignator.Append(version.Left(pos1));
+ if (typeDesignator.Length() > 0) {
+ type = XQConversions::s60DescToQString(typeDesignator);
+ }
+ }
+ }
+ }
+ }
+ return type;
+}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboututils.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboututils.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef CPABOUTUTILS_H
+#define CPABOUTUTILS_H
+
+#include
+#include
+#include
+
+//for Qt
+const QChar lineBreak = '\n';
+const QString htmlLineBreak = "
";
+const QString doubleHtmlLineBreak = "
";
+const QString htmlLinkStart("");
+const QString htmlLinkEnd("");
+const TInt sysUtilVersionTextLength = 128;
+//for Symbian
+_LIT(KEol, "\n");
+
+class CpAboutUtils
+{
+public:
+ static HbTextEdit *createTextEdit();
+ static QString contentString(const QString &prefixString, int index);
+ static QString linkHtmlContent(const QString &textContent);
+ static QString findAndReplaceWithLink(const QString &string);
+ static QString preprocessText(const QString &string);
+ static QString getPhoneModel();
+ static QString getProductRelease();
+ static QString getSoftwareVersion();
+ static QString getPhoneType();
+};
+
+#endif /* CPABOUTUTILS_H */
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutview.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "cpaboutview.h"
+#include "cpaboutthirdpartyview.h"
+#include "cpaboutopensourceview.h"
+#include "cpaboututils.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*!
+ \class CpAboutView
+*/
+
+/*!
+ Constructor
+*/
+CpAboutView::CpAboutView(QGraphicsItem *parent)
+: CpBaseSettingView(0, parent),
+ mThirdPartyView(0),
+ mThirdPartyBackAction(0),
+ mOpenSourceView(0),
+ mOpenSourceBackAction(0)
+{
+ //application title
+ setTitle(hbTrId("txt_cp_title_control_panel"));
+ //view layout
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+ layout->setContentsMargins(0, 0, 0, 0);
+ //view's title
+ HbGroupBox *label = new HbGroupBox();
+ label->setHeading(hbTrId("txt_cp_subhead_about"));
+ layout->addItem(label);
+
+ //phone model
+ QString phoneInfo(HbParameterLengthLimiter("txt_cp_subhead_device_model").arg(\
+ CpAboutUtils::getPhoneModel()));
+ phoneInfo.append(doubleHtmlLineBreak);
+ //product release
+ phoneInfo.append(hbTrId("txt_cp_subhead_product_release"));
+ phoneInfo.append(htmlLineBreak);
+ phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_product_release").arg(\
+ CpAboutUtils::getProductRelease()));
+ phoneInfo.append(doubleHtmlLineBreak);
+ //software version
+ phoneInfo.append(hbTrId("txt_cp_subhead_software_version"));
+ phoneInfo.append(htmlLineBreak);
+ phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_software_vesion").arg(\
+ CpAboutUtils::getSoftwareVersion()));
+ phoneInfo.append(doubleHtmlLineBreak);
+ //produce type
+ phoneInfo.append(hbTrId("txt_cp_subhead_type"));
+ phoneInfo.append(htmlLineBreak);
+ phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_type").arg(\
+ CpAboutUtils::getPhoneType()));
+ //first text edit for showing phone and release info
+ HbTextEdit *first = CpAboutUtils::createTextEdit();
+ first->setHtml(CpAboutUtils::preprocessText(phoneInfo));
+ layout->addItem(first);
+ //second text edit for showing nokia copy right.
+ HbTextEdit *second = CpAboutUtils::createTextEdit();
+ QString info(hbTrId("txt_cp_info_1"));
+ second->setHtml(CpAboutUtils::preprocessText(info));
+ layout->addItem(second);
+ //thirdParty content.
+ HbTextEdit *thirdParty = CpAboutUtils::createTextEdit();
+ thirdParty->setHtml(CpAboutUtils::linkHtmlContent(hbTrId("txt_cp_3rd_party_notices")));
+ layout->addItem(thirdParty);
+ connect(thirdParty, SIGNAL(anchorTapped(QString)), this, SLOT(openThirdPartyView()));
+ //Open source notices
+ HbTextEdit *openSourceEdit = CpAboutUtils::createTextEdit();
+ openSourceEdit->setHtml(CpAboutUtils::linkHtmlContent(hbTrId("txt_cp_open_source_software_notices")));
+ layout->addItem(openSourceEdit);
+ connect(openSourceEdit, SIGNAL(anchorTapped(QString)), this, SLOT(openOpenSourceView()));
+
+ HbScrollArea* scrollArea = new HbScrollArea();
+ QGraphicsWidget* widget = new QGraphicsWidget();
+ widget->setLayout(layout);
+ scrollArea->setContentWidget(widget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ setWidget(scrollArea);
+}
+
+/*!
+ Destructor
+*/
+CpAboutView::~CpAboutView()
+{
+ // delete mModel;
+ delete mThirdPartyBackAction;
+ delete mOpenSourceBackAction;
+}
+
+/*!
+ Opens the third party view
+*/
+void CpAboutView::openThirdPartyView()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ mThirdPartyView = new CpAboutThirdPartyView();
+ mainWindow->addView(mThirdPartyView);
+
+ mThirdPartyBackAction = new HbAction(Hb::BackNaviAction);
+ mThirdPartyView->setNavigationAction(mThirdPartyBackAction);
+ connect(mThirdPartyBackAction, SIGNAL(triggered()),
+ this, SLOT(handleThirdPartyViewBackAction()));
+
+ mThirdPartyView->setTitle(hbTrId("txt_cp_title_control_panel"));
+
+ mainWindow->setCurrentView(mThirdPartyView);
+}
+
+/*!
+ Opens the open source view
+*/
+void CpAboutView::openOpenSourceView()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+
+ mOpenSourceView = new CpAboutOpenSourceView();
+ mainWindow->addView(mOpenSourceView);
+
+ mOpenSourceBackAction = new HbAction(Hb::BackNaviAction);
+ mOpenSourceView->setNavigationAction(mOpenSourceBackAction);
+ connect(mOpenSourceBackAction, SIGNAL(triggered()),
+ this, SLOT(handleOpenSourceViewBackAction()));
+
+ mOpenSourceView->setTitle(hbTrId("txt_cp_title_control_panel"));
+
+ mainWindow->setCurrentView(mOpenSourceView);
+}
+
+/*!
+ Handles the back action from Third Party view
+*/
+void CpAboutView::handleThirdPartyViewBackAction()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ mainWindow->removeView(mThirdPartyView);
+ mThirdPartyView->deleteLater();
+}
+
+/*!
+ Handles the back action from Open Source view
+*/
+void CpAboutView::handleOpenSourceViewBackAction()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ mainWindow->removeView(mOpenSourceView);
+ mOpenSourceView->deleteLater();
+}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/src/cpaboutview.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/src/cpaboutview.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef CPABOUTVIEW_H
+#define CPABOUTVIEW_H
+
+#include
+#include "cpabout_global.h"
+
+class CpAboutThirdPartyView;
+class CpAboutOpenSourceView;
+
+class CpAboutView : public CpBaseSettingView
+{
+ Q_OBJECT
+
+public:
+ explicit CpAboutView(QGraphicsItem *parent = 0);
+ virtual ~CpAboutView();
+
+private slots:
+ void openThirdPartyView();
+ void openOpenSourceView();
+ void handleThirdPartyViewBackAction();
+ void handleOpenSourceViewBackAction();
+
+private:
+ CpAboutThirdPartyView *mThirdPartyView;
+ HbAction *mThirdPartyBackAction;
+ CpAboutOpenSourceView *mOpenSourceView;
+ HbAction *mOpenSourceBackAction;
+ ABOUT_TEST_FRIEND_CLASS(TestAboutPlugin)
+};
+#endif //CPABOUTVIEW_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/t_aboutplugin/inc/t_aboutplugin.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/t_aboutplugin/inc/t_aboutplugin.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main test class for Control Panel's About plugin
+*
+*/
+
+#ifndef T_CPABOUTPLUGIN_H
+#define T_CPABOUTPLUGIN_H
+
+#include
+
+class CpAboutPlugin;
+
+/**
+* TestAboutPlugin
+*/
+class TestAboutPlugin : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+ // CpAboutPlugin
+ void testCreateSettingFormItemData();
+
+ // CpAboutView
+ void testCpAboutView();
+ void testCpAboutViewOpenThirdPartyView();
+ void testCpAboutViewOpenOpenSourceView();
+
+ //CpAboutThirdPartyView
+ void testCpAboutThirdPartyView();
+
+ //CpAboutOpenSourceView
+ void testCpAboutOpenSourceView();
+
+private:
+ CpAboutPlugin *mPlugin;
+
+};
+
+#endif // T_CPABOUTPLUGIN_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/t_aboutplugin/src/t_aboutplugin.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/t_aboutplugin/src/t_aboutplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main test class for about plugin library.
+*
+*/
+
+
+#include
+#include "t_aboutplugin.h"
+#include "cpaboutplugin.h"
+#include "cpaboutview.h"
+#include "cpaboutthirdpartyview.h"
+#include "cpaboutopensourceview.h"
+#include
+
+#include
+#include
+#include
+#include
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::init()
+{
+ mPlugin = new CpAboutPlugin;
+ QVERIFY(mPlugin);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::cleanup()
+{
+ if (mPlugin) {
+ delete mPlugin;
+ mPlugin = 0;
+ QVERIFY(mPlugin == 0);
+ }
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::testCreateSettingFormItemData()
+{
+ CpItemDataHelper itemDataHelper;
+ QList itemData = mPlugin->createSettingFormItemData(itemDataHelper);
+ QVERIFY(itemData.count() == 1);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::testCpAboutView()
+{
+ CpAboutView *view = new CpAboutView();
+ QVERIFY(view);
+ delete view;
+ view = 0;
+ QVERIFY(view == 0);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::testCpAboutViewOpenThirdPartyView()
+{
+ CpAboutView *view = new CpAboutView();
+ QVERIFY(view);
+
+ HbMainWindow *mainWindow = new HbMainWindow();
+ mainWindow->addView(view);
+
+ view->openThirdPartyView();
+ const QString title = hbTrId("txt_cp_title_control_panel");
+ QVERIFY(view->mThirdPartyView->title() == title);
+ view->handleThirdPartyViewBackAction();
+
+ delete view;
+ view = 0;
+ QVERIFY(view == 0);
+ delete mainWindow;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::testCpAboutViewOpenOpenSourceView()
+{
+ CpAboutView *view = new CpAboutView();
+ QVERIFY(view);
+
+ HbMainWindow *mainWindow = new HbMainWindow();
+ mainWindow->addView(view);
+
+ view->openOpenSourceView();
+ const QString title = hbTrId("txt_cp_title_control_panel");
+ QVERIFY(view->mOpenSourceView->title() == title);
+ view->handleOpenSourceViewBackAction();
+
+ delete view;
+ view = 0;
+ QVERIFY(view == 0);
+ delete mainWindow;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+
+void TestAboutPlugin::testCpAboutThirdPartyView()
+{
+ CpAboutThirdPartyView *view = new CpAboutThirdPartyView();
+ QVERIFY(view);
+ delete view;
+ view = 0;
+ QVERIFY(view == 0);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestAboutPlugin::testCpAboutOpenSourceView()
+{
+ CpAboutOpenSourceView *view = new CpAboutOpenSourceView();
+ QVERIFY(view);
+ delete view;
+ view = 0;
+ QVERIFY(view == 0);
+}
+QTEST_MAIN(TestAboutPlugin)
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/t_aboutplugin/t_aboutplugin.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/t_aboutplugin/t_aboutplugin.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: tests for About plugin
+#
+
+HEADERS += ./inc/t_aboutplugin.h \
+ ../src/cpaboutplugin.h \
+ ../src/cpaboutview.h \
+ ../src/cpaboutthirdpartyview.h \
+ ../src/cpaboutopensourceview.h \
+ ../src/cpabout_global.h \
+ ../src/cpaboututils.h
+
+SOURCES += ./src/t_aboutplugin.cpp \
+ ../src/cpaboutplugin.cpp \
+ ../src/cpaboutview.cpp \
+ ../src/cpaboutthirdpartyview.cpp \
+ ../src/cpaboutopensourceview.cpp \
+ ../src/cpaboututils.cpp
+
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/aboutplugin/t_aboutplugin/t_aboutplugin.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/aboutplugin/t_aboutplugin/t_aboutplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: tests for About plugin
+#
+
+TEMPLATE = app
+
+CONFIG += debug_and_release
+
+QT += testlib
+
+symbian {
+ LIBS += -lsysversioninfo \
+ -lsysutil \
+ -lxqutils
+}
+
+CONFIG(debug, debug|release) {
+ DESTDIR = ./debug
+} else {
+ DESTDIR = ./release
+}
+
+symbian: LIBS += -lcpframework
+CONFIG += hb
+
+INCLUDEPATH += ./inc
+
+
+
+DEPENDPATH += ./inc \
+ ./src \
+ ../inc \
+ ../src
+
+DEFINES += ABOUT_TEST
+
+symbian {
+ TARGET.UID3 = 0x2002BCD5
+ TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+}
+symbian:MMP_RULES += SMPSAFE
+include(t_aboutplugin.pri)
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/data/cplanguagepluginlog.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/data/cplanguagepluginlog.conf Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,7 @@
+[CpLanguagePlugin]
+logdatetime = 1
+logloggername = 1
+datetimeformat = hh:mm:ss
+output = debugoutput fileoutput
+fileoutput/logfile = C:/data/logs/cplanguageplugin.log
+fileoutput/truncate = 0
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/languageplugin.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/languageplugin.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: controlpanel project - common qmake settings
+#
+
+HEADERS += src/cplanguageview.h \
+ src/cplanguageplugin.h \
+ src/cplanguagepluginutil.h \
+ src/extendedlocaleutil.h
+
+SOURCES += src/cplanguageview.cpp \
+ src/cplanguageplugin.cpp \
+ src/cplanguagepluginutil.cpp \
+ src/extendedlocaleutil.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/languageplugin.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/languageplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,99 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+TEMPLATE = lib
+TARGET = cplanguageplugin
+
+CONFIG += hb plugin
+
+include ( languageplugin.pri )
+include (rom/languageplugin_rom.pri)
+
+LIBS += -lcpframework
+LIBS += -lstarterclient
+
+TRANSLATIONS = control_panel.ts
+
+CONFIG += debug_and_release
+
+
+MOC_DIR = moc
+OBJECT_DIR = obj
+RCC_DIR = rcc
+
+# On win32 and mac, debug and release libraries are named differently.
+# We must follow the debug and release settings Qt was compiled with:
+# build debug iff Qt built debug, build release iff Qt built release.
+
+win32|mac {
+ !contains(QT_CONFIG,debug)|!contains(QT_CONFIG,release) {
+ CONFIG -= debug_and_release debug release
+ contains(QT_CONFIG,debug): CONFIG+=debug
+ contains(QT_CONFIG,release):CONFIG+=release
+ }
+}
+
+CONFIG(debug, debug|release) {
+ SUBDIRPART = debug
+} else {
+ SUBDIRPART = release
+}
+
+win32 {
+ DESTDIR = C:/ControlPanel/$$SUBDIRPART/bin
+ OBJECTS_DIR = $$PWD/$$SUBDIRPART/tmp/$$TARGET
+ # add platfrom API for windows
+ INCLUDEPATH += $$PWD/../../../controlpanel_plat/inc
+}
+
+# Add the output dirs to the link path too
+LIBS += -L$$DESTDIR
+LIBS += -lcplogger
+
+RESOURCES += languageplugin.qrc
+
+#DEFINES += ENABLE_CPLANG_LOG
+
+#For some reason the default include path doesn't include MOC_DIR on symbian
+symbian {
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += $$MW_LAYER_PLATFORM_EXPORT_PATH(cplogger)
+ INCLUDEPATH += $$MOC_DIR
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.UID3 = 0X2002873C
+
+ INCLUDEPATH += /sf/app/organizer/organizer_plat/clock_settingsview_plugin_api/inc
+}
+
+symbian: plugin { # copy qtstub and manifest
+
+ PLUGIN_STUB_PATH = /resource/qt/plugins/controlpanel
+
+ deploy.path = C:
+ pluginstub.sources = $${TARGET}.dll
+ pluginstub.path = $$PLUGIN_STUB_PATH
+ DEPLOYMENT += pluginstub
+
+ qtplugins.path = $$PLUGIN_STUB_PATH
+ qtplugins.sources += qmakepluginstubs/$${TARGET}.qtplugin
+
+ for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)"
+}
+symbian:MMP_RULES += SMPSAFE
+
+# End of file --Don't remove this.
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/languageplugin.qrc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/languageplugin.qrc Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,5 @@
+
+
+ data/cplanguagepluginlog.conf
+
+
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/layers.sysdef.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/layers.sysdef.xml Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,14 @@
+
+
+]>
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/rom/languageplugin.iby
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/rom/languageplugin.iby Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __LANGUAGEPLUGIN_IBY__
+#define __LANGUAGEPLUGIN_IBY__
+
+#include
+#include
+
+file=ABI_DIR\BUILD_DIR\cplanguageplugin.dll SHARED_LIB_DIR\cplanguageplugin.dll
+
+data=\epoc32\data\c\resource\qt\plugins\controlpanel\cplanguageplugin.qtplugin resource\qt\plugins\controlpanel\cplanguageplugin.qtplugin
+
+#endif
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/rom/languageplugin_rom.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/rom/languageplugin_rom.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+symbian {
+ BLD_INF_RULES.prj_exports += \
+ "$${LITERAL_HASH}include" \
+ "rom/languageplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(languageplugin.iby)"
+}
\ No newline at end of file
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguageplugin.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguageplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "cplanguageplugin.h"
+#include "cplanguageview.h"
+#include
+#include
+#include
+#include "cplanguagepluginlog.h"
+
+
+#ifdef ENABLE_CPLANG_LOG
+ INIT_LOGGER (CPLANG_LOGGER_NAME,CPLANG_LOGGER_CONFIG_PATH)
+#endif
+
+static QPointer g_pluginEntryItemData;
+
+/*!
+ * Constructor
+ */
+CpLanguagePlugin::CpLanguagePlugin()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::CpLanguagePlugin")
+}
+
+/*!
+ * Destructor
+ */
+CpLanguagePlugin::~CpLanguagePlugin()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::~CpLanguagePlugin")
+}
+
+/*!
+ * Overide CpPluginInterface::createSettingFormItemData
+ */
+QList CpLanguagePlugin::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::createSettingFormItemData")
+
+ g_pluginEntryItemData = new CpSettingFormEntryItemDataImpl(
+ CpSettingFormEntryItemData::ListEntryItem,
+ itemDataHelper,
+ hbTrId("txt_cp_dblist_language_and_region"),
+ QString(),
+ "qtg_large_language" );
+
+ updateEntryItem();
+
+ return QList() << g_pluginEntryItemData;
+}
+
+/*!
+ * update the description of the entry item.
+ */
+void CpLanguagePlugin::updateEntryItem()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguagePlugin::updateEntryItem")
+
+
+ if (g_pluginEntryItemData) {
+ QStringList allLanguages = HbLocaleUtil::supportedLanguages();
+ QString currentLanguage = HbLocaleUtil::currentLanguage();
+
+ CPLANG_LOG(QLatin1String("Current language:") + currentLanguage);
+
+ int index = allLanguages.indexOf(currentLanguage);
+
+ CPLANG_LOG(QString("Index of current language: %1").arg(index));
+
+ QString localisedLanguage;
+ if (index >= 0) {
+ localisedLanguage = HbLocaleUtil::localisedLanguageName(currentLanguage);
+ CPLANG_LOG(QLatin1String("Localised Region:") + localisedLanguage);
+ }
+ g_pluginEntryItemData->setDescription(localisedLanguage);
+ }
+}
+
+Q_EXPORT_PLUGIN2(cplanguageplugin, CpLanguagePlugin);
+
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguageplugin.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguageplugin.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef CPLANGUAGEPLUGIN_H
+#define CPLANGUAGEPLUGIN_H
+
+#include
+#include
+#include "cplanguageplugin_global.h"
+
+class CpLanguagePlugin : public QObject, public CpPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(CpPluginInterface)
+public:
+ CpLanguagePlugin();
+ virtual ~CpLanguagePlugin();
+ virtual QList createSettingFormItemData(CpItemDataHelper &itemDataHelper) const;
+public:
+ static void updateEntryItem();
+};
+
+#endif // CPLANGUAGEPLUGIN_H
+
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguageplugin_global.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguageplugin_global.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef CPLANGUAGEPLUGIN_GLOBAL_H
+#define CPLANGUAGEPLUGIN_GLOBAL_H
+
+#ifndef LANGUAGEPLUGIN_TEST
+ #define LANGUAGEPLUGIN_TEST_FRIEND_CLASS(aClassName)
+#else
+ #define LANGUAGEPLUGIN_TEST_FRIEND_CLASS(aClassName) friend class aClassName;
+#endif //LANGUAGEPLUGIN_TEST
+
+#endif // CPLANGUAGEPLUGIN_GLOBAL_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguagepluginlog.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguagepluginlog.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef CPLANGUAGEPLUGINLOG_H
+#define CPLANGUAGEPLUGINLOG_H
+
+#include
+#include
+
+#ifdef ENABLE_CPLANG_LOG
+ #define CPLANG_LOGGER_NAME QLatin1String("CpLanguagePlugin")
+ #define CPLANG_LOGGER_CONFIG_PATH QLatin1String(":/logconf/cplanguagepluginlog.conf")
+
+ #define CPLANG_LOG(str) Logger::instance(CPLANG_LOGGER_NAME)->log(str);
+ #define CPLANG_LOG_FUNC_ENTRY(func) LogFunctionEntryHelper ___cplang_log_func_entry_helper(CPLANG_LOGGER_NAME,func);
+#else
+ #define CPLANG_LOG(str)
+ #define CPLANG_LOG_FUNC_ENTRY(func)
+#endif
+
+#endif
+
+//End of File
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguagepluginutil.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguagepluginutil.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: utility class
+ *
+ */
+#include "cplanguagepluginutil.h"
+#include
+#include
+#include "cplanguagepluginlog.h"
+#include
+
+QStringList CpLanguagePluginUtil::localizedLanguageNames(const QStringList &languageNames)
+{
+ QStringList localizedLanguages;
+
+ CPLANG_LOG("=================All languages=======================");
+ foreach(const QString &language,languageNames) {
+ CPLANG_LOG("Language: " + language + "\tLocalised:" + HbLocaleUtil::localisedLanguageName(language));
+ localizedLanguages << HbLocaleUtil::localisedLanguageName(language);
+ }
+ CPLANG_LOG("======================================================");
+
+ return localizedLanguages;
+}
+
+QStringList CpLanguagePluginUtil::localizedRegionNames(const QStringList ®ionNames)
+{
+ QStringList localizedRegions;
+
+ CPLANG_LOG("=================All regions=======================");
+ foreach(const QString ®ion,regionNames) {
+ CPLANG_LOG("Region: " + region + "\tLocalised:" + HbLocaleUtil::localisedRegionName(region));
+ localizedRegions << HbLocaleUtil::localisedRegionName(region);
+ }
+ CPLANG_LOG("===================================================");
+ return localizedRegions;
+}
+
+QStringList CpLanguagePluginUtil::localizedInputLanguageNames(const QList &inputLanguages)
+{
+ QStringList localizedInputLanguages;
+
+ CPLANG_LOG("=================All Input languages=======================");
+ foreach (HbInputLanguage inputLanguage, inputLanguages) {
+ CPLANG_LOG("Input language:" + inputLanguage.asString() + "\tLocalised:" + inputLanguage.localisedName());
+ if (inputLanguage == HbInputLanguage()) {
+ localizedInputLanguages << hbTrId("txt_cp_setlabel_secondary_writing_language_val_non");
+ }
+ else {
+ localizedInputLanguages << inputLanguage.localisedName();
+ }
+ }
+ CPLANG_LOG("============================================================");
+
+ return localizedInputLanguages;
+}
+
+bool CpLanguagePluginUtil::isChineseVariant()
+{
+ QStringList supportedLanguages = HbLocaleUtil::supportedLanguages();
+ foreach(const QString &language, supportedLanguages) {
+ if (QLocale(language).language() == QLocale::Chinese) {
+ CPLANG_LOG("Chinese Variant.");
+ return true;
+ }
+ }
+ return false;
+}
+
+//End of File
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguagepluginutil.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguagepluginutil.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: utility class
+ *
+ */
+#ifndef CPLANGUAGEPLUGINUTIL_H
+#define CPLANGUAGEPLUGINUTIL_H
+
+#include
+#include
+#include
+
+class CpLanguagePluginUtil
+{
+public:
+ static QStringList localizedLanguageNames(const QStringList &languageNames);
+ static QStringList localizedRegionNames(const QStringList ®ionNames);
+ static QStringList localizedInputLanguageNames(const QList &inputLanguages);
+ static bool isChineseVariant();
+private:
+ CpLanguagePluginUtil();
+ Q_DISABLE_COPY(CpLanguagePluginUtil)
+};
+
+#endif
+
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguageview.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguageview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,558 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Language plugin view class
+ *
+ */
+
+#include "cplanguageview.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "cplanguageplugin.h"
+#include "cplanguagepluginlog.h"
+
+static int PRIMARY_INPUT_ITEM_INDEX = 0;
+static int SECONDARY_INPUT_ITEM_INDEX = 1;
+static int REGION_ITEM_INDEX = 2;
+
+/*
+ * Constructor
+ */
+CpLanguageView::CpLanguageView(QGraphicsItem *parent) :
+ CpBaseSettingView(0,parent),
+ mModel(0),
+ mCurrentLanguagePage(0),
+ mCurrentRegionItem(0),
+ mCurrentPrimaryInputLanguageItem(0),
+ mCurrentSecondaryInputLanguageItem(0),
+ mClockPluginLoader(0)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::CpLanguageView")
+
+ mChineseVariant = CpLanguagePluginUtil::isChineseVariant();
+ if (mChineseVariant) {
+ PRIMARY_INPUT_ITEM_INDEX = 0;
+ SECONDARY_INPUT_ITEM_INDEX = -1; // no secondary writing language in Chinese variant
+ REGION_ITEM_INDEX = 1;
+ }
+
+ HbDataForm *form = qobject_cast(widget());
+ if (form) {
+ mModel = new HbDataFormModel;
+
+ form->setHeading(hbTrId("txt_cp_subhead_display_language"));
+ form->setDescription(hbTrId("txt_cp_info_after_changign_deivce_language_device"));
+
+ mLanguageRegionMapping = ExtendedLocaleUtil::localeMappings(true);
+
+ mSupportedLanguages = HbLocaleUtil::supportedLanguages();
+ QStringList localizedLanguages = CpLanguagePluginUtil::localizedLanguageNames(mSupportedLanguages);
+
+ mSupportedRegions = HbLocaleUtil::supportedRegions();
+ QStringList localizedRegions = CpLanguagePluginUtil::localizedRegionNames(mSupportedRegions);
+
+ CPLANG_LOG ( QString("map count:%1").arg(mLanguageRegionMapping.count()) );
+ CPLANG_LOG ( QString("support language count:%1").arg(mSupportedLanguages.count()) );
+ CPLANG_LOG ( QString("support region count:%1").arg(mSupportedRegions.count()) );
+
+ HbInputUtils::listSupportedInputLanguages(mPrimaryInputLanguages);
+ QStringList localizedInputLanguages = CpLanguagePluginUtil::localizedInputLanguageNames(mPrimaryInputLanguages);
+
+ QString currentLanguage = HbLocaleUtil::currentLanguage();
+
+ //prvious setting
+ mPreviousSetting.languageId = currentLanguage;
+ mPreviousSetting.regionId = HbLocaleUtil::currentRegion();
+ mPreviousSetting.primaryWritingLan = HbInputSettingProxy::instance()->globalInputLanguage();
+ mPreviousSetting.secondaryWritingLan = HbInputSettingProxy::instance()->globalSecondaryInputLanguage();
+
+ mCurrentSetting = mPreviousSetting;
+
+ //update with current setting
+ if (LanguageRegionMapping *setting = languageRegionMapping(currentLanguage)) {
+ *setting = mCurrentSetting;
+ }
+
+ for (int index = 0; index < mLanguageRegionMapping.count();index++) {
+ const LanguageRegionMapping &setting = mLanguageRegionMapping.at(index);
+ HbDataFormModelItem *languageAndRegionPage = mModel->appendDataFormPage( HbLocaleUtil::localisedLanguageName(setting.languageId) );
+ mLanguagePages.append(languageAndRegionPage);
+
+ /*
+ * Create primary writing language item.
+ */
+ HbDataFormModelItem *primaryInputLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem,
+ hbTrId("txt_cp_setlabel_primary_writing_language"));
+
+
+ int primaryInputLanguageIndex = mPrimaryInputLanguages.indexOf(setting.primaryWritingLan);
+
+ CPLANG_LOG(QLatin1String("Primary input Language:") + setting.primaryWritingLan.asString());
+ CPLANG_LOG(QString("Index of primary input language: %1").arg(primaryInputLanguageIndex));
+
+ fillDataFormComboBoxItem(primaryInputLanguageItem,localizedInputLanguages,primaryInputLanguageIndex);
+
+ form->addConnection(primaryInputLanguageItem, SIGNAL(currentIndexChanged (int)),
+ this,SLOT(onPrimaryInputLanguageChanged(int)));
+ languageAndRegionPage->appendChild(primaryInputLanguageItem);
+
+ /*
+ * Create secondary writing language item.
+ * (No secondary writing language for Chinese variant)
+ */
+ if (!mChineseVariant) {
+ HbDataFormModelItem *secondaryInputLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem,
+ hbTrId("txt_cp_setlabel_secondary_writing_language"));
+
+ form->addConnection(secondaryInputLanguageItem, SIGNAL(currentIndexChanged (int)),
+ this,SLOT(onSecondaryInputLanguageChanged(int)));
+ languageAndRegionPage->appendChild(secondaryInputLanguageItem);
+ }
+
+ /*
+ * Create region item.
+ */
+ HbDataFormModelItem *regionItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem,
+ hbTrId("Region"));
+
+ int regionIndex = mSupportedRegions.indexOf(setting.regionId);
+
+ CPLANG_LOG(QLatin1String("Current region:") + setting.regionId);
+ CPLANG_LOG(QString("Index of current region: %1").arg(regionIndex));
+
+ fillDataFormComboBoxItem(regionItem,localizedRegions,regionIndex);
+
+ form->addConnection(regionItem, SIGNAL(currentIndexChanged (int)),
+ this,SLOT(onRegionChanged(int)));
+ languageAndRegionPage->appendChild(regionItem);
+
+ if (mSupportedLanguages.at(index) == currentLanguage) {
+ mCurrentLanguagePage = languageAndRegionPage;
+ mCurrentRegionItem = mCurrentLanguagePage->childAt(REGION_ITEM_INDEX);
+ mCurrentPrimaryInputLanguageItem = mCurrentLanguagePage->childAt(PRIMARY_INPUT_ITEM_INDEX);
+ mCurrentSecondaryInputLanguageItem = mCurrentLanguagePage->childAt(SECONDARY_INPUT_ITEM_INDEX);
+ }
+ }
+
+ // update secondary input language item according to primary input language
+ updateSecondaryInputLanguageItem();
+
+ /*
+ * Create region settings item.
+ */
+ HbDataFormModelItem *regionalSettingsItem = new HbDataFormModelItem(
+ static_cast(CpSettingFormEntryItemData::ButtonEntryItem));
+ regionalSettingsItem->setContentWidgetData("text",hbTrId("txt_cp_button_regional_settings"));
+ regionalSettingsItem->setContentWidgetData("textAlignment",
+ QVariant(Qt::AlignHCenter | Qt::AlignVCenter));
+ form->addConnection(regionalSettingsItem,SIGNAL(clicked()),
+ this,SLOT(launchRegionalSettingsView()));
+
+ mModel->appendDataFormItem(regionalSettingsItem);
+
+ form->setModel(mModel);
+ // active current language page
+ form->setExpanded(mModel->indexFromItem(mCurrentLanguagePage),true);
+
+
+ /*
+ * observe input language changed event
+ */
+ connect(HbInputSettingProxy::instance(),
+ SIGNAL(globalInputLanguageChanged(HbInputLanguage)),
+ this,
+ SLOT(onPrimaryInputLanguageChanged(HbInputLanguage)));
+
+ connect(HbInputSettingProxy::instance(),
+ SIGNAL(globalSecondaryInputLanguageChanged(HbInputLanguage)),
+ this,
+ SLOT(onSecondaryInputLanguageChanged(HbInputLanguage)));
+
+ connect(form,
+ SIGNAL(activated(QModelIndex)),
+ this,
+ SLOT(onDataFormItemActivated(QModelIndex)));
+
+ }
+}
+
+/*
+ * Destructor
+ */
+CpLanguageView::~CpLanguageView()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::~CpLanguageView")
+ // Unload RegionalSettingsView plugin
+ if (mClockPluginLoader) {
+ mClockPluginLoader->unload();
+ delete mClockPluginLoader;
+ }
+ delete mModel;
+}
+
+/*!
+ * Handle region changed
+ */
+void CpLanguageView::onRegionChanged(int index)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onRegionChanged")
+
+ CPLANG_LOG(QLatin1String("Before change region:") + HbLocaleUtil::currentRegion());
+
+ if (index >= 0 && index < mSupportedRegions.count()) {
+ HbLocaleUtil::changeRegion( mSupportedRegions.at(index) );
+ mCurrentSetting.regionId = mSupportedRegions.at(index);
+ if (LanguageRegionMapping *setting = languageRegionMapping(mCurrentSetting.languageId)) {
+ setting->regionId = mCurrentSetting.regionId;
+ }
+
+ CPLANG_LOG(QLatin1String("After change region:") + HbLocaleUtil::currentRegion());
+ }
+}
+
+
+/*
+ * prompt user to restart device.
+ */
+bool CpLanguageView::promptRestart()
+{
+ HbDeviceMessageBox messageBox(
+ hbTrId("txt_cp_text_edit_device_will_be_restarted_to_chang"),
+ HbMessageBox::MessageTypeQuestion, this);
+
+ QString okText = hbTrId("txt_cp_button_restart");
+ QString cancelText = hbTrId("txt_cp_button_discard_changes");
+ messageBox.setAction(new QAction(okText,&messageBox),
+ HbDeviceMessageBox::AcceptButtonRole);
+ messageBox.setAction(new QAction(cancelText,&messageBox),
+ HbDeviceMessageBox::RejectButtonRole);
+ messageBox.setIconVisible(false);
+
+ return (messageBox.exec()
+ == messageBox.action(HbDeviceMessageBox::AcceptButtonRole) );
+}
+
+/*!
+ * Handle primary language changed.
+ */
+void CpLanguageView::onPrimaryInputLanguageChanged(int index)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onPrimaryInputLanguageChanged(int index)")
+
+ CPLANG_LOG(QLatin1String("Before change primary input language:") + HbInputSettingProxy::instance()->globalInputLanguage().asString());
+
+ if (index >= 0 && index < mPrimaryInputLanguages.count()) {
+ HbInputLanguage inputLanguage = mPrimaryInputLanguages.at(index);
+ if (inputLanguage != HbInputSettingProxy::instance()->globalInputLanguage()) {
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(inputLanguage);
+ mCurrentSetting.primaryWritingLan = inputLanguage;
+ if (LanguageRegionMapping *setting = languageRegionMapping(mCurrentSetting.languageId)) {
+ setting->primaryWritingLan = mCurrentSetting.primaryWritingLan;
+ }
+
+ updateSecondaryInputLanguageItem();
+ CPLANG_LOG(QLatin1String("After change primary input language:") + HbInputSettingProxy::instance()->globalInputLanguage().asString());
+ }
+ }
+}
+
+/*!
+ * Handle secondary language changed.
+ */
+void CpLanguageView::onSecondaryInputLanguageChanged(int index)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onSecondaryInputLanguageChanged(int index)")
+
+ CPLANG_LOG(QLatin1String("Before change secondary input language:") + HbInputSettingProxy::instance()->globalSecondaryInputLanguage().asString());
+
+ if (index >= 0 && index < mSecondaryInputLanguages.count()) {
+ HbInputLanguage inputLanguage = mSecondaryInputLanguages.at(index);
+ if (inputLanguage != HbInputSettingProxy::instance()->globalSecondaryInputLanguage() ) {
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(inputLanguage);
+ mCurrentSetting.secondaryWritingLan = inputLanguage;
+ if (LanguageRegionMapping *setting = languageRegionMapping(mCurrentSetting.languageId)) {
+ setting->secondaryWritingLan = mCurrentSetting.secondaryWritingLan;
+ }
+
+ CPLANG_LOG(QLatin1String("After change secondary input language:") + HbInputSettingProxy::instance()->globalSecondaryInputLanguage().asString());
+ }
+ }
+}
+
+/*!
+ * Observe primary input language changed event and update the ui, if it is being changed from outside of this plugin
+ */
+void CpLanguageView::onPrimaryInputLanguageChanged(const HbInputLanguage &inputLanguage)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onPrimaryInputLanguageChanged(const HbInputLanguage &inputLanguage)")
+ if (mCurrentPrimaryInputLanguageItem) {
+ int index = mPrimaryInputLanguages.indexOf(inputLanguage);
+ if (index != mCurrentPrimaryInputLanguageItem->contentWidgetData("currentIndex").toInt() ) {
+ CPLANG_LOG( QString("New Index: %1").arg(index) )
+
+ mCurrentSetting.primaryWritingLan = inputLanguage;
+ mCurrentPrimaryInputLanguageItem->setContentWidgetData("currentIndex",index);
+ updateSecondaryInputLanguageItem();
+ }
+ }
+}
+
+/*!
+ * Observe secondary input language changed event and update the ui, if it is being changed from outside of this plugin
+ */
+void CpLanguageView::onSecondaryInputLanguageChanged(const HbInputLanguage &inputLanguage)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onSecondaryInputLanguageChanged(const HbInputLanguage &inputLanguage)")
+
+ if (mCurrentSecondaryInputLanguageItem) {
+ int index = mSecondaryInputLanguages.indexOf(inputLanguage);
+ if (index != mCurrentSecondaryInputLanguageItem->contentWidgetData("currentIndex").toInt()) {
+ CPLANG_LOG( QString("New Index: %1").arg(index) )
+ mCurrentSetting.secondaryWritingLan = inputLanguage;
+ mCurrentSecondaryInputLanguageItem->setContentWidgetData("currentIndex",index);
+ }
+ }
+}
+
+
+/*!
+ * Fill contents in the data form model items.
+ * \param comboBoxItem a data form model item whose type is HbDataFormModelItem::ComboBoxItem
+ * \param items items showing in the combobox
+ * \param currentIndex index of the selected item
+ */
+void CpLanguageView::fillDataFormComboBoxItem(HbDataFormModelItem *comboBoxItem,
+ const QStringList &items,
+ int currentIndex /*= -1*/)
+{
+ Q_ASSERT(comboBoxItem);
+ Q_ASSERT(comboBoxItem->type() == HbDataFormModelItem::ComboBoxItem);
+
+ comboBoxItem->setContentWidgetData("items", items);
+ comboBoxItem->setContentWidgetData("currentIndex",currentIndex);
+}
+
+/*!
+ * Update secondary input language item according to primary input language
+ */
+void CpLanguageView::updateSecondaryInputLanguageItem()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::updateSecondaryInputLanguageItem")
+
+ // no secondary writing language in Chinese variant.
+ if (mChineseVariant) {
+ return;
+ }
+
+ HbInputLanguage primaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
+
+ mSecondaryInputLanguages.clear();
+ // append a "none set" item
+ mSecondaryInputLanguages.append(HbInputLanguage());
+
+ // Chinese input doesn't have secondary input language
+ if (primaryInputLanguage.language() == QLocale::Chinese) {
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(HbInputLanguage());
+ CPLANG_LOG("Primary input language: Chinese");
+ }
+ else {
+ foreach(const HbInputLanguage &inputLanguage,mPrimaryInputLanguages) {
+ if ( inputLanguage != primaryInputLanguage // Secondary input language can't be set the same as primary input language
+ && inputLanguage.language() != QLocale::Chinese) { // Chinese input can't be set as secondary input language
+ mSecondaryInputLanguages.append(inputLanguage);
+ }
+ }
+ }
+
+ QStringList localisedNames = CpLanguagePluginUtil::localizedInputLanguageNames(mSecondaryInputLanguages);
+
+ // if the secondary input language is the same as primary input language, set it as "none set"
+ HbInputLanguage secondaryInputLanguage = HbInputSettingProxy::instance()->globalSecondaryInputLanguage();
+
+ if (secondaryInputLanguage == primaryInputLanguage) {
+ secondaryInputLanguage = HbInputLanguage();
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(HbInputLanguage());
+
+ CPLANG_LOG("secondary == primary, set secondary input as \"None\"");
+ }
+
+ mCurrentSetting.secondaryWritingLan = secondaryInputLanguage;
+ if (LanguageRegionMapping *setting = languageRegionMapping(mCurrentSetting.languageId)) {
+ setting->secondaryWritingLan = mCurrentSetting.secondaryWritingLan;
+ }
+
+ fillDataFormComboBoxItem(mCurrentSecondaryInputLanguageItem,localisedNames,mSecondaryInputLanguages.indexOf(secondaryInputLanguage));
+}
+
+/*!
+ * Restart the device.
+ */
+int CpLanguageView::restartDevice()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::restartDevice")
+#ifdef Q_OS_SYMBIAN
+ RStarterSession session;
+ TInt error = session.Connect();
+
+ if (error == KErrNone) {
+ session.Reset( RStarterSession::ELanguageSwitchReset );
+ session.Close();
+ }
+
+ return error;
+#else
+ return 0;
+#endif
+}
+
+/*!
+ Launch the regional settings view.
+ */
+void CpLanguageView::launchRegionalSettingsView()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::launchRegionalSettingsView")
+
+ //Load the clock settings view plugin if it is not loaded
+ if (!mClockPluginLoader) {
+ QDir dir(CLOCK_SETTINGSVIEW_PLUGIN_PATH);
+ QString pluginName = dir.absoluteFilePath(CLOCK_SETTINGSVIEW_PLUGIN_NAME);
+ mClockPluginLoader = new QPluginLoader(pluginName);
+ mClockPluginLoader->load();
+ }
+
+ //Launch the settings view
+ ClockSettingsViewInterface *clockSettingsViewInterface
+ = qobject_cast(mClockPluginLoader->instance());
+ if (clockSettingsViewInterface) {
+ clockSettingsViewInterface->launchRegionalSettingsView();
+ }
+ else {
+ CPLANG_LOG("Load clocksettingsviewplugin failed.");
+ }
+}
+
+/*!
+ * handle data form page changed event
+ */
+void CpLanguageView::onDataFormItemActivated(const QModelIndex &modelIndex)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::onDataFormItemActivated")
+
+ mCurrentLanguagePage = mModel->itemFromIndex(modelIndex);
+
+ mCurrentRegionItem = mCurrentLanguagePage->childAt(REGION_ITEM_INDEX);
+ mCurrentPrimaryInputLanguageItem = mCurrentLanguagePage->childAt(PRIMARY_INPUT_ITEM_INDEX);
+ mCurrentSecondaryInputLanguageItem = mCurrentLanguagePage->childAt(SECONDARY_INPUT_ITEM_INDEX);
+
+ int index = mLanguagePages.indexOf(mCurrentLanguagePage);
+
+ if (index >= 0) {
+ QString newLanguage = mSupportedLanguages.at(index);
+ LanguageRegionMapping *setting = languageRegionMapping(newLanguage);
+ if (setting) {
+ setting->secondaryWritingLan = HbInputSettingProxy::instance()->globalSecondaryInputLanguage();
+ mCurrentSetting = *setting;
+
+ HbLocaleUtil::changeRegion(mCurrentSetting.regionId);
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(mCurrentSetting.primaryWritingLan);
+
+ //update combobox
+ mCurrentPrimaryInputLanguageItem->setContentWidgetData("currentIndex",mPrimaryInputLanguages.indexOf(mCurrentSetting.primaryWritingLan));
+ mCurrentRegionItem->setContentWidgetData("currentIndex",mSupportedRegions.indexOf(mCurrentSetting.regionId));
+
+ CPLANG_LOG(QString("Primary writing:") + HbInputSettingProxy::instance()->globalInputLanguage().asString());
+ CPLANG_LOG(QString("Secondary writing:") + HbInputSettingProxy::instance()->globalSecondaryInputLanguage().asString());
+
+ updateSecondaryInputLanguageItem();
+ }
+ }
+
+}
+
+/*!
+ * From CpBaseSettingView, prompt user to restart device before exiting the view
+ */
+void CpLanguageView::close()
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::close()")
+
+ CPLANG_LOG( QString("mCurrentSetting.languageId :") + mCurrentSetting.languageId )
+ CPLANG_LOG( QString("HbLocaleUtil::currentLanguage():") + HbLocaleUtil::currentLanguage() )
+
+ if (mCurrentSetting.languageId != HbLocaleUtil::currentLanguage()) {
+ // apply new settings
+ if (promptRestart()) {
+ HbLocaleUtil::changeLocale(mCurrentSetting.languageId);
+
+ /*
+ * change other settings.
+ */
+ if (mSupportedRegions.contains(mCurrentSetting.regionId,Qt::CaseInsensitive)) {
+ HbLocaleUtil::changeRegion(mCurrentSetting.regionId);
+ }
+ CpLanguagePlugin::updateEntryItem();
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(mCurrentSetting.primaryWritingLan);
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(mCurrentSetting.secondaryWritingLan);
+
+ restartDevice();
+ }
+ // restore previous values
+ else {
+ if (mCurrentSetting.regionId != mPreviousSetting.regionId) {
+ HbLocaleUtil::changeRegion(mPreviousSetting.regionId);
+ }
+ if (mCurrentSetting.primaryWritingLan != mPreviousSetting.primaryWritingLan) {
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(mPreviousSetting.primaryWritingLan);
+ }
+ if (mCurrentSetting.secondaryWritingLan != mPreviousSetting.secondaryWritingLan) {
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(mPreviousSetting.secondaryWritingLan);
+ }
+ }
+ }
+
+ CpBaseSettingView::close();
+}
+
+/*!
+ * get the language-region mapping table
+ */
+LanguageRegionMapping *CpLanguageView::languageRegionMapping(const QString &language)
+{
+ CPLANG_LOG_FUNC_ENTRY("CpLanguageView::languageRegionMapping(const QString &language)")
+
+ foreach(const LanguageRegionMapping &setting,mLanguageRegionMapping) {
+ if (setting.languageId.compare(language,Qt::CaseInsensitive) == 0) {
+ return const_cast(&setting);
+ }
+ }
+
+ CPLANG_LOG("Not found.")
+
+ return 0;
+}
+
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/cplanguageview.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/cplanguageview.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Language plugin view class
+ *
+ */
+#ifndef CPLANGUAGEVIEW_H
+#define CPLANGUAGEVIEW_H
+
+#include
+#include
+#include
+#include
+#include "cplanguagepluginutil.h"
+#include "extendedlocaleutil.h"
+#include "cplanguageplugin_global.h"
+
+class QStringList;
+class QPluginLoader;
+class HbDataFormModel;
+class HbDataFormModelItem;
+class HbInputLanguage;
+class QModelIndex;
+
+class CpLanguageView : public CpBaseSettingView
+{
+ Q_OBJECT
+public:
+ explicit CpLanguageView(QGraphicsItem *parent = 0);
+ virtual ~CpLanguageView();
+
+private slots:
+ //handle combobox index changes
+ void onRegionChanged(int index);
+ void onPrimaryInputLanguageChanged(int index);
+ void onSecondaryInputLanguageChanged(int index);
+
+ //observe input language changed event
+ void onPrimaryInputLanguageChanged(const HbInputLanguage &inputLanguage);
+ void onSecondaryInputLanguageChanged(const HbInputLanguage &inputLanguage);
+
+ //launch regional setting view
+ void launchRegionalSettingsView();
+
+ //handle data form page changed event
+ void onDataFormItemActivated(const QModelIndex &modelIndex);
+protected:
+ //From CpBaseSettingView
+ virtual void close();
+private:
+ void fillDataFormComboBoxItem(HbDataFormModelItem *comboBoxItem,
+ const QStringList &items, int currentIndex = -1);
+ void updateSecondaryInputLanguageItem();
+ bool promptRestart();
+ int restartDevice();
+ LanguageRegionMapping *languageRegionMapping(const QString &language);
+private:
+ QList mLanguageRegionMapping;
+
+ LanguageRegionMapping mPreviousSetting;
+ LanguageRegionMapping mCurrentSetting;
+
+ HbDataFormModel *mModel;
+
+ QList mLanguagePages;
+ HbDataFormModelItem *mCurrentLanguagePage;
+
+ //Current items
+ HbDataFormModelItem *mCurrentRegionItem;
+ HbDataFormModelItem *mCurrentPrimaryInputLanguageItem;
+ HbDataFormModelItem *mCurrentSecondaryInputLanguageItem;
+
+ QList mPrimaryInputLanguages;
+ QList mSecondaryInputLanguages;
+ QStringList mSupportedLanguages;
+ QStringList mSupportedRegions;
+
+ QPluginLoader *mClockPluginLoader;
+
+ bool mChineseVariant;
+
+ LANGUAGEPLUGIN_TEST_FRIEND_CLASS(TestLanguagePlugin)
+};
+#endif //CPLANGUAGEVIEW_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/extendedlocaleutil.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/extendedlocaleutil.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+#include "extendedlocaleutil.h"
+
+#if defined(Q_OS_SYMBIAN)
+#include
+#include
+#include
+
+#define LANGUAGE_LIST_FILE "/resource/hbi18n/translations/language_list.txt"
+#define LANGUAGE_MAPPINGS_FILE "/resource/hbi18n/translations/locale_mappings.txt"
+#endif // Q_OS_SYMBIAN
+
+#include "cplanguagepluginlog.h"
+
+/*!
+ @beta
+ @hbcore
+ \class ExtendedLocaleUtil
+ \brief ExtendedLocaleUtil provides mappings needed for Control Panel plugin which are not available through HbLocaleUtil class.
+*/
+
+
+/*!
+ \brief Return list of language, region, collation and writing language mappings.
+
+ \attention Symbian specific API
+
+ \return a list containing mapped locale properties
+*/
+
+//#define __TESTCODE__
+
+QList ExtendedLocaleUtil::localeMappings(bool onlySupported)
+{
+ CPLANG_LOG_FUNC_ENTRY("ExtendedLocaleUtil::localeMappings")
+
+ QList mps = allLocaleMappings();
+
+ if (!onlySupported) {
+ return mps;
+ }
+
+ QList supportedmps;
+
+ QStringList supportedLanguages = HbLocaleUtil::supportedLanguages();
+ QStringList supportedRegions = HbLocaleUtil::supportedRegions();
+
+ foreach (const QString &language,supportedLanguages) {
+ LanguageRegionMapping *found = 0;
+ for (int i = 0; i < mps.count();i++) {
+ if (mps.at(i).languageId == language) {
+ found = const_cast(&mps.at(i));
+ break;
+ }
+ }
+ if (found) {
+ supportedmps.append(*found);
+ }
+ else {
+ LanguageRegionMapping map;
+ map.languageId = language;
+ map.primaryWritingLan = HbInputLanguage(QLocale(language).language());
+ }
+
+ }
+
+ return supportedmps;
+}
+
+QList ExtendedLocaleUtil::allLocaleMappings()
+{
+ CPLANG_LOG_FUNC_ENTRY("ExtendedLocaleUtil::allLocaleMappings")
+
+ QList mps;
+
+#if defined(Q_OS_SYMBIAN)
+
+ QString path = "c:";
+ path += QString(LANGUAGE_MAPPINGS_FILE);
+ QFile* file = new QFile(path);
+ if (!file->exists() ) {
+ path = "z:";
+ path += QString(LANGUAGE_MAPPINGS_FILE);
+ delete file;
+ file = new QFile(path);
+ }
+ if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
+ delete file;
+ return mps;
+ }
+
+ QTextStream in(file);
+ while (!in.atEnd()) {
+ QString line = in.readLine(256);
+ if (!line.isEmpty()) {
+ QStringList list = line.split(',', QString::SkipEmptyParts);
+ if (list.count() < 7) {
+ continue;
+ }
+
+ QString strCode = list[0];
+ QString lanName = list[4];
+ QString region = list[5];
+ QString collation = list[6];
+
+ bool ok;
+ int code = strCode.toUInt(&ok);
+ if (!ok) {
+ continue;
+ }
+
+ QString lanPart = (lanName.indexOf('_')>0) ? lanName.left(lanName.indexOf('_')) : lanName;
+ QString regPart = (region.indexOf('_')>0) ? region.left(region.indexOf('_')) : region;
+ QLocale loc = QLocale(QString(lanPart+'_'+regPart));
+ HbInputLanguage primaryWriting = HbInputLanguage(loc.language(), loc.country());
+ HbInputLanguage secondaryWriting = HbInputLanguage(QLocale::English, QLocale::UnitedKingdom);
+
+ LanguageRegionMapping map;
+ map.languageId = lanName;
+ map.regionId = region;
+ map.collationId = collation;
+ map.primaryWritingLan = primaryWriting;
+ map.secondaryWritingLan = secondaryWriting;
+ mps.append(map);
+
+ }
+ }
+ delete file;
+
+#endif // Q_OS_SYMBIAN
+
+
+ return mps;
+}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/src/extendedlocaleutil.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/src/extendedlocaleutil.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Language plugin view class
+ *
+ */
+
+/*
+ * extendedlocaleutil.h
+ *
+ * Created on: 24.8.2010
+ * Author: mhujanen
+ */
+
+#ifndef EXTENDEDLOCALEUTIL_H_
+#define EXTENDEDLOCALEUTIL_H_
+
+#include
+#include
+
+/*
+ * Temporary class.
+ * will be replaced by function added in HbLocaleUtil in future.
+ *
+ * */
+
+struct LanguageRegionMapping
+ {
+ QString languageId;
+ QString regionId;
+ QString collationId;
+ HbInputLanguage primaryWritingLan;
+ HbInputLanguage secondaryWritingLan;
+ };
+
+class ExtendedLocaleUtil : public HbLocaleUtil
+ {
+ public:
+ static QList localeMappings(bool onlySupported);
+ private:
+ static QList allLocaleMappings();
+ };
+
+#endif /* EXTENDEDLOCALEUTIL_H_ */
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/t_languageplugin/inc/t_languageplugin.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/t_languageplugin/inc/t_languageplugin.h Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main test class for Control Panel's Language plugin
+*
+*/
+
+#ifndef TESTLANGUAGEPLUGIN_H
+#define TESTLANGUAGEPLUGIN_H
+
+#include
+#include
+
+class CpLanguagePlugin;
+class CpLanguageView;
+class CpSettingFormEntryItemData;
+class HbMainWindow;
+
+/**
+* TestLanguagePlugin
+*/
+class TestLanguagePlugin : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+ // Test cases start from here
+ // CpLanguagePlugin
+ void test_CpLanguagePlugin_createSettingFormItemData();
+ void test_CpLanguagePlugin_updateEntryItem();
+
+ void test_ExtendedLocaleUtil_localeMappings();
+
+ void test_CpLanguagePluginUtil_localizedLanguageNames();
+ void test_CpLanguagePluginUtil_localizedRegionNames();
+ void test_CpLanguagePluginUtil_localizedInputLanguageNames();
+ void test_CpLanguagePluginUtil_isChineseVariant();
+
+ void test_CpLanguageView_new();
+ void test_CpLanguageView_onRegionChanged();
+ void test_CpLanguageView_onPrimaryInputLanguageChanged();
+ void test_CpLanguageView_onSecondaryInputLanguageChanged();
+ void test_CpLanguageView_onPrimaryInputLanguageChanged2();
+ void test_CpLanguageView_onSecondaryInputLanguageChanged2();
+ void test_CpLanguageView_launchRegionalSettingsView();
+ void test_CpLanguageView_onDataFormItemActivated();
+ void test_CpLanguageView_close();
+ void test_CpLanguageView_fillDataFormComboBoxItem();
+ void test_CpLanguageView_updateSecondaryInputLanguageItem();
+ void test_CpLanguageView_promptRestart();
+ void test_CpLanguageView_restartDevice();
+ void test_CpLanguageView_languageRegionMapping();
+
+private:
+ HbMainWindow *mMainWindow;
+ CpLanguagePlugin* mPlugin;
+ CpLanguageView* mView;
+ CpSettingFormEntryItemData *mEntryItemData;
+
+};
+
+#endif // T_CPLANGUAGEPLUGIN_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/t_languageplugin/src/t_languageplugin.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/t_languageplugin/src/t_languageplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,389 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main test class for Control Panel's Language plugin.
+*
+*/
+
+#include "t_languageplugin.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "cplanguageplugin.h"
+#include "extendedlocaleutil.h"
+#include "cplanguageview.h"
+#include "cplanguagepluginutil.h"
+
+/*!
+ Initialize test case.
+ Called before each testfunction is executed.
+*/
+void TestLanguagePlugin::init()
+{
+ mMainWindow = new HbMainWindow();
+ QVERIFY(mMainWindow);
+
+ mPlugin = new CpLanguagePlugin;
+ QVERIFY(mPlugin);
+ // Note: we get different values for condition coverage of CpLanguageView()
+ // depending on which values have been selected in Control Panel settings.
+ mView = new CpLanguageView();
+ QVERIFY(mView);
+
+ CpItemDataHelper itemDataHelper;
+ QList itemData = mPlugin->createSettingFormItemData(itemDataHelper);
+ mEntryItemData = qobject_cast(itemData.front());
+}
+
+/*!
+ Cleanup test case.
+ Called after every testfunction.
+*/
+void TestLanguagePlugin::cleanup()
+{
+ delete mView;
+ mView = 0;
+
+ delete mPlugin;
+ mPlugin = 0;
+
+ delete mEntryItemData;
+ mEntryItemData = 0;
+
+ delete mMainWindow;
+ mMainWindow = 0;
+}
+
+/* ---------------------------------------------------------------------------
+ * Unit test cases
+ * ---------------------------------------------------------------------------*/
+
+/*!
+ * test CpLanguagePlugin::createSettingFormItemData
+ */
+void TestLanguagePlugin::test_CpLanguagePlugin_createSettingFormItemData()
+{
+ CpItemDataHelper itemDataHelper;
+ QList itemData = mPlugin->createSettingFormItemData(itemDataHelper);
+ QVERIFY(itemData.count() == 1);
+
+ CpSettingFormEntryItemData *entryItemData = qobject_cast(itemData.front());
+ QVERIFY(entryItemData != 0);
+ QVERIFY(entryItemData->type() == static_cast(CpSettingFormEntryItemData::ListEntryItem) );
+}
+
+/*!
+ * test CpLanguagePlugin::updateEntryItem
+ */
+void TestLanguagePlugin::test_CpLanguagePlugin_updateEntryItem()
+{
+ CpLanguagePlugin::updateEntryItem();
+
+ QString localisedLanguage = HbLocaleUtil::localisedLanguageName(HbLocaleUtil::currentLanguage());
+
+ QVERIFY(mEntryItemData->description() == localisedLanguage);
+}
+
+/*!
+ * test ExtendedLocaleUtil::localeMappings
+ */
+void TestLanguagePlugin::test_ExtendedLocaleUtil_localeMappings()
+{
+ QList allMaps = ExtendedLocaleUtil::localeMappings(false);
+ QVERIFY(allMaps.count() > 0);
+
+ QList supportedMaps = ExtendedLocaleUtil::localeMappings(true);
+ QVERIFY(supportedMaps.count() > 0);
+
+ QVERIFY(allMaps.count() >= supportedMaps.count());
+}
+
+/*!
+ * test CpLanguagePluginUtil::localizedLanguageNames
+ */
+void TestLanguagePlugin::test_CpLanguagePluginUtil_localizedLanguageNames()
+{
+ QStringList supportLanguages = HbLocaleUtil::supportedLanguages();
+ QStringList localisedLanguages = CpLanguagePluginUtil::localizedLanguageNames(supportLanguages);
+
+ QVERIFY (supportLanguages.count() == localisedLanguages.count());
+}
+
+/*!
+ * test CpLanguagePluginUtil::localizedRegionNames
+ */
+void TestLanguagePlugin::test_CpLanguagePluginUtil_localizedRegionNames()
+{
+ QStringList supportedRegions = HbLocaleUtil::supportedRegions();
+ QStringList localisedRegions = CpLanguagePluginUtil::localizedRegionNames(supportedRegions);
+
+ QVERIFY (supportedRegions.count() == localisedRegions.count());
+}
+
+/*
+ * test CpLanguagePluginUtil::localizedInputLanguageNames
+ */
+void TestLanguagePlugin::test_CpLanguagePluginUtil_localizedInputLanguageNames()
+{
+ QList supportedInputLanguages;
+ HbInputUtils::listSupportedInputLanguages(supportedInputLanguages);
+
+ QStringList localisedInputLanguages = CpLanguagePluginUtil::localizedInputLanguageNames(supportedInputLanguages);
+ QVERIFY(supportedInputLanguages.count() == localisedInputLanguages.count());
+}
+
+/*!
+ * test CpLanguagePluginUtil::isChineseVariant
+ */
+void TestLanguagePlugin::test_CpLanguagePluginUtil_isChineseVariant()
+{
+ bool isChineseVariant = CpLanguagePluginUtil::isChineseVariant();
+
+ QStringList supportedLanguages = HbLocaleUtil::supportedLanguages();
+ foreach(const QString &language, supportedLanguages) {
+ if (QLocale(language).language() == QLocale::Chinese) {
+ QVERIFY (isChineseVariant);
+ return;
+ }
+ }
+
+ QVERIFY (!isChineseVariant);
+}
+
+/*!
+ * test new CpLanguageView
+ */
+void TestLanguagePlugin::test_CpLanguageView_new()
+{
+ CpLanguageView* view = new CpLanguageView();
+ QVERIFY(view != 0);
+ delete view;
+}
+
+/*!
+ * test CpLanguageView::onRegionChanged(int index)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onRegionChanged()
+{
+ QString oldRegion = HbLocaleUtil::currentRegion();
+
+ QStringList allRegions = mView->mSupportedRegions;
+ QVERIFY(allRegions.count() > 0);
+
+ for(int i = 0; i < allRegions.count();i++) {
+ if (!allRegions.at(i).trimmed().isEmpty()) {
+ mView->onRegionChanged(i);
+ QVERIFY(HbLocaleUtil::currentRegion() == allRegions.at(i));
+ }
+ }
+
+ HbLocaleUtil::changeRegion(oldRegion);
+ QVERIFY(HbLocaleUtil::currentRegion() == oldRegion);
+
+ mView->onRegionChanged(-1);
+ QVERIFY(HbLocaleUtil::currentRegion() == oldRegion);
+
+ mView->onRegionChanged(allRegions.count());
+ QVERIFY(HbLocaleUtil::currentRegion() == oldRegion);
+}
+
+/*!
+ * test CpLanguageView::onPrimaryInputLanguageChanged(int index)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onPrimaryInputLanguageChanged()
+{
+ HbInputLanguage oldPrimaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
+
+ QList supportedInputLanguages = mView->mPrimaryInputLanguages;
+
+ QVERIFY(supportedInputLanguages.count() > 0);
+ for (int i = 0; i < supportedInputLanguages.count();i++) {
+ mView->onPrimaryInputLanguageChanged(i);
+ QVERIFY(HbInputSettingProxy::instance()->globalInputLanguage() == supportedInputLanguages.at(i));
+ }
+
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(oldPrimaryInputLanguage);
+ QVERIFY(HbInputSettingProxy::instance()->globalInputLanguage() == oldPrimaryInputLanguage);
+
+ mView->onPrimaryInputLanguageChanged(-1);
+ QVERIFY(HbInputSettingProxy::instance()->globalInputLanguage() == oldPrimaryInputLanguage);
+
+ mView->onPrimaryInputLanguageChanged(supportedInputLanguages.count());
+ QVERIFY(HbInputSettingProxy::instance()->globalInputLanguage() == oldPrimaryInputLanguage);
+}
+
+/*!
+ * test CpLanguageView::onSecondaryInputLanguageChanged(int index)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onSecondaryInputLanguageChanged()
+{
+ HbInputLanguage primaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
+ HbInputLanguage oldSecondaryInputLanguage = HbInputSettingProxy::instance()->globalSecondaryInputLanguage();
+
+ QList supportedInputLanguages = mView->mSecondaryInputLanguages;
+
+ QVERIFY(supportedInputLanguages.count() > 0);
+ for (int i = 0; i < supportedInputLanguages.count();i++) {
+ if ( supportedInputLanguages.at(i) != primaryInputLanguage) {
+ mView->onSecondaryInputLanguageChanged(i);
+ QVERIFY(HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == supportedInputLanguages.at(i));
+ }
+ }
+
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(oldSecondaryInputLanguage);
+ QVERIFY(HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == oldSecondaryInputLanguage);
+
+ mView->onSecondaryInputLanguageChanged(-1);
+ QVERIFY(HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == oldSecondaryInputLanguage);
+
+ mView->onSecondaryInputLanguageChanged(supportedInputLanguages.count());
+ QVERIFY(HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == oldSecondaryInputLanguage);
+}
+
+/*!
+ * test CpLanguageView::onPrimaryInputLanguageChanged(const HbInputLanguage &inputLanguage)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onPrimaryInputLanguageChanged2()
+{
+ int oldIndex = mView->mCurrentPrimaryInputLanguageItem->contentWidgetData("currentIndex").toInt();
+
+ QList supportedInputLanguages = mView->mPrimaryInputLanguages;
+
+ QVERIFY(supportedInputLanguages.count() > 0);
+ for (int i = 0; i < supportedInputLanguages.count();i++) {
+ mView->onPrimaryInputLanguageChanged(supportedInputLanguages.at(i));
+ QVERIFY( mView->mCurrentPrimaryInputLanguageItem->contentWidgetData("currentIndex").toInt() == i );
+ }
+
+ mView->mCurrentPrimaryInputLanguageItem->setContentWidgetData("currentIndex",oldIndex);
+
+ QVERIFY(oldIndex == mView->mCurrentPrimaryInputLanguageItem->contentWidgetData("currentIndex").toInt());
+}
+
+/*!
+ * test CpLanguageView::onSecondaryInputLanguageChanged(const HbInputLanguage &inputLanguage)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onSecondaryInputLanguageChanged2()
+{
+ int oldIndex = mView->mCurrentSecondaryInputLanguageItem->contentWidgetData("currentIndex").toInt();
+
+ QList supportedInputLanguages = mView->mSecondaryInputLanguages;
+
+ QVERIFY(supportedInputLanguages.count() > 0);
+ for (int i = 0; i < supportedInputLanguages.count();i++) {
+ mView->onSecondaryInputLanguageChanged(supportedInputLanguages.at(i));
+ QVERIFY( mView->mCurrentSecondaryInputLanguageItem->contentWidgetData("currentIndex").toInt() == i );
+ }
+
+ mView->mCurrentSecondaryInputLanguageItem->setContentWidgetData("currentIndex",oldIndex);
+
+ QVERIFY(oldIndex == mView->mCurrentSecondaryInputLanguageItem->contentWidgetData("currentIndex").toInt());
+}
+
+/*!
+ * test CpLanguageView::launchRegionalSettingsView()
+ */
+void TestLanguagePlugin::test_CpLanguageView_launchRegionalSettingsView()
+{
+ mView->launchRegionalSettingsView();
+ QVERIFY(mView->mClockPluginLoader != 0);
+}
+
+/*!
+ * test CpLanguageView::onDataFormItemActivated(const QModelIndex &modelIndex)
+ */
+void TestLanguagePlugin::test_CpLanguageView_onDataFormItemActivated()
+{
+ QVERIFY(true);
+}
+
+/*!
+ * test CpLanguageView::close()
+ */
+void TestLanguagePlugin::test_CpLanguageView_close()
+{
+ QVERIFY(true);
+}
+
+/*!
+ * test CpLanguageView::fillDataFormComboBoxItem
+ */
+void TestLanguagePlugin::test_CpLanguageView_fillDataFormComboBoxItem()
+{
+ QStringList supportedRegions = HbLocaleUtil::supportedRegions();
+ QStringList localizedRegions = CpLanguagePluginUtil::localizedRegionNames(supportedRegions);
+
+ int regionIndex = supportedRegions.indexOf(HbLocaleUtil::currentRegion());
+
+ mView->fillDataFormComboBoxItem(mView->mCurrentRegionItem,localizedRegions,regionIndex);
+
+ QVERIFY(mView->mCurrentRegionItem->contentWidgetData("currentIndex").toInt() == regionIndex);
+ QVERIFY(mView->mCurrentRegionItem->contentWidgetData("items").toStringList() == localizedRegions);
+}
+
+/*!
+ * test CpLanguageView::updateSecondaryInputLanguageItem
+ */
+void TestLanguagePlugin::test_CpLanguageView_updateSecondaryInputLanguageItem()
+{
+ QList supportedInputLanguages;
+ HbInputUtils::listSupportedInputLanguages(supportedInputLanguages);
+
+ HbInputLanguage primaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
+ HbInputLanguage secondaryInputLanguage = HbInputSettingProxy::instance()->globalSecondaryInputLanguage();
+
+ QVERIFY(supportedInputLanguages.count() > 0);
+
+ HbInputSettingProxy::instance()->setGlobalInputLanguage(supportedInputLanguages.front());
+ HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(supportedInputLanguages.front());
+
+ mView->updateSecondaryInputLanguageItem();
+
+ QVERIFY(mView->mCurrentSecondaryInputLanguageItem->contentWidgetData("currentIndex").toInt() == 0);
+
+}
+
+/*!
+ * test CpLanguageView::promptRestart
+ */
+void TestLanguagePlugin::test_CpLanguageView_promptRestart()
+{
+ QVERIFY(true);
+}
+
+/*!
+ * test CpLanguageView::restartDevice
+ */
+void TestLanguagePlugin::test_CpLanguageView_restartDevice()
+{
+ QVERIFY(true);
+}
+
+/*!
+ * test CpLanguageView::languageRegionMapping
+ */
+void TestLanguagePlugin::test_CpLanguageView_languageRegionMapping()
+{
+ QStringList supportedLanguages = HbLocaleUtil::supportedLanguages();
+ foreach(const QString &language,supportedLanguages) {
+ LanguageRegionMapping *entry = mView->languageRegionMapping(language);
+ QVERIFY(entry != 0);
+ }
+}
+
+QTEST_MAIN(TestLanguagePlugin)
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/t_languageplugin/t_languageplugin.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/t_languageplugin/t_languageplugin.pri Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: tests for Language plugin
+#
+
+HEADERS += ./inc/t_languageplugin.h \
+ ../src/cplanguageview.h \
+ ../src/cplanguageplugin.h \
+ ../src/cplanguagepluginutil.h \
+ ../src/extendedlocaleutil.h
+
+SOURCES += ./src/t_languageplugin.cpp \
+ ../src/cplanguageview.cpp \
+ ../src/cplanguageplugin.cpp \
+ ../src/cplanguagepluginutil.cpp \
+ ../src/extendedlocaleutil.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/langandregplugin/t_languageplugin/t_languageplugin.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/langandregplugin/t_languageplugin/t_languageplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,60 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: tests for Language plugin
+#
+
+TEMPLATE = app
+
+CONFIG += debug_and_release
+QT += testlib
+CONFIG += hb qtestlib
+CONFIG += symbian_test
+
+CONFIG(debug, debug|release) {
+ DESTDIR = ./debug
+} else {
+ DESTDIR = ./release
+}
+
+symbian: LIBS+=-lcpframework
+LIBS += -lstarterclient
+
+CONFIG += hb
+
+INCLUDEPATH += ./inc \
+ ../inc
+
+
+DEPENDPATH += ./inc \
+ ./src \
+ ../inc \
+ ../src
+
+DEFINES += LANGUAGEPLUGIN_TEST
+
+
+symbian {
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += $$MW_LAYER_PLATFORM_EXPORT_PATH(cplogger)
+ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += $$MOC_DIR
+
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.UID3 = 0x2002BCD6
+ TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+ PLUGIN_SUBDIR = c:/private/2002BCD6
+}
+symbian:MMP_RULES += SMPSAFE
+include( t_languageplugin.pri )
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemechanger.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemechanger.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemechanger.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -39,7 +39,9 @@
QObject(p),
mCurrentTheme(0)
{
- connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(changeFinished()));
+ if(hbInstance->theme()) {
+ connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(changeFinished()));
+ }
setCurrentTheme();
}
@@ -73,8 +75,7 @@
if(mCurrentTheme && mCurrentTheme->name() == themeName) {
return;
- }
- else {
+ } else {
//buildThemeInfo creates new theme info.
CpThemeInfo* tmpTheme = CpThemeUtil::buildThemeInfo(HbThemeServices::themePath(), themeName);
@@ -92,15 +93,15 @@
/*!
Change a theme. Returns true on success, false otherwise.
*/
-bool CpThemeChanger::changeTheme(const QString& newTheme)
+bool CpThemeChanger::changeTheme(const CpThemeInfo& newTheme)
{
bool result = false;
// Skip doing this if the request is for the current theme
- if (newTheme.isEmpty() || newTheme == mCurrentTheme->name()) {
+ if (newTheme.name().isEmpty() || (mCurrentTheme && newTheme.name() == mCurrentTheme->name())) {
return result;
}
- QString themePath = CpThemeUtil::themePath(newTheme);
+ QString themePath = newTheme.itemData();
if(!themePath.isEmpty()) {
HbThemeServices::setTheme(themePath);
@@ -124,9 +125,7 @@
*/
void CpThemeChanger::changeFinished()
{
-
setCurrentTheme();
-
emit themeChangeFinished();
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemechanger.h
--- a/controlpanelplugins/themeplugin/src/cpthemechanger.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemechanger.h Wed Sep 29 10:09:58 2010 +0800
@@ -39,12 +39,12 @@
~CpThemeChanger();
const CpThemeInfo* currentTheme() const;
- bool changeTheme(const QString& newtheme);
+ bool changeTheme(const CpThemeInfo& newtheme);
signals:
void themeChangeFinished();
-public slots:
+private slots:
void changeFinished();
private:
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemecontrol.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -17,12 +17,9 @@
/*!
\class CpThemeControl
- \brief CpThemeControl creates and controls two views for Theme Changer plugin and handles
+ \brief CpThemeControl creates and controls views for Theme Changer plugin and handles
user interaction to preview and change the themes.
- It creates a list view of the themes. When a list item is selected, it creates a preview
- of the theme icon using a CpThemePreview class.
-
This class also connects to the theme server using the HbThemeChanger and sets the theme
based on user interaction with the views.
@@ -43,32 +40,19 @@
#include "cpthemecontrol.h"
#include "cpthemelistview.h"
-#include "cpthemepreview.h"
#include "cpthemeinfo.h"
#include "cpthemelistmodel.h"
#include
#include
-
-/*!
- Helper function to fetch the main window.
-*/
-
-static HbMainWindow *mainWindow()
-{
- QList< HbMainWindow* > mainWindows = hbInstance->allMainWindows();
- if (!mainWindows.isEmpty()) {
- return mainWindows.front();
- }
- return 0;
-}
+//time out time before showing a processing dialog.
+static const int KThemeChangeTimeOutMilliSeconds = 2000;
/*!
constructor.
*/
CpThemeControl::CpThemeControl(): mThemeListView(0),
- mThemePreview(0),
mThemeChanger(0),
mListModel(0),
mThemeChangeFinished(false),
@@ -88,7 +72,7 @@
/*!
- destorys the list view, preview and theme changer objects.
+ destorys the list view and theme changer objects.
*/
CpThemeControl::~CpThemeControl()
{
@@ -98,16 +82,12 @@
delete mThemeChanger;
mThemeChanger = 0;
- delete mThemePreview;
- mThemePreview = 0;
-
delete mWaitDialog;
mWaitDialog = 0;
}
/*!
- Creates the theme list view. Gets the themes, creates a model based on
- theme names, icons, and icon paths and sets the list model.
+ Creates the theme list view. Gets the themes, creates a model and sets the list model.
*/
void CpThemeControl::createThemeList()
{
@@ -120,14 +100,14 @@
// Set the model for theme list.
mThemeListView->setModel(mListModel);
- mThemeListView->themeList()->setSelectionMode(HbAbstractItemView::SingleSelection);
setActiveThemeIndex();
+ //connect to signal for selecting a list item.
+ connect(mThemeListView,SIGNAL(newThemeSelected(QModelIndex)),
+ this,SLOT(newThemeSelected(QModelIndex)));
- //connect to signal for selecting a list item.
- connect(mThemeListView,SIGNAL(newThemeSelected(const QModelIndex&)),
- this,SLOT(newThemeSelected(const QModelIndex&)));
+ connect(mThemeListView, SIGNAL(oviClicked()), this, SLOT(getOviTheme()));
//handle signal for list view closing. (e.g Back softkey pressed)
connect(mThemeListView,SIGNAL(aboutToClose()),
@@ -188,83 +168,35 @@
//theme even though another list item is selected.
setActiveThemeIndex();
- // Figure out whether this is a URI and appropriately delegate
- data = index.data(CpThemeListModel::ItemTypeRole);
- if(data.isValid() && data.canConvert()) {
-
- CpThemeInfo::ThemeListItemType type = data.value();
-
- switch (type) {
- case CpThemeInfo::ThemeListItemType_URL:
- //get the URL
- data = index.data(CpThemeListModel::ItemDataRole);
- if(data.isValid()) {
- QString url = data.toString();
- // Launch the URL in the browser and
- // continue to Preview if not successful
- if (QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode))) {
- return;
- }
- }
- break;
-
- case CpThemeInfo::ThemeListItemType_APP:
- break;
-
- default:
- // do nothing
- qt_noop();
- }
- }
-
//get the theme name.
data = index.data(Qt::DisplayRole);
if(data.isValid()) {
themeInfo.setName(data.toString());
}
- //get theme icon.
- data = index.data(Qt::DecorationRole);
+ //get theme path
+ data = index.data(CpThemeListModel::ItemDataRole);
if(data.isValid()) {
- themeInfo.setIcon(data.value());
- }
-
- data = index.data(CpThemeListModel::PortraitPreviewRole);
- if(data.isValid()) {
- themeInfo.setPortraitPreviewIcon(data.value());
- }
-
- data = index.data(CpThemeListModel::LandscapePreviewRole);
- if(data.isValid()) {
- themeInfo.setLandscapePreviewIcon(data.value());
+ themeInfo.setItemData(data.toString());
}
- //Set up the theme preview and set it to
- //the current view of main window.
- HbMainWindow* mWindow = ::mainWindow();
-
- if(!mThemePreview){
- mThemePreview = new CpThemePreview(themeInfo);
- mWindow->addView(mThemePreview);
-
- connect(mThemePreview,SIGNAL(aboutToClose()),
- this, SLOT(previewClosed()));
+ applyTheme(themeInfo);
+
+}
- connect(mThemePreview, SIGNAL(applyTheme(const QString&)),
- this, SLOT(themeApplied(const QString&)));
- } else {
- mThemePreview->setThemeInfo(themeInfo);
- }
- mThemePreview->setTitle(hbTrId("txt_cp_title_control_panel"));
-
- mWindow->setCurrentView(mThemePreview);
-
+void CpThemeControl::getOviTheme()
+{
+ QString url = QString("http://lr.ovi.mobi/store/themes");
+ // Launch the URL in the browser and
+ // continue to Preview if not successful
+ QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
+
}
/*!
Slot called when a Select key is pressed in theme preview view.
*/
-void CpThemeControl::themeApplied(const QString& theme)
+void CpThemeControl::applyTheme(const CpThemeInfo& theme)
{
QThread::currentThread()->setPriority(QThread::HighPriority);
@@ -273,36 +205,17 @@
//Start a timer. If theme change takes more than 1 seconds,
//we will show a dialog (mWaitDialog) until theme change
//is done (themeChangeFinished is called).
- QTimer::singleShot(1000, this, SLOT(themeWaitTimeout()));
+ QTimer::singleShot(KThemeChangeTimeOutMilliSeconds, this, SLOT(themeWaitTimeout()));
mThemeChangeFinished = false;
} else {
//theme change failed, go back to control panel.
- previewClosed();
- triggerThemeListClose();
+ setActiveThemeIndex();
}
}
/*!
- Slot called when the theme preview view is closed.
-*/
-void CpThemeControl::previewClosed()
-{
- //The theme preview closed, go back
- //to theme list view.
- HbMainWindow* mainWindow = ::mainWindow();
- mainWindow->removeView(mThemePreview);
- mThemePreview->deleteLater();
- mThemePreview = 0;
-
- //reset the current index to active theme, so that the selection remains on current
- //theme even though another list item is selected.
- setActiveThemeIndex();
- mainWindow->setCurrentView(mThemeListView);
-}
-
-/*!
Slot for when the theme list view is closed. Ownership of the theme list was given to
control panel, so the class won't delete it.
@@ -310,9 +223,6 @@
void CpThemeControl::themeListClosed()
{
mThemeListView = 0;
-
- delete mThemePreview;
- mThemePreview = 0;
}
/*!
@@ -331,12 +241,7 @@
if(mWaitDialog && mWaitDialog->isVisible()) {
mWaitDialog->hide();
}
-
- previewClosed();
- //ask the themelistview to close. Control Panel will
- //take care of removing it from window.
- triggerThemeListClose();
-
+ setActiveThemeIndex();
QThread::currentThread()->setPriority(QThread::NormalPriority);
}
@@ -344,16 +249,15 @@
{
//If after this timeOut, theme change is still in progress,
//show a processing dialog.
- if(!mThemeChangeFinished)
- {
+ if(!mThemeChangeFinished){
if(!mWaitDialog) {
mWaitDialog = new HbDialog();
mWaitDialog->setDismissPolicy(HbPopup::NoDismiss);
mWaitDialog->setModal(false);
mWaitDialog->setTimeout(HbPopup::NoTimeout);
- //TODO: need localized text for Hb Dialog
// Create and set HbLabel as content widget.
- HbLabel *label = new HbLabel("Processing ...");
+ QString processingText = hbTrId("txt_common_info_processing") + QString("...");
+ HbLabel *label = new HbLabel(processingText);
label->setAlignment(Qt::AlignCenter);
mWaitDialog->setContentWidget(label);
}
@@ -389,6 +293,9 @@
//set current index.
mThemeListView->themeList()->setCurrentIndex(sourceIndex, QItemSelectionModel::SelectCurrent);
}
+ else {
+ mThemeListView->themeList()->setCurrentIndex(QModelIndex(), QItemSelectionModel::Clear);
+ }
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemecontrol.h
--- a/controlpanelplugins/themeplugin/src/cpthemecontrol.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemecontrol.h Wed Sep 29 10:09:58 2010 +0800
@@ -32,7 +32,6 @@
class HbDialog;
class CpThemeListView;
-class CpThemePreview;
class CpBaseSettingView;
class CpThemeListModel;
@@ -51,14 +50,14 @@
signals:
void themeUpdated(const QString& themeName, const HbIcon& icon);
-public slots:
+private slots:
void newThemeSelected(const QModelIndex& index);
- void previewClosed();
- void themeApplied(const QString& theme);
+ void applyTheme(const CpThemeInfo& theme);
void themeListClosed();
void themeChangeTimeout();
void themeWaitTimeout();
void themeChangeFinished();
+ void getOviTheme();
private:
void createThemeList();
@@ -67,7 +66,6 @@
private:
CpThemeListView* mThemeListView;
- CpThemePreview* mThemePreview;
CpThemeChanger* mThemeChanger;
QAbstractItemModel* mListModel;
bool mThemeChangeFinished;
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemeinfo.h
--- a/controlpanelplugins/themeplugin/src/cpthemeinfo.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemeinfo.h Wed Sep 29 10:09:58 2010 +0800
@@ -26,7 +26,6 @@
public:
- Q_ENUMS(ThemeListItemType)
enum ThemeListItemType {
ThemeListItemType_default = 0,
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemelistmodel.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemelistmodel.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemelistmodel.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
#include
@@ -45,25 +46,14 @@
//Look into theme paths and add a file watcher for it
//to get notified when themes are added.
- QStringList themesPathList = CpThemeUtil::themePathList();
- foreach (const QString &path, themesPathList) {
- QDir themeDir;
- themeDir.setPath( path ) ;
- QStringList list = themeDir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
- if(list.contains("themes", Qt::CaseSensitive )) {
- mFileWatcher->addPath(themeDir.path() + "/themes/");
- }
+ QStringList themePaths = CpThemeUtil::themeDirectories(mThemeList);
+ if(!themePaths.empty()) {
+ mFileWatcher->addPaths(themePaths);
}
- connect(mFileWatcher, SIGNAL(directoryChanged(const QString&)),
+
+ connect(mFileWatcher, SIGNAL(directoryChanged(QString)),
this, SLOT(themeListChanged()));
-
- // data for the list which appears after the themes:
- CpThemeInfo fetchFromStore;
- fetchFromStore.setName(hbTrId("txt_cp_list_get_more_tones"));
- fetchFromStore.setItemType(CpThemeInfo::ThemeListItemType_URL);
- fetchFromStore.setItemData(QString("http://lr.ovi.mobi/store/themes"));
- fetchFromStore.setIcon(HbIcon("qtg_large_ovistore"));
- mBottomThemeList.append(fetchFromStore);
+
}
/*
@@ -116,23 +106,11 @@
case Qt::DisplayRole:
retVal = list->at(row).name();
break;
-
- case Qt::DecorationRole:
- retVal = list->at(row).icon();
- break;
-
+
case Qt::SizeHintRole:
retVal = list->at(row).icon().size();
break;
-
- case PortraitPreviewRole:
- retVal = list->at(row).portraitPreviewIcon();
- break;
-
- case LandscapePreviewRole:
- retVal = list->at(row).landscapePreviewIcon();
- break;
-
+
case ItemDataRole:
retVal = list->at(row).itemData();
break;
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemelistmodel.h
--- a/controlpanelplugins/themeplugin/src/cpthemelistmodel.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemelistmodel.h Wed Sep 29 10:09:58 2010 +0800
@@ -32,11 +32,9 @@
public:
enum ThemeListUserRole {
- PortraitPreviewRole = Qt::UserRole,
- LandscapePreviewRole,
- ItemTypeRole,
- ItemDataRole
- };
+ ItemTypeRole = Qt::UserRole,
+ ItemDataRole
+ };
explicit CpThemeListModel(QObject *parent = 0);
virtual ~CpThemeListModel();
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemelistview.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemelistview.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemelistview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -20,20 +20,22 @@
#include
#include
-#include
#include
#include
+#include
+#include
+#include
+
#include "cpthemelistview.h"
/*!
\class CpThemeListView
- \brief CpThemeListView displays a heading (Select theme) and a list of themes with
+ \brief CpThemeListView displays a heading (e.g Theme) and a list of themes with
corresponding icons.
Note: This class is a subclass of CpBaseSettingView for compatibility with Control Panel
- framework. However, it does not use HbDataForm as its widget and as its parent does, so
- it uses SetWidget to set the listview to its widget instead of an HbDataForm.
+ framework.
*/
/*!
@@ -42,27 +44,46 @@
CpThemeListView::CpThemeListView(QGraphicsItem *parent) : CpBaseSettingView(0, parent),
mThemeList(new HbListView(this))
{
-
- //Create a layout with a heading "Select theme" at top and the list below it.
+
+ //Create a layout with a heading at top and the list below it.
HbWidget* contentWidget = new HbWidget(this);
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
+ layout->setContentsMargins(0,0,0,0);
//setup the heading.
- HbLabel* label = new HbLabel(hbTrId("txt_cp_title_select_theme"), contentWidget);//txt_cp_title_select_theme
- layout->addItem(label);
-
- connect(mThemeList, SIGNAL(activated(const QModelIndex&)),
- this, SIGNAL(newThemeSelected(const QModelIndex&)));
+ HbGroupBox *simpleLabel = new HbGroupBox();
+ simpleLabel->setHeading(hbTrId("txt_cp_title_select_theme"));
+
+ layout->addItem(simpleLabel);
+
+ connect(mThemeList, SIGNAL(activated(QModelIndex)),
+ this, SIGNAL(newThemeSelected(QModelIndex)));
+ //set list item icons to be large.
HbListViewItem* listViewItem = mThemeList->listItemPrototype();
listViewItem->setGraphicsSize(HbListViewItem::LargeIcon);
-
+ //set singleSelection to enable showing an indicator (e.g check mark) next to active theme.
+ mThemeList->setSelectionMode(HbAbstractItemView::SingleSelection);
+
//add the list to layout.
layout->addItem(mThemeList);
+
+ //Create the toolbar for Ovi Store.
+ HbToolBar* toolBar = new HbToolBar(this);
+
+ HbAction* oviAction = new HbAction(HbIcon("qtg_large_ovistore"), hbTrId("txt_cp_list_get_more_tones"));
+ QObject::connect( oviAction, SIGNAL(triggered()),
+ this, SIGNAL(oviClicked()));
+
+ //Add Action to the toolbar and show toolbar
+ toolBar->addAction(oviAction);
+
+ setToolBar(toolBar);
contentWidget->setLayout(layout);
setWidget(contentWidget);
+
}
/*!
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemelistview.h
--- a/controlpanelplugins/themeplugin/src/cpthemelistview.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemelistview.h Wed Sep 29 10:09:58 2010 +0800
@@ -32,7 +32,7 @@
Q_OBJECT
public:
- CpThemeListView(QGraphicsItem *parent = 0);
+ explicit CpThemeListView(QGraphicsItem *parent = 0);
~CpThemeListView();
void setWidget(QGraphicsWidget *widget);
HbListView* themeList() const;
@@ -41,6 +41,7 @@
signals:
void newThemeSelected(const QModelIndex& index);
+ void oviClicked();
private:
HbListView* mThemeList;
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemeplugin.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemeplugin.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemeplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -48,9 +48,9 @@
//create a cpthemepluginentryitemdata with default values and return it.
CpSettingFormEntryItemData *entryItem = new CpThemePluginEntryItemData(
itemDataHelper,
- tr("Theme"),
- tr("Theme Name"),
- HbIcon(":/image/qgn_menu_note.svg"));
+ hbTrId("txt_cp_dblist_theme"),
+ QString(),
+ HbIcon("qtg_large_personalization"));
return QList() << entryItem;
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemepluginentryitemdata.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemepluginentryitemdata.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemepluginentryitemdata.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -47,8 +47,7 @@
//Create a CpThemeControl. the themeControl takes care of displaying the themes
//and letting user select a theme and apply a theme change.
mThemeControl = new CpThemeControl();
-
- setEntryItemIcon(mThemeControl->currentThemeIcon());
+
setDescription(mThemeControl->currentThemeName());
//connect to signal to update the current theme name and icon whenever the theme changes.
@@ -71,7 +70,7 @@
*/
void CpThemePluginEntryItemData::themeUpdated(const QString& themeName, const HbIcon& icon)
{
- setEntryItemIcon(icon);
+ Q_UNUSED(icon);
setDescription(themeName);
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemepreview.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemepreview.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemepreview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -15,6 +15,7 @@
*
*/
+#include
#include
#include
#include
@@ -27,6 +28,7 @@
#include
#include
#include
+#include
#include "cpthemepreview.h"
#include "cpthemeinfo.h"
@@ -38,6 +40,7 @@
the theme change or press Cancel and go back to theme list view.
*/
+
/*!
constructor.
*/
@@ -47,20 +50,52 @@
mSoftKeyBackAction(0),
mPreviewIcon(0)
{
+ QGraphicsLinearLayout* containerLayout = new QGraphicsLinearLayout(Qt::Vertical);
+ QGraphicsLinearLayout* bottomLayout = new QGraphicsLinearLayout(Qt::Vertical);
+
+ //Preview icon margins.
+ qreal leftMargin = 0.0;
+ qreal rightMargin = 0.0;
+ qreal topMargin = 0.0;
+ qreal bottomMargin = 0.0;
+
+ style()->parameter(QString("hb-param-margin-gene-left"), leftMargin);
+ style()->parameter("hb-param-margin-gene-right", rightMargin);
+ style()->parameter("hb-param-margin-gene-top", topMargin);
+ style()->parameter("hb-param-margin-gene-bottom", bottomMargin);
+
+ containerLayout->setContentsMargins(0,0,0,0);
+ bottomLayout->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
+
+ //Using an empty dataform as heading because the heading should
+ //look like an HbDataForm headiing.
+ HbDataForm* heading = new HbDataForm(this);
+ QString themeHeading = HbParameterLengthLimiter("txt_cp_title_preview_1").arg(mTheme.name());
+ heading->setHeading(themeHeading);
+
+ containerLayout->addItem(heading);
+ //Fixed vertical policy so that the heading doesn't expand.
+ heading->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed,QSizePolicy::DefaultType);
- //Create the layout and add heading and and preview icon to the layout.
- QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
+ if(mainWindow()->orientation() == Qt::Horizontal) {
+ mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon(), this);
+ }
+ else {
+ mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon(), this);
+ //set to ignore aspect ratio so the layout would rezise the icon correctly.
+
+ }
+ mPreviewIcon->setAspectRatioMode(Qt::IgnoreAspectRatio);
+
+ // set an object name for preview icon to make it testable for automation testing
+ mPreviewIcon->setObjectName(QString("themePreviewIcon"));
- //setup the heading.
- QString themeHeading = HbParameterLengthLimiter("txt_cp_title_preview_1").arg(mTheme.name());
- HbLabel* label = new HbLabel(themeHeading, this);
-
- layout->addItem(label);
-
- layout->setAlignment(layout->itemAt(0), Qt::AlignTop);
- layout->itemAt(0)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed,QSizePolicy::DefaultType);
-
+ bottomLayout->addItem(mPreviewIcon);
+ containerLayout->addItem(bottomLayout);
+
+ setLayout(containerLayout);
+
//Create the toolbar and "Select" and "Cancel" actions.
HbToolBar* mToolBar = new HbToolBar(this);
@@ -77,24 +112,11 @@
QObject::connect( cancelAction, SIGNAL(triggered()),
this, SIGNAL(aboutToClose()));
-
QObject::connect( mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
this, SLOT(previewOrientationChanged(Qt::Orientation)));
-
- if(mainWindow()->orientation() == Qt::Horizontal) {
- mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon(), this);
- }
- else {
- mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon(), this);
- }
- layout->addItem(mPreviewIcon);
- layout->itemAt(1)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred,QSizePolicy::DefaultType);
-
setToolBar(mToolBar);
- setLayout(layout);
-
//Setup the Back button action and set softkey. Back button
//takes the user to the theme list view.
mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
@@ -102,6 +124,7 @@
this, SIGNAL(aboutToClose()) );
setNavigationAction(mSoftKeyBackAction);
+
}
/*!
@@ -122,7 +145,7 @@
/*!
returns the themeName.
*/
-const QString& CpThemePreview::themeName() const
+const QString CpThemePreview::themeName() const
{
return mTheme.name();
}
@@ -130,7 +153,7 @@
/*!
returns the repersentative themeIcon of the current theme.
*/
-const HbIcon& CpThemePreview::themeIcon() const
+const HbIcon CpThemePreview::themeIcon() const
{
return mTheme.icon();
}
@@ -140,7 +163,7 @@
*/
void CpThemePreview::themeSelected()
{
- emit applyTheme(mTheme.name());
+ emit applyTheme(mTheme);
}
/*!
@@ -150,13 +173,20 @@
void CpThemePreview::previewOrientationChanged(Qt::Orientation orientation)
{
- QGraphicsLinearLayout* previewLayout = dynamic_cast(layout());
+ QGraphicsLinearLayout* containerLayout = dynamic_cast(layout());
+ QGraphicsLinearLayout* previewLayout = 0;
+ if(containerLayout) {
+ //get the layout that preview icon belongs to.
+ previewLayout = dynamic_cast(containerLayout->itemAt(1));
+ }
- if(mPreviewIcon && mPreviewIcon == dynamic_cast(previewLayout->itemAt(1)) ) {
- previewLayout->removeAt(1);
+ if(previewLayout && mPreviewIcon && mPreviewIcon == dynamic_cast(previewLayout->itemAt(0)) ) {
+ //Remove preview icon.
+ previewLayout->removeAt(0);
if(orientation == Qt::Horizontal) {
mPreviewIcon->setIcon(mTheme.landscapePreviewIcon());
+
}
else {
mPreviewIcon->setIcon(mTheme.portraitPreviewIcon());
@@ -166,4 +196,6 @@
}
}
+
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemepreview.h
--- a/controlpanelplugins/themeplugin/src/cpthemepreview.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemepreview.h Wed Sep 29 10:09:58 2010 +0800
@@ -41,17 +41,17 @@
explicit CpThemePreview(const CpThemeInfo &theme, QGraphicsItem *parent = 0);
~CpThemePreview();
void setThemeInfo(const CpThemeInfo& theme);
- const QString& themeName() const;
- const HbIcon& themeIcon() const;
+ const QString themeName() const;
+ const HbIcon themeIcon() const;
signals:
- void applyTheme(const QString&);
+ void applyTheme(const CpThemeInfo&);
void aboutToClose();
-public slots:
+private slots:
void themeSelected();
void previewOrientationChanged(Qt::Orientation orientation);
-
+
private:
CpThemeInfo mTheme;
HbAction* mSoftKeyBackAction;
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemeutil.cpp
--- a/controlpanelplugins/themeplugin/src/cpthemeutil.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemeutil.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -26,6 +26,7 @@
#include
#include
+#include
/*!
* This class provides utility function to get Theme information.
@@ -36,94 +37,23 @@
#include
static const TUid KServerUid3={0x20022E82};
static const TUint32 KDefaultThemeNameKey = 0x2;
- static const TUint32 KDefaultThemeRootPathKey = 0x3;
-
+
#endif
-#if !defined(Q_OS_SYMBIAN)
- #include
- static const char* KThemePathKey = "HB_THEMES_DIR"; //used for getting default theme.
-#endif
-
-
-#ifdef Q_OS_WIN
- static char* _path = NULL;
- static size_t _size = 0;
- _dupenv_s(&_path, &_size, KThemePathKey);
- static QString themeRootPath = QString(_path);
- static QString themeRootPathPostfix = QString();
- free(_path);
-#elif defined(Q_OS_SYMBIAN)
- static QString themeRootPath = "c:\\resource\\hb";
- static QString themeRootPathPostfix = "resource\\hb";
-#elif defined(Q_OS_MACX)
- static QString themeRootPath = QDir::homePath() + '/' + "Library" + QString("hb");
- static QString themeRootPathPostfix = QString();
-#elif defined(Q_OS_UNIX)
- static QString themeRootPath = QString(getenv(KThemePathKey));
- static QString themeRootPathPostfix = QString();
-#else
- static QString themeRootPath = "c:\\resource\\hb";
- static QString themeRootPathPostfix = QString();
-#endif
//Location of theme preview and background icons.
static const QString KPreviewThumbnailNVG = "/scalable/qtg_graf_theme_preview_thumbnail.nvg";
static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg";
- static const QString KPreviewPrtNVG = "/scalable/qtg_graf_theme_preview_prt.nvg";
- static const QString KPreviewLscNVG = "/scalable/qtg_graf_theme_preview_lsc.nvg";
- static const QString KPreviewPrtSVG = "/scalable/qtg_graf_theme_preview_prt.svg";
- static const QString KPreviewLscSVG = "/scalable/qtg_graf_theme_preview_lsc.svg";
-
static const QString KBackgroundPrtNVG = "/scalable/qtg_graf_screen_bg_prt.nvg";
static const QString KBackgroundLscNVG = "/scalable/qtg_graf_screen_bg_lsc.nvg";
static const QString KBackgroundPrtSVG = "/scalable/qtg_graf_screen_bg_prt.svg";
static const QString KBackgroundLscSVG = "/scalable/qtg_graf_screen_bg_lsc.svg";
- static const QString KBackgroundPrtPNG = "/pixmap/qtg_graf_screen_bg_prt.png";
- static const QString KBackgroundLscPNG = "/pixmap/qtg_graf_screen_bg_lsc.png";
-/*!
- * Returns a list of paths where themes folder reside.
- */
-QStringList CpThemeUtil::themePathList()
-{
- static QStringList themesPathList;
-
- if(themesPathList.isEmpty()) {
-#if defined(Q_OS_SYMBIAN)
- QFileInfoList driveInfoList = QDir::drives();
- foreach (const QFileInfo &driveInfo, driveInfoList) {
- const QString themePath = driveInfo.absolutePath() + themeRootPathPostfix;
- if(QDir(themePath).exists())
- themesPathList << themePath;
- }
-#else
- themesPathList << themeRootPath;
-#endif
- }
- return themesPathList;
-}
-/*!
- * Given the theme name, it returns the absolute path of the theme.
- */
-QString CpThemeUtil::themePath(const QString& themeName)
-{
- QString themePath = "";
- QStringList themesPathList = themePathList();
- foreach (const QString &path, themesPathList) {
- QString tmpPath = path + "/themes/icons/" + themeName;
- if(QDir(tmpPath).exists()) {
- themePath = tmpPath;
- break;
- }
- }
- return themePath;
-}
-
+
/*
* Builds a CpThemeInfo object given theme path and theme name. It creates the name and
* preview icons for the object. Creates a new CpThemeInfo objects. Caller takes ownership.
@@ -134,8 +64,6 @@
CpThemeInfo *themeInfo = new CpThemeInfo();
QString iconPath;
- QString previewPathPrt;
- QString previewPathLsc;
QString name = themeName;
QString hidden = "";
@@ -147,18 +75,18 @@
name = iniSetting.value("Name").toString();
hidden = iniSetting.value("Hidden").toString();
iconPath = iniSetting.value("PreviewThumbnailPath").toString();
- previewPathPrt = iniSetting.value("PreviewIconPath_prt").toString();
- previewPathLsc = iniSetting.value("PreviewIconPath_lsc").toString();
iniSetting.endGroup();
}
if(name.isEmpty() || (hidden == "true") ||( hidden == "")) {
+ delete themeInfo;
return NULL;
}
themeInfo->setName(name);
themeInfo->setItemType(CpThemeInfo::ThemeListItemType_default);
+ themeInfo->setItemData(themePath);
//Get the icons. Logic is as follow:
/* 1. If the icon path is in index.theme and the icon exist, use it.
@@ -167,101 +95,63 @@
* 3. If no icon exist (background or preview),use default theme icon.
*/
if(iconPath.isEmpty() || !QFileInfo(themePath + iconPath).exists()){
- //Set thumbnail
- if(QFileInfo(themePath + KPreviewThumbnailNVG).exists()){
- themeInfo->setIcon(HbIcon(themePath + KPreviewThumbnailNVG));
- }else if(QFileInfo(themePath + KPreviewThumbnailSVG).exists()){
- themeInfo->setIcon(HbIcon(themePath + KPreviewThumbnailSVG));
- }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){
- themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtNVG));
- } else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){
- themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtSVG));
- } else if(QFileInfo(themePath + KBackgroundPrtPNG).exists()){
- themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtPNG));
- }else{
- themeInfo->setIcon(HbIcon(defaultTheme()->icon()));
+ //Set thumbnail
+ HbIcon themeIcon = getPreviewIcon(themePath);
+ if(themeIcon.isNull()){
+ QString defaultThemePath = defaultTheme();
+ if(!defaultThemePath.isEmpty()) {
+ themeIcon = getPreviewIcon(defaultThemePath);
+ }
}
-
+ themeInfo->setIcon(themeIcon);
} else {
themeInfo->setIcon(HbIcon(themePath + iconPath));
}
- //Portrait preview
-
- if(previewPathPrt.isEmpty() || !QFileInfo(themePath + previewPathPrt).exists()) {
-
- if(QFileInfo(themePath + KPreviewPrtNVG).exists()){
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KPreviewPrtNVG));
- }else if(QFileInfo(themePath + KPreviewPrtSVG).exists()){
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KPreviewPrtSVG));
- }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtNVG));
- } else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtSVG));
- } else if(QFileInfo(themePath + KBackgroundPrtPNG).exists()){
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtPNG));
- } else{
- themeInfo->setPortraitPreviewIcon(HbIcon(defaultTheme()->icon()));
- }
- }
- else {
- themeInfo->setPortraitPreviewIcon(HbIcon(themePath + previewPathPrt));
- }
-
- //Landscape preview
-
- if(previewPathLsc.isEmpty() || !QFileInfo(themePath + previewPathLsc).exists()) {
- if(QFileInfo(themePath + KPreviewLscNVG).exists()){
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KPreviewLscNVG));
- }else if(QFileInfo(themePath + KPreviewLscSVG).exists()){
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KPreviewLscSVG));
- }else if(QFileInfo(themePath + KBackgroundLscNVG).exists()){
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscNVG));
- } else if(QFileInfo(themePath + KBackgroundLscSVG).exists()){
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscSVG));
- } else if(QFileInfo(themePath + KBackgroundLscPNG).exists()){
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscPNG));
- } else{
- themeInfo->setLandscapePreviewIcon(HbIcon(defaultTheme()->icon()));
- }
- }
- else {
- themeInfo->setLandscapePreviewIcon(HbIcon(themePath + previewPathLsc));
- }
return themeInfo;
}
+/*!
+ * given a path to the theme, returns the preview icon or just a Null icon
+ * if it doesn't exist.
+ */
+HbIcon CpThemeUtil::getPreviewIcon(const QString& themePath)
+{
+ HbIcon themeIcon;
+ if(QFileInfo(themePath + KPreviewThumbnailNVG).exists()){
+ themeIcon = HbIcon(themePath + KPreviewThumbnailNVG);
+ }else if(QFileInfo(themePath + KPreviewThumbnailSVG).exists()){
+ themeIcon = HbIcon(themePath + KPreviewThumbnailSVG);
+ }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){
+ themeIcon = HbIcon(themePath + KBackgroundPrtNVG);
+ }else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){
+ themeIcon = HbIcon(themePath + KBackgroundPrtSVG);
+ }
+ return themeIcon;
+
+}
+
/*! Creates a list of CpThemeInfo objects representing theme information.
- * Caller should take ownership of the list.
+ *
*/
QList CpThemeUtil::buildThemeList()
{
QList themeList;
-
- QStringList mThemesPathList = themePathList();
- foreach (const QString &path, mThemesPathList) {
+ QList > mThemesPathList = availableThemes();
+ QPairpair;
+ foreach (pair, mThemesPathList) {
QDir themeDir;
+ QString name = pair.first;
+ QString path = pair.second;
themeDir.setPath( path ) ;
- QStringList iconthemeslist;
- QStringList list = themeDir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
CpThemeInfo* themeInfo;
-
- if(list.contains("themes", Qt::CaseSensitive )) {
- QDir root(themeDir.path());
- themeDir.setPath(root.path() + "/themes/icons/") ;
- iconthemeslist = themeDir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
- foreach(QString themefolder, iconthemeslist) {
- QDir iconThemePath(root.path() + "/themes/icons/" + themefolder);
- if(iconThemePath.exists("index.theme") &&
- (iconThemePath.exists("scalable") || iconThemePath.exists("pixmap") )) {
-
- themeInfo = buildThemeInfo(iconThemePath.path(), themefolder);
- if(themeInfo && !themeInfo->name().isEmpty()) {
- themeList.append(*themeInfo);
- }
- }
+ if(themeDir.exists("index.theme") &&
+ (themeDir.exists("scalable") || themeDir.exists("pixmap") )) {
+ themeInfo = buildThemeInfo(path, name);
+ if(themeInfo && !themeInfo->name().isEmpty()) {
+ themeList.append(*themeInfo);
}
}
}
@@ -270,15 +160,14 @@
}
/*!
- * Returns the default theme information.
+ * Returns the default theme path.
*/
-CpThemeInfo* CpThemeUtil::defaultTheme()
+QString CpThemeUtil::defaultTheme()
{
//static because default theme doesn't change.
- static CpThemeInfo *defaultTheme = new CpThemeInfo();
- QString defaultThemeName;
- QString defaultThemeRootDir;
- if(defaultTheme->name().isEmpty()) {
+ static QString defaultThemePath("");
+
+ if(defaultThemePath.isEmpty()) {
#ifdef Q_OS_SYMBIAN
@@ -288,24 +177,42 @@
TBuf<256> value;
if (KErrNone == repository->Get((TUint32)KDefaultThemeNameKey, value)) {
QString qvalue((QChar*)value.Ptr(), value.Length());
- defaultThemeName = qvalue.trimmed();
+ defaultThemePath = qvalue.trimmed();
}
value.Zero();
- if (KErrNone == repository->Get((TUint32)KDefaultThemeRootPathKey, value)) {
- QString qvalue((QChar*)value.Ptr(), value.Length());
- defaultThemeRootDir = qvalue.trimmed();
- }
- else {
- defaultThemeRootDir = themePath(defaultThemeName);
- }
- value.Zero();
- delete repository;
+ delete repository;
}
#endif
- defaultTheme = buildThemeInfo(defaultThemeRootDir, defaultThemeName);
-
+
}
- return defaultTheme;
+ return defaultThemePath;
}
+
+const QStringList CpThemeUtil::themeDirectories(const QList& themeInfoList)
+{
+ QStringList themeDirs;
+
+ foreach(const CpThemeInfo& themeInfo, themeInfoList) {
+ QDir themePath(themeInfo.itemData());
+ QString topDir;
+ if(themePath.cdUp()) {
+ topDir = themePath.path();
+ if(!themeDirs.contains(topDir)) {
+ themeDirs.append(topDir);
+ }
+ }
+ }
+ return themeDirs;
+}
+
+const QList< QPair< QString, QString > > CpThemeUtil::availableThemes( )
+{
+
+ QList > result = HbThemeServices::availableThemes();
+ return result;
+
+}
+
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/src/cpthemeutil.h
--- a/controlpanelplugins/themeplugin/src/cpthemeutil.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/src/cpthemeutil.h Wed Sep 29 10:09:58 2010 +0800
@@ -19,18 +19,25 @@
#define CPTHEMEUTIL_H_
#include
+#include
class QStringList;
class CpThemeInfo;
+class HbIcon;
class CpThemeUtil {
public:
- static QStringList themePathList();
static QList buildThemeList();
- static CpThemeInfo* buildThemeInfo(const QString& themePath, const QString& themeName);
- static QString themePath(const QString& themeName);
- static CpThemeInfo* defaultTheme();
+ static CpThemeInfo* buildThemeInfo(const QString& themePath, const QString& themeName = QString());
+ static QString defaultTheme();
+ static const QList< QPair< QString, QString > > availableThemes();
+ static const QStringList themeDirectories(const QList &themeInfoList);
+
+private:
+ static HbIcon getPreviewIcon(const QString& themePath);
+
+
};
#endif /* CPTHEMEUTIL_H_ */
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/themeplugin.pri
--- a/controlpanelplugins/themeplugin/themeplugin.pri Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/themeplugin.pri Wed Sep 29 10:09:58 2010 +0800
@@ -9,8 +9,7 @@
# Contributors:
# Description: cpthemeplugin source files
# Input
-HEADERS += src/cpthemepreview.h \
- src/cpthemecontrol.h \
+HEADERS += src/cpthemecontrol.h \
src/cpthemeplugin.h \
src/cpthemelistview.h \
src/cpthemelistmodel.h \
@@ -18,8 +17,7 @@
src/cpthemepluginentryitemdata.h \
src/cpthemeutil.h \
src/cpthemeinfo.h
-SOURCES += src/cpthemepreview.cpp \
- src/cpthemecontrol.cpp \
+SOURCES += src/cpthemecontrol.cpp \
src/cpthemeplugin.cpp \
src/cpthemelistview.cpp \
src/cpthemelistmodel.cpp \
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/themeplugin.pro
--- a/controlpanelplugins/themeplugin/themeplugin.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/themeplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -25,6 +25,10 @@
CONFIG += debug_and_release
RESOURCES += themeplugin.qrc
+#comment this out if theme plugin should have
+#a preview view.
+#DEFINES += CP_THEME_PREVIEW_DEFINED
+
include (themeplugin.pri)
include (rom/themeplugin_rom.pri)
@@ -61,6 +65,7 @@
LIBS += -L$$DESTDIR
+
#For some reason the default include path doesn't include MOC_DIR on symbian
symbian {
INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
@@ -86,6 +91,7 @@
for(qtplugin, qtplugins.sources):BLD_INF_RULES.prj_exports += "./$$qtplugin $$deploy.path$$qtplugins.path/$$basename(qtplugin)"
}
+symbian:MMP_RULES += SMPSAFE
#symbian: INCLUDEPATH += /sf/mw/hb/include/hbservices \
# /sf/mw/hb/include/hbservices/private \
@@ -94,3 +100,4 @@
#
# End of file --Don't remove this.
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/themeplugin.ts
--- a/controlpanelplugins/themeplugin/themeplugin.ts Fri Jun 25 17:12:20 2010 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-
-
-
-
-
- Select theme view title
- Select theme
- Select theme
-
- CP_04
- subtitle
- CP
- False
-
-
- This is the view title, shown in all Control Panel views.
- Control Panel
- Control Panel
- qtl_chrome_title
- CP_01
- title
- CP
- False
-
-
- List item, opens Theme selector view
- Theme
- Theme
- qtl_list_pri_large_graphic
- CP_01
- list
- CP
- False
-
-
- Theme preview view title, where %1 is the name of the theme that is previewed
- Preview: %1
- Preview: %1
-
- CP_05
- subtitle
- CP
- False
-
-
-
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/tsrc.pro
--- a/controlpanelplugins/themeplugin/tsrc/tsrc.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/tsrc.pro Wed Sep 29 10:09:58 2010 +0800
@@ -19,6 +19,8 @@
SUBDIRS += unit/unittest_cpthemelistview
SUBDIRS += unit/unittest_cpthemeplugin
SUBDIRS += unit/unittest_cpthemepluginentryitemdata
+SUBDIRS += unit/unittest_cpthemelistmodel
+SUBDIRS += unit/unittest_cpthemeutil
CONFIG += ordered
test.depends = first
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/common.pri
--- a/controlpanelplugins/themeplugin/tsrc/unit/common.pri Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/common.pri Wed Sep 29 10:09:58 2010 +0800
@@ -42,6 +42,7 @@
symbian {
INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
INCLUDEPATH += $$MOC_DIR
+ LIBS += -lcentralrepository
TARGET.CAPABILITY = ALL -TCB
TARGET.EPOCALLOWDLLDATA = 1
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.cpp
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -16,45 +16,32 @@
*/
#include
-#include
#include
+#include
+#include
+
#include "cpthemechanger.h"
#include "cpthemecontrol.h"
-#include "cpthemechanger.h"
+#include "cpthemeinfo.h"
+#include "cpthemeutil.h"
class TestCpThemeControl : public QObject
{
Q_OBJECT
private slots:
- void init();
void testConstructor();
void testThemeListView();
void testCurrentThemeName();
void testCurrentThemeIcon();
- void testNewThemeSelected();
- void testPreviewClosed();
- void testThemeApplied();
- void testUpdateThemeList();
-
- void cleanup();
-
+
private:
CpThemeChanger* mThemeChanger;
};
-// setup and cleanup
-void TestCpThemeControl::init()
-{
- mThemeChanger = new CpThemeChanger();
-}
-void TestCpThemeControl::cleanup()
-{
- delete mThemeChanger;
-}
// verify that the constructor works and that the
// defaults are sane.
@@ -64,7 +51,7 @@
QVERIFY(control !=0 );
QVERIFY(!control->currentThemeName().isEmpty());
- QVERIFY(!control->currentThemeIcon().isEmpty());
+ QVERIFY(!control->currentThemeIcon().iconName().isEmpty());
delete control;
}
@@ -82,8 +69,8 @@
{
CpThemeControl control;
- QVERIFY((control.currentThemeName() == mThemeChanger->currentTheme())
- || (control.currentThemeName() == QString("hbdefault")));
+ QVERIFY( (control.currentThemeName() == hbInstance->theme()->name())
+ || (control.currentThemeName() == QString("hbdefault")));
}
// test that we get a non-empty string for current theme icon
@@ -91,56 +78,10 @@
{
CpThemeControl control;
- QVERIFY(!control.currentThemeIcon().isEmpty());
-}
-
-// NULL test there's no way to externally get the model the QModelIndex is based on
-void TestCpThemeControl::testNewThemeSelected()
-{
- CpThemeControl control;
-
- control.newThemeSelected(QModelIndex());
-
+ QVERIFY(!control.currentThemeIcon().isNull() && !control.currentThemeIcon().iconName().isEmpty());
}
-// NULL test - basically verifies that it doesn't burst into flames.
-void TestCpThemeControl::testPreviewClosed()
-{
- CpThemeControl control;
-
- control.previewClosed();
-
-}
-void TestCpThemeControl::testThemeApplied()
-{
- CpThemeControl control;
- QList themeList = mThemeChanger->themes();
- QSignalSpy spy(&control, SIGNAL(themeUpdated(const QString&, const QString&)));
- int expectedSignalCount = 0;
-
- for (int i = 0; i < themeList.size(); ++i) {
- CpThemeChanger::ThemeInfo info = themeList.at(i);
- QString name = info.themeName;
-
- if (control.currentThemeName() == mThemeChanger->currentTheme()) {
- ++expectedSignalCount;
- }
-
- control.themeApplied(name);
- QCOMPARE(control.currentThemeName(), mThemeChanger->currentTheme());
-
- QCOMPARE(spy.count(),expectedSignalCount);
- }
-}
-
-// NULL test - basically verifies that it doesn't burst into flames.
-void TestCpThemeControl::testUpdateThemeList()
-{
- CpThemeControl control;
-
- control.updateThemeList();
-}
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.pro
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemecontrol/unittest_cpthemecontrol.pro Wed Sep 29 10:09:58 2010 +0800
@@ -37,18 +37,14 @@
HEADERS += ../../../src/cpthemecontrol.h
HEADERS += ../../../src/cpthemechanger.h
-HEADERS += ../../../src/cpthemechanger_p.h
-HEADERS += ../../../src/cpthemeclient_p.h
-symbian::HEADERS += ../../../src/cpthemeclientsymbian_p.h
-win32::HEADERS += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.h
HEADERS += ../../../src/cpthemelistview.h
-HEADERS += ../../../src/cpthemepreview.h
+HEADERS += ../../../src/cpthemeutil.h
+HEADERS += ../../../src/cpthemeinfo.h
+HEADERS += ../../../src/cpthemelistmodel.h
SOURCES += unittest_cpthemecontrol.cpp
SOURCES += ../../../src/cpthemecontrol.cpp
SOURCES += ../../../src/cpthemechanger.cpp
-SOURCES += ../../../src/cpthemechanger_p.cpp
-SOURCES += ../../../src/cpthemeclient_p.cpp
-symbian::SOURCES += ../../../src/cpthemeclientsymbian_p.cpp
-win32::SOURCES += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
+SOURCES += ../../../src/cpthemelistmodel.cpp
SOURCES += ../../../src/cpthemelistview.cpp
-SOURCES += ../../../src/cpthemepreview.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistmodel/unittest_cpthemelistmodel.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistmodel/unittest_cpthemelistmodel.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors: XENT-MV
+*
+* Description: unit tests for the CpThemeListModel class from themeplugin
+*
+*/
+
+#include
+
+#include "cpthemelistmodel.h"
+
+class TestCpThemeListModel : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+ void testConstructor();
+ void testRowCount();
+ void testData();
+ void testIndexOf();
+};
+
+
+void TestCpThemeListModel::testConstructor()
+{
+
+ CpThemeListModel *obj = new CpThemeListModel();
+
+
+ QVERIFY (obj != 0 );
+ QVERIFY (obj->rowCount() > 0);
+
+ delete obj;
+
+}
+
+void TestCpThemeListModel::testRowCount()
+{
+ CpThemeListModel *themeModel = new CpThemeListModel();
+ QList > allThemes = CpThemeUtil::availableThemes();
+ QVERIFY(themeModel->rowCount() >= allThemes.size());
+}
+
+void TestCpThemeListModel::testData()
+{
+ CpThemeListModel *themeModel = new CpThemeListModel();
+ QList > allThemes = CpThemeUtil::availableThemes();
+
+ QModelIndex index = themeModel->index(0,0, QModelIndex());
+
+ //Check theme name (first) and theme path (second). Skipping icons for now.
+ QCOMPARE(themeModel->data(index, Qt::DisplayRole).toString(), allThemes.at(0).first);
+ QCOMPARE(themeModel->data(index, CpThemeListModel::ItemDataRole).toString(), allThemes.at(0).second);
+
+
+}
+
+void TestCpThemeListModel::testIndexOf()
+{
+ CpThemeListModel *themeModel = new CpThemeListModel();
+ QList > allThemes = CpThemeUtil::availableThemes();
+
+ CpThemeInfo *themeInfo = CpThemeUtil::buildThemeInfo(allThemes.at(1).second, allThemes.at(1).first);
+
+ int index = themeModel->indexOf(*themeInfo);
+
+ QVERIFY(index == 1);
+
+}
+QTEST_MAIN(TestCpThemeListModel)
+#include "unittest_cpthemelistmodel.moc"
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistmodel/unittest_cpthemelistmodel.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistmodel/unittest_cpthemelistmodel.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,30 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0".
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors: XENT-MV
+# Description: unit tests for the cpthemelistmodel class in the themeplugin.
+include(../common.pri)
+TEMPLATE = app
+TARGET = unittest_cpthemelistmodel
+DEPENDPATH += .
+win32::DEPENDPATH += c:/ControlPanel/debug/bin
+INCLUDEPATH += .
+INCLUDEPATH += src/
+INCLUDEPATH += ../../../src
+LIBS += -lcpframework
+win32::LIBS += -LC:/ControlPanel/debug/bin
+symbian::TARGET.UID3 = 0x20031DAD
+
+# Input
+HEADERS += ../../../src/cpthemelistmodel.h
+HEADERS += ../../../src/cpthemeinfo.h
+HEADERS += ../../../src/cpthemeutil.h
+SOURCES += unittest_cpthemelistmodel.cpp
+SOURCES += ../../../src/cpthemelistmodel.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistview/unittest_cpthemelistview.cpp
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistview/unittest_cpthemelistview.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistview/unittest_cpthemelistview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -62,13 +62,13 @@
delete listView;
}
-// no getter so this is basically a NULL test.
void TestCpThemeListView::testSetModel()
{
CpThemeListView *listView = new CpThemeListView();
QStandardItemModel *model = new QStandardItemModel(this);
listView->setModel(model);
+ QVERIFY(listView->themeList()->model() == model);
// model shouldn't be deleted because it is a QObject with a parent.
@@ -88,4 +88,4 @@
QTEST_MAIN(TestCpThemeListView)
-#include "unittest_cpthemelistview.moc"
\ No newline at end of file
+#include "unittest_cpthemelistview.moc"
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.cpp
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -42,11 +42,11 @@
CpThemePlugin *obj = new CpThemePlugin();
CpItemDataHelper helper;
- QVERIFY(obj->createSettingFormItemData(helper) != 0);
+ QVERIFY(obj->createSettingFormItemData(helper).at(0) != 0);
delete obj;
}
QTEST_MAIN(TestCpThemePlugin)
-#include "unittest_cpthemeplugin.moc"
\ No newline at end of file
+#include "unittest_cpthemeplugin.moc"
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.pro
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeplugin/unittest_cpthemeplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -35,23 +35,21 @@
# Input
HEADERS += ../../../src/cpthemecontrol.h
-HEADERS += ../../../src/cpthemeclient_p.h
-win32::HEADERS += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.h
-symbian::HEADERS += ../../../src/cpthemeclientsymbian_p.h
-HEADERS += ../../../src/cpthemepreview.h
HEADERS += ../../../src/cpthemechanger.h
-HEADERS += ../../../src/cpthemechanger_p.h
HEADERS += ../../../src/cpthemelistview.h
HEADERS += ../../../src/cpthemeplugin.h
HEADERS += ../../../src/cpthemepluginentryitemdata.h
+HEADERS += ../../../src/cpthemeinfo.h
+HEADERS += ../../../src/cpthemeutil.h
+HEADERS += ../../../src/cpthemelistmodel.h
SOURCES += unittest_cpthemeplugin.cpp
SOURCES += ../../../src/cpthemecontrol.cpp
-SOURCES += ../../../src/cpthemeclient_p.cpp
-win32::SOURCES += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.cpp
-symbian::SOURCES += ../../../src/cpthemeclientsymbian_p.cpp
-SOURCES += ../../../src/cpthemepreview.cpp
SOURCES += ../../../src/cpthemechanger.cpp
-SOURCES += ../../../src/cpthemechanger_p.cpp
SOURCES += ../../../src/cpthemelistview.cpp
SOURCES += ../../../src/cpthemeplugin.cpp
SOURCES += ../../../src/cpthemepluginentryitemdata.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
+SOURCES += ../../../src/cpthemelistmodel.cpp
+
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.cpp
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -35,7 +35,7 @@
CpItemDataHelper helper;
CpThemePluginEntryItemData *obj = new CpThemePluginEntryItemData(helper);
-
+
QVERIFY(obj != NULL);
delete obj;
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.pro
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepluginentryitemdata/unittest_cpthemepluginentryitemdata.pro Wed Sep 29 10:09:58 2010 +0800
@@ -34,23 +34,19 @@
# Input
+HEADERS += ../../../src/cpthemeinfo.h
+HEADERS += ../../../src/cpthemeutil.h
+HEADERS += ../../../src/cpthemelistmodel.h
HEADERS += ../../../src/cpthemecontrol.h
HEADERS += ../../../src/cpthemelistview.h
HEADERS += ../../../src/cpthemechanger.h
-HEADERS += ../../../src/cpthemepreview.h
-HEADERS += ../../../src/cpthemechanger_p.h
-HEADERS += ../../../src/cpthemeclient_p.h
-win32::HEADERS += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.h
-symbian::HEADERS += ../../../src/cpthemeclientsymbian_p.h
HEADERS += ../../../src/cpthemepluginentryitemdata.h
SOURCES += unittest_cpthemepluginentryitemdata.cpp
SOURCES += ../../../src/cpthemepluginentryitemdata.cpp
SOURCES += ../../../src/cpthemelistview.cpp
SOURCES += ../../../src/cpthemecontrol.cpp
-SOURCES += ../../../src/cpthemepreview.cpp
SOURCES += ../../../src/cpthemechanger.cpp
-SOURCES += ../../../src/cpthemechanger_p.cpp
-SOURCES += ../../../src/cpthemeclient_p.cpp
-win32::SOURCES += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.cpp
-symbian::SOURCES += ../../../src/cpthemeclientsymbian_p.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
+SOURCES += ../../../src/cpthemelistmodel.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.cpp
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -19,116 +19,54 @@
#include "cpthemepreview.h"
#include "cpthemechanger.h"
+#include "cpthemeutil.h"
class TestCpThemePreview : public QObject
{
Q_OBJECT
private slots:
- void init();
-
- void testConstructor();
- void testConstructor2();
- void testSetThemeName();
- void testSetPreviewIcon();
- void testThemeSelected();
-
- void cleanup();
-
-private:
- CpThemeChanger *mThemeChanger;
+
+ void testAll();
+
};
-void TestCpThemePreview::init()
-{
- mThemeChanger = new CpThemeChanger();
-}
-
-void TestCpThemePreview::cleanup()
+void TestCpThemePreview::testAll()
{
- delete mThemeChanger;
-}
+ QList > themes = CpThemeUtil::availableThemes();
+
+ QPair pair;
+
+ pair = themes.at(0);
+
+ QString name = pair.first;
+ QString themePath = pair.second;
+ CpThemeInfo* themeInfo = CpThemeUtil::buildThemeInfo(themePath, name);
+
+ CpThemePreview *obj = new CpThemePreview(*themeInfo);
+
+
+ QVERIFY (obj != 0 );
+ QCOMPARE(obj->themeName(), name);
+ QCOMPARE(obj->themeIcon(), themeInfo->icon());
-void TestCpThemePreview::testConstructor()
-{
- CpThemePreview *obj = new CpThemePreview();
-
- QVERIFY( obj != 0 );
+ delete themeInfo;
+
+ pair = themes.at(1);
+ name = pair.first;
+ themePath = pair.second;
+ themeInfo = CpThemeUtil::buildThemeInfo(themePath, name);
+
+ obj->setThemeInfo(*themeInfo);
+
+ QCOMPARE(obj->themeName(), name);
+ QCOMPARE(obj->themeIcon(), themeInfo->icon());
+
delete obj;
-}
-void TestCpThemePreview::testConstructor2()
-{
- QList themeInfo = mThemeChanger->themes();
-
- for (int i = 0; i < themeInfo.size(); ++i) {
- QString name = themeInfo.at(i).themeName;
- QString icon = themeInfo.at(i).iconPath;
-
- CpThemePreview *obj = new CpThemePreview(name, icon);
- QVERIFY (obj != 0 );
- QCOMPARE(obj->themeName(), name);
-
- delete obj;
- }
-
- // try with gibberish for the name and/or icon
- QString name = QString("alzihgiaureh");
- QString icon = QString("ahilwvihln");
- CpThemePreview *obj = new CpThemePreview(name);
- QVERIFY(obj != 0);
- delete obj;
-
- obj = new CpThemePreview(name,icon);
- QVERIFY(obj != 0);
- delete obj;
}
-void TestCpThemePreview::testSetThemeName()
-{
- CpThemePreview *obj = new CpThemePreview();
- QList themeInfo = mThemeChanger->themes();
-
- for (int i = 0; i < themeInfo.size(); ++i) {
- QString name = themeInfo.at(i).themeName;
-
- obj->setThemeName(name);
- QCOMPARE(obj->themeName(), name);
- }
-
- delete obj;
-}
-
-// NULL TEST
-void TestCpThemePreview::testSetPreviewIcon()
-{
- CpThemePreview *obj = new CpThemePreview();
- QList themeInfo = mThemeChanger->themes();
-
- for (int i = 0; i < themeInfo.size(); ++i) {
- QString name = themeInfo.at(i).themeName;
-
- obj->setThemeName(name);
- QCOMPARE(obj->themeName(), name);
- }
-
- delete obj;
-}
-
-void TestCpThemePreview::testThemeSelected()
-{
- CpThemePreview *obj = new CpThemePreview();
- QSignalSpy spy(obj,SIGNAL(applyTheme(const QString&)));
-
- obj->themeSelected();
-
- QCOMPARE(spy.count(), 1);
-
- delete obj;
-}
-
-
QTEST_MAIN(TestCpThemePreview)
#include "unittest_cpthemepreview.moc"
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.pro
--- a/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemepreview/unittest_cpthemepreview.pro Wed Sep 29 10:09:58 2010 +0800
@@ -35,15 +35,11 @@
# Input
HEADERS += ../../../src/cpthemepreview.h
-HEADERS += ../../../src/cpthemeclient_p.h
-win32::HEADERS += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.h
-symbian::HEADERS += ../../../src/cpthemeclientsymbian_p.h
+HEADERS += ../../../src/cpthemeinfo.h
+HEADERS += ../../../src/cpthemeutil.h
HEADERS += ../../../src/cpthemechanger.h
-HEADERS += ../../../src/cpthemechanger_p.h
SOURCES += unittest_cpthemepreview.cpp
SOURCES += ../../../src/cpthemepreview.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
SOURCES += ../../../src/cpthemechanger.cpp
-SOURCES += ../../../src/cpthemeclient_p.cpp
-win32::SOURCES += ../../../src/cpplugins/themeplugin/src/cpthemeclientqt_p.cpp
-symbian::SOURCES += ../../../src/cpthemeclientsymbian_p.cpp
-SOURCES += ../../../src/cpthemechanger_p.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0""
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors: XENT-MV
+*
+* Description: unit tests for the CpThemePreview class from themeplugin
+*
+*/
+
+#include
+
+#include
+#include
+#include
+#include
+#include "cpthemeutil.h"
+#include "cpthemeinfo.h"
+
+class TestCpThemeUtil : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+ void testMultiple();
+ void testAvailableThemes();
+ void testThemeDirectories();
+
+};
+
+void TestCpThemeUtil::testMultiple()
+{
+ QList > themes = HbThemeServices::availableThemes();
+
+ QPair pair;
+
+ pair = themes.at(0);
+
+ QString name = pair.first;
+ QString themePath = pair.second;
+
+ QList themeList = CpThemeUtil::buildThemeList();
+
+ QCOMPARE(name, themeList.at(0).name());
+ QCOMPARE(themePath, themeList.at(0).itemData());
+
+ CpThemeInfo *themeInfo = CpThemeUtil::buildThemeInfo(themePath, name);
+ QCOMPARE(name, themeInfo->name());
+ QCOMPARE(themePath, themeInfo->itemData());
+
+
+ //null test, making sure no crash happens.
+ QString defaultThemePath = CpThemeUtil::defaultTheme();
+
+ delete themeInfo;
+ themeInfo = 0;
+
+}
+void TestCpThemeUtil::testAvailableThemes()
+{
+ QList > themes = HbThemeServices::availableThemes();
+ QList > utilThemes = CpThemeUtil::availableThemes();
+
+ for(int i = 0; i < themes.size(); i++) {
+ QPairpair1;
+ QPairpair2;
+
+ pair1 = themes.at(i);
+ pair2 = utilThemes.at(i);
+ QCOMPARE(pair1.first, pair2.first);
+ QCOMPARE(pair1.second, pair2.second);
+ }
+}
+
+void TestCpThemeUtil::testThemeDirectories()
+{
+ QList themeList = CpThemeUtil::buildThemeList();
+ QStringList themeDirs = CpThemeUtil::themeDirectories(themeList);
+ QVERIFY(themeList.size() > 0 && themeDirs.size() > 0);
+}
+
+QTEST_MAIN(TestCpThemeUtil)
+#include "unittest_cpthemeutil.moc"
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.pro Wed Sep 29 10:09:58 2010 +0800
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0".
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors: XENT-MV
+#
+# Description: unit tests for the cpthemeutil class in the themeplugin.
+#
+#
+
+include(../common.pri)
+
+TEMPLATE = app
+TARGET = unittest_cpthemeutil
+DEPENDPATH += .
+win32::DEPENDPATH += c:/ControlPanel/debug/bin
+
+INCLUDEPATH += .
+INCLUDEPATH += src/
+INCLUDEPATH += ../../../src
+
+LIBS += -lcpframework
+win32::LIBS += -LC:/ControlPanel/debug/bin
+
+symbian::TARGET.UID3=0x20031DAE
+
+
+# Input
+
+HEADERS += ../../../src/cpthemeutil.h
+HEADERS += ../../../src/cpthemeinfo.h
+SOURCES += unittest_cpthemeutil.cpp
+SOURCES += ../../../src/cpthemeutil.cpp
+SOURCES += ../../../src/cpthemeinfo.cpp
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/examples/groupplugin/groupplugin.pro
--- a/controlpanelui/examples/groupplugin/groupplugin.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/examples/groupplugin/groupplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -26,3 +26,6 @@
}
+
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/examples/pluginlauncherclient/pluginlauncherclient.pro
--- a/controlpanelui/examples/pluginlauncherclient/pluginlauncherclient.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/examples/pluginlauncherclient/pluginlauncherclient.pro Wed Sep 29 10:09:58 2010 +0800
@@ -36,3 +36,6 @@
LIBS += -lxqservice -lcpframework
symbian::TARGET::UID3 = 0X2002873A
+
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/examples/themeplugin/themeplugin.pro
--- a/controlpanelui/examples/themeplugin/themeplugin.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/examples/themeplugin/themeplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -27,3 +27,6 @@
symbian {
TARGET.UID3 = 0X20025FDB
}
+
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/examples/viewplugin/viewplugin.pro
--- a/controlpanelui/examples/viewplugin/viewplugin.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/examples/viewplugin/viewplugin.pro Wed Sep 29 10:09:58 2010 +0800
@@ -25,3 +25,6 @@
}
+
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/rom/controlpanelui.iby
--- a/controlpanelui/rom/controlpanelui.iby Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/rom/controlpanelui.iby Wed Sep 29 10:09:58 2010 +0800
@@ -40,7 +40,6 @@
file=ABI_DIR\BUILD_DIR\cpcommunicationplugin.dll SHARED_LIB_DIR\cpcommunicationplugin.dll
file=ABI_DIR\BUILD_DIR\cpdeviceplugin.dll SHARED_LIB_DIR\cpdeviceplugin.dll
file=ABI_DIR\BUILD_DIR\cpprivacyplugin.dll SHARED_LIB_DIR\cpprivacyplugin.dll
-file=ABI_DIR\BUILD_DIR\cplookfeelplugin.dll SHARED_LIB_DIR\cplookfeelplugin.dll
file=ABI_DIR\BUILD_DIR\cpkeytouchfdbkplugin.dll SHARED_LIB_DIR\cpkeytouchfdbkplugin.dll
file=ABI_DIR\BUILD_DIR\cpprofileactivator.dll SHARED_LIB_DIR\cpprofileactivator.dll
file=ABI_DIR\BUILD_DIR\cpvolumeplugin.dll SHARED_LIB_DIR\cpvolumeplugin.dll
@@ -51,14 +50,12 @@
data=\epoc32\data\c\resource\qt\plugins\controlpanel\config\cpcommunicationplugin.cpcfg resource\qt\plugins\controlpanel\config\cpcommunicationplugin.cpcfg
data=\epoc32\data\c\resource\qt\plugins\controlpanel\config\cpdeviceplugin.cpcfg resource\qt\plugins\controlpanel\config\cpdeviceplugin.cpcfg
data=\epoc32\data\c\resource\qt\plugins\controlpanel\config\cpprivacyplugin.cpcfg resource\qt\plugins\controlpanel\config\cpprivacyplugin.cpcfg
-data=\epoc32\data\c\resource\qt\plugins\controlpanel\config\cplookfeelplugin.cpcfg resource\qt\plugins\controlpanel\config\cplookfeelplugin.cpcfg
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cppersonalizationplugin.qtplugin resource\qt\plugins\controlpanel\cppersonalizationplugin.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpcommunicationplugin.qtplugin resource\qt\plugins\controlpanel\cpcommunicationplugin.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpdeviceplugin.qtplugin resource\qt\plugins\controlpanel\cpdeviceplugin.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpprivacyplugin.qtplugin resource\qt\plugins\controlpanel\cpprivacyplugin.qtplugin
-data=\epoc32\data\c\resource\qt\plugins\controlpanel\cplookfeelplugin.qtplugin resource\qt\plugins\controlpanel\cplookfeelplugin.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpkeytouchfdbkplugin.qtplugin resource\qt\plugins\controlpanel\cpkeytouchfdbkplugin.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpprofileactivator.qtplugin resource\qt\plugins\controlpanel\cpprofileactivator.qtplugin
data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpvolumeplugin.qtplugin resource\qt\plugins\controlpanel\cpvolumeplugin.qtplugin
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/cpapplication.pro
--- a/controlpanelui/src/cpapplication/cpapplication.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/cpapplication.pro Wed Sep 29 10:09:58 2010 +0800
@@ -26,14 +26,14 @@
RESOURCES += cpapplication.qrc
-LIBS += -lcpframework -lcpcategorymodel
+LIBS += -lcplogger -lcpframework -lcpcategorymodel
TRANSLATIONS = control_panel.ts
symbian: {
- SKINICON = qtg_large_settings
- TARGET.UID3 = 0x20025FD9
- TARGET.EPOCHEAPSIZE = 0x020000 0x1000000
+ SKINICON = qtg_large_settings
+ TARGET.UID3 = 0x20025FD9
+ TARGET.EPOCHEAPSIZE = 0x020000 0x1000000
deploy.path = C:
headers.sources += data/mainview.cpcfg
@@ -41,4 +41,6 @@
DEPLOYMENT += exportheaders
for(header, headers.sources):BLD_INF_RULES.prj_exports += "./$$header $$deploy.path$$headers.path/$$basename(header)"
-}
\ No newline at end of file
+}
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/src/cpmainview.cpp
--- a/controlpanelui/src/cpapplication/src/cpmainview.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/src/cpmainview.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -22,16 +22,28 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
+#include "cpcategorysettingformitemdata.h"
//CpMainView implementation
CpMainView::CpMainView(HbMainWindow *mainWindow/*= 0*/)
: CpBaseSettingView(0,0),
mMainModel(0),
mItemDataHelper(0),
- mMainWindow(mainWindow)
+ mMainWindow(mainWindow),
+ mActivityManager(0)
{
//delay loading
- connect(mMainWindow,SIGNAL(viewReady()),this,SLOT(initializeMainModel()));
+ //connect(mMainWindow,SIGNAL(viewReady()),this,SLOT(initializeMainModel()));
+ // AUTO SAVE ACTIVITY OF CONTROLPANEL
+ HbApplication *app= qobject_cast(qApp);
+ mActivityManager = app->activityManager();
+ initializeMainModel();
+ connect(this, SIGNAL(aboutToClose()),this, SLOT(saveActivity()));
}
CpMainView::~CpMainView()
@@ -56,9 +68,95 @@
mMainModel = new CpMainModel;
mMainModel->initialize(*mItemDataHelper);
form->setModel(mMainModel);
+ connect(form, SIGNAL(activated(QModelIndex)), this, SLOT(onDataFormItemActivated(QModelIndex)));
- connect(form,SIGNAL(activated(QModelIndex)),this,SLOT(onDataFormItemActivated(QModelIndex)));
+ connect(mMainWindow, SIGNAL(aboutToChangeView(HbView *, HbView *)), this, SLOT(onAboutToChangeView(HbView *, HbView *)));
}
}
+ loadActivity();
}
+
+void CpMainView::loadActivity()
+{
+ if (mMainModel == 0) {
+ return;
+ }
+ QVariant data = mActivityManager->activityData(QString("ControlPanelView"));
+ if (data.canConvert >())
+ {
+ QList isExpanded = qvariant_cast >(data);
+ HbDataFormModelItem *root = mMainModel->invisibleRootItem();
+ int groupCount = 0;
+
+ if (root) {
+ groupCount = root->childCount();
+ }
+
+ if (groupCount == isExpanded.count()) {
+ for (int i = 0; i < groupCount; i++) {
+ HbDataFormModelItem *groupItem = root->childAt(i);
+ QModelIndex index = mMainModel->indexFromItem(groupItem);
+ HbDataForm *form = qobject_cast(widget());
+ if (form) {
+ if (isExpanded.at(i).toBool()) {
+ onDataFormItemActivated(index);
+ }
+ form->setExpanded(index,isExpanded.at(i).toBool());
+ }
+ }
+ }
+
+ mActivityManager->removeActivity("ControlPanelView");
+ }
+}
+
+void CpMainView::saveActivity()
+{
+ HbDataFormModelItem *root = mMainModel->invisibleRootItem();
+ int groupCount = 0;
+ QList isExpanded;
+ if (root) {
+ groupCount = root->childCount();
+ }
+ for (int i = 0; i < groupCount; i++) {
+ HbDataFormModelItem *groupItem = root->childAt(i);
+ QModelIndex index = mMainModel->indexFromItem(groupItem);
+ HbDataForm *form = qobject_cast(widget());
+ isExpanded << form->isExpanded(index);
+ }
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ HbView *view = mainWindow->currentView();
+ if(this == view)
+ {
+ mScreenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ }
+
+ QVariantHash metadata;
+ metadata.insert("screenshot", mScreenshot);
+ QVariant data(isExpanded);
+
+ mActivityManager->addActivity("ControlPanelView", data, metadata);
+}
+
+void CpMainView::onDataFormItemActivated(const QModelIndex &index)
+{
+ CPFW_LOG("CpMainView::onDataFormItemActivated");
+ HbDataFormModelItem *modelItem = mMainModel->itemFromIndex(index);
+ if (modelItem != 0 && modelItem->type() == HbDataFormModelItem::GroupItem) {
+ CpSettingFormItemData *itemData = static_cast(modelItem);
+ if (CpCategorySettingFormItemData *categoryItemData = qobject_cast(itemData)) {
+ categoryItemData->initialize(*mItemDataHelper);
+ }
+ }
+
+}
+void CpMainView::onAboutToChangeView(HbView * oldView, HbView *newView)
+{
+ Q_UNUSED(newView);
+ if (this == oldView) {
+ mScreenshot = QPixmap::grabWidget(mMainWindow, mMainWindow->rect());
+ }
+ }
+
// End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/src/cpmainview.h
--- a/controlpanelui/src/cpapplication/src/cpmainview.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/src/cpmainview.h Wed Sep 29 10:09:58 2010 +0800
@@ -24,6 +24,7 @@
class HbDataFormModelItem;
class CpItemDataHelper;
class HbMainWindow;
+class HbActivityManager;
class CpMainView : public CpBaseSettingView
{
@@ -32,14 +33,23 @@
explicit CpMainView(HbMainWindow *mainWindow = 0);
virtual ~CpMainView();
bool event(QEvent *e);
+public slots:
+ void loadActivity();
+ void saveActivity();
private slots:
void initializeMainModel();
+ void onAboutToChangeView(HbView * oldView, HbView *newView);
+ void onDataFormItemActivated(const QModelIndex &index);
private:
Q_DISABLE_COPY(CpMainView)
private:
CpMainModel *mMainModel;
CpItemDataHelper *mItemDataHelper;
HbMainWindow *mMainWindow;
+ // not own
+ HbActivityManager *mActivityManager;
+
+ QPixmap mScreenshot;
};
#endif
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/src/cpmainwindow.cpp
--- a/controlpanelui/src/cpapplication/src/cpmainwindow.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/src/cpmainwindow.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -21,16 +21,26 @@
#include
#include
#include
-
+#include
//CpMainWindow implementation
CpMainWindow::CpMainWindow(QWidget *parent /*= 0*/, Hb::WindowFlags windowFlags /*= Hb::WindowFlagNone*/)
-: HbMainWindow(parent,windowFlags)
+: HbMainWindow(parent,windowFlags),mStartupTimer(0)
{
+ // start a zero interval timer to identify the startup of control panel is finished.
+ mStartupTimer = new QTimer(this);
+ connect(mStartupTimer, SIGNAL(timeout()), this, SLOT(onStartupFininshed()));
+ mStartupTimer->start();
}
CpMainWindow::~CpMainWindow()
{
-
+ CpMainView *mainView = qobject_cast(views().first());
+ if(mainView != 0) {
+ mainView->saveActivity();
+ }
+ if(mStartupTimer != 0) {
+ delete mStartupTimer;
+ }
}
bool CpMainWindow::event(QEvent *e)
@@ -43,6 +53,20 @@
return HbMainWindow::event(e);
}
+/**
+ * Emit applicationReady signal when start up process is finished.
+ */
+void CpMainWindow::onStartupFininshed()
+{
+ // emit applicationReady signal when the all initilizing event has been deal with.
+ // only emit it once
+ emit applicationReady();
+ if (mStartupTimer != 0) {
+ mStartupTimer->stop();
+ delete mStartupTimer;
+ mStartupTimer = 0;
+ }
+}
//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/src/cpmainwindow.h
--- a/controlpanelui/src/cpapplication/src/cpmainwindow.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/src/cpmainwindow.h Wed Sep 29 10:09:58 2010 +0800
@@ -19,7 +19,7 @@
#define CPMAINWINDOW_H
#include
-
+class QTimer;
class CpMainWindow : public HbMainWindow
{
Q_OBJECT
@@ -28,6 +28,16 @@
~CpMainWindow();
public:
virtual bool event(QEvent *e);
+signals:
+ /**
+ * Emit when control panel's startup is finished
+ */
+ void applicationReady();
+private slots:
+ void onStartupFininshed();
+
+private:
+ QTimer *mStartupTimer;
};
#endif // CPMAINWINDOW_H
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpapplication/src/main.cpp
--- a/controlpanelui/src/cpapplication/src/main.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpapplication/src/main.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -19,7 +19,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -35,23 +35,18 @@
QCoreApplication::setApplicationName("ControlPanel");
#ifdef ENABLE_CPFW_LOG
- Logger::instance(CPFW_LOGGER_NAME)->configure(
- CP_LOGGER_CONFIG_PATH,QSettings::IniFormat);
+ INIT_LOGGER(CPFW_LOGGER_NAME,CP_LOGGER_CONFIG_PATH)
#endif
#ifdef ENABLE_CPPERF_LOG
- Logger::instance(CPPERF_LOGGER_NAME)->configure(
- CP_LOGGER_CONFIG_PATH,QSettings::IniFormat);
+ INIT_LOGGER(CPPERF_LOGGER_NAME,CP_LOGGER_CONFIG_PATH)
#endif
CPFW_LOG("Entering ControlPanel.exe...");
CPPERF_LOG("Entering ControlPanel.exe...");
-
- QTranslator translator;
- if (translator.load("control_panel_" + QLocale::system().name(),"Z:/resource/qt/translations"))
- {
- qApp->installTranslator(&translator);
- }
+
+ HbTranslator translator("control_panel");
+ translator.loadCommon();
HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem.css");
HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem_color.css");
@@ -70,8 +65,6 @@
CPFW_LOG("Exiting ControlPanel.exe.");
- Logger::closeAll();
-
return ret;
}
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/cpcategorymodel.pro
--- a/controlpanelui/src/cpcategorymodel/cpcategorymodel.pro Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/cpcategorymodel.pro Wed Sep 29 10:09:58 2010 +0800
@@ -24,10 +24,13 @@
CONFIG += Hb xml
DEFINES += BUILD_CPCATEGORY_GLOBAL
-LIBS += -lcpframework
+LIBS += -lcplogger -lcpframework
symbian: {
TARGET.UID3 = 0X20028736
}
+
+
+symbian:MMP_RULES += SMPSAFE
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: Utility class for cpcategorymodel.
*
*/
#include "cpcategorymodelutility.h"
@@ -110,7 +110,7 @@
event->mPluginFile = pluginConfig.mPluginFile;
//firstly, handle CpPluginInterface
- if (CpPluginInterface *plugin = CpPluginLoader().loadCpPluginInterface(pluginConfig.mPluginFile)) {
+ if (CpPluginInterface *plugin = CpPluginLoader::loadCpPluginInterface(pluginConfig.mPluginFile)) {
CPFW_LOG("Load root component CpPluginInterface succeed.");
event->mPluginInterface = plugin;
}
@@ -164,7 +164,7 @@
QList itemDataList;
//firstly, handle CpPluginInterface
- if (CpPluginInterface *plugin = CpPluginLoader().loadCpPluginInterface(pluginConfig.mPluginFile)) {
+ if (CpPluginInterface *plugin = CpPluginLoader::loadCpPluginInterface(pluginConfig.mPluginFile)) {
CPFW_LOG("Load root component CpPluginInterface succeed.");
itemDataList = plugin->createSettingFormItemData(itemDataHelper);
}
@@ -181,11 +181,11 @@
if (itemData) {
//append the new created setting form item to its parent item.
parent->insertChild(startPosition++,itemData);
-
- if (CpCategorySettingFormItemData *categoryItemData
+ //commented this for only loading group plugin when startup
+ /*if (CpCategorySettingFormItemData *categoryItemData
= qobject_cast(itemData)) {
categoryItemData->initialize(itemDataHelper);
- }
+ }*/
//set the text and description from config if it is empty.
setEntryItemContentIfEmpty(itemData,pluginConfig.mDisplayName,pluginConfig.mDescription);
@@ -212,9 +212,10 @@
if (entryItemData->description().isEmpty()) {
entryItemData->setDescription(description);
}
- if (entryItemData->iconName().isEmpty()) {
- entryItemData->setIconName(
- QLatin1String(":/icon/qgn_prop_set_default_sub.svg") );
+
+ if (entryItemData->type() == static_cast(CpSettingFormEntryItemData::ListEntryItem)
+ && entryItemData->iconName().isEmpty()) {
+ entryItemData->setIconName(DEFAULT_ICON_LISTENTRYITEM);
}
return true;
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.h
--- a/controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpcategorymodelutility.h Wed Sep 29 10:09:58 2010 +0800
@@ -19,6 +19,8 @@
#include
+#define DEFAULT_ICON_LISTENTRYITEM QLatin1String("qtg_large_non_default.nvg")
+
class HbDataFormModelItem;
class CpItemDataHelper;
class CpSettingFormItemData;
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpcategorysettingformitemdata.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cpcategorysettingformitemdata.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpcategorysettingformitemdata.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,13 +11,16 @@
*
* Contributors:
*
-* Description:
+* Description: An extension to CpSettingFormItemData, can be filled with model items comes from controlpanel plugins.
*
*/
#include "cpcategorysettingformitemdata.h"
#include
#include "cpcategorymodelutility.h"
+/*
+ * Private implementation
+ */
class CpCategorySettingFormItemDataPrivate
{
public:
@@ -36,7 +39,9 @@
QString mConfigFile;
};
-
+/*
+ * Constructor
+ */
CpCategorySettingFormItemData::CpCategorySettingFormItemData(
HbDataFormModelItem::DataItemType type,
const QString &label,
@@ -47,6 +52,9 @@
{
}
+/*
+ * Overloaded constructor
+ */
CpCategorySettingFormItemData::CpCategorySettingFormItemData(
const QString &configFile /*= QString()*/,
const HbDataFormModelItem *parent /*= 0*/) :
@@ -55,11 +63,17 @@
{
}
+/*
+ * Desctructor
+ */
CpCategorySettingFormItemData::~CpCategorySettingFormItemData()
{
delete d;
}
+/*
+ * Initialize
+ */
void CpCategorySettingFormItemData::initialize(CpItemDataHelper &itemDataHelper)
{
//avoid to be called twice
@@ -82,12 +96,17 @@
}
}
-
+/*
+ * Derived class can override this function to do some specific work before loading config plugins
+ */
void CpCategorySettingFormItemData::beforeLoadingConfigPlugins(CpItemDataHelper &/*itemDataHelper*/)
{
}
-
+/*
+ * Derived class can override this function to do some specific work before loading config plugins
+ */
void CpCategorySettingFormItemData::afterLoadingConfigPlugins(CpItemDataHelper &/*itemDataHelper*/)
{
}
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpcategorysettingformmodel.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cpcategorysettingformmodel.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpcategorysettingformmodel.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,16 +11,18 @@
*
* Contributors:
*
-* Description:
+* Description: An extension to HbDataFormModel, can be filled with model items comes from controlpanel plugins.
*
*/
#include "cpcategorysettingformmodel.h"
#include
-
#include "cpcategorymodelutility.h"
#include
+/*
+ * Private implementation
+ */
class CpCategorySettingFormModelPrivate
{
public:
@@ -39,16 +41,25 @@
QString mConfigFile;
};
+/*
+ * Constructor
+ */
CpCategorySettingFormModel::CpCategorySettingFormModel(const QString &configFile) :
d (new CpCategorySettingFormModelPrivate(configFile))
{
}
+/*
+ * Destructor
+ */
CpCategorySettingFormModel::~CpCategorySettingFormModel()
{
delete d;
}
+/*
+ * Initialize
+ */
void CpCategorySettingFormModel::initialize(CpItemDataHelper &itemDataHelper)
{
//avoid to be called twice
@@ -70,11 +81,18 @@
}
}
-
+/*
+ * Derived class can override this function to do some specific work before loading config plugins
+ */
void CpCategorySettingFormModel::beforeLoadingConfigPlugins(CpItemDataHelper&/*itemDataHelper*/)
{
}
+/*
+ * Derived class can override this function to do some specific work after loading config plugins
+ */
void CpCategorySettingFormModel::afterLoadingConfigPlugins(CpItemDataHelper &/*itemDataHelper*/)
{
}
+
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: Placeholder for plugin configured in cpcfg file but the target is missing.
*
*/
@@ -64,3 +64,6 @@
{
return 0;
}
+
+//End of File
+
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.h
--- a/controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cpplaceholderitemdata.h Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: Placeholder for plugin configured in cpcfg file but the target is missing.
*
*/
@@ -36,5 +36,6 @@
virtual CpBaseSettingView *createSettingView() const;
};
+#endif //CPPLACEHOLDERITEMDATA_H
-#endif //CPPLACEHOLDERITEMDATA_H
+//End of File
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cppluginconfig.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cppluginconfig.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cppluginconfig.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: An entry for a plugin defined in cpcfg file.
*
*/
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cppluginconfig.h
--- a/controlpanelui/src/cpcategorymodel/src/cppluginconfig.h Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cppluginconfig.h Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: An entry for a controlpanel plugin defined in cpcfg file.
*
*/
@@ -26,9 +26,9 @@
CpPluginConfig();
void dump();
public:
- int mUid;
+ int mUid; //UID3 for the plugin
QString mDisplayName;
- QString mPluginFile;
+ QString mPluginFile;
QString mDescription;
};
diff -r a5692c68d772 -r 593f946f4fec controlpanelui/src/cpcategorymodel/src/cppluginconfigreader.cpp
--- a/controlpanelui/src/cpcategorymodel/src/cppluginconfigreader.cpp Fri Jun 25 17:12:20 2010 +0800
+++ b/controlpanelui/src/cpcategorymodel/src/cppluginconfigreader.cpp Wed Sep 29 10:09:58 2010 +0800
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description: This class reads cpcfg files.
*
*/
@@ -27,19 +27,30 @@
const QString PLUGIN_DISPALYNAME_ATTR = "displayname";
const QString DESC_TAG = "desc";
+/*
+ * Constructor.
+ * @configPath : the full path of the config file.
+ */
CpPluginConfigReader::CpPluginConfigReader(const QString &configPath)
: mConfigPath (configPath)
{
}
+/*
+ * Desctructor
+ */
CpPluginConfigReader::~CpPluginConfigReader()
{
}
+/*
+ * Reads a cpcfg file, returns a list of CpPluginConfig.
+ */
QList