# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1276252757 -10800 # Node ID 4a9568303383e8c60ca87a03ca648538a5674c8a # Parent cc79acdc26cbb85819b1f988710cda6529ad8b84 Revision: 201021 Kit: 2010123 diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemechanger.cpp --- a/controlpanelplugins/themeplugin/src/cpthemechanger.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemechanger.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -17,10 +17,10 @@ #include "cpthemechanger.h" #include "cpthemechanger_p.h" +#include "cpthemelistmodel.h" /*! @alpha - @hbcore \class CpThemeChanger \brief CpThemeChanger provides an interface for changing the current @@ -46,8 +46,8 @@ QAbstractItemModel& CpThemeChanger::model() { Q_D(CpThemeChanger); - - return d->model; + + return d->mModel; } @@ -83,13 +83,17 @@ const CpThemeChanger::ThemeInfo& CpThemeChanger::currentTheme() const { Q_D(const CpThemeChanger); - + return d->currentTheme(); } +/* + * Returns index of theme from the theme list (not the model). + */ int CpThemeChanger::indexOf(const ThemeInfo& theme) const { Q_D(const CpThemeChanger); + return d->indexOf(theme); } diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemechanger.h --- a/controlpanelplugins/themeplugin/src/cpthemechanger.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemechanger.h Fri Jun 11 13:39:17 2010 +0300 @@ -19,6 +19,7 @@ #define CPTHEMECHANGER_H #include + #include #include @@ -36,8 +37,12 @@ explicit CpThemeChanger(QObject* parent=0); ~CpThemeChanger(); - struct ThemeInfo - { + enum ThemeListUserRole { + PortraitPreviewRole = Qt::UserRole, + LandscapePreviewRole + }; + + struct ThemeInfo{ QString name; HbIcon icon; HbIcon portraitPreviewIcon; @@ -50,11 +55,6 @@ } }; - enum ThemeListUserRole { - PortraitPreviewRole = Qt::UserRole, - LandscapePreviewRole - }; - QAbstractItemModel& model(); const ThemeInfo& currentTheme() const; diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemechanger_p.cpp --- a/controlpanelplugins/themeplugin/src/cpthemechanger_p.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemechanger_p.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -17,35 +17,45 @@ #include "cpthemechanger.h" #include "cpthemechanger_p.h" +#include "cpthemelistmodel.h" +#include "cpthemeclient_p.h" +#include "cpthemecommon_p.h" + #include #include #include #include -#include +#include +#include + #include #include -#include "cpthemeclient_p.h" -#include "cpthemecommon_p.h" -#ifdef Q_OS_SYMBIAN -#include "cpthemeclientsymbian_p.h" -#else -#include "cpthemeclientqt_p.h" -#endif -namespace { + #if !defined(Q_OS_SYMBIAN) #include static const char* KThemePathKey = "HB_THEMES_DIR"; #endif - - static const QString KDefaultTheme = "hbdefault"; -} + static const QString KDefaultTheme = "sfblacktheme"; + + static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg"; + + 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 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"; + + CpThemeChangerPrivate::CpThemeChangerPrivate(CpThemeChanger* qq): q_ptr(qq), - themeClient(CpThemeClient::global()), - fileWatcher(new QFileSystemWatcher(qq)), - model(this, qq) + mThemeClient(CpThemeClient::global()), + mFileWatcher(new QFileSystemWatcher(qq)), + mModel(this, qq) { Q_Q(CpThemeChanger); @@ -53,26 +63,26 @@ // Figure out where our themes are. This is platform-dependent, // but not worth breaking out into platform-private implementations // at the moment. Ideally, this would be given to us by the theme server, - #ifdef Q_OS_WIN - static char* _path=NULL; - static size_t _size=0; +#ifdef Q_OS_WIN + static char* _path = NULL; + static size_t _size = 0; _dupenv_s(&_path, &_size, KThemePathKey); - themeRootPath = QString(_path); - themeRootPathPostfix = QString(); + mThemeRootPath = QString(_path); + mThemeRootPathPostfix = QString(); free(_path); - #elif defined(Q_OS_SYMBIAN) - themeRootPath = "c:\\resource\\hb"; - themeRootPathPostfix = "resource\\hb"; - #elif defined(Q_OS_UNIX) - themeRootPath = QString(getenv(KThemePathKey)); - themeRootPathPostfix = QString(); - #elif defined(Q_OS_MACX) - themeRootPath = QDir::homePath() + '/' + "Library" + QString("hb"); - themeRootPathPostfix = QString(); - #else - themeRootPath = "c:\\resource\\hb"; - themeRootPathPostfix = QString(); - #endif +#elif defined(Q_OS_SYMBIAN) + mThemeRootPath = "c:\\resource\\hb"; + mThemeRootPathPostfix = "resource\\hb"; +#elif defined(Q_OS_MACX) + mThemeRootPath = QDir::homePath() + '/' + "Library" + QString("hb"); + mThemeRootPathPostfix = QString(); +#elif defined(Q_OS_UNIX) + mThemeRootPath = QString(getenv(KThemePathKey)); + mThemeRootPathPostfix = QString(); +#else + mThemeRootPath = "c:\\resource\\hb"; + mThemeRootPathPostfix = QString(); +#endif // Get our current state if (HbInstance::instance()) { @@ -81,21 +91,40 @@ mCurrentTheme.name = hbTheme->name(); } } - updateThemeList(mCurrentTheme.name); - + // Watch for changes to the theme directory in flash. // This may change once we start offering a model. - fileWatcher->addPath(themeRootPath+"/themes/"); - q->connect(fileWatcher, SIGNAL(directoryChanged(const QString&)), +#if defined(Q_OS_SYMBIAN) + QFileInfoList driveInfoList = QDir::drives(); + foreach (const QFileInfo &driveInfo, driveInfoList) { + const QString drive = driveInfo.absolutePath(); + mThemesPathList << drive + mThemeRootPathPostfix; + } +#else + mThemesPathList << mThemeRootPath; +#endif + foreach (const QString &path, mThemesPathList) { + 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/"); + } + } + + q->connect(mFileWatcher, SIGNAL(directoryChanged(const QString&)), q, SLOT(_q_themeDirectoryChanged(const QString&))); + updateThemeList(mCurrentTheme.name); + // Connect to the theme server connectToServer(); } CpThemeChangerPrivate::~CpThemeChangerPrivate() { - themeClient->releaseInstance(); + mThemeClient->releaseInstance(); + mThemeClient = 0; } const CpThemeChanger::ThemeInfo& CpThemeChangerPrivate::currentTheme() const @@ -110,50 +139,33 @@ int CpThemeChangerPrivate::indexOf(const CpThemeChanger::ThemeInfo& theme) const { - return themeList.indexOf(theme); + return mThemeList.indexOf(theme); } void CpThemeChangerPrivate::updateThemeList(const QString& newThemeName) { - if(!themeList.isEmpty()) { - themeList.clear(); + if(!mThemeList.isEmpty()) { + mThemeList.clear(); } mCurrentTheme.name = newThemeName.isEmpty() ? KDefaultTheme : newThemeName; - // Get the list of Drives here - QStringList themesPathList; - -#if defined(Q_OS_WIN32) - themesPathList << themeRootPath; -#elif defined(Q_OS_SYMBIAN) - QFileInfoList driveInfoList = QDir::drives(); - foreach (const QFileInfo &driveInfo, driveInfoList) { - const QString drive = driveInfo.absolutePath(); - themesPathList << drive + themeRootPathPostfix; - } -#elif defined(Q_OS_UNIX) - themesPathList << themeRootPath; -#elif defined(Q_OS_MACX) - themesPathList << themeRootPath; -#endif - - foreach (const QString &path, themesPathList) { + foreach (const QString &path, mThemesPathList) { QDir themeDir; themeDir.setPath( path ) ; QStringList iconthemeslist; QStringList list = themeDir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name); CpThemeChanger::ThemeInfo nameIconPair; - if(list.contains("themes",Qt::CaseSensitive )) { + 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); + 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); + QDir iconThemePath(root.path() + "/themes/icons/" + themefolder); if(iconThemePath.exists("index.theme") && (iconThemePath.exists("scalable") || iconThemePath.exists("pixmap") )) { - QSettings iniSetting(iconThemePath.path()+"/index.theme",QSettings::IniFormat); + QSettings iniSetting(iconThemePath.path() + "/index.theme", QSettings::IniFormat); iniSetting.beginGroup("Icon Theme"); QString hidden = iniSetting.value("Hidden").toString(); QString name = iniSetting.value("Name").toString(); @@ -167,22 +179,13 @@ QString fullPathToIcon(iconThemePath.path() + iconPath); if(iconPath.isEmpty()|| !QFileInfo(fullPathToIcon).exists()){ - - //Set thumbnail - if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg").exists()){ - nameIconPair.icon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg"); - }else if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ - QPixmap px(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); - QIcon scaledIcon(px.scaled(QSize(64, 64))); - nameIconPair.icon = HbIcon(scaledIcon); - nameIconPair.icon.setIconName(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); - - } else if(QFileInfo(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ - QPixmap px(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png"); - QIcon scaledIcon(px.scaled(QSize(64, 64))); - nameIconPair.icon = HbIcon(scaledIcon); - nameIconPair.icon.setIconName(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.png"); - + //Set thumbnail + if(QFileInfo(fullPathToIcon + KPreviewThumbnailSVG).exists()){ + nameIconPair.icon = HbIcon(fullPathToIcon + KPreviewThumbnailSVG); + }else if(QFileInfo(fullPathToIcon + KBackgroundPrtSVG).exists()){ + nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtSVG); + } else if(QFileInfo(fullPathToIcon + KBackgroundPrtPNG).exists()){ + nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtPNG); } else{ nameIconPair.icon = HbIcon(":/image/themePreview.svg"); } @@ -195,12 +198,12 @@ if(previewPathPrt.isEmpty() || !QFileInfo(fullPathToPreviewPrt).exists()) { - if(QFileInfo(fullPathToPreviewPrt + "/scalable/qtg_graf_theme_preview_prt.svg").exists()){ - nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/scalable/qtg_graf_theme_preview_prt.svg"); - }else if(QFileInfo(fullPathToPreviewPrt + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ - nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/scalable/qtg_graf_screen_bg_prt.svg"); - } else if(QFileInfo(fullPathToPreviewPrt + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ - nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/pixmap/qtg_graf_screen_bg_prt.png"); + if(QFileInfo(fullPathToPreviewPrt + KPreviewPrtSVG).exists()){ + nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KPreviewPrtSVG); + }else if(QFileInfo(fullPathToPreviewPrt + KBackgroundPrtSVG).exists()){ + nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KBackgroundPrtSVG); + } else if(QFileInfo(fullPathToPreviewPrt + KBackgroundPrtPNG).exists()){ + nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KBackgroundPrtPNG); } else{ nameIconPair.portraitPreviewIcon = HbIcon(":/image/themePreview.svg"); } @@ -214,12 +217,12 @@ if(previewPathLsc.isEmpty() || !QFileInfo(fullPathToPreviewLsc).exists()) { - if(QFileInfo(fullPathToPreviewLsc + "/scalable/qtg_graf_theme_preview_lsc.svg").exists()){ - nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/scalable/qtg_graf_theme_preview_lsc.svg"); - }else if(QFileInfo(fullPathToPreviewLsc + "/scalable/qtg_graf_screen_bg_lsc.svg").exists()){ - nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/scalable/qtg_graf_screen_bg_lsc.svg"); - } else if(QFileInfo(fullPathToPreviewLsc + "/pixmap/qtg_graf_screen_bg_lsc.png").exists()){ - nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/pixmap/qtg_graf_screen_bg_lsc.png"); + if(QFileInfo(fullPathToPreviewLsc + KPreviewLscSVG).exists()){ + nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KPreviewLscSVG); + }else if(QFileInfo(fullPathToPreviewLsc + KBackgroundLscSVG).exists()){ + nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KBackgroundLscSVG); + } else if(QFileInfo(fullPathToPreviewLsc + KBackgroundLscPNG).exists()){ + nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KBackgroundLscPNG); } else{ nameIconPair.landscapePreviewIcon = HbIcon(":/image/themePreview.svg"); } @@ -230,23 +233,23 @@ nameIconPair.name = name; - themeList.append(nameIconPair); + mThemeList.append(nameIconPair); if (name == mCurrentTheme.name) { mCurrentTheme = nameIconPair; } iniSetting.endGroup(); - if((hidden == "true") ||( hidden == "")||(name!=themefolder) ) { + if((hidden == "true") ||( hidden == "")||(name != themefolder) ) { iconthemeslist.removeOne(themefolder); - if(!themeList.isEmpty()) { - themeList.removeLast(); + if(!mThemeList.isEmpty()) { + mThemeList.removeLast(); } } } else { iconthemeslist.removeOne(themefolder); - if(!themeList.isEmpty()) { - themeList.removeLast(); + if(!mThemeList.isEmpty()) { + mThemeList.removeLast(); } } } @@ -259,7 +262,7 @@ CpThemeChanger::ThemeInfo def; def.name = KDefaultTheme; def.icon = HbIcon(":/image/themePreview.svg"); - themeList.append(def); + mThemeList.append(def); mCurrentTheme = def; } @@ -268,12 +271,12 @@ const QList& CpThemeChangerPrivate::themes() const { - return themeList; + return mThemeList; } bool CpThemeChangerPrivate::connectToServer() { - return themeClient->connectToServer(); + return mThemeClient->connectToServer(); } /** @@ -281,7 +284,7 @@ */ bool CpThemeChangerPrivate::isConnected() const { - return themeClient->isConnected(); + return mThemeClient->isConnected(); } /** @@ -291,13 +294,14 @@ { bool result = false; // Skip doing this if the request is for the current theme - if (newTheme.isEmpty() || newTheme == mCurrentTheme.name) return result; + if (newTheme.isEmpty() || newTheme == mCurrentTheme.name) { + return result; + } - // Make sure it's a valid theme name + // Make sure it's a valid theme name and set the current theme. bool exists = false; - QList themeList = themes(); QList::const_iterator i; - for (i = themeList.constBegin(); i != themeList.constEnd(); ++i) { + for (i = mThemeList.constBegin(); i != mThemeList.constEnd(); ++i) { if ( newTheme == i->name) { exists = true; break; @@ -305,8 +309,10 @@ } if (exists) { - result = themeClient->changeTheme(newTheme); - updateThemeList(newTheme); + result = mThemeClient->changeTheme(newTheme); + if(result) { + mCurrentTheme = *i; + } } return result; } @@ -316,88 +322,6 @@ updateThemeList(); } -/* - HbThemeChangerModel provides an interface to the data contained in the - HbThemeChanger using QAbstractListModel. -*/ -/* - Constructor -*/ -HbThemeListModel::HbThemeListModel(CpThemeChangerPrivate *dd, QObject* parent) - : QAbstractListModel(parent) - , mThemeChangerPrivate(dd) -{ - connect(dd->fileWatcher, SIGNAL(directoryChanged(const QString&)), - this, SLOT(themeListChanged())); -} - -/* - Destructor -*/ -HbThemeListModel::~HbThemeListModel() -{ - -} - -/* - Reimplemented from QAbstractListModel. -*/ -int HbThemeListModel::rowCount(const QModelIndex&) const -{ - return mThemeChangerPrivate->themeList.size(); -} - -/* - Reimplemented from QAbstractListModel. Provides the data for Qt::DisplayRole and - Qt::DecorationRole. -*/ -QVariant HbThemeListModel::data(const QModelIndex& index, int role) const -{ - QVariant retVal = QVariant(); - - if (index.isValid()) { - switch (role) { - case Qt::DisplayRole: - retVal = mThemeChangerPrivate->themeList.at(index.row()).name; - break; - - case Qt::DecorationRole: - retVal = mThemeChangerPrivate->themeList.at(index.row()).icon; - break; - - case Qt::SizeHintRole: - retVal = mThemeChangerPrivate->themeList.at(index.row()).icon.size(); - break; - case CpThemeChanger::PortraitPreviewRole: - retVal = mThemeChangerPrivate->themeList.at(index.row()).portraitPreviewIcon; - break; - case CpThemeChanger::LandscapePreviewRole: - retVal = mThemeChangerPrivate->themeList.at(index.row()).landscapePreviewIcon; - - default: - // do nothing - qt_noop(); - } - } - - return retVal; -} - -/* - Responds appropriately when the underlying data in the theme changer is modified. - - Unfortunately the directory watcher from QFileWatcher only says when something changed - not what changed. Therefore the model is considered reset rather than having rows - with dataChanged. -*/ -void HbThemeListModel::themeListChanged() -{ - beginResetModel(); - - mThemeChangerPrivate->themes(); - - endResetModel(); -} // End of file diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemechanger_p.h --- a/controlpanelplugins/themeplugin/src/cpthemechanger_p.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemechanger_p.h Fri Jun 11 13:39:17 2010 +0300 @@ -22,39 +22,17 @@ #include -#include -#include -#include -#include -#include - #include "cpthemechanger.h" +#include "cpthemelistmodel.h" QT_BEGIN_NAMESPACE +class QString; +class QStringList; class QFileSystemWatcher; QT_END_NAMESPACE class CpThemeClient; -class HbThemeListModel : public QAbstractListModel -{ - Q_OBJECT - -public: - - HbThemeListModel(CpThemeChangerPrivate* dd, QObject *parent = 0); - virtual ~HbThemeListModel(); - - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; - -public slots: - void themeListChanged(); - -private: - CpThemeChangerPrivate *mThemeChangerPrivate; -}; - class CpThemeChangerPrivate { CpThemeChanger* q_ptr; @@ -80,14 +58,15 @@ CpThemeChanger::ThemeInfo mCurrentTheme; - QString themeRootPath; - QString themeRootPathPostfix; + QString mThemeRootPath; + QString mThemeRootPathPostfix; + QStringList mThemesPathList; - CpThemeClient* themeClient; - QFileSystemWatcher* fileWatcher; - QList themeList; - HbThemeListModel model; - friend class HbThemeChangerModel; + CpThemeClient* mThemeClient; + QFileSystemWatcher* mFileWatcher; + QList mThemeList; + CpThemeListModel mModel; + friend class CpThemeListModel; }; #endif /* HBTHEMECHANGER_P_H */ diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclient_p.cpp --- a/controlpanelplugins/themeplugin/src/cpthemeclient_p.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemeclient_p.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -16,12 +16,7 @@ */ #include "cpthemeclient_p.h" - -#ifdef Q_OS_SYMBIAN -#include "cpthemeclientsymbian_p.h" -#else -#include "cpthemeclientqt_p.h" -#endif +#include "cpthemeclient_p_p.h" static CpThemeClient *clientInst=0; @@ -39,12 +34,14 @@ bool CpThemeClient::connectToServer() { Q_D(CpThemeClient); + return d->connectToServer(); } bool CpThemeClient::isConnected() { - Q_D(CpThemeClient); + Q_D(const CpThemeClient); + return d->isConnected(); } @@ -54,22 +51,20 @@ bool CpThemeClient::changeTheme(const QString& newtheme) { Q_D(CpThemeClient); + return d->changeTheme(newtheme); } - - /** * CpThemeClient::~CpThemeClient() */ CpThemeClient::~CpThemeClient() { Q_D(CpThemeClient); + delete d; } - - /** * CpThemeClient::global() */ diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclient_p.h --- a/controlpanelplugins/themeplugin/src/cpthemeclient_p.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemeclient_p.h Fri Jun 11 13:39:17 2010 +0300 @@ -19,8 +19,6 @@ #define CPTHEMECLIENT_P_H #include -#include - class CpThemeClientPrivate; diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclient_p_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelplugins/themeplugin/src/cpthemeclient_p_p.h Fri Jun 11 13:39:17 2010 +0300 @@ -0,0 +1,74 @@ +/* + * 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 CPTHEMECLIENT_P_P_H +#define CPTHEMECLIENT_P_P_H + +#include +#include "cpthemecommon_p.h" + +#ifdef Q_OS_SYMBIAN +#include +#endif + +class QSizeF; +#ifndef Q_OS_SYMBIAN +class QLocalSocket; +#endif + +class CpThemeClientPrivate : +#ifdef Q_OS_SYMBIAN +public RSessionBase +#else +public QObject +#endif +{ +#ifndef Q_OS_SYMBIAN + Q_OBJECT +#endif + +public: + CpThemeClientPrivate(); + bool connectToServer(); + bool isConnected() const; + bool changeTheme(const QString& newTheme); + ~CpThemeClientPrivate(); + +#ifndef Q_OS_SYMBIAN +public slots: + void changeTheme(); +#endif + +public: + bool clientConnected; + +private: +#ifdef Q_OS_SYMBIAN + TVersion Version() const; + TInt StartServer(); + TInt CreateServerProcess(); +#endif + +private: +#ifdef Q_OS_SYMBIAN + friend class CThemeListenerPrivate; +#else + QLocalSocket* localSocket; +#endif +}; + +#endif // HBTHEMECLIENT_P_P_H diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclientqt_p.cpp --- a/controlpanelplugins/themeplugin/src/cpthemeclientqt_p.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemeclientqt_p.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -15,7 +15,7 @@ * */ -#include "cpthemeclientqt_p.h" +#include "cpthemeclient_p_p.h" #include #include #include @@ -28,8 +28,6 @@ #define WAIT_TIME_TO_CONNECT_TO_SERVER 500 #define WAIT_TIME_TO_START_SERVER 5000 -//static const QString SERVERFILEPATH = QLatin1String(HB_BIN_DIR) + QDir::separator() + QLatin1String("hbthemeserver"); - /** * Constructor */ @@ -87,7 +85,7 @@ /** * isConnected */ -bool CpThemeClientPrivate::isConnected() +bool CpThemeClientPrivate::isConnected() const { return clientConnected; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclientqt_p.h --- a/controlpanelplugins/themeplugin/src/cpthemeclientqt_p.h Thu May 27 12:52:25 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * 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 CPTHEMECLIENTQT_P_H -#define CPTHEMECLIENTQT_P_H - -#include -#include "cpthemecommon_p.h" - -class QString; -class QSizeF; -class QLocalSocket; - -class CpThemeClientPrivate : public QObject -{ - Q_OBJECT - -public: - CpThemeClientPrivate(); - bool connectToServer(); - bool isConnected(); - - bool changeTheme(const QString& newtheme); - - ~CpThemeClientPrivate(); - -public slots: - void themeChanged(); - -public: - bool clientConnected; - -private: - void handleThemeChangeRequest(QDataStream &dataStream); - -private: - QLocalSocket* localSocket; - QString themeName; -}; - -#endif // HBTHEMECLIENTQT_P_H diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclientsymbian_p.cpp --- a/controlpanelplugins/themeplugin/src/cpthemeclientsymbian_p.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemeclientsymbian_p.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -15,7 +15,7 @@ * */ -#include "cpthemeclientsymbian_p.h" +#include "cpthemeclient_p_p.h" #include "cpthemesymbiancommon_p.h" #include @@ -40,7 +40,7 @@ /** Indicates a connection to the server */ -bool CpThemeClientPrivate::isConnected() +bool CpThemeClientPrivate::isConnected() const { return true; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemeclientsymbian_p.h --- a/controlpanelplugins/themeplugin/src/cpthemeclientsymbian_p.h Thu May 27 12:52:25 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * 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 CPTHEMECLIENTSYMBIAN_P_H -#define CPTHEMECLIENTSYMBIAN_P_H - -#include -#if !defined(__E32BASE_H__) -#include -#endif - -class CpThemeClientPrivate -{ -public: - CpThemeClientPrivate(); - - bool connectToServer(); - - bool changeTheme(const QString& newtheme); - - bool isConnected(); - - ~CpThemeClientPrivate(); -}; - -#endif /* CPTHEMECLIENTSYMBIAN_P_H */ diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemecontrol.cpp --- a/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -30,11 +30,8 @@ #include #include -#include -#include #include #include -#include #include #include @@ -142,8 +139,9 @@ CpBaseSettingView* CpThemeControl::themeListView() { //If the view was removed before by control panel app, create it again. - if(!mThemeListView) + if(!mThemeListView) { createThemeList(); + } return mThemeListView; } @@ -248,6 +246,7 @@ triggerThemeListClose(); } + /*! Slot called when the theme preview view is closed. */ @@ -289,15 +288,13 @@ void CpThemeControl::themeChangeTimeout() { - //qDebug() << "ThemeChangeTimeout " ; mIdleTimer->stop(); - QThread::currentThread()->setPriority(QThread::NormalPriority); + QThread::currentThread()->setPriority(QThread::NormalPriority); } void CpThemeControl::themeChangeFinished() { - //qDebug() << "ThemeChangeFinished " ; mIdleTimer->start(0); } diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemelistmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelplugins/themeplugin/src/cpthemelistmodel.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -0,0 +1,108 @@ +/* + * ============================================================================ + * Name : cpthemelistmodel_p.cpp + * Part of : LibHb / theme + * Description : Private implementation of the theme listmodel. + * Version : %version: 1 % << Don't touch! Updated by Synergy at check-out. + * + * Copyright (c) 2008-2009 Nokia. All rights reserved. + * This material, including documentation and any related computer + * programs, is protected by copyright controlled by Nokia. All + * rights are reserved. Copying, including reproducing, storing, + * adapting or translating, any or all of this material requires the + * prior written consent of Nokia. This material also contains + * confidential information which may not be disclosed to others + * without the prior written consent of Nokia. + * ============================================================================ + */ + +#include "cpthemelistmodel.h" +#include "cpthemechanger_p.h" +#include + +/* + CpThemeChangerModel provides an interface to the data contained in the + CpThemeChanger using QAbstractListModel. +*/ + +/* + Constructor +*/ +CpThemeListModel::CpThemeListModel(CpThemeChangerPrivate *dd, QObject* parent) + : QAbstractListModel(parent) + , mThemeChangerPrivate(dd) +{ + connect(dd->mFileWatcher, SIGNAL(directoryChanged(const QString&)), + this, SLOT(themeListChanged())); +} + +/* + Destructor +*/ +CpThemeListModel::~CpThemeListModel() +{ + +} + +/* + Reimplemented from QAbstractListModel. +*/ +int CpThemeListModel::rowCount(const QModelIndex&) const +{ + return mThemeChangerPrivate->mThemeList.size(); +} + +/* + Reimplemented from QAbstractListModel. Provides the data for Qt::DisplayRole and + Qt::DecorationRole. +*/ +QVariant CpThemeListModel::data(const QModelIndex& index, int role) const +{ + QVariant retVal = QVariant(); + + if (index.isValid()) { + switch (role) { + case Qt::DisplayRole: + retVal = mThemeChangerPrivate->mThemeList.at(index.row()).name; + break; + + case Qt::DecorationRole: + retVal = mThemeChangerPrivate->mThemeList.at(index.row()).icon; + break; + + case Qt::SizeHintRole: + retVal = mThemeChangerPrivate->mThemeList.at(index.row()).icon.size(); + break; + + case CpThemeChanger::PortraitPreviewRole: + retVal = mThemeChangerPrivate->mThemeList.at(index.row()).portraitPreviewIcon; + break; + + case CpThemeChanger::LandscapePreviewRole: + retVal = mThemeChangerPrivate->mThemeList.at(index.row()).landscapePreviewIcon; + break; + + default: + // do nothing + qt_noop(); + } + } + + return retVal; +} + +/* + Responds appropriately when the underlying data in the theme changer is modified. + + Unfortunately the directory watcher from QFileWatcher only says when something changed + not what changed. Therefore the model is considered reset rather than having rows + with dataChanged. +*/ +void CpThemeListModel::themeListChanged() +{ + beginResetModel(); + + mThemeChangerPrivate->themes(); + + endResetModel(); +} diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemelistmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelplugins/themeplugin/src/cpthemelistmodel.h Fri Jun 11 13:39:17 2010 +0300 @@ -0,0 +1,46 @@ +/* +* ============================================================================ +* Name : cpthemelistmodel_p.h +* Part of : LibHb / theme +* Description : CpThemeListModel class definition +* Version : %version: 1 % << Don't touch! Updated by Synergy at check-out. +* +* Copyright (c) 2008-2009 Nokia. All rights reserved. +* This material, including documentation and any related computer +* programs, is protected by copyright controlled by Nokia. All +* rights are reserved. Copying, including reproducing, storing, +* adapting or translating, any or all of this material requires the +* prior written consent of Nokia. This material also contains +* confidential information which may not be disclosed to others +* without the prior written consent of Nokia. +* ============================================================================ +*/ + +#ifndef CP_THEME_LIST_MODEL_P_H +#define CP_THEME_LIST_MODEL_P_H + +#include +#include +#include + +class CpThemeChangerPrivate; + +class CpThemeListModel : public QAbstractListModel +{ + Q_OBJECT + +public: + CpThemeListModel(CpThemeChangerPrivate* dd, QObject *parent = 0); + virtual ~CpThemeListModel(); + + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + +public slots: + void themeListChanged(); + +private: + CpThemeChangerPrivate *mThemeChangerPrivate; +}; + +#endif //CP_THEME_LIST_MODEL_P_H diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/src/cpthemepreview.cpp --- a/controlpanelplugins/themeplugin/src/cpthemepreview.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemepreview.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -18,7 +18,7 @@ #include #include #include -#include + #include #include #include @@ -52,12 +52,10 @@ //setup the heading. //TODO: translation of string hbTrId("txt_cp_title_preview_1") - QString themeHeading = tr("Preview: ") + mTheme.name; HbLabel* label = new HbLabel(themeHeading, this); label->setFontSpec(HbFontSpec(HbFontSpec::Primary)); - label->setPreferredHeight(5.0); layout->addItem(label); layout->setAlignment(layout->itemAt(0), Qt::AlignTop); @@ -90,8 +88,7 @@ mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this); } layout->addItem(mPreviewIcon); - layout->setAlignment(layout->itemAt(0), Qt::AlignTop); - + setToolBar(mToolBar); setLayout(layout); @@ -101,7 +98,7 @@ QObject::connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SIGNAL(aboutToClose()) ); - this->setNavigationAction(mSoftKeyBackAction); + setNavigationAction(mSoftKeyBackAction); } /*! @@ -152,16 +149,14 @@ QGraphicsLinearLayout* previewLayout = dynamic_cast(layout()); - if(mPreviewIcon == dynamic_cast(previewLayout->itemAt(1)) ) { + if(mPreviewIcon && mPreviewIcon == dynamic_cast(previewLayout->itemAt(1)) ) { previewLayout->removeAt(1); - delete mPreviewIcon; - mPreviewIcon = 0; if(orientation == Qt::Horizontal) { - mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon, this); + mPreviewIcon->setIcon(mTheme.landscapePreviewIcon); } else { - mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this); + mPreviewIcon->setIcon(mTheme.portraitPreviewIcon); } previewLayout->addItem(mPreviewIcon); diff -r cc79acdc26cb -r 4a9568303383 controlpanelplugins/themeplugin/themeplugin.pri --- a/controlpanelplugins/themeplugin/themeplugin.pri Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelplugins/themeplugin/themeplugin.pri Fri Jun 11 13:39:17 2010 +0300 @@ -1,52 +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: -# # Description: cpthemeplugin source files -# - # Input -HEADERS += src/cpthemepreview.h \ - src/cpthemecontrol.h \ - src/cpthemeplugin.h \ - src/cpthemelistview.h \ - src/cpthemepluginentryitemdata.h +HEADERS += src/cpthemeclient_p_p.h \ + src/cpthemepreview.h \ + src/cpthemecontrol.h \ + src/cpthemeplugin.h \ + src/cpthemelistview.h \ + src/cpthemelistmodel.h \ + src/cpthemechanger.h \ + src/cpthemeclient_p.h \ + src/cpthemecommon_p.h \ + src/cpthemechanger_p.h \ + src/cpthemepluginentryitemdata.h SOURCES += src/cpthemepreview.cpp \ - src/cpthemecontrol.cpp \ - src/cpthemeplugin.cpp \ - src/cpthemelistview.cpp \ - src/cpthemepluginentryitemdata.cpp - -# Remove once this goes into Hb. -HEADERS += src/cpthemechanger.h \ - src/cpthemeclient_p.h \ - src/cpthemecommon_p.h \ - src/cpthemechanger_p.h - -# Remove once this goes into Hb. -SOURCES += src/cpthemechanger.cpp \ - src/cpthemechanger_p.cpp \ - src/cpthemeclient_p.cpp - -# Remove once this goes into Hb. -win32|mac { - HEADERS += src/cpthemeclientqt_p.h + src/cpthemecontrol.cpp \ + src/cpthemeplugin.cpp \ + src/cpthemelistview.cpp \ + src/cpthemelistmodel.cpp \ + src/cpthemepluginentryitemdata.cpp \ + src/cpthemechanger.cpp \ + src/cpthemechanger_p.cpp \ + src/cpthemeclient_p.cpp + +win32|mac { SOURCES += src/cpthemeclientqt_p.cpp } -# Remove once this goes into Hb. -symbian { - HEADERS += src/cpthemeclientsymbian_p.h \ - src/cpthemesymbiancommon_p.h +symbian { + HEADERS += src/cpthemesymbiancommon_p.h SOURCES += src/cpthemeclientsymbian_p.cpp } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/rom/controlpanelui.iby --- a/controlpanelui/rom/controlpanelui.iby Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/rom/controlpanelui.iby Fri Jun 11 13:39:17 2010 +0300 @@ -26,11 +26,11 @@ file=ABI_DIR\BUILD_DIR\controlpanel.exe SHARED_LIB_DIR\controlpanel.exe CP_UPGRADABLE_APP_REG_RSC(controlpanel) + file=ABI_DIR\BUILD_DIR\cpserviceprovider.exe SHARED_LIB_DIR\cpserviceprovider.exe CP_UPGRADABLE_APP_REG_RSC(cpserviceprovider) file=ABI_DIR\BUILD_DIR\cpcategorymodel.dll SHARED_LIB_DIR\cpcategorymodel.dll -file=ABI_DIR\BUILD_DIR\seccodeui.dll SHARED_LIB_DIR\seccodeui.dll file=ABI_DIR\BUILD_DIR\cpprofilewrapper.dll SHARED_LIB_DIR\cpprofilewrapper.dll file=ABI_DIR\BUILD_DIR\cpringtoneview.dll SHARED_LIB_DIR\cpringtoneview.dll @@ -41,8 +41,6 @@ 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\cppincodeplugin.dll SHARED_LIB_DIR\cppincodeplugin.dll -file=ABI_DIR\BUILD_DIR\cpdevicelockplugin.dll SHARED_LIB_DIR\cpdevicelockplugin.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 file=ABI_DIR\BUILD_DIR\cpringtoneplugin.dll SHARED_LIB_DIR\cpringtoneplugin.dll @@ -61,8 +59,6 @@ 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\cppincodeplugin.qtplugin resource\qt\plugins\controlpanel\cppincodeplugin.qtplugin -data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpdevicelockplugin.qtplugin resource\qt\plugins\controlpanel\cpdevicelockplugin.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 data=\epoc32\data\c\resource\qt\plugins\controlpanel\cpringtoneplugin.qtplugin resource\qt\plugins\controlpanel\cpringtoneplugin.qtplugin diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpapplication/src/cpmainview.cpp --- a/controlpanelui/src/cpapplication/src/cpmainview.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpapplication/src/cpmainview.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -32,8 +32,6 @@ { //delay loading connect(mMainWindow,SIGNAL(viewReady()),this,SLOT(initializeMainModel())); - - setTitle( QObject::tr("Control Panel") ); //should use qtTrId("txt_cp_title_control_panel") } CpMainView::~CpMainView() diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/communicationplugin/communicationplugin.pro --- a/controlpanelui/src/cpplugins/communicationplugin/communicationplugin.pro Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/communicationplugin/communicationplugin.pro Fri Jun 11 13:39:17 2010 +0300 @@ -26,6 +26,7 @@ symbian { TARGET.UID3 = 0x20025FDF + LIBS += -lxqsettingsmanager } symbian { diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.cpp --- a/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -16,10 +16,16 @@ */ #include "cpcommunicationgroupitemdata.h" #include +#include +#include +#include +#include CpCommunicationGroupItemData::CpCommunicationGroupItemData(const QString &configFile, const HbDataFormModelItem *parent): -CpCategorySettingFormItemData(configFile,parent) + CpCategorySettingFormItemData(configFile,parent), + mAirplaneModeItem(0), + mSettingManager(new XQSettingsManager()) { } @@ -28,24 +34,64 @@ const QString &label, const QString &configFile, const HbDataFormModelItem *parent): -CpCategorySettingFormItemData(type, label, configFile, parent) + CpCategorySettingFormItemData(type, label, configFile, parent), + mAirplaneModeItem(0), + mSettingManager(new XQSettingsManager()) { } + CpCommunicationGroupItemData::~CpCommunicationGroupItemData() { + delete mSettingManager; +} + +void CpCommunicationGroupItemData::beforeLoadingConfigPlugins(CpItemDataHelper &itemDataHelper) +{ + mAirplaneModeItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem, + hbTrId("txt_cp_setlabel_offline_airplane_mode")); + + itemDataHelper.addConnection(mAirplaneModeItem, + SIGNAL(clicked()), + this, + SLOT(toggleAirplaneMode())); + + XQCentralRepositorySettingsKey key(KCRUidCommunicationSettings.iUid,KSettingsAirplaneMode); + QVariant airplaneMode = mSettingManager->readItemValue(key,XQSettingsManager::TypeInt); + settingValueChanged(key,airplaneMode); + + mSettingManager->startMonitoring(key,XQSettingsManager::TypeInt); + connect(mSettingManager, SIGNAL(valueChanged (XQSettingsKey, QVariant)), + this, SLOT(settingValueChanged(XQSettingsKey, QVariant))); + + this->appendChild(mAirplaneModeItem); } -void CpCommunicationGroupItemData::beforeLoadingConfigPlugins(CpItemDataHelper &/*itemDataHelper*/) + +void CpCommunicationGroupItemData::toggleAirplaneMode() +{ + XQCentralRepositorySettingsKey key(KCRUidCommunicationSettings.iUid,KSettingsAirplaneMode); + QVariant airplaneMode = mSettingManager->readItemValue(key,XQSettingsManager::TypeInt); + + airplaneMode.setValue( static_cast (!airplaneMode.toBool()) ); + + mSettingManager->writeItemValue(key,airplaneMode); +} + +void CpCommunicationGroupItemData::settingValueChanged(const XQSettingsKey &key, const QVariant &value) { - HbDataFormModelItem *airPlaneMode = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem, - tr("Offline mode")); - QStringList airModeList; - airModeList << QObject::tr("On") << QObject::tr("Off"); - - airPlaneMode->setContentWidgetData("text",airModeList.at(1)); - airPlaneMode->setContentWidgetData("additionalText",airModeList.at(0)); + if (mAirplaneModeItem + && key.uid() == KCRUidCommunicationSettings.iUid + && key.key() == KSettingsAirplaneMode + && value.isValid()) { + QString text = hbTrId("txt_cp_setlabel_offline_mode_val_on"); + QString additionalText = hbTrId("txt_cp_setlabel_offline_mode_val_off"); + if (!value.toBool()) { + ::qSwap (text, additionalText); + } + mAirplaneModeItem->setContentWidgetData("text",text); + mAirplaneModeItem->setContentWidgetData("additionalText",additionalText); + } +} - this->appendChild(airPlaneMode); - -} +//End of File diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.h --- a/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.h Fri Jun 11 13:39:17 2010 +0300 @@ -19,8 +19,12 @@ #include class CpItemDataHelper; +class XQSettingsManager; +class XQSettingsKey; + class CpCommunicationGroupItemData: public CpCategorySettingFormItemData { + Q_OBJECT public: explicit CpCommunicationGroupItemData(const QString &configFile = QString(), const HbDataFormModelItem *parent = 0); @@ -31,7 +35,13 @@ const HbDataFormModelItem *parent = 0); ~CpCommunicationGroupItemData(); +private slots: + void toggleAirplaneMode(); + void settingValueChanged(const XQSettingsKey &key, const QVariant &value); private: virtual void beforeLoadingConfigPlugins(CpItemDataHelper &itemDataHelper); +private: + HbDataFormModelItem *mAirplaneModeItem; + XQSettingsManager *mSettingManager; }; #endif /* CPCOMMUNICATIONGROUPITEMDATA_H */ diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationplugin.cpp --- a/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationplugin.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationplugin.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -32,7 +32,7 @@ CpCategorySettingFormItemData *itemData = new CpCommunicationGroupItemData( HbDataFormModelItem::GroupItem, - QString("Connectivity"), + hbTrId("txt_cp_subhead_connectivity"), QString("cpcommunicationplugin.cpcfg") ); return QList() << itemData; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/deviceplugin/src/cpdeviceplugin.cpp --- a/controlpanelui/src/cpplugins/deviceplugin/src/cpdeviceplugin.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/deviceplugin/src/cpdeviceplugin.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -32,7 +32,7 @@ CpCategorySettingFormItemData *itemData = new CpCategorySettingFormItemData( HbDataFormModelItem::GroupItem, - tr("Device"), + hbTrId("txt_cp_subhead_device"), QString("cpdeviceplugin.cpcfg") ); return QList() << itemData; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/keytouchfdbkplugin/src/cpkeyscreenplugin.cpp --- a/controlpanelui/src/cpplugins/keytouchfdbkplugin/src/cpkeyscreenplugin.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/keytouchfdbkplugin/src/cpkeyscreenplugin.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -30,7 +30,7 @@ { CpSettingFormItemData* itemData = new CpSettingFormEntryItemDataImpl( itemDataHelper, - hbTrId("Keys & screen")); + hbTrId("txt_cp_list_keys_screen")); return QList() << itemData; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/privacyplugin/src/cpprivacyplugin.cpp --- a/controlpanelui/src/cpplugins/privacyplugin/src/cpprivacyplugin.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/privacyplugin/src/cpprivacyplugin.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -34,7 +34,7 @@ CpCategorySettingFormItemData *itemData = new CpCategorySettingFormItemData( HbDataFormModelItem::GroupItem, - tr("Security"), + hbTrId("txt_cp_subhead_security"), QString("cpprivacyplugin.cpcfg") ); return QList() << itemData; } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/profileactivatorplugin.pro --- a/controlpanelui/src/cpplugins/profileactivatorplugin/profileactivatorplugin.pro Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/profileactivatorplugin.pro Fri Jun 11 13:39:17 2010 +0300 @@ -27,4 +27,5 @@ TARGET.UID3 = 0X20028739 TARGET.CAPABILITY = All -TCB TARGET.EPOCALLOWDLLDATA = 1 + LIBS += -lprofileeng } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatordialog.cpp --- a/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatordialog.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatordialog.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -61,6 +61,9 @@ void CpProfileActivatorDialog::confirmProfileSelection() { int currentIndex = mProfileList->selected(); + if (currentIndex == -1) { + return; + } // the best choice is no need to convert the index to id mProfileModel.activateProfile(mProfileIds.at(currentIndex)); diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.cpp --- a/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -20,23 +20,31 @@ #include #include #include +#include "cpprofilemonitor.h" + CpProfileActivatorEntryItem::CpProfileActivatorEntryItem(CpItemDataHelper &itemDataHelper, const QString &text, const QString &description, const HbIcon &icon, const HbDataFormModelItem *parent) :CpSettingFormEntryItemData(itemDataHelper,text,description, - icon,parent) + icon,parent),mProfileModel(0),mProfileMonitor(0) { + mProfileMonitor = new CpProfileMonitor(); mProfileModel = new CpProfileModel(); + int currentId = mProfileModel->activeProfileId(); QString currentName = mProfileModel->profileName(currentId); this->setDescription(currentName); + connect(mProfileMonitor, SIGNAL(profileActivated(int)), this, SLOT(onProfileChanged(int))); } + CpProfileActivatorEntryItem::~CpProfileActivatorEntryItem() { delete mProfileModel; + delete mProfileMonitor; } + void CpProfileActivatorEntryItem::onLaunchView() { CpProfileActivatorDialog *dialog = @@ -46,6 +54,12 @@ dialog->show(); } + +void CpProfileActivatorEntryItem::onProfileChanged(int activeProfileId) +{ + QString profileName = mProfileModel->profileName(activeProfileId); + this->setDescription(profileName); +} /*void CpPersonalizationEntryItemData::handleOk(const QVariant &result) { if (!result.canConvert()) diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.h --- a/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.h Fri Jun 11 13:39:17 2010 +0300 @@ -20,6 +20,8 @@ #include class CpProfileModel; +class CpProfileMonitor; + class CpProfileActivatorEntryItem : public CpSettingFormEntryItemData { Q_OBJECT @@ -31,12 +33,14 @@ virtual ~CpProfileActivatorEntryItem(); private slots: void onLaunchView(); + void onProfileChanged(int activeProfileId); //void handleOk(const QVariant &result); //void handleError(int errorCode, const QString& errorMessage); private: virtual CpBaseSettingView *createSettingView() const; private: CpProfileModel *mProfileModel; + CpProfileMonitor *mProfileMonitor; }; #endif // CPPROFILEACTIVATORENTRYITEM_H diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofilemonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofilemonitor.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -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: + * + */ + +#include "cpprofilemonitor.h" + +#include + +CpProfileMonitor::CpProfileMonitor(QObject *parent) + :QObject(parent),mProfileNotifier(0) +{ + mProfileNotifier = CProfileChangeNotifyHandler::NewL(this); +} + +CpProfileMonitor::~CpProfileMonitor() +{ + delete mProfileNotifier; +} + +void CpProfileMonitor::HandleActiveProfileEventL(TProfileEvent aProfileEvent, TInt aProfileId) +{ + if (EProfileNewActiveProfile == aProfileEvent) { + emit profileActivated(aProfileId); + } +} diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofilemonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofilemonitor.h Fri Jun 11 13:39:17 2010 +0300 @@ -0,0 +1,42 @@ +/* + * 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 CPPROFILEMONITOR_H_ +#define CPPROFILEMONITOR_H_ + +#include +#include + +class CProfileChangeNotifyHandler; + +class CpProfileMonitor: public QObject,public MProfileChangeObserver +{ + Q_OBJECT +public: + explicit CpProfileMonitor(QObject *parent = 0); + ~CpProfileMonitor(); +signals: + void profileActivated(int activeProfileId); +private: + virtual void HandleActiveProfileEventL( + TProfileEvent aProfileEvent, TInt aProfileId ); + +private: + CProfileChangeNotifyHandler* mProfileNotifier; +}; + +#endif /* CPPROFILEMONITOR_H_ */ diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/cpserviceprovider/src/main.cpp --- a/controlpanelui/src/cpserviceprovider/src/main.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/cpserviceprovider/src/main.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include "cpservicemainwindow.h" #include "cpsplogger.h" @@ -29,6 +31,12 @@ CPSP_LOGGER_CONFIG_PATH,QSettings::IniFormat); CPSP_LOG("Entering CpServiceProvider.exe..."); + QTranslator translator; + if (translator.load("control_panel_" + QLocale::system().name(),"Z:/resource/qt/translations")) + { + qApp->installTranslator(&translator); + } + HbStyleLoader::registerFilePath(CP_RESOURCE_PATH + QDir::separator() + WIDGETML_SUB_PATH); CpServiceMainWindow wnd; diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/src/tonefetchermodel.cpp --- a/controlpanelui/src/tonefetcher/src/tonefetchermodel.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/src/tonefetchermodel.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -88,6 +88,11 @@ emit layoutChanged(); } +void ToneFetcherModel::toBeFreshed() +{ + emit layoutAboutToBeChanged(); +} + void ToneFetcherModel::clearAll() { mUserDataLst.clear(); diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/src/tonefetchermodel.h --- a/controlpanelui/src/tonefetcher/src/tonefetchermodel.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/src/tonefetchermodel.h Fri Jun 11 13:39:17 2010 +0300 @@ -38,6 +38,7 @@ void insertInOrder(QStandardItem *fileName, QStandardItem *filePath, int role = Qt::DisplayRole); QString path(const QModelIndex &index) const; void refresh(); + void toBeFreshed(); void clearAll(); private: /* diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp --- a/controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -73,7 +73,7 @@ //stop previewing when clicking another item. if (mServiceEngine->IsPlaying()) { - mServiceEngine->preview(getCurrentItemPath()); + mServiceEngine->stop(); } /* * when one item is selected, reselecting it will deselect it. selecting another @@ -171,7 +171,12 @@ void ToneFetcherWidget::playOrPause() { + if(mServiceEngine->IsPlaying()) { + mServiceEngine->stop(); + } else { mServiceEngine->preview(getCurrentItemPath()); + } + } void ToneFetcherWidget::previewEvent(ToneFetcherEngine::TPreviewEvent event, int errorId) @@ -186,6 +191,11 @@ void ToneFetcherWidget::onObjectChanged() { + if (mServiceEngine->IsPlaying()) { + mServiceEngine->stop(); + } + emit triggerToolBar(false); + mToneModel->toBeFreshed(); mToneModel->clearAll(); mDigitalSoundList.clear(); mSimpleSoundList.clear(); diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/tonefetcher.pro --- a/controlpanelui/src/tonefetcher/tonefetcher.pro Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/tonefetcher.pro Fri Jun 11 13:39:17 2010 +0300 @@ -51,7 +51,7 @@ SERVICE.FILE = service_conf.xml SERVICE.OPTIONS = embeddable -#SERVICE.OPTIONS += hidden +SERVICE.OPTIONS += hidden libFiles.sources = xqservice.dll libFiles.path = "!:\sys\bin" DEPLOYMENT += libFiles diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.cpp --- a/controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -237,6 +237,8 @@ iAudioPlayerStatus = EPlayerNotCreated; CMFPreviewHandlerBase::ConstructL(); iTonePlayerStatus = EPlayerNotCreated; + CCoeEnv* coeEnv = CCoeEnv::Static(); + coeEnv->AddForegroundObserverL( *this ); } TonePreviewPrivate::~TonePreviewPrivate() @@ -264,12 +266,7 @@ } void TonePreviewPrivate::Play() - { - if( IsPlaying() ) - { - Stop(); - return; - } + { //sequence for playing a beep once sound _LIT8( KFileListBeepSequence, "\x00\x11\x06\x0A\x08\x73\x0A\x40\x28\x0A\xF7\ \x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B" ); @@ -601,3 +598,15 @@ Cancel(); emit notifyPreviewEvent( ToneFetcherEngine::EAudioPreviewComplete, aError ); } + +void TonePreviewPrivate::HandleLosingForeground() + { + if ( IsPlaying() ) + { + Stop(); + } + } +void TonePreviewPrivate::HandleGainingForeground() + { + + } diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.h --- a/controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.h Fri Jun 11 13:39:17 2010 +0300 @@ -27,6 +27,7 @@ #include #include #include "tonefetcherengine.h" +#include class C3DRingingToneInterface; class RWindow; @@ -164,7 +165,8 @@ class TonePreviewPrivate : public CMFPreviewHandlerBase, public MDrmAudioPlayerCallback, - public MMdaAudioToneObserver + public MMdaAudioToneObserver, + public MCoeForegroundObserver { Q_OBJECT @@ -196,6 +198,9 @@ void MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); void MdapcPlayComplete(TInt aError); + // from MCoeForegroundObserver + void HandleLosingForeground(); + void HandleGainingForeground(); private: // audio player diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.cpp --- a/controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.cpp Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.cpp Fri Jun 11 13:39:17 2010 +0300 @@ -59,4 +59,10 @@ { mAudioPlayer->IsPlaying(); } + +void ToneFetcherEngine::stop() +{ + mAudioPlayer->Stop(); +} + //End of File diff -r cc79acdc26cb -r 4a9568303383 controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.h --- a/controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.h Thu May 27 12:52:25 2010 +0300 +++ b/controlpanelui/src/tonefetcher/tonefetcherengine/tonefetcherengine.h Fri Jun 11 13:39:17 2010 +0300 @@ -82,6 +82,11 @@ void preview(const QString &file); bool IsPlaying(); + + /* + * stop previewing + */ + void stop(); signals: void mdeSessionOpened(); void mdeSessionError(int error);