From fd7dca696e09f3f57c54406fe1393fccdc298a36 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 20 Aug 2009 17:37:59 +1000 Subject: Renaming Palette -> SystemPalette --- demos/declarative/calculator/calculator.qml | 2 +- demos/declarative/samegame/SameGame.qml | 14 +- examples/declarative/fonts/fonts.qml | 2 +- examples/declarative/loader/Browser.qml | 18 +- src/declarative/util/qmlpalette.cpp | 317 ---------------------------- src/declarative/util/qmlpalette.h | 122 ----------- src/declarative/util/qmlsystempalette.cpp | 317 ++++++++++++++++++++++++++++ src/declarative/util/qmlsystempalette.h | 122 +++++++++++ src/declarative/util/util.pri | 4 +- 9 files changed, 459 insertions(+), 459 deletions(-) delete mode 100644 src/declarative/util/qmlpalette.cpp delete mode 100644 src/declarative/util/qmlpalette.h create mode 100644 src/declarative/util/qmlsystempalette.cpp create mode 100644 src/declarative/util/qmlsystempalette.h diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 56fdc59..fd5002b 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -4,7 +4,7 @@ Rectangle { id: MainWindow; width: 320; height: 270; color: Palette.window - Palette { id: Palette } + SystemPalette { id: Palette; colorGroup: Qt.Active } Script { source: "calculator.js" } VerticalPositioner { diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 00853ad..d476e8b 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -5,13 +5,13 @@ import "content" Rectangle { id: page; width: 460; height: 700; color: activePalette.window Script { source: "content/samegame.js" } - Palette { id: activePalette; colorGroup: "Active" } + SystemPalette { id: activePalette; colorGroup: Qt.Active } Rectangle { id: gameCanvas property int score: 0 z:20; y:20; color: "white"; border.width: 1 - width:parent.width - tileSize - (parent.width % tileSize); - height:parent.height - tileSize - (parent.height % tileSize); + width:parent.width - tileSize - (parent.width % tileSize); + height:parent.height - tileSize - (parent.height % tileSize); anchors.horizontalCenter: parent.horizontalCenter Image { id:background; source: "content/pics/background.png" @@ -23,12 +23,12 @@ Rectangle { } Dialog { id: dialog; anchors.centerIn: parent; z: 21} - Button { - id: btnA; text: "New Game"; onClicked: {initBoard();} + Button { + id: btnA; text: "New Game"; onClicked: {initBoard();} anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.left: gameCanvas.left; } - Text { - text: "Score: " + gameCanvas.score; width:100; font.pointSize:14 + Text { + text: "Score: " + gameCanvas.score; width:100; font.pointSize:14 anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right; } } diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 3620a00..2aa4851 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -6,7 +6,7 @@ Rectangle { width: 800; height: 600 color: Palette.base - Palette { id: Palette; colorGroup: "Active" } + SystemPalette { id: Palette; colorGroup: Qt.Active } FontLoader { id: FixedFont; name: "Courier" } diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index d3566da..e152779 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -4,14 +4,14 @@ Rectangle { id: Root width: parent.width height: parent.height - color: activePalette.base + color: Palette.base FolderListModel { id: folders nameFilters: [ "*.qml" ] // folder: "E:" } - Palette { id: activePalette; colorGroup: "Active" } + SystemPalette { id: Palette; colorGroup: Qt.Active } Component { id: FolderDelegate @@ -31,8 +31,8 @@ Rectangle { id: Highlight; visible: false anchors.fill: parent gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: activePalette.highlight } - GradientStop { id: t2; position: 1.0; color: activePalette.lighter(activePalette.highlight) } + GradientStop { id: t1; position: 0.0; color: Palette.highlight } + GradientStop { id: t2; position: 1.0; color: Palette.lighter(Palette.highlight) } } } Item { @@ -44,7 +44,7 @@ Rectangle { anchors.fill: parent; verticalAlignment: "AlignVCenter" text: fileName; anchors.leftMargin: 32 font.pointSize: 10 - color: activePalette.windowText + color: Palette.windowText } MouseRegion { id: Mouse @@ -56,7 +56,7 @@ Rectangle { name: "pressed" when: Mouse.pressed SetProperties { target: Highlight; visible: true } - SetProperties { target: NameText; color: activePalette.highlightedText } + SetProperties { target: NameText; color: Palette.highlightedText } } ] } @@ -92,13 +92,13 @@ Rectangle { id: TitleBar width: parent.width height: 32 - color: activePalette.button; border.color: activePalette.mid + color: Palette.button; border.color: Palette.mid Rectangle { id: UpButton width: 30 height: TitleBar.height - border.color: activePalette.mid; color: "transparent" + border.color: Palette.mid; color: "transparent" MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) } Image { anchors.centerIn: parent; source: "images/up.png" } } @@ -106,7 +106,7 @@ Rectangle { Text { anchors.left: UpButton.right; anchors.right: parent.right; height: parent.height anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder; color: activePalette.buttonText + text: folders.folder; color: Palette.buttonText elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter" } } diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp deleted file mode 100644 index d86f98f..0000000 --- a/src/declarative/util/qmlpalette.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qobject_p.h" -#include "qmlpalette.h" -#include - -QT_BEGIN_NAMESPACE - -class QmlPalettePrivate : public QObjectPrivate -{ -public: - QPalette palette; - QPalette::ColorGroup group; -}; - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Palette,QmlPalette) - -/*! - \qmlclass Palette QmlPalette - \ingroup group_utility - \brief The Palette item gives access to the Qt palettes. - \sa QPalette - - Example: - \code - Palette { id: MyPalette; colorGroup: Qt.Active } - - Rectangle { - width: 640; height: 480 - color: MyPalette.window - Text { - anchors.fill: parent - text: "Hello!"; color: MyPalette.windowText - } - } - \endcode -*/ -QmlPalette::QmlPalette(QObject *parent) - : QObject(*(new QmlPalettePrivate), parent) -{ - Q_D(QmlPalette); - d->palette = qApp->palette(); - d->group = QPalette::Active; - qApp->installEventFilter(this); -} - -QmlPalette::~QmlPalette() -{ -} - -/*! - \qmlproperty color Palette::window - The window (general background) color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::window() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Window); -} - -/*! - \qmlproperty color Palette::windowText - The window text (general foreground) color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::windowText() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::WindowText); -} - -/*! - \qmlproperty color Palette::base - The base color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::base() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Base); -} - -/*! - \qmlproperty color Palette::text - The text color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::text() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Text); -} - -/*! - \qmlproperty color Palette::alternateBase - The alternate base color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::alternateBase() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::AlternateBase); -} - -/*! - \qmlproperty color Palette::button - The button color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::button() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Button); -} - -/*! - \qmlproperty color Palette::buttonText - The button text foreground color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::buttonText() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::ButtonText); -} - -/*! - \qmlproperty color Palette::light - The light color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::light() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Light); -} - -/*! - \qmlproperty color Palette::midlight - The midlight color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::midlight() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Midlight); -} - -/*! - \qmlproperty color Palette::dark - The dark color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::dark() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Dark); -} - -/*! - \qmlproperty color Palette::mid - The mid color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::mid() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Mid); -} - -/*! - \qmlproperty color Palette::shadow - The shadow color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::shadow() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Shadow); -} - -/*! - \qmlproperty color Palette::highlight - The highlight color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::highlight() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::Highlight); -} - -/*! - \qmlproperty color Palette::highlightedText - The highlighted text color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QmlPalette::highlightedText() const -{ - Q_D(const QmlPalette); - return d->palette.color(d->group, QPalette::HighlightedText); -} - -/*! - \qmlproperty color Palette::lighter -*/ -QColor QmlPalette::lighter(const QColor& color) const -{ - return color.lighter(); -} - -/*! - \qmlproperty color Palette::darker -*/ -QColor QmlPalette::darker(const QColor& color) const -{ - return color.darker(); -} - -/*! - \qmlproperty QPalette::ColorGroup Palette::colorGroup - - The color group of the palette. It can be Active, Inactive or Disabled. - Active is the default. - - \sa QPalette::ColorGroup -*/ -QPalette::ColorGroup QmlPalette::colorGroup() const -{ - Q_D(const QmlPalette); - return d->group; -} - -void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup) -{ - Q_D(QmlPalette); - d->group = colorGroup; - emit paletteChanged(); -} - -bool QmlPalette::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == qApp) { - if (event->type() == QEvent::ApplicationPaletteChange) { - QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); - return false; - } - } - return QObject::eventFilter(watched, event); -} - -bool QmlPalette::event(QEvent *event) -{ - Q_D(QmlPalette); - if (event->type() == QEvent::ApplicationPaletteChange) { - d->palette = qApp->palette(); - emit paletteChanged(); - return true; - } - return QObject::event(event); -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h deleted file mode 100644 index e381814..0000000 --- a/src/declarative/util/qmlpalette.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLPALETTE_H -#define QMLPALETTE_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlPalettePrivate; -class Q_DECLARATIVE_EXPORT QmlPalette : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlPalette) - - Q_PROPERTY(QPalette::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) - Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) - Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) - Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) - Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) - Q_PROPERTY(QColor light READ light NOTIFY paletteChanged) - Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged) - Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged) - Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged) - Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged) - Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged) - Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) - -public: - QmlPalette(QObject *parent=0); - ~QmlPalette(); - - QColor window() const; - QColor windowText() const; - - QColor base() const; - QColor text() const; - QColor alternateBase() const; - - QColor button() const; - QColor buttonText() const; - - QColor light() const; - QColor midlight() const; - QColor dark() const; - QColor mid() const; - QColor shadow() const; - - QColor highlight() const; - QColor highlightedText() const; - - QPalette::ColorGroup colorGroup() const; - void setColorGroup(QPalette::ColorGroup); - - // FIXME: Move to utility class? - Q_INVOKABLE QColor lighter(const QColor&) const; - Q_INVOKABLE QColor darker(const QColor&) const; - -Q_SIGNALS: - void paletteChanged(); - -private: - bool eventFilter(QObject *watched, QEvent *event); - bool event(QEvent *event); - -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlPalette) - -QT_END_HEADER - -#endif // QMLPALETTE_H diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp new file mode 100644 index 0000000..88278c3 --- /dev/null +++ b/src/declarative/util/qmlsystempalette.cpp @@ -0,0 +1,317 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qobject_p.h" +#include "qmlsystempalette.h" +#include + +QT_BEGIN_NAMESPACE + +class QmlSystemPalettePrivate : public QObjectPrivate +{ +public: + QPalette palette; + QPalette::ColorGroup group; +}; + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,SystemPalette,QmlSystemPalette) + +/*! + \qmlclass SystemPalette QmlSystemPalette + \ingroup group_utility + \brief The SystemPalette item gives access to the Qt palettes. + \sa QPalette + + Example: + \qml + SystemPalette { id: MyPalette; colorGroup: Qt.Active } + + Rectangle { + width: 640; height: 480 + color: MyPalette.window + Text { + anchors.fill: parent + text: "Hello!"; color: MyPalette.windowText + } + } + \endqml +*/ +QmlSystemPalette::QmlSystemPalette(QObject *parent) + : QObject(*(new QmlSystemPalettePrivate), parent) +{ + Q_D(QmlSystemPalette); + d->palette = qApp->palette(); + d->group = QPalette::Active; + qApp->installEventFilter(this); +} + +QmlSystemPalette::~QmlSystemPalette() +{ +} + +/*! + \qmlproperty color SystemPalette::window + The window (general background) color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::window() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Window); +} + +/*! + \qmlproperty color SystemPalette::windowText + The window text (general foreground) color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::windowText() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::WindowText); +} + +/*! + \qmlproperty color SystemPalette::base + The base color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::base() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Base); +} + +/*! + \qmlproperty color SystemPalette::text + The text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::text() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Text); +} + +/*! + \qmlproperty color SystemPalette::alternateBase + The alternate base color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::alternateBase() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::AlternateBase); +} + +/*! + \qmlproperty color SystemPalette::button + The button color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::button() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Button); +} + +/*! + \qmlproperty color SystemPalette::buttonText + The button text foreground color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::buttonText() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::ButtonText); +} + +/*! + \qmlproperty color SystemPalette::light + The light color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::light() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Light); +} + +/*! + \qmlproperty color SystemPalette::midlight + The midlight color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::midlight() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Midlight); +} + +/*! + \qmlproperty color SystemPalette::dark + The dark color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::dark() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Dark); +} + +/*! + \qmlproperty color SystemPalette::mid + The mid color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::mid() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Mid); +} + +/*! + \qmlproperty color SystemPalette::shadow + The shadow color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::shadow() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Shadow); +} + +/*! + \qmlproperty color SystemPalette::highlight + The highlight color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::highlight() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::Highlight); +} + +/*! + \qmlproperty color SystemPalette::highlightedText + The highlighted text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlSystemPalette::highlightedText() const +{ + Q_D(const QmlSystemPalette); + return d->palette.color(d->group, QPalette::HighlightedText); +} + +/*! + \qmlproperty color SystemPalette::lighter +*/ +QColor QmlSystemPalette::lighter(const QColor& color) const +{ + return color.lighter(); +} + +/*! + \qmlproperty color SystemPalette::darker +*/ +QColor QmlSystemPalette::darker(const QColor& color) const +{ + return color.darker(); +} + +/*! + \qmlproperty QPalette::ColorGroup SystemPalette::colorGroup + + The color group of the palette. It can be Active, Inactive or Disabled. + Active is the default. + + \sa QPalette::ColorGroup +*/ +QPalette::ColorGroup QmlSystemPalette::colorGroup() const +{ + Q_D(const QmlSystemPalette); + return d->group; +} + +void QmlSystemPalette::setColorGroup(QPalette::ColorGroup colorGroup) +{ + Q_D(QmlSystemPalette); + d->group = colorGroup; + emit paletteChanged(); +} + +bool QmlSystemPalette::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == qApp) { + if (event->type() == QEvent::ApplicationPaletteChange) { + QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); + return false; + } + } + return QObject::eventFilter(watched, event); +} + +bool QmlSystemPalette::event(QEvent *event) +{ + Q_D(QmlSystemPalette); + if (event->type() == QEvent::ApplicationPaletteChange) { + d->palette = qApp->palette(); + emit paletteChanged(); + return true; + } + return QObject::event(event); +} + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlsystempalette.h b/src/declarative/util/qmlsystempalette.h new file mode 100644 index 0000000..6558c7e --- /dev/null +++ b/src/declarative/util/qmlsystempalette.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSYSTEMPALETTE_H +#define QMLSYSTEMPALETTE_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlSystemPalettePrivate; +class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlSystemPalette) + + Q_PROPERTY(QPalette::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) + Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) + Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) + Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) + Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) + Q_PROPERTY(QColor light READ light NOTIFY paletteChanged) + Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged) + Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged) + Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged) + Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged) + Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged) + Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) + +public: + QmlSystemPalette(QObject *parent=0); + ~QmlSystemPalette(); + + QColor window() const; + QColor windowText() const; + + QColor base() const; + QColor text() const; + QColor alternateBase() const; + + QColor button() const; + QColor buttonText() const; + + QColor light() const; + QColor midlight() const; + QColor dark() const; + QColor mid() const; + QColor shadow() const; + + QColor highlight() const; + QColor highlightedText() const; + + QPalette::ColorGroup colorGroup() const; + void setColorGroup(QPalette::ColorGroup); + + // FIXME: Move to utility class? + Q_INVOKABLE QColor lighter(const QColor&) const; + Q_INVOKABLE QColor darker(const QColor&) const; + +Q_SIGNALS: + void paletteChanged(); + +private: + bool eventFilter(QObject *watched, QEvent *event); + bool event(QEvent *event); + +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlSystemPalette) + +QT_END_HEADER + +#endif // QMLSYSTEMPALETTE_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 9374f00..1a0d402 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -6,7 +6,7 @@ SOURCES += \ util/qmlpackage.cpp \ util/qmlscript.cpp \ util/qmlanimation.cpp \ - util/qmlpalette.cpp \ + util/qmlsystempalette.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ util/qmltransitionmanager.cpp \ @@ -31,7 +31,7 @@ HEADERS += \ util/qmlscript.h \ util/qmlanimation.h \ util/qmlanimation_p.h \ - util/qmlpalette.h \ + util/qmlsystempalette.h \ util/qmlfollow.h \ util/qmlstate.h\ util/qmlstateoperations.h \ -- cgit v0.12