diff options
Diffstat (limited to 'examples/bars/graphmodifier.cpp')
-rw-r--r-- | examples/bars/graphmodifier.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp index 13e4d3e7..09fec65d 100644 --- a/examples/bars/graphmodifier.cpp +++ b/examples/bars/graphmodifier.cpp @@ -54,9 +54,9 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) { //! [2] m_graph->setShadowQuality(QDataVis::ShadowQualitySoftMedium); - m_graph->theme()->setBackgroundEnabled(false); - m_graph->theme()->setFont(QFont("Times New Roman", m_fontSize)); - m_graph->theme()->setLabelBackgroundEnabled(true); + m_graph->activeTheme()->setBackgroundEnabled(false); + m_graph->activeTheme()->setFont(QFont("Times New Roman", m_fontSize)); + m_graph->activeTheme()->setLabelBackgroundEnabled(true); //! [2] m_months << "January" << "February" << "March" << "April" << "May" << "June" << "July" << "August" << "September" << "October" << "November" << "December"; @@ -185,16 +185,20 @@ void GraphModifier::changePresetCamera() void GraphModifier::changeTheme(int theme) { - m_graph->setTheme(new Q3DTheme(Q3DTheme::Theme(theme))); - emit backgroundEnabledChanged(m_graph->theme()->isBackgroundEnabled()); - emit gridEnabledChanged(m_graph->theme()->isGridEnabled()); - emit fontChanged(m_graph->theme()->font()); - emit fontSizeChanged(m_graph->theme()->font().pointSize()); + Q3DTheme *currentTheme = m_graph->activeTheme(); + m_graph->releaseTheme(currentTheme); + delete currentTheme; + currentTheme = new Q3DTheme(Q3DTheme::Theme(theme)); + m_graph->setActiveTheme(currentTheme); + emit backgroundEnabledChanged(currentTheme->isBackgroundEnabled()); + emit gridEnabledChanged(currentTheme->isGridEnabled()); + emit fontChanged(currentTheme->font()); + emit fontSizeChanged(currentTheme->font().pointSize()); } void GraphModifier::changeLabelBackground() { - m_graph->theme()->setLabelBackgroundEnabled(!m_graph->theme()->isLabelBackgroundEnabled()); + m_graph->activeTheme()->setLabelBackgroundEnabled(!m_graph->activeTheme()->isLabelBackgroundEnabled()); } void GraphModifier::changeSelectionMode(int selectionMode) @@ -209,15 +213,15 @@ void GraphModifier::changeSelectionMode(int selectionMode) void GraphModifier::changeFont(const QFont &font) { QFont newFont = font; - m_graph->theme()->setFont(newFont); + m_graph->activeTheme()->setFont(newFont); } void GraphModifier::changeFontSize(int fontsize) { m_fontSize = fontsize; - QFont font = m_graph->theme()->font(); + QFont font = m_graph->activeTheme()->font(); font.setPointSize(m_fontSize); - m_graph->theme()->setFont(font); + m_graph->activeTheme()->setFont(font); } void GraphModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) @@ -250,12 +254,12 @@ void GraphModifier::rotateY(int rotation) void GraphModifier::setBackgroundEnabled(int enabled) { - m_graph->theme()->setBackgroundEnabled(bool(enabled)); + m_graph->activeTheme()->setBackgroundEnabled(bool(enabled)); } void GraphModifier::setGridEnabled(int enabled) { - m_graph->theme()->setGridEnabled(bool(enabled)); + m_graph->activeTheme()->setGridEnabled(bool(enabled)); } void GraphModifier::setSmoothBars(int smooth) |