summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/theme
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-11-28 06:40:59 +0200
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-11-28 08:10:29 +0200
commit5fde532408da5b6b3ddef13aff5e07f32015e7d9 (patch)
tree8a243126c37a92be3ca14734adc5074a9642c129 /src/datavisualization/theme
parent964897e316c0fd524cba3a3cbb3c32fad53f965a (diff)
Visual properties moved to theme
Task-number: QTRD-2632 Change-Id: I91eaa8fa26e232de24fe89ef0c8a2fc53f31fb8c Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/theme')
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp99
-rw-r--r--src/datavisualization/theme/q3dtheme.h24
-rw-r--r--src/datavisualization/theme/q3dtheme_p.h21
-rw-r--r--src/datavisualization/theme/thememanager.cpp121
-rw-r--r--src/datavisualization/theme/thememanager_p.h4
5 files changed, 237 insertions, 32 deletions
diff --git a/src/datavisualization/theme/q3dtheme.cpp b/src/datavisualization/theme/q3dtheme.cpp
index e43eb52d..dccaee91 100644
--- a/src/datavisualization/theme/q3dtheme.cpp
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -271,6 +271,62 @@ bool Q3DTheme::isLabelBorderEnabled() const
return d_ptr->m_labelBorders;
}
+void Q3DTheme::setFont(const QFont &font)
+{
+ if (d_ptr->m_font != font) {
+ d_ptr->m_dirtyBits.fontDirty = true;
+ d_ptr->m_font = font;
+ emit fontChanged(font);
+ }
+}
+
+QFont Q3DTheme::font() const
+{
+ return d_ptr->m_font;
+}
+
+void Q3DTheme::setBackgroundEnabled(bool enabled)
+{
+ if (d_ptr->m_backgoundEnabled != enabled) {
+ d_ptr->m_dirtyBits.backgroundEnabledDirty = true;
+ d_ptr->m_backgoundEnabled = enabled;
+ emit backgroundEnabledChanged(enabled);
+ }
+}
+
+bool Q3DTheme::isBackgroundEnabled() const
+{
+ return d_ptr->m_backgoundEnabled;
+}
+
+void Q3DTheme::setGridEnabled(bool enabled)
+{
+ if (d_ptr->m_gridEnabled != enabled) {
+ d_ptr->m_dirtyBits.gridEnabledDirty = true;
+ d_ptr->m_gridEnabled = enabled;
+ emit gridEnabledChanged(enabled);
+ }
+}
+
+bool Q3DTheme::isGridEnabled() const
+{
+ return d_ptr->m_gridEnabled;
+}
+
+void Q3DTheme::setLabelBackgroundEnabled(bool enabled)
+{
+ if (d_ptr->m_labelBackground != enabled) {
+ d_ptr->m_dirtyBits.labelBackgroundEnabledDirty = true;
+ d_ptr->m_labelBackground = enabled;
+ emit labelBackgroundEnabledChanged(enabled);
+ }
+}
+
+bool Q3DTheme::isLabelBackgroundEnabled() const
+{
+ return d_ptr->m_labelBackground;
+}
+
void Q3DTheme::setColorStyle(QDataVis::ColorStyle style)
{
if (d_ptr->m_colorStyle != style) {
@@ -303,6 +359,15 @@ QDataVis::Theme Q3DTheme::type() const
Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
: QObject(0),
m_themeId(theme_id),
+ m_baseColor(Qt::white),
+ m_backgroundColor(Qt::black),
+ m_windowColor(Qt::black),
+ m_textColor(Qt::white),
+ m_textBackgroundColor(Qt::gray),
+ m_gridLineColor(Qt::white),
+ m_singleHighlightColor(Qt::red),
+ m_multiHighlightColor(Qt::blue),
+ m_lightColor(Qt::white),
m_baseGradient(QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0)),
@@ -312,6 +377,15 @@ Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
m_multiHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0)),
+ m_lightStrength(0.5f),
+ m_ambientLightStrength(0.25f),
+ m_highlightLightStrength(0.75f),
+ m_labelBorders(true),
+ m_colorStyle(QDataVis::ColorStyleUniform),
+ m_font(QFont(QStringLiteral("Arial"))),
+ m_backgoundEnabled(true),
+ m_gridEnabled(true),
+ m_labelBackground(true),
q_ptr(q)
{
}
@@ -320,4 +394,29 @@ Q3DThemePrivate::~Q3DThemePrivate()
{
}
+void Q3DThemePrivate::resetDirtyBits()
+{
+ m_dirtyBits.ambientLightStrengthDirty = false;
+ m_dirtyBits.backgroundColorDirty = false;
+ m_dirtyBits.backgroundEnabledDirty = false;
+ m_dirtyBits.baseColorDirty = false;
+ m_dirtyBits.baseGradientDirty = false;
+ m_dirtyBits.colorStyleDirty = false;
+ m_dirtyBits.fontDirty = false;
+ m_dirtyBits.gridEnabledDirty = false;
+ m_dirtyBits.gridLineColorDirty = false;
+ m_dirtyBits.highlightLightStrengthDirty = false;
+ m_dirtyBits.labelBackgroundEnabledDirty = false;
+ m_dirtyBits.labelBorderEnabledDirty = false;
+ m_dirtyBits.lightColorDirty = false;
+ m_dirtyBits.lightStrengthDirty = false;
+ m_dirtyBits.multiHighlightColorDirty = false;
+ m_dirtyBits.multiHighlightGradientDirty = false;
+ m_dirtyBits.singleHighlightColorDirty = false;
+ m_dirtyBits.singleHighlightGradientDirty = false;
+ m_dirtyBits.textBackgroundColorDirty = false;
+ m_dirtyBits.textColorDirty = false;
+ m_dirtyBits.windowColorDirty = false;
+}
+
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
index 4cea4341..43e9fd70 100644
--- a/src/datavisualization/theme/q3dtheme.h
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -21,8 +21,8 @@
#include <QtDataVisualization/qdatavisualizationenums.h>
#include <QLinearGradient>
-
-class QColor;
+#include <QFont>
+#include <QColor>
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
@@ -48,6 +48,10 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(float ambientLightStrength READ ambientLightStrength WRITE setAmbientLightStrength NOTIFY ambientLightStrengthChanged)
Q_PROPERTY(float highlightLightStrength READ highlightLightStrength WRITE setHighlightLightStrength NOTIFY highlightLightStrengthChanged)
Q_PROPERTY(bool labelBorderEnabled READ isLabelBorderEnabled WRITE setLabelBorderEnabled NOTIFY labelBorderEnabledChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(bool backgroundEnabled READ isBackgroundEnabled WRITE setBackgroundEnabled NOTIFY backgroundEnabledChanged)
+ Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
+ Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged)
Q_PROPERTY(QtDataVisualization::QDataVis::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
// TODO: Add everything that we need
@@ -107,6 +111,18 @@ public:
void setLabelBorderEnabled(bool enabled);
bool isLabelBorderEnabled() const;
+ void setFont(const QFont &font);
+ QFont font() const;
+
+ void setBackgroundEnabled(bool enabled);
+ bool isBackgroundEnabled() const;
+
+ void setGridEnabled(bool enabled);
+ bool isGridEnabled() const;
+
+ void setLabelBackgroundEnabled(bool enabled);
+ bool isLabelBackgroundEnabled() const;
+
void setColorStyle(QDataVis::ColorStyle style);
QDataVis::ColorStyle colorStyle() const;
@@ -128,6 +144,10 @@ signals:
void ambientLightStrengthChanged(float strength);
void highlightLightStrengthChanged(float strength);
void labelBorderEnabledChanged(bool enabled);
+ void fontChanged(QFont font);
+ void backgroundEnabledChanged(bool enabled);
+ void gridEnabledChanged(bool enabled);
+ void labelBackgroundEnabledChanged(bool enabled);
void colorStyleChanged(QDataVis::ColorStyle style);
protected:
diff --git a/src/datavisualization/theme/q3dtheme_p.h b/src/datavisualization/theme/q3dtheme_p.h
index ca3108c8..08efa61e 100644
--- a/src/datavisualization/theme/q3dtheme_p.h
+++ b/src/datavisualization/theme/q3dtheme_p.h
@@ -32,9 +32,6 @@
#include "datavisualizationglobal_p.h"
#include "q3dtheme.h"
-class QColor;
-class QLinearGradient;
-
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
struct Q3DThemeDirtyBitField {
@@ -55,6 +52,10 @@ struct Q3DThemeDirtyBitField {
bool highlightLightStrengthDirty : 1;
bool labelBorderEnabledDirty : 1;
bool colorStyleDirty : 1;
+ bool fontDirty : 1;
+ bool backgroundEnabledDirty : 1;
+ bool gridEnabledDirty : 1;
+ bool labelBackgroundEnabledDirty : 1;
Q3DThemeDirtyBitField()
: baseColorDirty(false),
@@ -73,7 +74,11 @@ struct Q3DThemeDirtyBitField {
ambientLightStrengthDirty(false),
highlightLightStrengthDirty(false),
labelBorderEnabledDirty(false),
- colorStyleDirty(false)
+ colorStyleDirty(false),
+ fontDirty(false),
+ backgroundEnabledDirty(false),
+ gridEnabledDirty(false),
+ labelBackgroundEnabledDirty(false)
{
}
};
@@ -86,14 +91,14 @@ public:
QDataVis::Theme theme_id = QDataVis::ThemeUserDefined);
virtual ~Q3DThemePrivate();
+ void resetDirtyBits();
+
public:
QDataVis::Theme m_themeId;
Q3DThemeDirtyBitField m_dirtyBits;
QColor m_baseColor;
- QColor m_heightColor;
- QColor m_depthColor;
QColor m_backgroundColor;
QColor m_windowColor;
QColor m_textColor;
@@ -110,6 +115,10 @@ public:
float m_highlightLightStrength;
bool m_labelBorders;
QDataVis::ColorStyle m_colorStyle;
+ QFont m_font;
+ bool m_backgoundEnabled;
+ bool m_gridEnabled;
+ bool m_labelBackground;
protected:
Q3DTheme *q_ptr;
diff --git a/src/datavisualization/theme/thememanager.cpp b/src/datavisualization/theme/thememanager.cpp
index 168409b3..36a879bf 100644
--- a/src/datavisualization/theme/thememanager.cpp
+++ b/src/datavisualization/theme/thememanager.cpp
@@ -47,8 +47,10 @@ void ThemeManager::setTheme(Q3DTheme *theme)
QDataVis::Theme type = m_theme->type();
- if (type != QDataVis::ThemeUserDefined)
+ if (type != QDataVis::ThemeUserDefined) {
useTheme(type);
+ m_theme->d_ptr->resetDirtyBits();
+ }
// Connect signals from new one
connectThemeSignals();
@@ -62,39 +64,46 @@ Q3DTheme *ThemeManager::theme() const
void ThemeManager::connectThemeSignals()
{
- // TODO: Implement receiving end for the commented ones (QTRD-2538)
connect(m_theme.data(), &Q3DTheme::baseColorChanged,
- m_controller, &Abstract3DController::setObjectColor);
- // connect(m_theme.data(), &Q3DTheme::backgroundColorChanged,
- // m_controller, &Abstract3DController::setBackgroundColorColor);
- // connect(m_theme.data(), &Q3DTheme::windowColorChanged,
- // m_controller, &Abstract3DController::setWindowColor);
- // connect(m_theme.data(), &Q3DTheme::textColorChanged,
- // m_controller, &Abstract3DController::setTextColor);
- // connect(m_theme.data(), &Q3DTheme::textBackgroundColorChanged,
- // m_controller, &Abstract3DController::setTextBackgroundColor);
- // connect(m_theme.data(), &Q3DTheme::gridLineColorChanged,
- // m_controller, &Abstract3DController::setGridLineColor);
+ m_controller, &Abstract3DController::setBaseColor);
+// connect(m_theme.data(), &Q3DTheme::backgroundColorChanged,
+// m_controller, &Abstract3DController::setBackgroundColor);
+// connect(m_theme.data(), &Q3DTheme::windowColorChanged,
+// m_controller, &Abstract3DController::setWindowColor);
+// connect(m_theme.data(), &Q3DTheme::textColorChanged,
+// m_controller, &Abstract3DController::setTextColor);
+// connect(m_theme.data(), &Q3DTheme::textBackgroundColorChanged,
+// m_controller, &Abstract3DController::setTextBackgroundColor);
+// connect(m_theme.data(), &Q3DTheme::gridLineColorChanged,
+// m_controller, &Abstract3DController::setGridLineColor);
connect(m_theme.data(), &Q3DTheme::singleHighlightColorChanged,
m_controller, &Abstract3DController::setSingleHighlightColor);
connect(m_theme.data(), &Q3DTheme::multiHighlightColorChanged,
m_controller, &Abstract3DController::setMultiHighlightColor);
- // connect(m_theme.data(), &Q3DTheme::lightColorChanged,
- // m_controller, &Abstract3DController::setLightColor);
+// connect(m_theme.data(), &Q3DTheme::lightColorChanged,
+// m_controller, &Abstract3DController::setLightColor);
connect(m_theme.data(), &Q3DTheme::baseGradientChanged,
- m_controller, &Abstract3DController::setObjectGradient);
+ m_controller, &Abstract3DController::setBaseGradient);
connect(m_theme.data(), &Q3DTheme::singleHighlightGradientChanged,
m_controller, &Abstract3DController::setSingleHighlightGradient);
connect(m_theme.data(), &Q3DTheme::multiHighlightGradientChanged,
m_controller, &Abstract3DController::setMultiHighlightGradient);
- // connect(m_theme.data(), &Q3DTheme::lightStrengthChanged,
- // m_controller, &Abstract3DController::setLightStrength);
- // connect(m_theme.data(), &Q3DTheme::ambientLightStrengthChanged,
- // m_controller, &Abstract3DController::setAmbientLightStrength);
- // connect(m_theme.data(), &Q3DTheme::highlightLightStrengthChanged,
- // m_controller, &Abstract3DController::setHighlightLightStrength);
- // connect(m_theme.data(), &Q3DTheme::labelBorderEnabledChanged,
- // m_controller, &Abstract3DController::setLabelBorderEnabled);
+// connect(m_theme.data(), &Q3DTheme::lightStrengthChanged,
+// m_controller, &Abstract3DController::setLightStrength);
+// connect(m_theme.data(), &Q3DTheme::ambientLightStrengthChanged,
+// m_controller, &Abstract3DController::setAmbientLightStrength);
+// connect(m_theme.data(), &Q3DTheme::highlightLightStrengthChanged,
+// m_controller, &Abstract3DController::setHighlightLightStrength);
+// connect(m_theme.data(), &Q3DTheme::labelBorderEnabledChanged,
+// m_controller, &Abstract3DController::setLabelBorderEnabled);
+ connect(m_theme.data(), &Q3DTheme::fontChanged,
+ m_controller, &Abstract3DController::setFont);
+ connect(m_theme.data(), &Q3DTheme::backgroundEnabledChanged,
+ m_controller, &Abstract3DController::setBackgroundEnabled);
+ connect(m_theme.data(), &Q3DTheme::gridEnabledChanged,
+ m_controller, &Abstract3DController::setGridEnabled);
+ connect(m_theme.data(), &Q3DTheme::labelBackgroundEnabledChanged,
+ m_controller, &Abstract3DController::setLabelBackgroundEnabled);
connect(m_theme.data(), &Q3DTheme::colorStyleChanged,
m_controller, &Abstract3DController::setColorStyle);
@@ -108,6 +117,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
switch (type) {
case QDataVis::ThemeQt: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0x80c342)));
setBackgroundColor(QColor(QRgb(0xffffff)));
setWindowColor(QColor(QRgb(0xffffff)));
@@ -146,6 +160,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemePrimaryColors: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0xffe400)));
setBackgroundColor(QColor(QRgb(0xffffff)));
setWindowColor(QColor(QRgb(0xffffff)));
@@ -184,6 +203,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeDigia: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0xcccccc)));
setBackgroundColor(QColor(QRgb(0xffffff)));
setWindowColor(QColor(QRgb(0xffffff)));
@@ -222,6 +246,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeStoneMoss: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0xbeb32b)));
setBackgroundColor(QColor(QRgb(0x4d4d4f)));
setWindowColor(QColor(QRgb(0x4d4d4f)));
@@ -260,6 +289,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeArmyBlue: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0x495f76)));
setBackgroundColor(QColor(QRgb(0xd5d6d7)));
setWindowColor(QColor(QRgb(0xd5d6d7)));
@@ -298,6 +332,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeRetro: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0x533b23)));
setBackgroundColor(QColor(QRgb(0xe9e2ce)));
setWindowColor(QColor(QRgb(0xe9e2ce)));
@@ -336,6 +375,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeEbony: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0xffffff)));
setBackgroundColor(QColor(QRgb(0x000000)));
setWindowColor(QColor(QRgb(0x000000)));
@@ -374,6 +418,11 @@ void ThemeManager::useTheme(QDataVis::Theme type)
}
case QDataVis::ThemeIsabelle: {
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
setBaseColor(QColor(QRgb(0xf9d900)));
setBackgroundColor(QColor(QRgb(0x000000)));
setWindowColor(QColor(QRgb(0x000000)));
@@ -511,6 +560,30 @@ void ThemeManager::setLabelBorderEnabled(bool enabled)
m_theme->setLabelBorderEnabled(enabled);
}
+void ThemeManager::setFont(const QFont &font)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.fontDirty)
+ m_theme->setFont(font);
+}
+
+void ThemeManager::setBackgroundEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.backgroundEnabledDirty)
+ m_theme->setBackgroundEnabled(enabled);
+}
+
+void ThemeManager::setGridEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.gridEnabledDirty)
+ m_theme->setGridEnabled(enabled);
+}
+
+void ThemeManager::setLabelBackgroundEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.labelBackgroundEnabledDirty)
+ m_theme->setLabelBackgroundEnabled(enabled);
+}
+
void ThemeManager::setColorStyle(QDataVis::ColorStyle style)
{
if (!m_theme->d_ptr->m_dirtyBits.colorStyleDirty)
diff --git a/src/datavisualization/theme/thememanager_p.h b/src/datavisualization/theme/thememanager_p.h
index 26ae6282..33277105 100644
--- a/src/datavisualization/theme/thememanager_p.h
+++ b/src/datavisualization/theme/thememanager_p.h
@@ -64,6 +64,10 @@ protected:
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(QDataVis::ColorStyle style);
private: