From ea7da32141c9f1b849d96833fa5bbde1b1cdefc6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 16 Sep 2020 14:32:48 +0200 Subject: [PATCH] #6514 Dark Theme : Use text color from theme instead from QPalette --- .../Application/Tools/RiaColorTools.cpp | 11 +++++------ ApplicationCode/Application/Tools/RiaColorTools.h | 4 ++-- ApplicationCode/ProjectDataModel/RimPlotCurve.cpp | 14 ++++---------- .../Summary/RimEnsembleCurveSet.cpp | 2 +- .../Summary/RimEnsembleStatistics.cpp | 2 +- ApplicationCode/UserInterface/RiuQwtSymbol.cpp | 2 +- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTools.cpp b/ApplicationCode/Application/Tools/RiaColorTools.cpp index 2013cd59a4..1fafb724e7 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTools.cpp @@ -18,6 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaColorTools.h" +#include "RiuGuiTheme.h" #include "cvfAssert.h" #include "cvfMath.h" @@ -146,19 +147,17 @@ cvf::Color3f RiaColorTools::fromQColorTo3f( QColor color ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QColor RiaColorTools::systemPaletteTextColor() +QColor RiaColorTools::textColor() { - QPalette systemPalette; - - return systemPalette.color( QPalette::Text ); + return RiuGuiTheme::getColorByVariableName( "textColor" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Color3f RiaColorTools::systemPaletteTextColor3f() +cvf::Color3f RiaColorTools::textColor3f() { - return fromQColorTo3f( systemPaletteTextColor() ); + return fromQColorTo3f( textColor() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTools.h b/ApplicationCode/Application/Tools/RiaColorTools.h index 403f643101..7555557df9 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.h +++ b/ApplicationCode/Application/Tools/RiaColorTools.h @@ -42,8 +42,8 @@ public: static QColor toQColor( cvf::Color4f color ); static cvf::Color3f fromQColorTo3f( QColor ); - static QColor systemPaletteTextColor(); - static cvf::Color3f systemPaletteTextColor3f(); + static QColor textColor(); + static cvf::Color3f textColor3f(); static cvf::Color3f blendCvfColors( const cvf::Color3f& color1, const cvf::Color3f& color2, int weight1 = 1, int weight2 = 1 ); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 0f9d611071..91c3c2567d 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -141,7 +141,7 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", "" ); - CAF_PDM_InitField( &m_curveColor, "Color", RiaColorTools::systemPaletteTextColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_curveColor, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); CAF_PDM_InitField( &m_fillColor, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color", "", "", "" ); CAF_PDM_InitField( &m_curveThickness, "Thickness", 1, "Line Thickness", "", "", "" ); @@ -151,13 +151,7 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitFieldNoDefault( &m_lineStyle, "LineStyle", "Line Style", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_fillStyle, "FillStyle", "Area Fill Style", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_pointSymbol, "PointSymbol", "Symbol", "", "", "" ); - CAF_PDM_InitField( &m_symbolEdgeColor, - "SymbolEdgeColor", - RiaColorTools::systemPaletteTextColor3f(), - "Symbol Edge Color", - "", - "", - "" ); + CAF_PDM_InitField( &m_symbolEdgeColor, "SymbolEdgeColor", RiaColorTools::textColor3f(), "Symbol Edge Color", "", "", "" ); CAF_PDM_InitField( &m_symbolSkipPixelDistance, "SymbolSkipPxDist", @@ -1005,8 +999,8 @@ void RimPlotCurve::setLineThickness( int thickness ) //-------------------------------------------------------------------------------------------------- void RimPlotCurve::resetAppearance() { - setColor( RiaColorTools::systemPaletteTextColor3f() ); - setSymbolEdgeColor( RiaColorTools::systemPaletteTextColor3f() ); + setColor( RiaColorTools::textColor3f() ); + setSymbolEdgeColor( RiaColorTools::textColor3f() ); setLineThickness( 2 ); setLineStyle( RiuQwtPlotCurve::STYLE_SOLID ); setSymbol( RiuQwtSymbol::SYMBOL_NONE ); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 1ede422289..7283c469ea 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -116,7 +116,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode", "", "", "" ); - CAF_PDM_InitField( &m_color, "Color", RiaColorTools::systemPaletteTextColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" ); m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp index 41bcf0568e..96bbd55edd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp @@ -47,7 +47,7 @@ RimEnsembleStatistics::RimEnsembleStatistics() CAF_PDM_InitField( &m_warningLabel, "WarningLabel", QString( "Warning: Ensemble time range mismatch" ), "", "", "", "" ); - CAF_PDM_InitField( &m_color, "Color", RiaColorTools::systemPaletteTextColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); m_warningLabel.xmlCapability()->disableIO(); m_warningLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); diff --git a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp index 09dd7f77c9..0f18f467e1 100644 --- a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp +++ b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp @@ -158,7 +158,7 @@ void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position QFont font = painter->font(); font.setPixelSize( m_labelFontSizePx ); painter->setFont( font ); - painter->setPen( RiaColorTools::systemPaletteTextColor() ); + painter->setPen( RiaColorTools::textColor() ); QSize symbolSize = QwtSymbol::size(); QRect symbolRect( position.x(), position.y(), symbolSize.width(), symbolSize.height() );