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 "Riu3DMainWindowTools.h"
|
||||
#include "RiuGuiTheme.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RiuViewerCommands.h"
|
||||
|
||||
@ -1223,6 +1224,8 @@ void RiaApplication::applyPreferences()
|
||||
m_defaultAnnotationFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::ANNOTATION_FONT] );
|
||||
m_defaultWellLabelFont = RiaFontCache::getFont( fontSizes[RiaDefines::FontSettingType::WELL_LABEL_FONT] );
|
||||
|
||||
RiuGuiTheme::updateGuiTheme( m_preferences->guiTheme() );
|
||||
|
||||
if ( this->project() )
|
||||
{
|
||||
this->project()->setScriptDirectories( m_preferences->scriptDirectories() );
|
||||
|
@ -219,7 +219,8 @@ enum class ThemeEnum
|
||||
{
|
||||
DEFAULT,
|
||||
DARK,
|
||||
LIGHT
|
||||
LIGHT,
|
||||
UNDEFINED
|
||||
};
|
||||
|
||||
}; // namespace RiaDefines
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RiuFileDialogTools.h"
|
||||
#include "RiuGuiTheme.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "RicSnapshotFilenameGenerator.h"
|
||||
@ -86,6 +87,9 @@ void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName, RimPlotWindow* plot )
|
||||
{
|
||||
auto currentTheme = RiuGuiTheme::currentGuiTheme();
|
||||
|
||||
RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum::LIGHT );
|
||||
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
||||
QCoreApplication::processEvents();
|
||||
QFile pdfFile( fileName );
|
||||
@ -132,6 +136,7 @@ void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName,
|
||||
{
|
||||
RiaLogging::error( QString( "Could not write PDF to %1" ).arg( fileName ) );
|
||||
}
|
||||
RiuGuiTheme::updateGuiTheme( currentTheme );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "RiaFontCache.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RiuGuiTheme.h"
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
@ -108,20 +110,24 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
||||
caf::FontTools::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
||||
this->setFont( font );
|
||||
|
||||
QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
|
||||
|
||||
LayoutInfo layout( QSize( targetRect.width(), targetRect.height() ) );
|
||||
layoutInfo( &layout );
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->setFont( this->font() );
|
||||
painter->translate( targetRect.topLeft() );
|
||||
QPoint titlePos( layout.margins.left(), layout.margins.top() );
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( QPoint( layout.margins.left(), layout.margins.top() ) );
|
||||
painter->setPen( QPen( textColor ) );
|
||||
QTextDocument td;
|
||||
td.setDocumentMargin( 0.0 );
|
||||
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 );
|
||||
painter->restore();
|
||||
}
|
||||
@ -131,10 +137,11 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( tickLabel.first.topLeft() );
|
||||
painter->setPen( QPen( textColor ) );
|
||||
QTextDocument td;
|
||||
td.setDocumentMargin( 0.0 );
|
||||
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 );
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiuThemesDirectory.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
@ -47,6 +46,8 @@
|
||||
#include "qwt_plot_marker.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_variableGuiTextMap = {};
|
||||
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 )
|
||||
{
|
||||
s_currentTheme = theme;
|
||||
s_qwtPlotItemPropertiesMap.clear();
|
||||
|
||||
applyStyleSheet( theme );
|
||||
const QWidgetList allWidgets = RiaGuiApplication::instance()->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;
|
||||
if ( dynamic_cast<RiaGuiApplication*>( RiaApplication::instance() ) )
|
||||
RiaDefines::ThemeEnum eTheme = s_currentTheme;
|
||||
|
||||
if ( theme != RiaDefines::ThemeEnum::UNDEFINED )
|
||||
{
|
||||
eTheme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
||||
}
|
||||
if ( theme >= 0 && theme < static_cast<int>( caf::AppEnum<RiaDefines::ThemeEnum>().size() ) )
|
||||
{
|
||||
eTheme = static_cast<RiaDefines::ThemeEnum>( theme );
|
||||
eTheme = theme;
|
||||
}
|
||||
|
||||
if ( s_variableValueMap.keys().contains( eTheme ) && s_variableValueMap[eTheme].keys().contains( "$" + variable ) )
|
||||
|
@ -43,8 +43,9 @@ typedef std::function<void( QRegularExpressionMatch& )> CustomStyleSheetApplicat
|
||||
class RiuGuiTheme
|
||||
{
|
||||
public:
|
||||
static void updateGuiTheme( RiaDefines::ThemeEnum theme );
|
||||
static bool applyStyleSheet( RiaDefines::ThemeEnum theme );
|
||||
static RiaDefines::ThemeEnum currentGuiTheme();
|
||||
static void updateGuiTheme( RiaDefines::ThemeEnum theme );
|
||||
static bool applyStyleSheet( RiaDefines::ThemeEnum theme );
|
||||
static void changeVariableValue( RiaDefines::ThemeEnum theme, const QString& variableName, const QString& newValue );
|
||||
static QMap<QString, QString> getVariableValueMap( RiaDefines::ThemeEnum theme );
|
||||
static QMap<QString, QString> getVariableGuiTextMap( RiaDefines::ThemeEnum theme );
|
||||
@ -52,7 +53,8 @@ public:
|
||||
static bool writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QString& styleSheet );
|
||||
static QString loadStyleSheet( RiaDefines::ThemeEnum theme );
|
||||
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
|
||||
getQwtStyleSheetProperty( QString plotName, const QString& itemType, QString itemName, const QString& propertyName );
|
||||
static void styleQwtItem( QwtPlotItem* item );
|
||||
@ -72,6 +74,8 @@ private:
|
||||
static void formatStyleSheetForWriting( QString& styleSheet );
|
||||
|
||||
private:
|
||||
static RiaDefines::ThemeEnum s_currentTheme;
|
||||
|
||||
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
|
||||
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableGuiTextMap;
|
||||
static QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> s_qwtPlotItemPropertiesMap;
|
||||
|
Loading…
Reference in New Issue
Block a user