diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-11-27 09:56:12 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-11-27 11:37:11 +0000 |
commit | 7031e85adf44355b56a5ec740ab26a7eb3d8f740 (patch) | |
tree | 87e198e88ead8d1b94567ce0bfcea71d99b847e3 /src | |
parent | bb807b32b7e85bc4ae5c2d2b7c627e0e2bde90ff (diff) |
Remove Theme
Given the presence of alternative styles, we'd like to focus on making
the default style as performant as possible. Removing Theme usage
is a step towards this.
Change-Id: I8f76dc98442e6c02703885591a44758f40c7a362
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
22 files changed, 19 insertions, 1023 deletions
diff --git a/src/imports/controls/ApplicationWindow.qml b/src/imports/controls/ApplicationWindow.qml index cb918b84..247752cb 100644 --- a/src/imports/controls/ApplicationWindow.qml +++ b/src/imports/controls/ApplicationWindow.qml @@ -36,11 +36,10 @@ import QtQuick 2.6 import QtQuick.Window 2.2 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.ApplicationWindow { id: window - color: Theme.backgroundColor + color: "#ffffff" } diff --git a/src/imports/controls/Drawer.qml b/src/imports/controls/Drawer.qml index 5cf0994a..2b50b7d4 100644 --- a/src/imports/controls/Drawer.qml +++ b/src/imports/controls/Drawer.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.Drawer { @@ -46,7 +45,7 @@ T.Drawer { //! [background] background: Rectangle { - color: control.Theme.shadowColor + color: "#28282a" opacity: position * 0.75 } //! [background] diff --git a/src/imports/controls/Label.qml b/src/imports/controls/Label.qml index 82b2c629..1047bfaa 100644 --- a/src/imports/controls/Label.qml +++ b/src/imports/controls/Label.qml @@ -35,12 +35,11 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.Label { id: control - color: Theme.textColor - linkColor: Theme.focusColor // TODO + color: "#26282a" + linkColor: "#45a7d7" // TODO } diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml index e1361b83..e569a0de 100644 --- a/src/imports/controls/PageIndicator.qml +++ b/src/imports/controls/PageIndicator.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.PageIndicator { @@ -55,7 +54,7 @@ T.PageIndicator { implicitHeight: 8 radius: width / 2 - color: control.Theme.shadowColor // TODO + color: "#28282a" // TODO opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45 Behavior on opacity { OpacityAnimator { duration: 100 } } diff --git a/src/imports/controls/ScrollBar.qml b/src/imports/controls/ScrollBar.qml index d1a45a71..55d53191 100644 --- a/src/imports/controls/ScrollBar.qml +++ b/src/imports/controls/ScrollBar.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.ScrollBar { @@ -56,7 +55,7 @@ T.ScrollBar { implicitHeight: 6 radius: width / 2 - color: control.pressed ? control.Theme.shadowColor : control.Theme.frameColor + color: control.pressed ? "#28282a" : "#bdbebf" visible: control.size < 1.0 opacity: 0.0 diff --git a/src/imports/controls/ScrollIndicator.qml b/src/imports/controls/ScrollIndicator.qml index 8c4fc1d5..e2fc23b1 100644 --- a/src/imports/controls/ScrollIndicator.qml +++ b/src/imports/controls/ScrollIndicator.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.ScrollIndicator { @@ -55,7 +54,7 @@ T.ScrollIndicator { implicitWidth: 2 implicitHeight: 2 - color: control.Theme.frameColor + color: "#bdbebf" visible: control.size < 1.0 opacity: 0.0 diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml index 6a157ba9..ff27d8ba 100644 --- a/src/imports/controls/SpinBox.qml +++ b/src/imports/controls/SpinBox.qml @@ -68,8 +68,8 @@ T.SpinBox { font: control.font color: control.enabled ? "#353637" : "#bdbebf" -// selectionColor: control.Theme.selectionColor -// selectedTextColor: control.Theme.selectedTextColor +// selectionColor: TODO +// selectedTextColor: TODO horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml index d4fa9497..de5994e8 100644 --- a/src/imports/controls/TextArea.qml +++ b/src/imports/controls/TextArea.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.TextArea { @@ -50,9 +49,9 @@ T.TextArea { padding: 6 - color: enabled ? Theme.textColor : Theme.disabledColor - selectionColor: Theme.selectionColor - selectedTextColor: Theme.selectedTextColor + color: enabled ? "#26282a" : "#c2c2c2" +// selectionColor: TODO +// selectedTextColor: TODO Text { id: placeholder @@ -63,7 +62,7 @@ T.TextArea { text: control.placeholderText font: control.font - color: control.Theme.disabledColor + color: "#c2c2c2" horizontalAlignment: control.horizontalAlignment verticalAlignment: control.verticalAlignment visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml index be1b5d7a..3d3fc74c 100644 --- a/src/imports/controls/ToolBar.qml +++ b/src/imports/controls/ToolBar.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.ToolBar { @@ -54,7 +53,7 @@ T.ToolBar { //! [background] background: Rectangle { implicitHeight: 26 - color: control.Theme.baseColor + color: "#eeeeee" } //! [background] } diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml index ecaad9a0..17fd03c5 100644 --- a/src/imports/controls/ToolButton.qml +++ b/src/imports/controls/ToolButton.qml @@ -35,7 +35,6 @@ ****************************************************************************/ import QtQuick 2.6 -import Qt.labs.controls 1.0 import Qt.labs.templates 1.0 as T T.ToolButton { @@ -58,7 +57,7 @@ T.ToolButton { text: control.text font: control.font - color: control.enabled ? control.Theme.textColor : control.Theme.disabledColor + color: control.enabled ? "#26282a" : "#c2c2c2" elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -70,7 +69,7 @@ T.ToolButton { implicitWidth: 26 implicitHeight: 26 - color: Qt.darker(control.Theme.pressColor, control.checkable && control.checked ? 1.5 : 1.0) + color: Qt.darker("#33333333", control.checkable && control.checked ? 1.5 : 1.0) opacity: control.pressed ? 1.0 : control.checkable && control.checked ? 0.5 : 0 visible: control.pressed || (control.checkable && control.checked) } diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index fa493508..d0cf0550 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -27,11 +27,3 @@ QML_FILES = \ ToolBar.qml \ ToolButton.qml \ Tumbler.qml - -HEADERS += \ - $$PWD/qquickthemedata_p.h \ - $$PWD/qquicktheme_p.h - -SOURCES += \ - $$PWD/qquicktheme.cpp \ - $$PWD/qquickthemedata.cpp diff --git a/src/imports/controls/doc/images/qtlabscontrols-pageindicator.png b/src/imports/controls/doc/images/qtlabscontrols-pageindicator.png Binary files differindex 4bef41e6..3f47fb9f 100644 --- a/src/imports/controls/doc/images/qtlabscontrols-pageindicator.png +++ b/src/imports/controls/doc/images/qtlabscontrols-pageindicator.png diff --git a/src/imports/controls/doc/images/qtlabscontrols-scrollbar.png b/src/imports/controls/doc/images/qtlabscontrols-scrollbar.png Binary files differindex 6756fd3c..65db9ad8 100644 --- a/src/imports/controls/doc/images/qtlabscontrols-scrollbar.png +++ b/src/imports/controls/doc/images/qtlabscontrols-scrollbar.png diff --git a/src/imports/controls/doc/images/qtlabscontrols-scrollindicator.png b/src/imports/controls/doc/images/qtlabscontrols-scrollindicator.png Binary files differindex f1ab6107..ea0923cc 100644 --- a/src/imports/controls/doc/images/qtlabscontrols-scrollindicator.png +++ b/src/imports/controls/doc/images/qtlabscontrols-scrollindicator.png diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-pageindicator.qml b/src/imports/controls/doc/snippets/qtlabscontrols-pageindicator.qml index 7118d99f..f13e1213 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-pageindicator.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-pageindicator.qml @@ -28,10 +28,9 @@ import QtQuick 2.0 import Qt.labs.controls 1.0 -Rectangle { +Frame { width: 100 height: 100 - border.color: Theme.frameColor //! [1] PageIndicator { diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-scrollbar.qml b/src/imports/controls/doc/snippets/qtlabscontrols-scrollbar.qml index 49416f84..b677137d 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-scrollbar.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-scrollbar.qml @@ -28,10 +28,9 @@ import QtQuick 2.0 import Qt.labs.controls 1.0 -Rectangle { +Frame { width: 100 height: 100 - border.color: Theme.frameColor ScrollBar { size: 0.3 diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-scrollindicator.qml b/src/imports/controls/doc/snippets/qtlabscontrols-scrollindicator.qml index 38a9e2eb..8efa0eed 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-scrollindicator.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-scrollindicator.qml @@ -28,10 +28,9 @@ import QtQuick 2.0 import Qt.labs.controls 1.0 -Rectangle { +Frame { width: 100 height: 100 - border.color: Theme.frameColor ScrollIndicator { size: 0.3 diff --git a/src/imports/controls/qquicktheme.cpp b/src/imports/controls/qquicktheme.cpp deleted file mode 100644 index 923d452b..00000000 --- a/src/imports/controls/qquicktheme.cpp +++ /dev/null @@ -1,620 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquicktheme_p.h" -#include "qquickthemedata_p.h" -#include "qquickstyle_p.h" - -#include <QtCore/qset.h> -#include <QtCore/qpointer.h> -#include <QtQml/qqmlengine.h> -#include <QtQuick/qquickitem.h> -#include <QtQuick/qquickwindow.h> -#include <QtQuick/private/qquickitem_p.h> -#include <QtQuick/private/qquickitemchangelistener_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Theme - \inherits QtObject - \instantiates QQuickThemeAttached - \inqmlmodule Qt.labs.controls - \ingroup utilities - \brief A theme interface. - - TODO -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::accentColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::backgroundColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::disabledColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::focusColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::frameColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::pressColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::selectedTextColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::selectionColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::shadowColor -*/ - -/*! - \qmlattachedproperty color Qt.labs.controls::Theme::textColor -*/ - -Q_GLOBAL_STATIC_WITH_ARGS(QQuickThemeData, globalThemeData, (QString::fromLatin1(":/qtlabscontrols/theme.json"))) - -class QQuickThemeAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener -{ - Q_DECLARE_PUBLIC(QQuickThemeAttached) - -public: - QQuickThemeAttachedPrivate(const QQuickThemeData &data) : data(data), - explicitAccentColor(false), - explicitBackgroundColor(false), - explicitBaseColor(false), - explicitDisabledColor(false), - explicitFocusColor(false), - explicitFrameColor(false), - explicitPressColor(false), - explicitSelectedTextColor(false), - explicitSelectionColor(false), - explicitShadowColor(false), - explicitTextColor(false) { } - - enum Method { Implicit, Explicit, Inherit }; - - void setAccentColor(const QColor &color, Method method); - void setBackgroundColor(const QColor &color, Method method); - void setBaseColor(const QColor &color, Method method); - void setDisabledColor(const QColor &color, Method method); - void setFocusColor(const QColor &color, Method method); - void setFrameColor(const QColor &color, Method method); - void setPressColor(const QColor &color, Method method); - void setSelectedTextColor(const QColor &color, Method method); - void setSelectionColor(const QColor &color, Method method); - void setShadowColor(const QColor &color, Method method); - void setTextColor(const QColor &color, Method method); - - void inherit(QQuickThemeAttached *theme); - - const QQuickThemeData &resolve() const; - - // TODO: add QQuickItemChangeListener::itemSceneChanged() - void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE; - - QQuickThemeData data; - QPointer<QQuickThemeAttached> parentTheme; - QSet<QQuickThemeAttached *> childThemes; - - bool explicitAccentColor; - bool explicitBackgroundColor; - bool explicitBaseColor; - bool explicitDisabledColor; - bool explicitFocusColor; - bool explicitFrameColor; - bool explicitPressColor; - bool explicitSelectedTextColor; - bool explicitSelectionColor; - bool explicitShadowColor; - bool explicitTextColor; -}; - -void QQuickThemeAttachedPrivate::setAccentColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitAccentColor || method != Inherit) { - explicitAccentColor = method == Explicit; - if (data.accentColor() != color) { - data.setAccentColor(color); - emit q->accentColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setAccentColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setBackgroundColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitBackgroundColor || method != Inherit) { - explicitBackgroundColor = method == Explicit; - if (data.backgroundColor() != color) { - data.setBackgroundColor(color); - emit q->backgroundColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setBackgroundColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setBaseColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitBaseColor || method != Inherit) { - explicitBaseColor = method == Explicit; - if (data.baseColor() != color) { - data.setBaseColor(color); - emit q->baseColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setBaseColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setDisabledColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitDisabledColor || method != Inherit) { - explicitDisabledColor = method == Explicit; - if (data.disabledColor() != color) { - data.setDisabledColor(color); - emit q->disabledColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setDisabledColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setFocusColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitFocusColor || method != Inherit) { - explicitFocusColor = method == Explicit; - if (data.focusColor() != color) { - data.setFocusColor(color); - emit q->focusColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setFocusColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setFrameColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitFrameColor || method != Inherit) { - explicitFrameColor = method == Explicit; - if (data.frameColor() != color) { - data.setFrameColor(color); - emit q->frameColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setFrameColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setPressColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitPressColor || method != Inherit) { - explicitPressColor = method == Explicit; - if (data.pressColor() != color) { - data.setPressColor(color); - emit q->pressColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setPressColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setSelectedTextColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitSelectedTextColor || method != Inherit) { - explicitSelectedTextColor = method == Explicit; - if (data.selectedTextColor() != color) { - data.setSelectedTextColor(color); - q->selectedTextColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setSelectedTextColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setSelectionColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitSelectionColor || method != Inherit) { - explicitSelectionColor = method == Explicit; - if (data.selectionColor() != color) { - data.setSelectionColor(color); - emit q->selectionColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setSelectionColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setShadowColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitShadowColor || method != Inherit) { - explicitShadowColor = method == Explicit; - if (data.shadowColor() != color) { - data.setShadowColor(color); - emit q->shadowColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setShadowColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::setTextColor(const QColor &color, Method method) -{ - Q_Q(QQuickThemeAttached); - if (!explicitTextColor || method != Inherit) { - explicitTextColor = method == Explicit; - if (data.textColor() != color) { - data.setTextColor(color); - emit q->textColorChanged(); - - foreach (QQuickThemeAttached *child, childThemes) - child->d_func()->setTextColor(color, Inherit); - } - } -} - -void QQuickThemeAttachedPrivate::inherit(QQuickThemeAttached *theme) -{ - setAccentColor(theme->accentColor(), Inherit); - setBackgroundColor(theme->backgroundColor(), Inherit); - setBaseColor(theme->baseColor(), QQuickThemeAttachedPrivate::Inherit); - setDisabledColor(theme->disabledColor(), QQuickThemeAttachedPrivate::Inherit); - setFocusColor(theme->focusColor(), Inherit); - setFrameColor(theme->frameColor(), Inherit); - setPressColor(theme->pressColor(), Inherit); - setSelectedTextColor(theme->selectedTextColor(), Inherit); - setSelectionColor(theme->selectionColor(), Inherit); - setShadowColor(theme->shadowColor(), Inherit); - setTextColor(theme->textColor(), Inherit); -} - -const QQuickThemeData &QQuickThemeAttachedPrivate::resolve() const -{ - Q_Q(const QQuickThemeAttached); - QQuickThemeAttached *theme = QQuickStyle::findParent<QQuickThemeAttached>(const_cast<QQuickThemeAttached *>(q)); - return theme ? theme->d_func()->data : *globalThemeData(); -} - -void QQuickThemeAttachedPrivate::itemParentChanged(QQuickItem *item, QQuickItem *parentItem) -{ - QQuickThemeAttached *theme = QQuickStyle::instance<QQuickThemeAttached>(item); - if (theme) { - QQuickThemeAttached *parent = QQuickStyle::findParent<QQuickThemeAttached>(parentItem); - if (parent) - theme->setParentTheme(parent); - } -} - -QQuickThemeAttached::QQuickThemeAttached(QObject *parent) : - QObject(*(new QQuickThemeAttachedPrivate(*globalThemeData())), parent) -{ - Q_D(QQuickThemeAttached); - QQuickItem *item = qobject_cast<QQuickItem *>(parent); - if (item) - QQuickItemPrivate::get(item)->addItemChangeListener(d, QQuickItemPrivate::Parent); -} - -QQuickThemeAttached::QQuickThemeAttached(const QQuickThemeData &data, QObject *parent) : - QObject(*(new QQuickThemeAttachedPrivate(data)), parent) -{ - Q_D(QQuickThemeAttached); - QQuickItem *item = qobject_cast<QQuickItem *>(parent); - if (item) - QQuickItemPrivate::get(item)->addItemChangeListener(d, QQuickItemPrivate::Parent); -} - -QQuickThemeAttached::~QQuickThemeAttached() -{ - Q_D(QQuickThemeAttached); - QQuickItem *item = qobject_cast<QQuickItem *>(parent()); - if (item) - QQuickItemPrivate::get(item)->removeItemChangeListener(d, QQuickItemPrivate::Parent); - - setParentTheme(Q_NULLPTR); -} - -QQuickThemeAttached *QQuickThemeAttached::qmlAttachedProperties(QObject *object) -{ - QQuickThemeAttached *theme = Q_NULLPTR; - QQuickThemeAttached *parent = QQuickStyle::findParent<QQuickThemeAttached>(object); - if (parent) { - theme = new QQuickThemeAttached(parent->d_func()->data, object); - theme->setParentTheme(parent); - } else { - theme = new QQuickThemeAttached(object); - } - - QList<QQuickThemeAttached *> childThemes = QQuickStyle::findChildren<QQuickThemeAttached>(object); - foreach (QQuickThemeAttached *child, childThemes) - child->setParentTheme(theme); - return theme; -} - -QQuickThemeAttached *QQuickThemeAttached::parentTheme() const -{ - Q_D(const QQuickThemeAttached); - return d->parentTheme; -} - -void QQuickThemeAttached::setParentTheme(QQuickThemeAttached *theme) -{ - Q_D(QQuickThemeAttached); - if (d->parentTheme != theme) { - if (d->parentTheme) - d->parentTheme->d_func()->childThemes.remove(this); - d->parentTheme = theme; - if (theme) { - theme->d_func()->childThemes.insert(this); - d->inherit(theme); - } - } -} - -QColor QQuickThemeAttached::accentColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.accentColor(); -} - -void QQuickThemeAttached::setAccentColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setAccentColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetAccentColor() -{ - Q_D(QQuickThemeAttached); - d->setAccentColor(d->resolve().accentColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::backgroundColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.backgroundColor(); -} - -void QQuickThemeAttached::setBackgroundColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setBackgroundColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetBackgroundColor() -{ - Q_D(QQuickThemeAttached); - d->setBackgroundColor(d->resolve().backgroundColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::baseColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.baseColor(); -} - -void QQuickThemeAttached::setBaseColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setBaseColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetBaseColor() -{ - Q_D(QQuickThemeAttached); - d->setBaseColor(d->resolve().baseColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::disabledColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.disabledColor(); -} - -void QQuickThemeAttached::setDisabledColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setDisabledColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetDisabledColor() -{ - Q_D(QQuickThemeAttached); - d->setDisabledColor(d->resolve().disabledColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::focusColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.focusColor(); -} - -void QQuickThemeAttached::setFocusColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setFocusColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetFocusColor() -{ - Q_D(QQuickThemeAttached); - d->setFocusColor(d->resolve().focusColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::frameColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.frameColor(); -} - -void QQuickThemeAttached::setFrameColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setFrameColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetFrameColor() -{ - Q_D(QQuickThemeAttached); - d->setFrameColor(d->resolve().frameColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::pressColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.pressColor(); -} - -void QQuickThemeAttached::setPressColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setPressColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetPressColor() -{ - Q_D(QQuickThemeAttached); - d->setPressColor(d->resolve().pressColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::selectedTextColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.selectedTextColor(); -} - -void QQuickThemeAttached::setSelectedTextColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setSelectedTextColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetSelectedTextColor() -{ - Q_D(QQuickThemeAttached); - d->setSelectedTextColor(d->resolve().selectedTextColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::selectionColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.selectionColor(); -} - -void QQuickThemeAttached::setSelectionColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setSelectionColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetSelectionColor() -{ - Q_D(QQuickThemeAttached); - d->setSelectionColor(d->resolve().selectionColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::shadowColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.shadowColor(); -} - -void QQuickThemeAttached::setShadowColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setShadowColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetShadowColor() -{ - Q_D(QQuickThemeAttached); - d->setShadowColor(d->resolve().shadowColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QColor QQuickThemeAttached::textColor() const -{ - Q_D(const QQuickThemeAttached); - return d->data.textColor(); -} - -void QQuickThemeAttached::setTextColor(const QColor &color) -{ - Q_D(QQuickThemeAttached); - d->setTextColor(color, QQuickThemeAttachedPrivate::Explicit); -} - -void QQuickThemeAttached::resetTextColor() -{ - Q_D(QQuickThemeAttached); - d->setTextColor(d->resolve().textColor(), QQuickThemeAttachedPrivate::Implicit); -} - -QT_END_NAMESPACE diff --git a/src/imports/controls/qquicktheme_p.h b/src/imports/controls/qquicktheme_p.h deleted file mode 100644 index 0d204537..00000000 --- a/src/imports/controls/qquicktheme_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKTHEME_P_H -#define QQUICKTHEME_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQml/qqml.h> -#include <QtGui/qcolor.h> -#include <QtCore/qobject.h> - -QT_BEGIN_NAMESPACE - -class QQuickThemeData; -class QQuickThemeAttachedPrivate; - -class QQuickThemeAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor RESET resetAccentColor NOTIFY accentColorChanged FINAL) - Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor RESET resetBackgroundColor NOTIFY backgroundColorChanged FINAL) - Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor RESET resetBaseColor NOTIFY baseColorChanged FINAL) - Q_PROPERTY(QColor disabledColor READ disabledColor WRITE setDisabledColor RESET resetDisabledColor NOTIFY disabledColorChanged FINAL) - Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor RESET resetFocusColor NOTIFY focusColorChanged FINAL) - Q_PROPERTY(QColor frameColor READ frameColor WRITE setFrameColor RESET resetFrameColor NOTIFY frameColorChanged FINAL) - Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor RESET resetPressColor NOTIFY pressColorChanged FINAL) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor RESET resetSelectedTextColor NOTIFY selectedTextColorChanged FINAL) - Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor RESET resetSelectionColor NOTIFY selectionColorChanged FINAL) - Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor RESET resetShadowColor NOTIFY shadowColorChanged FINAL) - Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor RESET resetTextColor NOTIFY textColorChanged FINAL) - -public: - explicit QQuickThemeAttached(QObject *parent = Q_NULLPTR); - explicit QQuickThemeAttached(const QQuickThemeData &data, QObject *parent = Q_NULLPTR); - ~QQuickThemeAttached(); - - static QQuickThemeAttached *qmlAttachedProperties(QObject *object); - - QQuickThemeAttached *parentTheme() const; - void setParentTheme(QQuickThemeAttached *theme); - - QColor accentColor() const; - void setAccentColor(const QColor &color); - void resetAccentColor(); - - QColor disabledColor() const; - void setDisabledColor(const QColor &color); - void resetDisabledColor(); - - QColor backgroundColor() const; - void setBackgroundColor(const QColor &color); - void resetBackgroundColor(); - - QColor baseColor() const; - void setBaseColor(const QColor &color); - void resetBaseColor(); - - QColor focusColor() const; - void setFocusColor(const QColor &color); - void resetFocusColor(); - - QColor frameColor() const; - void setFrameColor(const QColor &color); - void resetFrameColor(); - - QColor pressColor() const; - void setPressColor(const QColor &color); - void resetPressColor(); - - QColor selectedTextColor() const; - void setSelectedTextColor(const QColor &color); - void resetSelectedTextColor(); - - QColor selectionColor() const; - void setSelectionColor(const QColor &color); - void resetSelectionColor(); - - QColor shadowColor() const; - void setShadowColor(const QColor &color); - void resetShadowColor(); - - QColor textColor() const; - void setTextColor(const QColor &color); - void resetTextColor(); - -Q_SIGNALS: - void accentColorChanged(); - void backgroundColorChanged(); - void baseColorChanged(); - void disabledColorChanged(); - void focusColorChanged(); - void frameColorChanged(); - void pressColorChanged(); - void selectedTextColorChanged(); - void selectionColorChanged(); - void shadowColorChanged(); - void textColorChanged(); - -private: - Q_DISABLE_COPY(QQuickThemeAttached) - Q_DECLARE_PRIVATE(QQuickThemeAttached) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QQuickThemeAttached, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QQUICKTHEME_P_H diff --git a/src/imports/controls/qquickthemedata.cpp b/src/imports/controls/qquickthemedata.cpp deleted file mode 100644 index e5624412..00000000 --- a/src/imports/controls/qquickthemedata.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickthemedata_p.h" - -#include <QtCore/qfile.h> -#include <QtCore/qjsondocument.h> -#include <QtCore/qjsonobject.h> -#include <QtCore/qjsonvalue.h> -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -QQuickThemeData::QQuickThemeData(const QString &filePath) : d(new Data) -{ - if (!filePath.isEmpty()) - load(filePath); -} - -static QColor readColorValue(const QJsonValue &value, const QColor &defaultValue) -{ - if (value.isString()) - return QColor(value.toString()); - return QColor::fromRgba(value.toInt(defaultValue.rgba())); -} - -bool QQuickThemeData::load(const QString &filePath) -{ - QJsonDocument doc; - - QFile file(filePath); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - qDebug() << file.error(); - qWarning() << "QQuickTheme: failed to open ':/qtlabscontrols/theme.json': " << qPrintable(file.errorString()); - return false; - } else { - QJsonParseError error; - doc = QJsonDocument::fromJson(file.readAll(), &error); - if (error.error != QJsonParseError::NoError) { - qWarning() << "QQuickTheme: failed to parse ':/qtlabscontrols/theme.json': " << qPrintable(error.errorString()); - return false; - } - } - - QJsonObject theme = doc.object(); - d->accentColor = readColorValue(theme.value(QStringLiteral("accentColor")), QColor("#7bc258")); - d->backgroundColor = readColorValue(theme.value(QStringLiteral("backgroundColor")), QColor("#ffffff")); - d->baseColor = readColorValue(theme.value(QStringLiteral("baseColor")), QColor("#eeeeee")); - d->disabledColor = readColorValue(theme.value(QStringLiteral("disabledColor")), QColor("#c2c2c2")); - d->focusColor = readColorValue(theme.value(QStringLiteral("focusColor")), QColor("#45a7d7")); - d->frameColor = readColorValue(theme.value(QStringLiteral("frameColor")), QColor("#bdbebf")); - d->pressColor = readColorValue(theme.value(QStringLiteral("pressColor")), QColor("#33333333")); - d->selectedTextColor = readColorValue(theme.value(QStringLiteral("selectedTextColor")), QColor("#ffffff")); - d->selectionColor = readColorValue(theme.value(QStringLiteral("selectionColor")), QColor("#45a7d7")); - d->shadowColor = readColorValue(theme.value(QStringLiteral("shadowColor")), QColor("#28282a")); - d->textColor = readColorValue(theme.value(QStringLiteral("textColor")), QColor("#26282a")); - return true; -} - -QT_END_NAMESPACE diff --git a/src/imports/controls/qquickthemedata_p.h b/src/imports/controls/qquickthemedata_p.h deleted file mode 100644 index 6154aa2a..00000000 --- a/src/imports/controls/qquickthemedata_p.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKTHEMEDATA_P_H -#define QQUICKTHEMEDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/qcolor.h> -#include <QtCore/qstring.h> -#include <QtCore/qshareddata.h> - -QT_BEGIN_NAMESPACE - -class QQuickThemeData -{ -public: - QQuickThemeData(const QString &filePath = QString()); - - bool load(const QString &filePath); - - QColor accentColor() const { return d->accentColor; } - void setAccentColor(const QColor &color) { d->accentColor = color; } - - QColor backgroundColor() const { return d->backgroundColor; } - void setBackgroundColor(const QColor &color) { d->backgroundColor = color; } - - QColor baseColor() const { return d->baseColor; } - void setBaseColor(const QColor &color) { d->baseColor = color; } - - QColor disabledColor() const { return d->disabledColor; } - void setDisabledColor(const QColor &color) { d->disabledColor = color; } - - QColor focusColor() const { return d->focusColor; } - void setFocusColor(const QColor &color) { d->focusColor = color; } - - QColor frameColor() const { return d->frameColor; } - void setFrameColor(const QColor &color) { d->frameColor = color; } - - QColor pressColor() const { return d->pressColor; } - void setPressColor(const QColor &color) { d->pressColor = color; } - - QColor selectedTextColor() const { return d->selectedTextColor; } - void setSelectedTextColor(const QColor &color) { d->selectedTextColor = color; } - - QColor selectionColor() const { return d->selectionColor; } - void setSelectionColor(const QColor &color) { d->selectionColor = color; } - - QColor shadowColor() const { return d->shadowColor; } - void setShadowColor(const QColor &color) { d->shadowColor = color; } - - QColor textColor() const { return d->textColor; } - void setTextColor(const QColor &color) { d->textColor = color; } - -private: - struct Data : public QSharedData { - QColor accentColor; - QColor baseColor; - QColor backgroundColor; - QColor disabledColor; - QColor focusColor; - QColor frameColor; - QColor pressColor; - QColor selectedTextColor; - QColor selectionColor; - QColor shadowColor; - QColor textColor; - }; - QSharedDataPointer<Data> d; -}; - -QT_END_NAMESPACE - -#endif // QQUICKTHEMEDATA_P_H diff --git a/src/imports/controls/qtlabscontrolsplugin.cpp b/src/imports/controls/qtlabscontrolsplugin.cpp index 8c65abc5..25b9c9ce 100644 --- a/src/imports/controls/qtlabscontrolsplugin.cpp +++ b/src/imports/controls/qtlabscontrolsplugin.cpp @@ -42,8 +42,6 @@ #include <QtLabsTemplates/private/qquickbuttongroup_p.h> #include <QtLabsControls/private/qquickstyleselector_p.h> -#include "qquicktheme_p.h" - void initResources() { Q_INIT_RESOURCE(qtlabscontrolsplugin); @@ -63,8 +61,6 @@ public: void QtLabsControlsPlugin::registerTypes(const char *uri) { - qmlRegisterUncreatableType<QQuickThemeAttached>(uri, 1, 0, "Theme", tr("Theme is an attached property")); - qmlRegisterType<QQuickButtonGroup>(uri, 1, 0, "ButtonGroup"); qmlRegisterType<QQuickButtonGroupAttached>(); |