summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/styles/qs60style.cpp8
-rw-r--r--src/gui/styles/qs60style.h2
-rw-r--r--src/gui/styles/qs60style_s60.cpp8
-rw-r--r--src/gui/styles/qs60style_simulated.cpp125
4 files changed, 135 insertions, 8 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index f7a1700..b30cc0d 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -870,14 +870,6 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
\sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle
*/
-/*!
- Constructs a QS60Style object.
-*/
-QS60Style::QS60Style()
- : QCommonStyle(*new QS60StylePrivate)
-{
-}
-
QS60Style::~QS60Style()
{
}
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index bf8f22e..21cdd1c 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -85,6 +85,8 @@ public:
static QStringList colorListKeys();
void setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors);
+ bool loadS60ThemeFromBlob(const QString &blobFile);
+ bool saveS60ThemeToBlob(const QString &blobFile) const;
#endif // !Q_WS_S60
#ifdef Q_WS_S60
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index d6f7109..55e80b9 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1326,6 +1326,14 @@ void QS60StyleModeSpecifics::colorGroupAndIndex(
}
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+}
+
void QS60Style::handleDynamicLayoutVariantSwitch()
{
Q_D(QS60Style);
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 089a252..a94d73e 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -51,11 +51,109 @@
#include "qlayout.h"
#include "qpixmapcache.h"
#include "qmetaobject.h"
+#include "qdebug.h"
+#include "qbuffer.h"
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
QT_BEGIN_NAMESPACE
+static const quint32 blobVersion = 1;
+static const int pictureSize = 256;
+
+bool saveThemeToBlob(const QString &themeBlob,
+ const QHash<QString, QPicture> &partPictures,
+ const QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::WriteOnly)) {
+ qWarning() << __FUNCTION__": Could not create blob: " << themeBlob;
+ return false;
+ }
+
+ QByteArray data;
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::WriteOnly);
+ QDataStream dataOut(&dataBuffer);
+
+ const int colorsCount = colors.count();
+ dataOut << colorsCount;
+ const QList<QPair<QString, int> > colorKeys = colors.keys();
+ for (int i = 0; i < colorsCount; ++i) {
+ const QPair<QString, int> &key = colorKeys.at(i);
+ dataOut << key;
+ const QColor color = colors.value(key);
+ dataOut << color;
+ }
+
+ const int picturesCount = partPictures.count();
+ dataOut << picturesCount;
+ foreach (const QString &key, partPictures.keys()) {
+ const QPicture picture = partPictures.value(key);
+ dataOut << key;
+ dataOut << picture;
+ }
+
+ QDataStream blobOut(&blob);
+ blobOut << blobVersion;
+ blobOut << qCompress(data);
+ return blobOut.status() == QDataStream::Ok;
+}
+
+bool loadThemeFromBlob(const QString &themeBlob,
+ QHash<QString, QPicture> &partPictures,
+ QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::ReadOnly)) {
+ qWarning() << __FUNCTION__": Could not read blob: " << themeBlob;
+ return false;
+ }
+ QDataStream blobIn(&blob);
+
+ quint32 version;
+ blobIn >> version;
+
+ if (version != blobVersion) {
+ qWarning() << __FUNCTION__": Invalid blob version: " << version << " ...expected: " << blobVersion;
+ return false;
+ }
+
+ QByteArray data;
+ blobIn >> data;
+ data = qUncompress(data);
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::ReadOnly);
+ QDataStream dataIn(&dataBuffer);
+
+ int colorsCount;
+ dataIn >> colorsCount;
+ for (int i = 0; i < colorsCount; ++i) {
+ QPair<QString, int> key;
+ dataIn >> key;
+ QColor value;
+ dataIn >> value;
+ colors.insert(key, value);
+ }
+
+ int picturesCount;
+ dataIn >> picturesCount;
+ for (int i = 0; i < picturesCount; ++i) {
+ QString key;
+ dataIn >> key;
+ QPicture value;
+ dataIn >> value;
+ value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized.
+ partPictures.insert(key, value);
+ }
+
+ if (dataIn.status() != QDataStream::Ok) {
+ qWarning() << __FUNCTION__": Invalid data blob: " << themeBlob;
+ return false;
+ }
+ return true;
+}
+
class QS60StyleModeSpecifics
{
public:
@@ -254,6 +352,16 @@ QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCate
return result;
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+ // Assume, that the resource system has a ':/s60Stylethemes/Default.blob'
+ loadS60ThemeFromBlob(QString::fromLatin1(":/s60Stylethemes/Default.blob"));
+}
+
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, {
const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("SkinParts");
Q_ASSERT(enumIndex >= 0);
@@ -303,6 +411,23 @@ void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts,
d->setThemePalette(qApp);
}
+bool QS60Style::loadS60ThemeFromBlob(const QString &blobFile)
+{
+ QHash<QString, QPicture> partPictures;
+ QHash<QPair<QString, int>, QColor> colors;
+
+ if (!loadThemeFromBlob(blobFile, partPictures, colors))
+ return false;
+ setS60Theme(partPictures, colors);
+ return true;
+}
+
+bool QS60Style::saveS60ThemeToBlob(const QString &blobFile) const
+{
+ return saveThemeToBlob(blobFile,
+ QS60StyleModeSpecifics::m_partPictures, QS60StyleModeSpecifics::m_colors);
+}
+
QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
{
Q_UNUSED(targetWidget)