summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-07-28 12:49:37 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-07-28 12:49:37 (GMT)
commit93ad359f93de72ef8c4d5f0073dc20ba22b9023c (patch)
tree2463602896f5d671d62a16c3338a9b7ba8492db1
parentf95cecebddb8ce0ef40bd691bbe574db1a570b8c (diff)
downloadQt-93ad359f93de72ef8c4d5f0073dc20ba22b9023c.zip
Qt-93ad359f93de72ef8c4d5f0073dc20ba22b9023c.tar.gz
Qt-93ad359f93de72ef8c4d5f0073dc20ba22b9023c.tar.bz2
Fix for QmlPalette
Add a colorGroup property and remove palette properties from the root context.
-rw-r--r--demos/declarative/samegame/SameGame.qml1
-rw-r--r--examples/declarative/loader/Browser.qml2
-rw-r--r--examples/declarative/loader/main.cpp3
-rw-r--r--src/declarative/util/qmlpalette.cpp11
-rw-r--r--src/declarative/util/qmlpalette.h16
-rw-r--r--tools/qmlviewer/qmlviewer.cpp17
-rw-r--r--tools/qmlviewer/qmlviewer.h4
7 files changed, 24 insertions, 30 deletions
diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml
index 1788341..3b80692 100644
--- a/demos/declarative/samegame/SameGame.qml
+++ b/demos/declarative/samegame/SameGame.qml
@@ -5,6 +5,7 @@ import "content"
Rect {
id: page; width: 460; height: 700; color: activePalette.window
Script { source: "content/samegame.js" }
+ Palette { id: activePalette; colorGroup: "Active" }
Rect {
id: gameCanvas
property int score: 0
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
index 5696f93..007b998 100644
--- a/examples/declarative/loader/Browser.qml
+++ b/examples/declarative/loader/Browser.qml
@@ -11,6 +11,8 @@ Rect {
// folder: "E:"
}
+ Palette { id: activePalette; colorGroup: "Active" }
+
Component {
id: FolderDelegate
Rect {
diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp
index aa86f8f..762212b 100644
--- a/examples/declarative/loader/main.cpp
+++ b/examples/declarative/loader/main.cpp
@@ -5,7 +5,7 @@
#include <QmlContext>
#include <QmlComponent>
#include <qfxview.h>
-#include "qmlpalette.h"
+#include <QDebug>
QFxView *canvas = 0;
@@ -62,7 +62,6 @@ int main(int argc, char *argv[])
canvas = new QFxView;
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("qmlLauncher", launcher);
- ctxt->setContextProperty("activePalette", new QmlPalette);
canvas->setUrl(QUrl("qrc:/loader.qml"));
canvas->execute();
canvas->show();
diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp
index 01b5ad3..3a6dadc 100644
--- a/src/declarative/util/qmlpalette.cpp
+++ b/src/declarative/util/qmlpalette.cpp
@@ -161,10 +161,17 @@ QColor QmlPalette::darker(const QColor& color) const
return color.darker();
}
-void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup)
+QmlPalette::ColorGroup QmlPalette::colorGroup() const
+{
+ Q_D(const QmlPalette);
+ return (QmlPalette::ColorGroup)int(d->group);
+}
+
+void QmlPalette::setColorGroup(ColorGroup colorGroup)
{
Q_D(QmlPalette);
- d->group = colorGroup;
+ d->group = (QPalette::ColorGroup)int(colorGroup);
+ emit paletteChanged();
}
QPalette QmlPalette::palette() const
diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h
index 7f26f9a..3030557 100644
--- a/src/declarative/util/qmlpalette.h
+++ b/src/declarative/util/qmlpalette.h
@@ -57,11 +57,9 @@ class Q_DECLARATIVE_EXPORT QmlPalette : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlPalette)
+ Q_ENUMS(ColorGroup)
-public:
- QmlPalette(QObject *parent=0);
- ~QmlPalette();
-
+ Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
@@ -76,6 +74,13 @@ public:
Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
+public:
+ QmlPalette(QObject *parent=0);
+ ~QmlPalette();
+
+ enum ColorGroup { Disabled = QPalette::Disabled, Active = QPalette::Active,
+ Inactive = QPalette::Inactive, Normal = QPalette::Normal };
+
QColor window() const;
QColor windowText() const;
@@ -96,7 +101,8 @@ public:
QPalette palette() const;
- void setColorGroup(QPalette::ColorGroup);
+ ColorGroup colorGroup() const;
+ void setColorGroup(ColorGroup);
bool virtual eventFilter(QObject *watched, QEvent *event);
bool virtual event(QEvent *event);
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 95cd24b..4f35fe8 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -16,7 +16,6 @@
#include "qmlviewer.h"
#include <QtDeclarative/qmlcontext.h>
#include <QtDeclarative/qmlengine.h>
-#include "qmlpalette.h"
#include "qml.h"
#include <private/qperformancelog_p.h>
#include <QAbstractAnimation>
@@ -134,8 +133,6 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
devicemode = false;
skin = 0;
canvas = 0;
- palette = 0;
- disabledPalette = 0;
record_autotime = 0;
record_period = 20;
@@ -392,7 +389,6 @@ void QmlViewer::openQml(const QString& fileName)
}
}
- setupPalettes();
canvas->setUrl(url);
QTime t;
@@ -417,19 +413,6 @@ void QmlViewer::openQml(const QString& fileName)
#endif
}
-void QmlViewer:: setupPalettes()
-{
- delete palette;
- palette = new QmlPalette;
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("activePalette", palette);
-
- delete disabledPalette;
- disabledPalette = new QmlPalette;
- disabledPalette->setColorGroup(QPalette::Disabled);
- ctxt->setContextProperty("disabledPalette", disabledPalette);
-}
-
void QmlViewer::setSkin(const QString& skinDirectory)
{
// XXX QWidget::setMask does not handle changes well, and we may
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index e7177eb..6d9f9d0 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -24,7 +24,6 @@ QT_BEGIN_NAMESPACE
class QFxView;
class PreviewDeviceSkin;
class QFxTestEngine;
-class QmlPalette;
class QProcess;
class QmlViewer : public QWidget
@@ -72,14 +71,11 @@ private slots:
private:
void setupProxy();
- void setupPalettes();
QString currentFileName;
PreviewDeviceSkin *skin;
QSize skinscreensize;
QFxView *canvas;
- QmlPalette *palette;
- QmlPalette *disabledPalette;
QmlTimer recordTimer;
QImage frame;
QList<QImage*> frames;