mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
This commit is contained in:
parent
d33ddf24c7
commit
135ca97ba4
@ -101,6 +101,7 @@
|
|||||||
#include "RimWellRftPlot.h"
|
#include "RimWellRftPlot.h"
|
||||||
|
|
||||||
#include "Riu3DMainWindowTools.h"
|
#include "Riu3DMainWindowTools.h"
|
||||||
|
#include "RiuGuiTheme.h"
|
||||||
#include "RiuViewer.h"
|
#include "RiuViewer.h"
|
||||||
#include "RiuViewerCommands.h"
|
#include "RiuViewerCommands.h"
|
||||||
|
|
||||||
@ -1223,6 +1224,8 @@ void RiaApplication::applyPreferences()
|
|||||||
m_defaultAnnotationFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::ANNOTATION_FONT] );
|
m_defaultAnnotationFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::ANNOTATION_FONT] );
|
||||||
m_defaultWellLabelFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::WELL_LABEL_FONT] );
|
m_defaultWellLabelFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::WELL_LABEL_FONT] );
|
||||||
|
|
||||||
|
RiuGuiTheme::updateGuiTheme( m_preferences->guiTheme() );
|
||||||
|
|
||||||
if ( this->project() )
|
if ( this->project() )
|
||||||
{
|
{
|
||||||
this->project()->setScriptDirectories( m_preferences->scriptDirectories() );
|
this->project()->setScriptDirectories( m_preferences->scriptDirectories() );
|
||||||
|
@ -219,7 +219,8 @@ enum class ThemeEnum
|
|||||||
{
|
{
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
DARK,
|
DARK,
|
||||||
LIGHT
|
LIGHT,
|
||||||
|
UNDEFINED
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace RiaDefines
|
}; // namespace RiaDefines
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "RimViewWindow.h"
|
#include "RimViewWindow.h"
|
||||||
|
|
||||||
#include "RiuFileDialogTools.h"
|
#include "RiuFileDialogTools.h"
|
||||||
|
#include "RiuGuiTheme.h"
|
||||||
#include "RiuPlotMainWindow.h"
|
#include "RiuPlotMainWindow.h"
|
||||||
|
|
||||||
#include "RicSnapshotFilenameGenerator.h"
|
#include "RicSnapshotFilenameGenerator.h"
|
||||||
@ -86,6 +87,9 @@ void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, cons
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName, RimPlotWindow* plot )
|
void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName, RimPlotWindow* plot )
|
||||||
{
|
{
|
||||||
|
auto currentTheme = RiuGuiTheme::currentGuiTheme();
|
||||||
|
|
||||||
|
RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum::LIGHT );
|
||||||
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
QFile pdfFile( fileName );
|
QFile pdfFile( fileName );
|
||||||
@ -132,6 +136,7 @@ void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName,
|
|||||||
{
|
{
|
||||||
RiaLogging::error( QString( "Could not write PDF to %1" ).arg( fileName ) );
|
RiaLogging::error( QString( "Could not write PDF to %1" ).arg( fileName ) );
|
||||||
}
|
}
|
||||||
|
RiuGuiTheme::updateGuiTheme( currentTheme );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "RiaFontCache.h"
|
#include "RiaFontCache.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
|
#include "RiuGuiTheme.h"
|
||||||
|
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@ -108,20 +110,24 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
|||||||
caf::FontTools::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
caf::FontTools::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
||||||
this->setFont( font );
|
this->setFont( font );
|
||||||
|
|
||||||
|
QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
|
||||||
|
|
||||||
LayoutInfo layout( QSize( targetRect.width(), targetRect.height() ) );
|
LayoutInfo layout( QSize( targetRect.width(), targetRect.height() ) );
|
||||||
layoutInfo( &layout );
|
layoutInfo( &layout );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->setFont( this->font() );
|
painter->setFont( this->font() );
|
||||||
painter->translate( targetRect.topLeft() );
|
painter->translate( targetRect.topLeft() );
|
||||||
QPoint titlePos( layout.margins.left(), layout.margins.top() );
|
QPoint titlePos( layout.margins.left(), layout.margins.top() );
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( QPoint( layout.margins.left(), layout.margins.top() ) );
|
painter->translate( QPoint( layout.margins.left(), layout.margins.top() ) );
|
||||||
|
painter->setPen( QPen( textColor ) );
|
||||||
QTextDocument td;
|
QTextDocument td;
|
||||||
td.setDocumentMargin( 0.0 );
|
td.setDocumentMargin( 0.0 );
|
||||||
td.setDefaultFont( this->font() );
|
td.setDefaultFont( this->font() );
|
||||||
td.setPlainText( m_title );
|
td.setHtml( QString( "<body><font color='%1'>%2</font></body>" ).arg( textColor.name() ).arg( m_title ) );
|
||||||
td.drawContents( painter );
|
td.drawContents( painter );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
@ -131,10 +137,11 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
|||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( tickLabel.first.topLeft() );
|
painter->translate( tickLabel.first.topLeft() );
|
||||||
|
painter->setPen( QPen( textColor ) );
|
||||||
QTextDocument td;
|
QTextDocument td;
|
||||||
td.setDocumentMargin( 0.0 );
|
td.setDocumentMargin( 0.0 );
|
||||||
td.setDefaultFont( this->font() );
|
td.setDefaultFont( this->font() );
|
||||||
td.setPlainText( tickLabel.second );
|
td.setHtml( QString( "<body><font color='%1'>%2</font></body>" ).arg( textColor.name() ).arg( tickLabel.second ) );
|
||||||
td.drawContents( painter );
|
td.drawContents( painter );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaPreferences.h"
|
|
||||||
#include "RiuThemesDirectory.h"
|
#include "RiuThemesDirectory.h"
|
||||||
|
|
||||||
#include "cafAppEnum.h"
|
#include "cafAppEnum.h"
|
||||||
@ -47,6 +46,8 @@
|
|||||||
#include "qwt_plot_marker.h"
|
#include "qwt_plot_marker.h"
|
||||||
#include "qwt_symbol.h"
|
#include "qwt_symbol.h"
|
||||||
|
|
||||||
|
RiaDefines::ThemeEnum RiuGuiTheme::s_currentTheme = RiaDefines::ThemeEnum::DEFAULT;
|
||||||
|
|
||||||
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableValueMap = {};
|
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableValueMap = {};
|
||||||
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableGuiTextMap = {};
|
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableGuiTextMap = {};
|
||||||
QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> RiuGuiTheme::s_qwtPlotItemPropertiesMap = {};
|
QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> RiuGuiTheme::s_qwtPlotItemPropertiesMap = {};
|
||||||
@ -352,12 +353,22 @@ QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme:
|
|||||||
}
|
}
|
||||||
}}};
|
}}};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiaDefines::ThemeEnum RiuGuiTheme::currentGuiTheme()
|
||||||
|
{
|
||||||
|
return s_currentTheme;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum theme )
|
void RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
|
s_currentTheme = theme;
|
||||||
s_qwtPlotItemPropertiesMap.clear();
|
s_qwtPlotItemPropertiesMap.clear();
|
||||||
|
|
||||||
applyStyleSheet( theme );
|
applyStyleSheet( theme );
|
||||||
const QWidgetList allWidgets = RiaGuiApplication::instance()->allWidgets();
|
const QWidgetList allWidgets = RiaGuiApplication::instance()->allWidgets();
|
||||||
for ( QWidget* widget : allWidgets )
|
for ( QWidget* widget : allWidgets )
|
||||||
@ -564,16 +575,13 @@ QAbstractItemModel* RiuGuiTheme::getQssCompletionModel( QCompleter* completer )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QColor RiuGuiTheme::getColorByVariableName( const QString& variable, int theme /*= -1 */ )
|
QColor RiuGuiTheme::getColorByVariableName( const QString& variable, RiaDefines::ThemeEnum theme /*= UNDEFINED */ )
|
||||||
{
|
{
|
||||||
RiaDefines::ThemeEnum eTheme = RiaDefines::ThemeEnum::DEFAULT;
|
RiaDefines::ThemeEnum eTheme = s_currentTheme;
|
||||||
if ( dynamic_cast<RiaGuiApplication*>( RiaApplication::instance() ) )
|
|
||||||
|
if ( theme != RiaDefines::ThemeEnum::UNDEFINED )
|
||||||
{
|
{
|
||||||
eTheme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
eTheme = theme;
|
||||||
}
|
|
||||||
if ( theme >= 0 && theme < static_cast<int>( caf::AppEnum<RiaDefines::ThemeEnum>().size() ) )
|
|
||||||
{
|
|
||||||
eTheme = static_cast<RiaDefines::ThemeEnum>( theme );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_variableValueMap.keys().contains( eTheme ) && s_variableValueMap[eTheme].keys().contains( "$" + variable ) )
|
if ( s_variableValueMap.keys().contains( eTheme ) && s_variableValueMap[eTheme].keys().contains( "$" + variable ) )
|
||||||
|
@ -43,6 +43,7 @@ typedef std::function<void( QRegularExpressionMatch& )> CustomStyleSheetApplicat
|
|||||||
class RiuGuiTheme
|
class RiuGuiTheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static RiaDefines::ThemeEnum currentGuiTheme();
|
||||||
static void updateGuiTheme( RiaDefines::ThemeEnum theme );
|
static void updateGuiTheme( RiaDefines::ThemeEnum theme );
|
||||||
static bool applyStyleSheet( RiaDefines::ThemeEnum theme );
|
static bool applyStyleSheet( RiaDefines::ThemeEnum theme );
|
||||||
static void changeVariableValue( RiaDefines::ThemeEnum theme, const QString& variableName, const QString& newValue );
|
static void changeVariableValue( RiaDefines::ThemeEnum theme, const QString& variableName, const QString& newValue );
|
||||||
@ -52,7 +53,8 @@ public:
|
|||||||
static bool writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QString& styleSheet );
|
static bool writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QString& styleSheet );
|
||||||
static QString loadStyleSheet( RiaDefines::ThemeEnum theme );
|
static QString loadStyleSheet( RiaDefines::ThemeEnum theme );
|
||||||
static QAbstractItemModel* getQssCompletionModel( QCompleter* completer );
|
static QAbstractItemModel* getQssCompletionModel( QCompleter* completer );
|
||||||
static QColor getColorByVariableName( const QString& variable, int theme = -1 );
|
static QColor getColorByVariableName( const QString& variable,
|
||||||
|
RiaDefines::ThemeEnum theme = RiaDefines::ThemeEnum::UNDEFINED );
|
||||||
static QString
|
static QString
|
||||||
getQwtStyleSheetProperty( QString plotName, const QString& itemType, QString itemName, const QString& propertyName );
|
getQwtStyleSheetProperty( QString plotName, const QString& itemType, QString itemName, const QString& propertyName );
|
||||||
static void styleQwtItem( QwtPlotItem* item );
|
static void styleQwtItem( QwtPlotItem* item );
|
||||||
@ -72,6 +74,8 @@ private:
|
|||||||
static void formatStyleSheetForWriting( QString& styleSheet );
|
static void formatStyleSheetForWriting( QString& styleSheet );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static RiaDefines::ThemeEnum s_currentTheme;
|
||||||
|
|
||||||
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
|
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
|
||||||
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableGuiTextMap;
|
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableGuiTextMap;
|
||||||
static QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> s_qwtPlotItemPropertiesMap;
|
static QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> s_qwtPlotItemPropertiesMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user