summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/theme
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/theme')
-rw-r--r--src/datavisualization/theme/builtin3dthemes.cpp230
-rw-r--r--src/datavisualization/theme/builtin3dthemes_p.h87
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp89
-rw-r--r--src/datavisualization/theme/q3dtheme.h14
-rw-r--r--src/datavisualization/theme/q3dtheme_p.h25
-rw-r--r--src/datavisualization/theme/thememanager.cpp609
-rw-r--r--src/datavisualization/theme/thememanager_p.h63
7 files changed, 426 insertions, 691 deletions
diff --git a/src/datavisualization/theme/builtin3dthemes.cpp b/src/datavisualization/theme/builtin3dthemes.cpp
deleted file mode 100644
index 9848e6e5..00000000
--- a/src/datavisualization/theme/builtin3dthemes.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-#include "builtin3dthemes_p.h"
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-BuiltIn3DThemeQt::BuiltIn3DThemeQt()
- : Q3DTheme(QDataVis::ThemeQt)
-{
- setBaseColor(QColor(QRgb(0x80c342)));
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x35322f)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0x14aaff)));
- setMultiHighlightColor(QColor(QRgb(0x6400aa)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(true);
- setColorStyle(QDataVis::ColorStyleUniform);
-}
-
-BuiltIn3DThemePrimaryColors::BuiltIn3DThemePrimaryColors()
- : Q3DTheme(QDataVis::ThemePrimaryColors)
-{
- setBaseColor(QColor(QRgb(0xffe400)));
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0x27beee)));
- setMultiHighlightColor(QColor(QRgb(0xee1414)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
-}
-
-BuiltIn3DThemeDigia::BuiltIn3DThemeDigia()
- : Q3DTheme(QDataVis::ThemeDigia)
-{
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x80));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0xfa0000)));
- setMultiHighlightColor(QColor(QRgb(0x555555)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
- QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
- qreal(gradientTextureHeight),
- 0.0, 0.0);
- QColor color;
- color.setRed(0xcc * 0.7);
- color.setGreen(0xcc * 0.7);
- color.setBlue(0xcc * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0xcccccc)));
- setBaseGradient(gradient);
- color.setRed(0xfa * 0.7);
- color.setGreen(0x00);
- color.setBlue(0x00);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0xfa0000)));
- setSingleHighlightGradient(gradient);
- color.setRed(0x55 * 0.7);
- color.setGreen(0x55 * 0.7);
- color.setBlue(0x55 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x555555)));
- setMultiHighlightGradient(gradient);
-}
-
-BuiltIn3DThemeStoneMoss::BuiltIn3DThemeStoneMoss()
- : Q3DTheme(QDataVis::ThemeStoneMoss)
-{
- setBaseColor(QColor(QRgb(0xbeb32b)));
- setBackgroundColor(QColor(QRgb(0x4d4d4f)));
- setWindowColor(QColor(QRgb(0x4d4d4f)));
- setTextColor(QColor(QRgb(0xffffff)));
- setTextBackgroundColor(QColor(0x4d, 0x4d, 0x4f, 0xcd));
- setGridLineColor(QColor(QRgb(0x3e3e40)));
- setSingleHighlightColor(QColor(QRgb(0xfbf6d6)));
- setMultiHighlightColor(QColor(QRgb(0x442f20)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(true);
- setColorStyle(QDataVis::ColorStyleUniform);
-}
-
-BuiltIn3DThemeArmyBlue::BuiltIn3DThemeArmyBlue()
- : Q3DTheme(QDataVis::ThemeArmyBlue)
-{
- setBackgroundColor(QColor(QRgb(0xd5d6d7)));
- setWindowColor(QColor(QRgb(0xd5d6d7)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xd5, 0xd6, 0xd7, 0xcd));
- setGridLineColor(QColor(QRgb(0xaeadac)));
- setSingleHighlightColor(QColor(QRgb(0x2aa2f9)));
- setMultiHighlightColor(QColor(QRgb(0x103753)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
- QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
- qreal(gradientTextureHeight),
- 0.0, 0.0);
- QColor color;
- color.setRed(0x49 * 0.7);
- color.setGreen(0x5f * 0.7);
- color.setBlue(0x76 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x495f76)));
- setBaseGradient(gradient);
- color.setRed(0x2a * 0.7);
- color.setGreen(0xa2 * 0.7);
- color.setBlue(0xf9 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x2aa2f9)));
- setSingleHighlightGradient(gradient);
- color.setRed(0x10 * 0.7);
- color.setGreen(0x37 * 0.7);
- color.setBlue(0x53 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x103753)));
- setMultiHighlightGradient(gradient);
-}
-
-BuiltIn3DThemeRetro::BuiltIn3DThemeRetro()
- : Q3DTheme(QDataVis::ThemeRetro)
-{
- setBackgroundColor(QColor(QRgb(0xe9e2ce)));
- setWindowColor(QColor(QRgb(0xe9e2ce)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xe9, 0xe2, 0xce, 0xc0));
- setGridLineColor(QColor(QRgb(0xd0c0b0)));
- setSingleHighlightColor(QColor(QRgb(0x8ea317)));
- setMultiHighlightColor(QColor(QRgb(0xc25708)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
- QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
- qreal(gradientTextureHeight),
- 0.0, 0.0);
- QColor color;
- color.setRed(0x53 * 0.7);
- color.setGreen(0x3b * 0.7);
- color.setBlue(0x23 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x533b23)));
- setBaseGradient(gradient);
- color.setRed(0x8e * 0.7);
- color.setGreen(0xa3 * 0.7);
- color.setBlue(0x17 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0x8ea317)));
- setSingleHighlightGradient(gradient);
- color.setRed(0xc2 * 0.7);
- color.setGreen(0x57 * 0.7);
- color.setBlue(0x08 * 0.7);
- gradient.setColorAt(0.0, color);
- gradient.setColorAt(1.0, QColor(QRgb(0xc25708)));
- setMultiHighlightGradient(gradient);
-}
-
-BuiltIn3DThemeEbony::BuiltIn3DThemeEbony()
- : Q3DTheme(QDataVis::ThemeEbony)
-{
- setBaseColor(QColor(QRgb(0xffffff)));
- setBackgroundColor(QColor(QRgb(0x000000)));
- setWindowColor(QColor(QRgb(0x000000)));
- setTextColor(QColor(QRgb(0xaeadac)));
- setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xcd));
- setGridLineColor(QColor(QRgb(0x35322f)));
- setSingleHighlightColor(QColor(QRgb(0xf5dc0d)));
- setMultiHighlightColor(QColor(QRgb(0xd72222)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
-}
-
-BuiltIn3DThemeIsabelle::BuiltIn3DThemeIsabelle()
- : Q3DTheme(QDataVis::ThemeIsabelle)
-{
- setBaseColor(QColor(QRgb(0xf9d900)));
- setBackgroundColor(QColor(QRgb(0x000000)));
- setWindowColor(QColor(QRgb(0x000000)));
- setTextColor(QColor(QRgb(0xaeadac)));
- setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xc0));
- setGridLineColor(QColor(QRgb(0x35322f)));
- setSingleHighlightColor(QColor(QRgb(0xfff7cc)));
- setMultiHighlightColor(QColor(QRgb(0xde0a0a)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
-}
-
-QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/builtin3dthemes_p.h b/src/datavisualization/theme/builtin3dthemes_p.h
deleted file mode 100644
index 8f2c3d04..00000000
--- a/src/datavisualization/theme/builtin3dthemes_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtDataVisualization 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.
-
-#ifndef BUILTIN3DTHEMES_P_H
-#define BUILTIN3DTHEMES_P_H
-
-#include "datavisualizationglobal_p.h"
-#include "q3dtheme_p.h"
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-class BuiltIn3DThemeQt : public Q3DTheme
-{
-public:
- BuiltIn3DThemeQt();
-};
-
-class BuiltIn3DThemePrimaryColors : public Q3DTheme
-{
-public:
- BuiltIn3DThemePrimaryColors();
-};
-
-class BuiltIn3DThemeDigia : public Q3DTheme
-{
-public:
- BuiltIn3DThemeDigia();
-};
-
-class BuiltIn3DThemeStoneMoss : public Q3DTheme
-{
-public:
- BuiltIn3DThemeStoneMoss();
-};
-
-class BuiltIn3DThemeArmyBlue : public Q3DTheme
-{
-public:
- BuiltIn3DThemeArmyBlue();
-};
-
-class BuiltIn3DThemeRetro : public Q3DTheme
-{
-public:
- BuiltIn3DThemeRetro();
-};
-
-class BuiltIn3DThemeEbony : public Q3DTheme
-{
-public:
- BuiltIn3DThemeEbony();
-};
-
-class BuiltIn3DThemeIsabelle : public Q3DTheme
-{
-public:
- BuiltIn3DThemeIsabelle();
-};
-
-QT_DATAVISUALIZATION_END_NAMESPACE
-
-#endif
diff --git a/src/datavisualization/theme/q3dtheme.cpp b/src/datavisualization/theme/q3dtheme.cpp
index 3d85b9fa..a3703779 100644
--- a/src/datavisualization/theme/q3dtheme.cpp
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -17,8 +17,9 @@
****************************************************************************/
#include "q3dtheme_p.h"
+#include "thememanager_p.h"
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
/*!
* \class Q3DTheme
@@ -110,8 +111,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \li Qt::white
* \row
* \li lightColor
- * \li The color of the specular light. Doesn't affect ambient light. \note Not yet supported
- * in alpha release.
+ * \li The color of the light. Affects both ambient and specular light.
* \li Qt::white
* \row
* \li lightStrength
@@ -121,22 +121,22 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \row
* \li multiHighlightColor
* \li The color to be used for highlighted objects, if \l{Q3DBars::selectionMode}{selectionMode}
- * of the graph has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * of the graph has \c QAbstract3DGraph::SelectionRow or \c QAbstract3DGraph::SelectionColumn flag set.
* \li Qt::blue
* \row
* \li multiHighlightGradient
* \li The gradient to be used for highlighted objects, if \l{Q3DBars::selectionMode}{selectionMode}
- * of the graph has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * of the graph has \c QAbstract3DGraph::SelectionRow or \c QAbstract3DGraph::SelectionColumn flag set.
* \li QLinearGradient(). Essentially fully black.
* \row
* \li singleHighlightColor
* \li The color to be used for a highlighted object, if \l{Q3DBars::selectionMode}{selectionMode}
- * of the graph has \c QDataVis::SelectionItem flag set.
+ * of the graph has \c QAbstract3DGraph::SelectionItem flag set.
* \li Qt::red
* \row
* \li singleHighlightGradient
* \li The gradient to be used for a highlighted object, if \l{Q3DBars::selectionMode}{selectionMode}
- * of the graph has \c QDataVis::SelectionItem flag set.
+ * of the graph has \c QAbstract3DGraph::SelectionItem flag set.
* \li QLinearGradient(). Essentially fully black.
* \row
* \li windowColor
@@ -234,6 +234,8 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* Using a user-defined theme:
*
* \snippet doc_src_q3dtheme.cpp 6
+ *
+ * For Theme3D enums, see \l Q3DTheme::ColorStyle and \l Q3DTheme::Theme
*/
/*!
@@ -292,8 +294,6 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \qmlproperty Color Theme3D::lightColor
*
* Color for the specular light defined in Scene3D.
- *
- * \warning Not supported in alpha release.
*/
/*!
@@ -377,6 +377,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \qmlproperty Theme3D.Theme Theme3D::type
*
* The type of the theme. If no type is set, the type is \c Theme3D.ThemeUserDefined.
+ * Changing the theme type after the item has been constructed will change all other properties
+ * of the theme to what the predefined theme specifies. Changing the theme type of the active theme
+ * of the graph will also reset all attached series to use the new theme.
*/
/*!
@@ -385,7 +388,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
*/
Q3DTheme::Q3DTheme(QObject *parent)
: QObject(parent),
- d_ptr(new Q3DThemePrivate(this, ThemeUserDefined))
+ d_ptr(new Q3DThemePrivate(this))
{
}
@@ -396,8 +399,9 @@ Q3DTheme::Q3DTheme(QObject *parent)
*/
Q3DTheme::Q3DTheme(Theme themeType, QObject *parent)
: QObject(parent),
- d_ptr(new Q3DThemePrivate(this, themeType))
+ d_ptr(new Q3DThemePrivate(this))
{
+ setType(themeType);
}
/*!
@@ -408,7 +412,7 @@ Q3DTheme::Q3DTheme(Q3DThemePrivate *d, Theme themeType,
QObject(parent),
d_ptr(d)
{
- d_ptr->m_themeId = themeType;
+ setType(themeType);
}
/*!
@@ -418,7 +422,6 @@ Q3DTheme::~Q3DTheme()
{
}
-// TODO: Add needRenders if necessary after color api has been added to series (QTRD-2200/2557)
/*!
* \property Q3DTheme::baseColors
*
@@ -549,7 +552,7 @@ QColor Q3DTheme::gridLineColor() const
* \property Q3DTheme::singleHighlightColor
*
* Highlight color for a highlighted object. Used if \l{Q3DBars::selectionMode}{selectionMode} has
- * \c QDataVis::SelectionItem flag set.
+ * \c QAbstract3DGraph::SelectionItem flag set.
*/
void Q3DTheme::setSingleHighlightColor(const QColor &color)
{
@@ -569,7 +572,7 @@ QColor Q3DTheme::singleHighlightColor() const
* \property Q3DTheme::multiHighlightColor
*
* Highlight color for highlighted objects. Used if \l{Q3DBars::selectionMode}{selectionMode} has
- * \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * \c QAbstract3DGraph::SelectionRow or \c QAbstract3DGraph::SelectionColumn flag set.
*/
void Q3DTheme::setMultiHighlightColor(const QColor &color)
{
@@ -589,8 +592,6 @@ QColor Q3DTheme::multiHighlightColor() const
* \property Q3DTheme::lightColor
*
* Color for the specular light defined in Q3DScene.
- *
- * \warning Not supported in alpha release.
*/
void Q3DTheme::setLightColor(const QColor &color)
{
@@ -638,7 +639,7 @@ QList<QLinearGradient> Q3DTheme::baseGradients() const
* \property Q3DTheme::singleHighlightGradient
*
* Highlight gradient for a highlighted object. Used if \l{Q3DBars::selectionMode}{selectionMode}
- * has \c QDataVis::SelectionItem flag set.
+ * has \c QAbstract3DGraph::SelectionItem flag set.
*/
void Q3DTheme::setSingleHighlightGradient(const QLinearGradient &gradient)
{
@@ -658,7 +659,7 @@ QLinearGradient Q3DTheme::singleHighlightGradient() const
* \property Q3DTheme::multiHighlightGradient
*
* Highlight gradient for highlighted objects. Used if \l{Q3DBars::selectionMode}{selectionMode}
- * has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * has \c QAbstract3DGraph::SelectionRow or \c QAbstract3DGraph::SelectionColumn flag set.
*/
void Q3DTheme::setMultiHighlightGradient(const QLinearGradient &gradient)
{
@@ -862,14 +863,18 @@ Q3DTheme::ColorStyle Q3DTheme::colorStyle() const
/*!
* \property Q3DTheme::type
*
- * The type of the theme. Type is automatically set when constructing a theme. User should not
- * need to use this when using C++ API.
+ * The type of the theme. The type is automatically set when constructing a theme,
+ * but can also be changed later. Changing the theme type will change all other
+ * properties of the theme to what the predefined theme specifies.
+ * Changing the theme type of the active theme of the graph will also reset all
+ * attached series to use the new theme.
*/
void Q3DTheme::setType(Theme themeType)
{
d_ptr->m_dirtyBits.themeIdDirty = true;
if (d_ptr->m_themeId != themeType) {
d_ptr->m_themeId = themeType;
+ ThemeManager::setPredefinedPropertiesToTheme(this, themeType);
emit typeChanged(themeType);
}
}
@@ -881,9 +886,9 @@ Q3DTheme::Theme Q3DTheme::type() const
// Q3DThemePrivate
-Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, Q3DTheme::Theme theme_id)
+Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q)
: QObject(0),
- m_themeId(theme_id),
+ m_themeId(Q3DTheme::ThemeUserDefined),
m_backgroundColor(Qt::black),
m_windowColor(Qt::black),
m_textColor(Qt::white),
@@ -907,6 +912,8 @@ Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, Q3DTheme::Theme theme_id)
m_backgoundEnabled(true),
m_gridEnabled(true),
m_labelBackground(true),
+ m_isDefaultTheme(false),
+ m_forcePredefinedType(true),
q_ptr(q)
{
m_baseColors.append(QColor(Qt::black));
@@ -947,118 +954,102 @@ void Q3DThemePrivate::resetDirtyBits()
bool Q3DThemePrivate::sync(Q3DThemePrivate &other)
{
- bool changed = false;
+ bool updateDrawer = false;
if (m_dirtyBits.ambientLightStrengthDirty) {
other.q_ptr->setAmbientLightStrength(m_ambientLightStrength);
m_dirtyBits.ambientLightStrengthDirty = false;
- changed = true;
}
if (m_dirtyBits.backgroundColorDirty) {
other.q_ptr->setBackgroundColor(m_backgroundColor);
m_dirtyBits.backgroundColorDirty = false;
- changed = true;
}
if (m_dirtyBits.backgroundEnabledDirty) {
other.q_ptr->setBackgroundEnabled(m_backgoundEnabled);
m_dirtyBits.backgroundEnabledDirty = false;
- changed = true;
}
if (m_dirtyBits.baseColorDirty) {
other.q_ptr->setBaseColors(m_baseColors);
m_dirtyBits.baseColorDirty = false;
- changed = true;
}
if (m_dirtyBits.baseGradientDirty) {
other.q_ptr->setBaseGradients(m_baseGradients);
m_dirtyBits.baseGradientDirty = false;
- changed = true;
}
if (m_dirtyBits.colorStyleDirty) {
other.q_ptr->setColorStyle(m_colorStyle);
m_dirtyBits.colorStyleDirty = false;
- changed = true;
}
if (m_dirtyBits.fontDirty) {
other.q_ptr->setFont(m_font);
m_dirtyBits.fontDirty = false;
- changed = true;
+ updateDrawer = true;
}
if (m_dirtyBits.gridEnabledDirty) {
other.q_ptr->setGridEnabled(m_gridEnabled);
m_dirtyBits.gridEnabledDirty = false;
- changed = true;
}
if (m_dirtyBits.gridLineColorDirty) {
other.q_ptr->setGridLineColor(m_gridLineColor);
m_dirtyBits.gridLineColorDirty = false;
- changed = true;
}
if (m_dirtyBits.highlightLightStrengthDirty) {
other.q_ptr->setHighlightLightStrength(m_highlightLightStrength);
m_dirtyBits.highlightLightStrengthDirty = false;
- changed = true;
}
if (m_dirtyBits.labelBackgroundColorDirty) {
other.q_ptr->setLabelBackgroundColor(m_textBackgroundColor);
m_dirtyBits.labelBackgroundColorDirty = false;
- changed = true;
+ updateDrawer = true;
}
if (m_dirtyBits.labelBackgroundEnabledDirty) {
other.q_ptr->setLabelBackgroundEnabled(m_labelBackground);
m_dirtyBits.labelBackgroundEnabledDirty = false;
- changed = true;
+ updateDrawer = true;
}
if (m_dirtyBits.labelBorderEnabledDirty) {
other.q_ptr->setLabelBorderEnabled(m_labelBorders);
m_dirtyBits.labelBorderEnabledDirty = false;
- changed = true;
+ updateDrawer = true;
}
if (m_dirtyBits.labelTextColorDirty) {
other.q_ptr->setLabelTextColor(m_textColor);
m_dirtyBits.labelTextColorDirty = false;
- changed = true;
+ updateDrawer = true;
}
if (m_dirtyBits.lightColorDirty) {
other.q_ptr->setLightColor(m_lightColor);
m_dirtyBits.lightColorDirty = false;
- changed = true;
}
if (m_dirtyBits.lightStrengthDirty) {
other.q_ptr->setLightStrength(m_lightStrength);
m_dirtyBits.lightStrengthDirty = false;
- changed = true;
}
if (m_dirtyBits.multiHighlightColorDirty) {
other.q_ptr->setMultiHighlightColor(m_multiHighlightColor);
m_dirtyBits.multiHighlightColorDirty = false;
- changed = true;
}
if (m_dirtyBits.multiHighlightGradientDirty) {
other.q_ptr->setMultiHighlightGradient(m_multiHighlightGradient);
m_dirtyBits.multiHighlightGradientDirty = false;
- changed = true;
}
if (m_dirtyBits.singleHighlightColorDirty) {
other.q_ptr->setSingleHighlightColor(m_singleHighlightColor);
m_dirtyBits.singleHighlightColorDirty = false;
- changed = true;
}
if (m_dirtyBits.singleHighlightGradientDirty) {
other.q_ptr->setSingleHighlightGradient(m_singleHighlightGradient);
m_dirtyBits.singleHighlightGradientDirty = false;
- changed = true;
}
if (m_dirtyBits.themeIdDirty) {
other.m_themeId = m_themeId; // Set directly to avoid a call to ThemeManager's useTheme()
m_dirtyBits.themeIdDirty = false;
- changed = true;
}
if (m_dirtyBits.windowColorDirty) {
other.q_ptr->setWindowColor(m_windowColor);
m_dirtyBits.windowColorDirty = false;
- changed = true;
}
- return changed;
+
+ return updateDrawer;
}
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
index 44e58e5d..91c5bb6f 100644
--- a/src/datavisualization/theme/q3dtheme.h
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -19,12 +19,13 @@
#ifndef Q3DTHEME_H
#define Q3DTHEME_H
-#include <QtDataVisualization/qdatavisualizationenums.h>
+#include <QtDataVisualization/qdatavisualizationglobal.h>
+
#include <QLinearGradient>
#include <QFont>
#include <QColor>
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
class Q3DThemePrivate;
@@ -42,7 +43,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged)
Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged)
Q_PROPERTY(QColor multiHighlightColor READ multiHighlightColor WRITE setMultiHighlightColor NOTIFY multiHighlightColorChanged)
- Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) // TODO: Not used yet
+ Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged)
Q_PROPERTY(QList<QLinearGradient> baseGradients READ baseGradients WRITE setBaseGradients NOTIFY baseGradientsChanged)
Q_PROPERTY(QLinearGradient singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
Q_PROPERTY(QLinearGradient multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
@@ -55,7 +56,6 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged)
Q_PROPERTY(ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
- // TODO: Add everything we need (specularIntensity, lightDegradation, shaders?)
public:
enum ColorStyle {
@@ -178,11 +178,13 @@ protected:
friend class ThemeManager;
friend class Abstract3DRenderer;
friend class Bars3DController;
+ friend class AbstractDeclarative;
+ friend class Abstract3DController;
private:
Q_DISABLE_COPY(Q3DTheme)
};
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION
#endif
diff --git a/src/datavisualization/theme/q3dtheme_p.h b/src/datavisualization/theme/q3dtheme_p.h
index c9f59d99..c378a504 100644
--- a/src/datavisualization/theme/q3dtheme_p.h
+++ b/src/datavisualization/theme/q3dtheme_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -32,7 +32,7 @@
#include "datavisualizationglobal_p.h"
#include "q3dtheme.h"
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
struct Q3DThemeDirtyBitField {
bool baseColorDirty : 1;
@@ -85,18 +85,29 @@ struct Q3DThemeDirtyBitField {
}
};
-class Q3DThemePrivate : public QObject
+class QT_DATAVISUALIZATION_EXPORT Q3DThemePrivate : public QObject
{
Q_OBJECT
public:
- Q3DThemePrivate(Q3DTheme *q,
- Q3DTheme::Theme theme_id = Q3DTheme::ThemeUserDefined);
+ Q3DThemePrivate(Q3DTheme *q);
virtual ~Q3DThemePrivate();
void resetDirtyBits();
bool sync(Q3DThemePrivate &other);
+ inline bool isDefaultTheme() { return m_isDefaultTheme; }
+ inline void setDefaultTheme(bool isDefault) { m_isDefaultTheme = isDefault; }
+
+ // If m_forcePredefinedType is true, it means we should forcibly update all properties
+ // of the theme to those of the predefined theme, when setting the theme type. Otherwise
+ // we only change the properties that haven't been explicitly changed since last render cycle.
+ // Defaults to true, and is only ever set to false by DeclarativeTheme3D to enable using
+ // predefined themes as base for custom themes, since the order of initial property sets cannot
+ // be easily controlled in QML.
+ inline bool isForcePredefinedType() { return m_forcePredefinedType; }
+ inline void setForcePredefinedType(bool enable) { m_forcePredefinedType = enable; }
+
signals:
void needRender();
@@ -126,11 +137,13 @@ public:
bool m_backgoundEnabled;
bool m_gridEnabled;
bool m_labelBackground;
+ bool m_isDefaultTheme;
+ bool m_forcePredefinedType;
protected:
Q3DTheme *q_ptr;
};
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION
#endif
diff --git a/src/datavisualization/theme/thememanager.cpp b/src/datavisualization/theme/thememanager.cpp
index cc5362ef..bef2eca1 100644
--- a/src/datavisualization/theme/thememanager.cpp
+++ b/src/datavisualization/theme/thememanager.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -19,13 +19,13 @@
#include "thememanager_p.h"
#include "q3dtheme_p.h"
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
const float defaultBuiltInColorLevel = 0.7f; // for built-in gradient themes
const float defaultColorLevel = 0.5f; // for built-in uniform themes
ThemeManager::ThemeManager(Abstract3DController *controller)
- : m_theme(0),
+ : m_activeTheme(0),
m_controller(controller)
{
}
@@ -34,374 +34,415 @@ ThemeManager::~ThemeManager()
{
}
-void ThemeManager::setTheme(Q3DTheme *theme)
+void ThemeManager::addTheme(Q3DTheme *theme)
{
- if (!theme)
- return;
-
- if (m_theme.data() != theme) {
- // Disconnect old theme signal connections
- if (m_theme) {
- disconnect(m_theme->d_ptr.data(), 0, m_controller, 0);
- disconnect(m_theme.data(), 0, m_controller, 0);
- disconnect(m_theme.data(), 0, this, 0);
- }
+ Q_ASSERT(theme);
+ ThemeManager *owner = qobject_cast<ThemeManager *>(theme->parent());
+ if (owner != this) {
+ Q_ASSERT_X(!owner, "addTheme", "Theme already attached to a graph.");
+ theme->setParent(this);
+ }
+ if (!m_themes.contains(theme))
+ m_themes.append(theme);
+}
- m_theme.reset(theme);
+void ThemeManager::releaseTheme(Q3DTheme *theme)
+{
+ if (theme && m_themes.contains(theme)) {
+ // Clear the default status from released default theme
+ if (theme->d_ptr->isDefaultTheme())
+ theme->d_ptr->setDefaultTheme(false);
- Q3DTheme::Theme type = m_theme->type();
+ // If the theme is in use, replace it with a temporary one
+ if (theme == m_activeTheme)
+ setActiveTheme(0);
- if (type != Q3DTheme::ThemeUserDefined) {
- useTheme(type);
- // Reset all bits to dirty for sync
- m_theme->d_ptr->resetDirtyBits();
- }
+ m_themes.removeAll(theme);
+ theme->setParent(0);
+ }
+}
- // Connect signals from new one
- connectThemeSignals();
+void ThemeManager::setActiveTheme(Q3DTheme *theme)
+{
+ // Setting null theme indicates using default theme
+ if (!theme) {
+ theme = new Q3DTheme;
+ theme->d_ptr->setDefaultTheme(true);
}
+
+ // If the old theme is default theme, delete it
+ Q3DTheme *oldTheme = m_activeTheme;
+ if (oldTheme) {
+ if (oldTheme->d_ptr->isDefaultTheme()) {
+ m_themes.removeAll(oldTheme);
+ delete oldTheme;
+ oldTheme = 0;
+ } else {
+ // Disconnect the old theme from use
+ disconnect(m_activeTheme->d_ptr.data(), 0, m_controller, 0);
+ disconnect(m_activeTheme, 0, m_controller, 0);
+ }
+ }
+
+ // Assume ownership
+ addTheme(theme);
+
+ m_activeTheme = theme;
+
+ // Reset all bits to dirty for sync
+ m_activeTheme->d_ptr->resetDirtyBits();
+
+ // Connect signals from new one
+ connectThemeSignals();
}
-Q3DTheme *ThemeManager::theme() const
+Q3DTheme *ThemeManager::activeTheme() const
{
- return m_theme.data();
+ return m_activeTheme;
+}
+
+QList<Q3DTheme *> ThemeManager::themes() const
+{
+ return m_themes;
}
void ThemeManager::connectThemeSignals()
{
- connect(m_theme.data(), &Q3DTheme::colorStyleChanged,
+ connect(m_activeTheme, &Q3DTheme::colorStyleChanged,
m_controller, &Abstract3DController::handleThemeColorStyleChanged);
- connect(m_theme.data(), &Q3DTheme::baseColorsChanged,
+ connect(m_activeTheme, &Q3DTheme::baseColorsChanged,
m_controller, &Abstract3DController::handleThemeBaseColorsChanged);
- connect(m_theme.data(), &Q3DTheme::singleHighlightColorChanged,
+ connect(m_activeTheme, &Q3DTheme::singleHighlightColorChanged,
m_controller, &Abstract3DController::handleThemeSingleHighlightColorChanged);
- connect(m_theme.data(), &Q3DTheme::multiHighlightColorChanged,
+ connect(m_activeTheme, &Q3DTheme::multiHighlightColorChanged,
m_controller, &Abstract3DController::handleThemeMultiHighlightColorChanged);
- connect(m_theme.data(), &Q3DTheme::baseGradientsChanged,
+ connect(m_activeTheme, &Q3DTheme::baseGradientsChanged,
m_controller, &Abstract3DController::handleThemeBaseGradientsChanged);
- connect(m_theme.data(), &Q3DTheme::singleHighlightGradientChanged,
+ connect(m_activeTheme, &Q3DTheme::singleHighlightGradientChanged,
m_controller, &Abstract3DController::handleThemeSingleHighlightGradientChanged);
- connect(m_theme.data(), &Q3DTheme::multiHighlightGradientChanged,
+ connect(m_activeTheme, &Q3DTheme::multiHighlightGradientChanged,
m_controller, &Abstract3DController::handleThemeMultiHighlightGradientChanged);
+ connect(m_activeTheme, &Q3DTheme::typeChanged,
+ m_controller, &Abstract3DController::handleThemeTypeChanged);
- connect(m_theme->d_ptr.data(), &Q3DThemePrivate::needRender,
+ connect(m_activeTheme->d_ptr.data(), &Q3DThemePrivate::needRender,
m_controller, &Abstract3DController::needRender);
-
- connect(m_theme.data(), &Q3DTheme::typeChanged, this, &ThemeManager::useTheme);
}
-void ThemeManager::useTheme(Q3DTheme::Theme type)
+void ThemeManager::setPredefinedPropertiesToTheme(Q3DTheme *theme, Q3DTheme::Theme type)
{
+ QList<QColor> baseColors;
+ QList<QLinearGradient> baseGradients;
switch (type) {
case Q3DTheme::ThemeQt: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0x80c342)));
baseColors.append(QColor(QRgb(0x469835)));
baseColors.append(QColor(QRgb(0x006325)));
baseColors.append(QColor(QRgb(0x5caa15)));
baseColors.append(QColor(QRgb(0x328930)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x35322f)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0x14aaff)));
- setMultiHighlightColor(QColor(QRgb(0x6400aa)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(true);
- setColorStyle(Q3DTheme::ColorStyleUniform);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0x14aaff)), defaultColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0x6400aa)), defaultColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0xffffff)));
+ setWindowColor(theme, QColor(QRgb(0xffffff)));
+ setTextColor(theme, QColor(QRgb(0x35322f)));
+ setTextBackgroundColor(theme, QColor(0xff, 0xff, 0xff, 0x99));
+ setGridLineColor(theme, QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(theme, QColor(QRgb(0x14aaff)));
+ setMultiHighlightColor(theme, QColor(QRgb(0x6400aa)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, true);
+ setColorStyle(theme, Q3DTheme::ColorStyleUniform);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0x14aaff)),
+ defaultColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0x6400aa)),
+ defaultColorLevel));
break;
}
case Q3DTheme::ThemePrimaryColors: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0xffe400)));
baseColors.append(QColor(QRgb(0xfaa106)));
baseColors.append(QColor(QRgb(0xf45f0d)));
baseColors.append(QColor(QRgb(0xfcba04)));
baseColors.append(QColor(QRgb(0xf7800a)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0x27beee)));
- setMultiHighlightColor(QColor(QRgb(0xee1414)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleUniform);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0x27beee)), defaultColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0xee1414)), defaultColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0xffffff)));
+ setWindowColor(theme, QColor(QRgb(0xffffff)));
+ setTextColor(theme, QColor(QRgb(0x000000)));
+ setTextBackgroundColor(theme, QColor(0xff, 0xff, 0xff, 0x99));
+ setGridLineColor(theme, QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(theme, QColor(QRgb(0x27beee)));
+ setMultiHighlightColor(theme, QColor(QRgb(0xee1414)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleUniform);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0x27beee)),
+ defaultColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0xee1414)),
+ defaultColorLevel));
break;
}
case Q3DTheme::ThemeDigia: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0xeaeaea)));
baseColors.append(QColor(QRgb(0xa0a0a0)));
baseColors.append(QColor(QRgb(0x626262)));
baseColors.append(QColor(QRgb(0xbebebe)));
baseColors.append(QColor(QRgb(0x818181)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0xffffff)));
- setWindowColor(QColor(QRgb(0xffffff)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x80));
- setGridLineColor(QColor(QRgb(0xd7d6d5)));
- setSingleHighlightColor(QColor(QRgb(0xfa0000)));
- setMultiHighlightColor(QColor(QRgb(0x333333)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleObjectGradient);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0xfa0000)), defaultBuiltInColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0x333333)), defaultBuiltInColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0xffffff)));
+ setWindowColor(theme, QColor(QRgb(0xffffff)));
+ setTextColor(theme, QColor(QRgb(0x000000)));
+ setTextBackgroundColor(theme, QColor(0xff, 0xff, 0xff, 0x80));
+ setGridLineColor(theme, QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(theme, QColor(QRgb(0xfa0000)));
+ setMultiHighlightColor(theme, QColor(QRgb(0x333333)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0xfa0000)),
+ defaultBuiltInColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0x333333)),
+ defaultBuiltInColorLevel));
break;
}
case Q3DTheme::ThemeStoneMoss: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0xbeb32b)));
baseColors.append(QColor(QRgb(0x928327)));
baseColors.append(QColor(QRgb(0x665423)));
baseColors.append(QColor(QRgb(0xa69929)));
baseColors.append(QColor(QRgb(0x7c6c25)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0x4d4d4f)));
- setWindowColor(QColor(QRgb(0x4d4d4f)));
- setTextColor(QColor(QRgb(0xffffff)));
- setTextBackgroundColor(QColor(0x4d, 0x4d, 0x4f, 0xcd));
- setGridLineColor(QColor(QRgb(0x3e3e40)));
- setSingleHighlightColor(QColor(QRgb(0xfbf6d6)));
- setMultiHighlightColor(QColor(QRgb(0x442f20)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(true);
- setColorStyle(Q3DTheme::ColorStyleUniform);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0xfbf6d6)), defaultColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0x442f20)), defaultColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0x4d4d4f)));
+ setWindowColor(theme, QColor(QRgb(0x4d4d4f)));
+ setTextColor(theme, QColor(QRgb(0xffffff)));
+ setTextBackgroundColor(theme, QColor(0x4d, 0x4d, 0x4f, 0xcd));
+ setGridLineColor(theme, QColor(QRgb(0x3e3e40)));
+ setSingleHighlightColor(theme, QColor(QRgb(0xfbf6d6)));
+ setMultiHighlightColor(theme, QColor(QRgb(0x442f20)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, true);
+ setColorStyle(theme, Q3DTheme::ColorStyleUniform);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0xfbf6d6)),
+ defaultColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0x442f20)),
+ defaultColorLevel));
break;
}
case Q3DTheme::ThemeArmyBlue: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0x495f76)));
baseColors.append(QColor(QRgb(0x81909f)));
baseColors.append(QColor(QRgb(0xbec5cd)));
baseColors.append(QColor(QRgb(0x687a8d)));
baseColors.append(QColor(QRgb(0xa3aeb9)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0xd5d6d7)));
- setWindowColor(QColor(QRgb(0xd5d6d7)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xd5, 0xd6, 0xd7, 0xcd));
- setGridLineColor(QColor(QRgb(0xaeadac)));
- setSingleHighlightColor(QColor(QRgb(0x2aa2f9)));
- setMultiHighlightColor(QColor(QRgb(0x103753)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleObjectGradient);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0x2aa2f9)), defaultBuiltInColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0x103753)), defaultBuiltInColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0xd5d6d7)));
+ setWindowColor(theme, QColor(QRgb(0xd5d6d7)));
+ setTextColor(theme, QColor(QRgb(0x000000)));
+ setTextBackgroundColor(theme, QColor(0xd5, 0xd6, 0xd7, 0xcd));
+ setGridLineColor(theme, QColor(QRgb(0xaeadac)));
+ setSingleHighlightColor(theme, QColor(QRgb(0x2aa2f9)));
+ setMultiHighlightColor(theme, QColor(QRgb(0x103753)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0x2aa2f9)),
+ defaultBuiltInColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0x103753)),
+ defaultBuiltInColorLevel));
break;
}
case Q3DTheme::ThemeRetro: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0x533b23)));
baseColors.append(QColor(QRgb(0x83715a)));
baseColors.append(QColor(QRgb(0xb3a690)));
baseColors.append(QColor(QRgb(0x6b563e)));
baseColors.append(QColor(QRgb(0x9b8b75)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0xe9e2ce)));
- setWindowColor(QColor(QRgb(0xe9e2ce)));
- setTextColor(QColor(QRgb(0x000000)));
- setTextBackgroundColor(QColor(0xe9, 0xe2, 0xce, 0xc0));
- setGridLineColor(QColor(QRgb(0xd0c0b0)));
- setSingleHighlightColor(QColor(QRgb(0x8ea317)));
- setMultiHighlightColor(QColor(QRgb(0xc25708)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleObjectGradient);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0x8ea317)), defaultBuiltInColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0xc25708)), defaultBuiltInColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0xe9e2ce)));
+ setWindowColor(theme, QColor(QRgb(0xe9e2ce)));
+ setTextColor(theme, QColor(QRgb(0x000000)));
+ setTextBackgroundColor(theme, QColor(0xe9, 0xe2, 0xce, 0xc0));
+ setGridLineColor(theme, QColor(QRgb(0xd0c0b0)));
+ setSingleHighlightColor(theme, QColor(QRgb(0x8ea317)));
+ setMultiHighlightColor(theme, QColor(QRgb(0xc25708)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0x8ea317)),
+ defaultBuiltInColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0xc25708)),
+ defaultBuiltInColorLevel));
break;
}
case Q3DTheme::ThemeEbony: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0xffffff)));
baseColors.append(QColor(QRgb(0x999999)));
baseColors.append(QColor(QRgb(0x474747)));
baseColors.append(QColor(QRgb(0xc7c7c7)));
baseColors.append(QColor(QRgb(0x6b6b6b)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0x000000)));
- setWindowColor(QColor(QRgb(0x000000)));
- setTextColor(QColor(QRgb(0xaeadac)));
- setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xcd));
- setGridLineColor(QColor(QRgb(0x35322f)));
- setSingleHighlightColor(QColor(QRgb(0xf5dc0d)));
- setMultiHighlightColor(QColor(QRgb(0xd72222)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleUniform);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0xf5dc0d)), defaultColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0xd72222)), defaultColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0x000000)));
+ setWindowColor(theme, QColor(QRgb(0x000000)));
+ setTextColor(theme, QColor(QRgb(0xaeadac)));
+ setTextBackgroundColor(theme, QColor(0x00, 0x00, 0x00, 0xcd));
+ setGridLineColor(theme, QColor(QRgb(0x35322f)));
+ setSingleHighlightColor(theme, QColor(QRgb(0xf5dc0d)));
+ setMultiHighlightColor(theme, QColor(QRgb(0xd72222)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleUniform);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0xf5dc0d)),
+ defaultColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0xd72222)),
+ defaultColorLevel));
break;
}
case Q3DTheme::ThemeIsabelle: {
- QList<QColor> baseColors;
baseColors.append(QColor(QRgb(0xf9d900)));
baseColors.append(QColor(QRgb(0xf09603)));
baseColors.append(QColor(QRgb(0xe85506)));
baseColors.append(QColor(QRgb(0xf5b802)));
baseColors.append(QColor(QRgb(0xec7605)));
- QList<QLinearGradient> baseGradients;
baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
- setBackgroundEnabled(true);
- setGridEnabled(true);
- setFont(QFont(QStringLiteral("Arial")));
- setLabelBackgroundEnabled(true);
- setLightColor(Qt::white);
- setBaseColors(baseColors);
- setBackgroundColor(QColor(QRgb(0x000000)));
- setWindowColor(QColor(QRgb(0x000000)));
- setTextColor(QColor(QRgb(0xaeadac)));
- setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xc0));
- setGridLineColor(QColor(QRgb(0x35322f)));
- setSingleHighlightColor(QColor(QRgb(0xfff7cc)));
- setMultiHighlightColor(QColor(QRgb(0xde0a0a)));
- setLightStrength(5.0f);
- setAmbientLightStrength(0.5f);
- setHighlightLightStrength(5.0f);
- setLabelBorderEnabled(false);
- setColorStyle(Q3DTheme::ColorStyleUniform);
- setBaseGradients(baseGradients);
- setSingleHighlightGradient(createGradient(QColor(QRgb(0xfff7cc)), defaultColorLevel));
- setMultiHighlightGradient(createGradient(QColor(QRgb(0xde0a0a)), defaultColorLevel));
+ setBackgroundEnabled(theme, true);
+ setGridEnabled(theme, true);
+ setFont(theme, QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(theme, true);
+ setLightColor(theme, Qt::white);
+ setBaseColors(theme, baseColors);
+ setBackgroundColor(theme, QColor(QRgb(0x000000)));
+ setWindowColor(theme, QColor(QRgb(0x000000)));
+ setTextColor(theme, QColor(QRgb(0xaeadac)));
+ setTextBackgroundColor(theme, QColor(0x00, 0x00, 0x00, 0xc0));
+ setGridLineColor(theme, QColor(QRgb(0x35322f)));
+ setSingleHighlightColor(theme, QColor(QRgb(0xfff7cc)));
+ setMultiHighlightColor(theme, QColor(QRgb(0xde0a0a)));
+ setLightStrength(theme, 5.0f);
+ setAmbientLightStrength(theme, 0.5f);
+ setHighlightLightStrength(theme, 5.0f);
+ setLabelBorderEnabled(theme, false);
+ setColorStyle(theme, Q3DTheme::ColorStyleUniform);
+ setBaseGradients(theme, baseGradients);
+ setSingleHighlightGradient(theme, createGradient(QColor(QRgb(0xfff7cc)),
+ defaultColorLevel));
+ setMultiHighlightGradient(theme, createGradient(QColor(QRgb(0xde0a0a)),
+ defaultColorLevel));
break;
}
default:
@@ -423,130 +464,130 @@ QLinearGradient ThemeManager::createGradient(const QColor &color, float colorLev
return gradient;
}
-void ThemeManager::setBaseColors(const QList<QColor> &colors)
+void ThemeManager::setBaseColors(Q3DTheme *theme, const QList<QColor> &colors)
{
- if (!m_theme->d_ptr->m_dirtyBits.baseColorDirty)
- m_theme->setBaseColors(colors);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.baseColorDirty)
+ theme->setBaseColors(colors);
}
-void ThemeManager::setBackgroundColor(const QColor &color)
+void ThemeManager::setBackgroundColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.backgroundColorDirty)
- m_theme->setBackgroundColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.backgroundColorDirty)
+ theme->setBackgroundColor(color);
}
-void ThemeManager::setWindowColor(const QColor &color)
+void ThemeManager::setWindowColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.windowColorDirty)
- m_theme->setWindowColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.windowColorDirty)
+ theme->setWindowColor(color);
}
-void ThemeManager::setTextColor(const QColor &color)
+void ThemeManager::setTextColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.labelTextColorDirty)
- m_theme->setLabelTextColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelTextColorDirty)
+ theme->setLabelTextColor(color);
}
-void ThemeManager::setTextBackgroundColor(const QColor &color)
+void ThemeManager::setTextBackgroundColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.labelBackgroundColorDirty)
- m_theme->setLabelBackgroundColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBackgroundColorDirty)
+ theme->setLabelBackgroundColor(color);
}
-void ThemeManager::setGridLineColor(const QColor &color)
+void ThemeManager::setGridLineColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.gridLineColorDirty)
- m_theme->setGridLineColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.gridLineColorDirty)
+ theme->setGridLineColor(color);
}
-void ThemeManager::setSingleHighlightColor(const QColor &color)
+void ThemeManager::setSingleHighlightColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.singleHighlightColorDirty)
- m_theme->setSingleHighlightColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.singleHighlightColorDirty)
+ theme->setSingleHighlightColor(color);
}
-void ThemeManager::setMultiHighlightColor(const QColor &color)
+void ThemeManager::setMultiHighlightColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.multiHighlightColorDirty)
- m_theme->setMultiHighlightColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.multiHighlightColorDirty)
+ theme->setMultiHighlightColor(color);
}
-void ThemeManager::setLightColor(const QColor &color)
+void ThemeManager::setLightColor(Q3DTheme *theme, const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.lightColorDirty)
- m_theme->setLightColor(color);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.lightColorDirty)
+ theme->setLightColor(color);
}
-void ThemeManager::setBaseGradients(const QList<QLinearGradient> &gradients)
+void ThemeManager::setBaseGradients(Q3DTheme *theme, const QList<QLinearGradient> &gradients)
{
- if (!m_theme->d_ptr->m_dirtyBits.baseGradientDirty)
- m_theme->setBaseGradients(gradients);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.baseGradientDirty)
+ theme->setBaseGradients(gradients);
}
-void ThemeManager::setSingleHighlightGradient(const QLinearGradient &gradient)
+void ThemeManager::setSingleHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient)
{
- if (!m_theme->d_ptr->m_dirtyBits.singleHighlightGradientDirty)
- m_theme->setSingleHighlightGradient(gradient);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.singleHighlightGradientDirty)
+ theme->setSingleHighlightGradient(gradient);
}
-void ThemeManager::setMultiHighlightGradient(const QLinearGradient &gradient)
+void ThemeManager::setMultiHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient)
{
- if (!m_theme->d_ptr->m_dirtyBits.multiHighlightGradientDirty)
- m_theme->setMultiHighlightGradient(gradient);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.multiHighlightGradientDirty)
+ theme->setMultiHighlightGradient(gradient);
}
-void ThemeManager::setLightStrength(float strength)
+void ThemeManager::setLightStrength(Q3DTheme *theme, float strength)
{
- if (!m_theme->d_ptr->m_dirtyBits.lightStrengthDirty)
- m_theme->setLightStrength(strength);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.lightStrengthDirty)
+ theme->setLightStrength(strength);
}
-void ThemeManager::setAmbientLightStrength(float strength)
+void ThemeManager::setAmbientLightStrength(Q3DTheme *theme, float strength)
{
- if (!m_theme->d_ptr->m_dirtyBits.ambientLightStrengthDirty)
- m_theme->setAmbientLightStrength(strength);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.ambientLightStrengthDirty)
+ theme->setAmbientLightStrength(strength);
}
-void ThemeManager::setHighlightLightStrength(float strength)
+void ThemeManager::setHighlightLightStrength(Q3DTheme *theme, float strength)
{
- if (!m_theme->d_ptr->m_dirtyBits.highlightLightStrengthDirty)
- m_theme->setHighlightLightStrength(strength);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.highlightLightStrengthDirty)
+ theme->setHighlightLightStrength(strength);
}
-void ThemeManager::setLabelBorderEnabled(bool enabled)
+void ThemeManager::setLabelBorderEnabled(Q3DTheme *theme, bool enabled)
{
- if (!m_theme->d_ptr->m_dirtyBits.labelBorderEnabledDirty)
- m_theme->setLabelBorderEnabled(enabled);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBorderEnabledDirty)
+ theme->setLabelBorderEnabled(enabled);
}
-void ThemeManager::setFont(const QFont &font)
+void ThemeManager::setFont(Q3DTheme *theme, const QFont &font)
{
- if (!m_theme->d_ptr->m_dirtyBits.fontDirty)
- m_theme->setFont(font);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.fontDirty)
+ theme->setFont(font);
}
-void ThemeManager::setBackgroundEnabled(bool enabled)
+void ThemeManager::setBackgroundEnabled(Q3DTheme *theme, bool enabled)
{
- if (!m_theme->d_ptr->m_dirtyBits.backgroundEnabledDirty)
- m_theme->setBackgroundEnabled(enabled);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.backgroundEnabledDirty)
+ theme->setBackgroundEnabled(enabled);
}
-void ThemeManager::setGridEnabled(bool enabled)
+void ThemeManager::setGridEnabled(Q3DTheme *theme, bool enabled)
{
- if (!m_theme->d_ptr->m_dirtyBits.gridEnabledDirty)
- m_theme->setGridEnabled(enabled);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.gridEnabledDirty)
+ theme->setGridEnabled(enabled);
}
-void ThemeManager::setLabelBackgroundEnabled(bool enabled)
+void ThemeManager::setLabelBackgroundEnabled(Q3DTheme *theme, bool enabled)
{
- if (!m_theme->d_ptr->m_dirtyBits.labelBackgroundEnabledDirty)
- m_theme->setLabelBackgroundEnabled(enabled);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.labelBackgroundEnabledDirty)
+ theme->setLabelBackgroundEnabled(enabled);
}
-void ThemeManager::setColorStyle(Q3DTheme::ColorStyle style)
+void ThemeManager::setColorStyle(Q3DTheme *theme, Q3DTheme::ColorStyle style)
{
- if (!m_theme->d_ptr->m_dirtyBits.colorStyleDirty)
- m_theme->setColorStyle(style);
+ if (theme->d_ptr->isForcePredefinedType() || !theme->d_ptr->m_dirtyBits.colorStyleDirty)
+ theme->setColorStyle(style);
}
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/theme/thememanager_p.h b/src/datavisualization/theme/thememanager_p.h
index c6e6a107..473c2ed7 100644
--- a/src/datavisualization/theme/thememanager_p.h
+++ b/src/datavisualization/theme/thememanager_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -33,7 +33,7 @@
#include "abstract3dcontroller_p.h"
#include "q3dtheme.h"
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
class ThemeManager : public QObject
{
@@ -42,40 +42,45 @@ public:
ThemeManager(Abstract3DController *controller);
~ThemeManager();
- void setTheme(Q3DTheme *theme);
- Q3DTheme *theme() const;
+ void addTheme(Q3DTheme *theme);
+ void releaseTheme(Q3DTheme *theme);
+ void setActiveTheme(Q3DTheme *theme);
+ Q3DTheme *activeTheme() const;
+ QList<Q3DTheme *> themes() const;
+
+ static void setPredefinedPropertiesToTheme(Q3DTheme *theme, Q3DTheme::Theme type);
protected:
void connectThemeSignals();
- void useTheme(Q3DTheme::Theme type);
- QLinearGradient createGradient(const QColor &color, float colorLevel);
- void setBaseColors(const QList<QColor> &colors);
- void setBackgroundColor(const QColor &color);
- void setWindowColor(const QColor &color);
- void setTextColor(const QColor &color);
- void setTextBackgroundColor(const QColor &color);
- void setGridLineColor(const QColor &color);
- void setSingleHighlightColor(const QColor &color);
- void setMultiHighlightColor(const QColor &color);
- void setLightColor(const QColor &color);
- void setBaseGradients(const QList<QLinearGradient> &gradients);
- void setSingleHighlightGradient(const QLinearGradient &gradient);
- void setMultiHighlightGradient(const QLinearGradient &gradient);
- void setLightStrength(float strength);
- void setAmbientLightStrength(float strength);
- void setHighlightLightStrength(float strength);
- void setLabelBorderEnabled(bool enabled);
- void setFont(const QFont &font);
- void setBackgroundEnabled(bool enabled);
- void setGridEnabled(bool enabled);
- void setLabelBackgroundEnabled(bool enabled);
- void setColorStyle(Q3DTheme::ColorStyle style);
+ static QLinearGradient createGradient(const QColor &color, float colorLevel);
+ static void setBaseColors(Q3DTheme *theme, const QList<QColor> &colors);
+ static void setBackgroundColor(Q3DTheme *theme, const QColor &color);
+ static void setWindowColor(Q3DTheme *theme, const QColor &color);
+ static void setTextColor(Q3DTheme *theme, const QColor &color);
+ static void setTextBackgroundColor(Q3DTheme *theme, const QColor &color);
+ static void setGridLineColor(Q3DTheme *theme, const QColor &color);
+ static void setSingleHighlightColor(Q3DTheme *theme, const QColor &color);
+ static void setMultiHighlightColor(Q3DTheme *theme, const QColor &color);
+ static void setLightColor(Q3DTheme *theme, const QColor &color);
+ static void setBaseGradients(Q3DTheme *theme, const QList<QLinearGradient> &gradients);
+ static void setSingleHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient);
+ static void setMultiHighlightGradient(Q3DTheme *theme, const QLinearGradient &gradient);
+ static void setLightStrength(Q3DTheme *theme, float strength);
+ static void setAmbientLightStrength(Q3DTheme *theme, float strength);
+ static void setHighlightLightStrength(Q3DTheme *theme, float strength);
+ static void setLabelBorderEnabled(Q3DTheme *theme, bool enabled);
+ static void setFont(Q3DTheme *theme, const QFont &font);
+ static void setBackgroundEnabled(Q3DTheme *theme, bool enabled);
+ static void setGridEnabled(Q3DTheme *theme, bool enabled);
+ static void setLabelBackgroundEnabled(Q3DTheme *theme, bool enabled);
+ static void setColorStyle(Q3DTheme *theme, Q3DTheme::ColorStyle style);
private:
- QScopedPointer<Q3DTheme> m_theme;
+ Q3DTheme *m_activeTheme;
+ QList<Q3DTheme *> m_themes; // List of all added themes
Abstract3DController *m_controller;
};
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION
#endif