mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6514 Dark Theme : Move define to RiaDefines
This commit is contained in:
parent
87bc6acd65
commit
4841d19d02
@ -114,6 +114,16 @@ void caf::AppEnum<RiaDefines::GridCaseAxis>::setUp()
|
|||||||
|
|
||||||
setDefault( RiaDefines::GridCaseAxis::AXIS_K );
|
setDefault( RiaDefines::GridCaseAxis::AXIS_K );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void caf::AppEnum<RiaDefines::ThemeEnum>::setUp()
|
||||||
|
{
|
||||||
|
addItem( RiaDefines::ThemeEnum::DEFAULT, "DEFAULT", "Default theme" );
|
||||||
|
addItem( RiaDefines::ThemeEnum::DARK, "DARK", "Dark theme" );
|
||||||
|
addItem( RiaDefines::ThemeEnum::LIGHT, "LIGHT", "Light theme" );
|
||||||
|
setDefault( RiaDefines::ThemeEnum::DEFAULT );
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace caf
|
} // namespace caf
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -215,4 +215,11 @@ enum class GridCaseAxis
|
|||||||
UNDEFINED_AXIS
|
UNDEFINED_AXIS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ThemeEnum
|
||||||
|
{
|
||||||
|
DEFAULT,
|
||||||
|
DARK,
|
||||||
|
LIGHT
|
||||||
|
};
|
||||||
|
|
||||||
}; // namespace RiaDefines
|
}; // namespace RiaDefines
|
||||||
|
@ -93,6 +93,7 @@
|
|||||||
#include "Riu3dSelectionManager.h"
|
#include "Riu3dSelectionManager.h"
|
||||||
#include "RiuDockWidgetTools.h"
|
#include "RiuDockWidgetTools.h"
|
||||||
#include "RiuFileDialogTools.h"
|
#include "RiuFileDialogTools.h"
|
||||||
|
#include "RiuGuiTheme.h"
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
#include "RiuMainWindowTools.h"
|
#include "RiuMainWindowTools.h"
|
||||||
#include "RiuMdiMaximizeWindowGuard.h"
|
#include "RiuMdiMaximizeWindowGuard.h"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "RiaColorTables.h"
|
#include "RiaColorTables.h"
|
||||||
#include "RifReaderSettings.h"
|
#include "RifReaderSettings.h"
|
||||||
|
#include "RiuGuiTheme.h"
|
||||||
|
|
||||||
#include "cafPdmFieldCvfColor.h"
|
#include "cafPdmFieldCvfColor.h"
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
@ -1002,7 +1003,7 @@ bool RiaPreferences::openExportedPdfInViewer() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuGuiTheme::ThemeEnum RiaPreferences::guiTheme() const
|
RiaDefines::ThemeEnum RiaPreferences::guiTheme() const
|
||||||
{
|
{
|
||||||
return m_guiTheme();
|
return m_guiTheme();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "RiaFontCache.h"
|
#include "RiaFontCache.h"
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaQDateTimeTools.h"
|
#include "RiaQDateTimeTools.h"
|
||||||
#include "RiuGuiTheme.h"
|
|
||||||
|
|
||||||
#include "cafAppEnum.h"
|
#include "cafAppEnum.h"
|
||||||
#include "cafPdmChildField.h"
|
#include "cafPdmChildField.h"
|
||||||
@ -113,7 +112,7 @@ public:
|
|||||||
bool showProgressBar() const;
|
bool showProgressBar() const;
|
||||||
bool openExportedPdfInViewer() const;
|
bool openExportedPdfInViewer() const;
|
||||||
|
|
||||||
RiuGuiTheme::ThemeEnum guiTheme() const;
|
RiaDefines::ThemeEnum guiTheme() const;
|
||||||
|
|
||||||
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
||||||
|
|
||||||
@ -215,7 +214,7 @@ private:
|
|||||||
caf::PdmField<bool> m_showProgressBar;
|
caf::PdmField<bool> m_showProgressBar;
|
||||||
caf::PdmField<QString> m_gtestFilter;
|
caf::PdmField<QString> m_gtestFilter;
|
||||||
|
|
||||||
caf::PdmField<caf::AppEnum<RiuGuiTheme::ThemeEnum>> m_guiTheme;
|
caf::PdmField<caf::AppEnum<RiaDefines::ThemeEnum>> m_guiTheme;
|
||||||
|
|
||||||
caf::PdmField<PageSizeEnum> m_pageSize;
|
caf::PdmField<PageSizeEnum> m_pageSize;
|
||||||
caf::PdmField<PageOrientationEnum> m_pageOrientation;
|
caf::PdmField<PageOrientationEnum> m_pageOrientation;
|
||||||
|
@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
#include "RicThemeColorEditorFeature.h"
|
#include "RicThemeColorEditorFeature.h"
|
||||||
|
|
||||||
|
#include "RiaDefines.h"
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
#include "RiuMainWindow.h"
|
|
||||||
|
|
||||||
#include "RiuGuiTheme.h"
|
#include "RiuGuiTheme.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
#include "RiuQssSyntaxHighlighter.h"
|
#include "RiuQssSyntaxHighlighter.h"
|
||||||
#include "RiuTextEditWithCompletion.h"
|
#include "RiuTextEditWithCompletion.h"
|
||||||
|
|
||||||
#include "cafAppEnum.h"
|
#include "cafAppEnum.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@ -51,7 +53,7 @@ bool RicThemeColorEditorFeature::isCommandEnabled()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
||||||
{
|
{
|
||||||
RiuGuiTheme::ThemeEnum theme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
RiaDefines::ThemeEnum theme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
||||||
|
|
||||||
QDialog* dialog = new QDialog( RiuMainWindow::instance() );
|
QDialog* dialog = new QDialog( RiuMainWindow::instance() );
|
||||||
connect( dialog, &QDialog::close, [this, theme]() { RiuGuiTheme::updateGuiTheme( theme ); } );
|
connect( dialog, &QDialog::close, [this, theme]() { RiuGuiTheme::updateGuiTheme( theme ); } );
|
||||||
@ -62,12 +64,12 @@ void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
layout->addWidget( new QLabel( "GUI theme" ), 0, 0 );
|
layout->addWidget( new QLabel( "GUI theme" ), 0, 0 );
|
||||||
|
|
||||||
QComboBox* themeSelector = new QComboBox();
|
QComboBox* themeSelector = new QComboBox();
|
||||||
caf::AppEnum<RiuGuiTheme::ThemeEnum> themes;
|
caf::AppEnum<RiaDefines::ThemeEnum> themes;
|
||||||
for ( size_t index = 0; index < themes.size(); index++ )
|
for ( size_t index = 0; index < themes.size(); index++ )
|
||||||
{
|
{
|
||||||
themeSelector->addItem( themes.uiTextFromIndex( index ), QVariant::fromValue( index ) );
|
themeSelector->addItem( themes.uiTextFromIndex( index ), QVariant::fromValue( index ) );
|
||||||
if ( static_cast<RiuGuiTheme::ThemeEnum>( index ) == theme )
|
if ( static_cast<RiaDefines::ThemeEnum>( index ) == theme )
|
||||||
{
|
{
|
||||||
themeSelector->setCurrentIndex( static_cast<int>( index ) );
|
themeSelector->setCurrentIndex( static_cast<int>( index ) );
|
||||||
}
|
}
|
||||||
@ -104,7 +106,7 @@ void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
|||||||
QGridLayout* innerLayout = new QGridLayout();
|
QGridLayout* innerLayout = new QGridLayout();
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
RiuGuiTheme::ThemeEnum theme = static_cast<RiuGuiTheme::ThemeEnum>( themeSelector->currentData().toInt() );
|
RiaDefines::ThemeEnum theme = static_cast<RiaDefines::ThemeEnum>( themeSelector->currentData().toInt() );
|
||||||
QMap<QString, QString> variableValueMap = RiuGuiTheme::getVariableValueMap( theme );
|
QMap<QString, QString> variableValueMap = RiuGuiTheme::getVariableValueMap( theme );
|
||||||
QMap<QString, QString> variableGuiTextMap = RiuGuiTheme::getVariableGuiTextMap( theme );
|
QMap<QString, QString> variableGuiTextMap = RiuGuiTheme::getVariableGuiTextMap( theme );
|
||||||
for ( const QString variableName : variableValueMap.keys() )
|
for ( const QString variableName : variableValueMap.keys() )
|
||||||
@ -139,8 +141,8 @@ void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
|||||||
// connect( themeSelector, qOverload<int>( &QComboBox::currentIndexChanged ), [=]() {
|
// connect( themeSelector, qOverload<int>( &QComboBox::currentIndexChanged ), [=]() {
|
||||||
connect( themeSelector, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), [=]() {
|
connect( themeSelector, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), [=]() {
|
||||||
generateColorFields();
|
generateColorFields();
|
||||||
RiuGuiTheme::ThemeEnum theme = static_cast<RiuGuiTheme::ThemeEnum>( themeSelector->currentData().toInt() );
|
RiaDefines::ThemeEnum theme = static_cast<RiaDefines::ThemeEnum>( themeSelector->currentData().toInt() );
|
||||||
RiuGuiTheme::updateGuiTheme( static_cast<RiuGuiTheme::ThemeEnum>( theme ) );
|
RiuGuiTheme::updateGuiTheme( static_cast<RiaDefines::ThemeEnum>( theme ) );
|
||||||
editor->setPlainText( RiuGuiTheme::loadStyleSheet( theme ) );
|
editor->setPlainText( RiuGuiTheme::loadStyleSheet( theme ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ void RicThemeColorEditorFeature::onActionTriggered( bool isChecked )
|
|||||||
QPushButton* button = new QPushButton( "Apply style sheet changes" );
|
QPushButton* button = new QPushButton( "Apply style sheet changes" );
|
||||||
layout->addWidget( button, 6, 1 );
|
layout->addWidget( button, 6, 1 );
|
||||||
connect( button, &QPushButton::clicked, [this, themeSelector, editor, generateColorFields]() {
|
connect( button, &QPushButton::clicked, [this, themeSelector, editor, generateColorFields]() {
|
||||||
RiuGuiTheme::ThemeEnum theme = static_cast<RiuGuiTheme::ThemeEnum>( themeSelector->currentData().toInt() );
|
RiaDefines::ThemeEnum theme = static_cast<RiaDefines::ThemeEnum>( themeSelector->currentData().toInt() );
|
||||||
RiuGuiTheme::writeStyleSheetToFile( theme, editor->toPlainText() );
|
RiuGuiTheme::writeStyleSheetToFile( theme, editor->toPlainText() );
|
||||||
generateColorFields();
|
generateColorFields();
|
||||||
} );
|
} );
|
||||||
|
@ -45,331 +45,315 @@
|
|||||||
#include "qwt_plot_marker.h"
|
#include "qwt_plot_marker.h"
|
||||||
#include "qwt_symbol.h"
|
#include "qwt_symbol.h"
|
||||||
|
|
||||||
namespace caf
|
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableValueMap = {};
|
||||||
{
|
QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableGuiTextMap = {};
|
||||||
template <>
|
|
||||||
void caf::AppEnum<RiuGuiTheme::ThemeEnum>::setUp()
|
|
||||||
{
|
|
||||||
addItem( RiuGuiTheme::ThemeEnum::DEFAULT, "DEFAULT", "Default theme" );
|
|
||||||
addItem( RiuGuiTheme::ThemeEnum::DARK, "DARK", "Dark theme" );
|
|
||||||
addItem( RiuGuiTheme::ThemeEnum::LIGHT, "LIGHT", "Light theme" );
|
|
||||||
setDefault( RiuGuiTheme::ThemeEnum::DEFAULT );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End namespace caf
|
|
||||||
|
|
||||||
QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableValueMap = {};
|
|
||||||
QMap<RiuGuiTheme::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 = {};
|
||||||
QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme::s_customStyleSheetApplicators =
|
QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme::s_customStyleSheetApplicators =
|
||||||
{ { QString(
|
{{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::curve\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
|
||||||
"QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::curve\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
|
"?<properties>([\\n\\r]*\\s*((line-color|symbol-color):"
|
||||||
"?<properties>([\\n\\r]*\\s*((line-color|symbol-color):"
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
[]( QRegularExpressionMatch& match ) {
|
||||||
[]( QRegularExpressionMatch& match ) {
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
|
||||||
|
|
||||||
QRegularExpression lineColorRegExp( "line-color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression lineColorRegExp( "line-color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString lineColor = lineColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString lineColor = lineColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
QRegularExpression symbolColorRegExp( "symbol-color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression symbolColorRegExp( "symbol-color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString symbolColor = symbolColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString symbolColor = symbolColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
if ( !lineColor.isEmpty() )
|
if ( !lineColor.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "curve" ),
|
QString( "curve" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"line-color",
|
"line-color",
|
||||||
lineColor );
|
lineColor );
|
||||||
}
|
}
|
||||||
if ( !symbolColor.isEmpty() )
|
if ( !symbolColor.isEmpty() )
|
||||||
{
|
{
|
||||||
// Symbols get the same color assigned as curves.
|
// Symbols get the same color assigned as curves.
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "curve" ),
|
QString( "curve" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"symbol-color",
|
"symbol-color",
|
||||||
symbolColor );
|
symbolColor );
|
||||||
}
|
}
|
||||||
if ( lineColor.isEmpty() && symbolColor.isEmpty() ) return;
|
if ( lineColor.isEmpty() && symbolColor.isEmpty() ) return;
|
||||||
|
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) )
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) )
|
||||||
{
|
{
|
||||||
for ( QwtPlotItem* item : plotWidget->itemList() )
|
for ( QwtPlotItem* item : plotWidget->itemList() )
|
||||||
{
|
{
|
||||||
if ( QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( item ) )
|
if ( QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( item ) )
|
||||||
{
|
{
|
||||||
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" )
|
||||||
match.captured( "itemName" ) == "*" )
|
{
|
||||||
{
|
QPen pen = curve->pen();
|
||||||
QPen pen = curve->pen();
|
pen.setColor( QColor( lineColor ) );
|
||||||
pen.setColor( QColor( lineColor ) );
|
curve->setPen( pen );
|
||||||
curve->setPen( pen );
|
|
||||||
|
|
||||||
if ( curve->symbol() && curve->symbol()->style() != QwtSymbol::NoSymbol )
|
if ( curve->symbol() && curve->symbol()->style() != QwtSymbol::NoSymbol )
|
||||||
{
|
{
|
||||||
QPen pen = curve->symbol()->pen();
|
QPen pen = curve->symbol()->pen();
|
||||||
pen.setColor( QColor( symbolColor ) );
|
pen.setColor( QColor( symbolColor ) );
|
||||||
QwtSymbol* symbol = cloneCurveSymbol( curve );
|
QwtSymbol* symbol = cloneCurveSymbol( curve );
|
||||||
symbol->setPen( pen );
|
symbol->setPen( pen );
|
||||||
curve->setSymbol( symbol );
|
curve->setSymbol( symbol );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotWidget->replot();
|
plotWidget->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} },
|
}},
|
||||||
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::grid\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
|
{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::grid\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
|
||||||
"?<properties>([\\n\\r]*\\s*((color):"
|
"?<properties>([\\n\\r]*\\s*((color):"
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
[]( QRegularExpressionMatch& match ) {
|
[]( QRegularExpressionMatch& match ) {
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
|
|
||||||
if ( !color.isEmpty() )
|
if ( !color.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "grid" ),
|
QString( "grid" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"color",
|
"color",
|
||||||
color );
|
color );
|
||||||
}
|
}
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
||||||
match.captured( "plotName" ) == "*" )
|
match.captured( "plotName" ) == "*" )
|
||||||
{
|
{
|
||||||
for ( QwtPlotItem* item : plotWidget->itemList() )
|
for ( QwtPlotItem* item : plotWidget->itemList() )
|
||||||
{
|
{
|
||||||
if ( QwtPlotGrid* grid = dynamic_cast<QwtPlotGrid*>( item ) )
|
if ( QwtPlotGrid* grid = dynamic_cast<QwtPlotGrid*>( item ) )
|
||||||
{
|
{
|
||||||
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" )
|
||||||
match.captured( "itemName" ) == "*" )
|
{
|
||||||
{
|
QPen pen = grid->majorPen();
|
||||||
QPen pen = grid->majorPen();
|
pen.setColor( QColor( color ) );
|
||||||
pen.setColor( QColor( color ) );
|
grid->setPen( pen );
|
||||||
grid->setPen( pen );
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
plotWidget->replot();
|
||||||
plotWidget->replot();
|
}
|
||||||
}
|
}
|
||||||
}
|
}},
|
||||||
} },
|
{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::legend\\s*\\{("
|
||||||
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::legend\\s*\\{("
|
"?<properties>([\\n\\r]*\\s*((text-color):"
|
||||||
"?<properties>([\\n\\r]*\\s*((text-color):"
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
[]( QRegularExpressionMatch& match ) {
|
||||||
[]( QRegularExpressionMatch& match ) {
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
QRegularExpression colorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QRegularExpression colorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
|
||||||
|
|
||||||
if ( !color.isEmpty() )
|
if ( !color.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "legend" ),
|
QString( "legend" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"text-color",
|
"text-color",
|
||||||
color );
|
color );
|
||||||
}
|
}
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
||||||
match.captured( "plotName" ) == "*" )
|
match.captured( "plotName" ) == "*" )
|
||||||
{
|
{
|
||||||
for ( QwtLegendLabel* label : plotWidget->findChildren<QwtLegendLabel*>() )
|
for ( QwtLegendLabel* label : plotWidget->findChildren<QwtLegendLabel*>() )
|
||||||
{
|
{
|
||||||
QwtText text = label->text();
|
QwtText text = label->text();
|
||||||
text.setColor( QColor( color ) );
|
text.setColor( QColor( color ) );
|
||||||
label->setText( text );
|
label->setText( text );
|
||||||
label->repaint();
|
label->repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotWidget->replot();
|
plotWidget->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} },
|
}},
|
||||||
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::lineMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
|
{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::lineMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
|
||||||
"\\s*\\{("
|
"\\s*\\{("
|
||||||
"?<properties>([\\n\\r]*\\s*((color|text-color):"
|
"?<properties>([\\n\\r]*\\s*((color|text-color):"
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
[]( QRegularExpressionMatch& match ) {
|
[]( QRegularExpressionMatch& match ) {
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
|
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
|
|
||||||
if ( !color.isEmpty() )
|
if ( !color.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "lineMarker" ),
|
QString( "lineMarker" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"color",
|
"color",
|
||||||
color );
|
color );
|
||||||
}
|
}
|
||||||
if ( !textColor.isEmpty() )
|
if ( !textColor.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "lineMarker" ),
|
QString( "lineMarker" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"text-color",
|
"text-color",
|
||||||
textColor );
|
textColor );
|
||||||
}
|
}
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
||||||
match.captured( "plotName" ) == "*" )
|
match.captured( "plotName" ) == "*" )
|
||||||
{
|
{
|
||||||
for ( QwtPlotItem* item : plotWidget->itemList() )
|
for ( QwtPlotItem* item : plotWidget->itemList() )
|
||||||
{
|
{
|
||||||
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
|
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
|
||||||
{
|
{
|
||||||
if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol )
|
if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol )
|
||||||
{
|
{
|
||||||
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
||||||
match.captured( "itemName" ) == "*" )
|
match.captured( "itemName" ) == "*" )
|
||||||
{
|
{
|
||||||
QPen pen = marker->linePen();
|
QPen pen = marker->linePen();
|
||||||
pen.setColor( QColor( color ) );
|
pen.setColor( QColor( color ) );
|
||||||
marker->setLinePen( pen );
|
marker->setLinePen( pen );
|
||||||
marker->label().setColor( QColor( textColor ) );
|
marker->label().setColor( QColor( textColor ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotWidget->replot();
|
plotWidget->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} },
|
}},
|
||||||
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::pointMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
|
{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::pointMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
|
||||||
"\\s*\\{("
|
"\\s*\\{("
|
||||||
"?<properties>([\\n\\r]*\\s*((color|text-color):"
|
"?<properties>([\\n\\r]*\\s*((color|text-color):"
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
[]( QRegularExpressionMatch& match ) {
|
[]( QRegularExpressionMatch& match ) {
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
|
||||||
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
|
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
|
|
||||||
if ( !color.isEmpty() )
|
if ( !color.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "pointMarker" ),
|
QString( "pointMarker" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"color",
|
"color",
|
||||||
color );
|
color );
|
||||||
}
|
}
|
||||||
if ( !textColor.isEmpty() )
|
if ( !textColor.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
storeQwtStyleSheetProperty( match.captured( "plotName" ),
|
||||||
QString( "pointMarker" ),
|
QString( "pointMarker" ),
|
||||||
match.captured( "itemName" ),
|
match.captured( "itemName" ),
|
||||||
"text-color",
|
"text-color",
|
||||||
textColor );
|
textColor );
|
||||||
}
|
}
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
||||||
match.captured( "plotName" ) == "*" )
|
match.captured( "plotName" ) == "*" )
|
||||||
{
|
{
|
||||||
for ( QwtPlotItem* item : plotWidget->itemList() )
|
for ( QwtPlotItem* item : plotWidget->itemList() )
|
||||||
{
|
{
|
||||||
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
|
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
|
||||||
{
|
{
|
||||||
if ( marker->symbol() && marker->symbol()->style() != QwtSymbol::NoSymbol )
|
if ( marker->symbol() && marker->symbol()->style() != QwtSymbol::NoSymbol )
|
||||||
{
|
{
|
||||||
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
|
||||||
match.captured( "itemName" ) == "*" )
|
match.captured( "itemName" ) == "*" )
|
||||||
{
|
{
|
||||||
QPen pen = marker->symbol()->pen();
|
QPen pen = marker->symbol()->pen();
|
||||||
pen.setColor( QColor( color ) );
|
pen.setColor( QColor( color ) );
|
||||||
QwtSymbol* symbol = cloneMarkerSymbol( marker );
|
QwtSymbol* symbol = cloneMarkerSymbol( marker );
|
||||||
symbol->setPen( pen );
|
symbol->setPen( pen );
|
||||||
marker->setSymbol( symbol );
|
marker->setSymbol( symbol );
|
||||||
marker->label().setColor( QColor( textColor ) );
|
marker->label().setColor( QColor( textColor ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotWidget->replot();
|
plotWidget->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} },
|
}},
|
||||||
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::picker"
|
{QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::picker"
|
||||||
"\\s*\\{("
|
"\\s*\\{("
|
||||||
"?<properties>([\\n\\r]*\\s*((text-color):"
|
"?<properties>([\\n\\r]*\\s*((text-color):"
|
||||||
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
|
||||||
[]( QRegularExpressionMatch& match ) {
|
[]( QRegularExpressionMatch& match ) {
|
||||||
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
QRegExp plotNameRegExp( match.captured( "plotName" ) );
|
||||||
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
QRegExp itemNameRegExp( match.captured( "itemName" ) );
|
||||||
QRegularExpression textColorRegExp( "text-color:\\s*([#a-zA-Z0-9]+)" );
|
QRegularExpression textColorRegExp( "text-color:\\s*([#a-zA-Z0-9]+)" );
|
||||||
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
|
||||||
|
|
||||||
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
|
||||||
|
|
||||||
if ( !textColor.isEmpty() )
|
if ( !textColor.isEmpty() )
|
||||||
{
|
{
|
||||||
storeQwtStyleSheetProperty( match.captured( "plotName" ), QString( "picker" ), "*", "text-color", textColor );
|
storeQwtStyleSheetProperty( match.captured( "plotName" ), QString( "picker" ), "*", "text-color", textColor );
|
||||||
}
|
}
|
||||||
for ( QWidget* widget : topLevelWidgets )
|
for ( QWidget* widget : topLevelWidgets )
|
||||||
{
|
{
|
||||||
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
|
||||||
{
|
{
|
||||||
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
|
||||||
match.captured( "plotName" ) == "*" )
|
match.captured( "plotName" ) == "*" )
|
||||||
{
|
{
|
||||||
QWidget* canvas = plotWidget->canvas();
|
QWidget* canvas = plotWidget->canvas();
|
||||||
if ( canvas )
|
if ( canvas )
|
||||||
{
|
{
|
||||||
for ( QwtPicker* picker : canvas->findChildren<QwtPicker*>() )
|
for ( QwtPicker* picker : canvas->findChildren<QwtPicker*>() )
|
||||||
{
|
{
|
||||||
QPen pen = picker->trackerPen();
|
QPen pen = picker->trackerPen();
|
||||||
pen.setColor( QColor( textColor ) );
|
pen.setColor( QColor( textColor ) );
|
||||||
picker->setTrackerPen( pen );
|
picker->setTrackerPen( pen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotWidget->replot();
|
plotWidget->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} } };
|
}}};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuGuiTheme::updateGuiTheme( ThemeEnum theme )
|
void RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
s_qwtPlotItemPropertiesMap.clear();
|
s_qwtPlotItemPropertiesMap.clear();
|
||||||
applyStyleSheet( theme );
|
applyStyleSheet( theme );
|
||||||
@ -384,7 +368,7 @@ void RiuGuiTheme::updateGuiTheme( ThemeEnum theme )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RiuGuiTheme::applyStyleSheet( ThemeEnum theme )
|
bool RiuGuiTheme::applyStyleSheet( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
QString styleSheetPath = getStyleSheetPath( theme );
|
QString styleSheetPath = getStyleSheetPath( theme );
|
||||||
QFile styleSheetFile( styleSheetPath );
|
QFile styleSheetFile( styleSheetPath );
|
||||||
@ -406,7 +390,7 @@ bool RiuGuiTheme::applyStyleSheet( ThemeEnum theme )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuGuiTheme::changeVariableValue( RiuGuiTheme::ThemeEnum theme, const QString& variableName, const QString& newValue )
|
void RiuGuiTheme::changeVariableValue( RiaDefines::ThemeEnum theme, const QString& variableName, const QString& newValue )
|
||||||
{
|
{
|
||||||
if ( !s_variableValueMap.keys().contains( theme ) )
|
if ( !s_variableValueMap.keys().contains( theme ) )
|
||||||
{
|
{
|
||||||
@ -422,7 +406,7 @@ void RiuGuiTheme::changeVariableValue( RiuGuiTheme::ThemeEnum theme, const QStri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> RiuGuiTheme::getVariableValueMap( RiuGuiTheme::ThemeEnum theme )
|
QMap<QString, QString> RiuGuiTheme::getVariableValueMap( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
if ( !s_variableValueMap.keys().contains( theme ) )
|
if ( !s_variableValueMap.keys().contains( theme ) )
|
||||||
{
|
{
|
||||||
@ -448,7 +432,7 @@ QMap<QString, QString> RiuGuiTheme::getVariableValueMap( RiuGuiTheme::ThemeEnum
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QMap<QString, QString> RiuGuiTheme::getVariableGuiTextMap( RiuGuiTheme::ThemeEnum theme )
|
QMap<QString, QString> RiuGuiTheme::getVariableGuiTextMap( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
if ( !s_variableGuiTextMap.keys().contains( theme ) )
|
if ( !s_variableGuiTextMap.keys().contains( theme ) )
|
||||||
{
|
{
|
||||||
@ -474,7 +458,7 @@ QMap<QString, QString> RiuGuiTheme::getVariableGuiTextMap( RiuGuiTheme::ThemeEnu
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RiuGuiTheme::applyVariableValueMapToStyleSheet( RiuGuiTheme::ThemeEnum theme )
|
QString RiuGuiTheme::applyVariableValueMapToStyleSheet( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
QFileInfo info( getStyleSheetPath( theme ) );
|
QFileInfo info( getStyleSheetPath( theme ) );
|
||||||
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
|
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
|
||||||
@ -512,7 +496,7 @@ QString RiuGuiTheme::applyVariableValueMapToStyleSheet( RiuGuiTheme::ThemeEnum t
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RiuGuiTheme::writeStyleSheetToFile( RiuGuiTheme::ThemeEnum theme, const QString& styleSheet )
|
bool RiuGuiTheme::writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QString& styleSheet )
|
||||||
{
|
{
|
||||||
QFileInfo info( getStyleSheetPath( theme ) );
|
QFileInfo info( getStyleSheetPath( theme ) );
|
||||||
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
|
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
|
||||||
@ -542,7 +526,7 @@ bool RiuGuiTheme::writeStyleSheetToFile( RiuGuiTheme::ThemeEnum theme, const QSt
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RiuGuiTheme::loadStyleSheet( RiuGuiTheme::ThemeEnum theme )
|
QString RiuGuiTheme::loadStyleSheet( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
QFile styleSheetFile( getStyleSheetPath( theme ) );
|
QFile styleSheetFile( getStyleSheetPath( theme ) );
|
||||||
QString styleSheet;
|
QString styleSheet;
|
||||||
@ -580,10 +564,10 @@ QAbstractItemModel* RiuGuiTheme::getQssCompletionModel( QCompleter* completer )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QColor RiuGuiTheme::getColorByVariableName( const QString& variable, int theme /*= -1 */ )
|
QColor RiuGuiTheme::getColorByVariableName( const QString& variable, int theme /*= -1 */ )
|
||||||
{
|
{
|
||||||
RiuGuiTheme::ThemeEnum eTheme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
RiaDefines::ThemeEnum eTheme = RiaGuiApplication::instance()->preferences()->guiTheme();
|
||||||
if ( theme >= 0 && theme < static_cast<int>( caf::AppEnum<RiuGuiTheme::ThemeEnum>().size() ) )
|
if ( theme >= 0 && theme < static_cast<int>( caf::AppEnum<RiaDefines::ThemeEnum>().size() ) )
|
||||||
{
|
{
|
||||||
eTheme = static_cast<RiuGuiTheme::ThemeEnum>( theme );
|
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 ) )
|
||||||
@ -759,7 +743,7 @@ void RiuGuiTheme::styleQwtItem( QwtPicker* item )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuGuiTheme::preparseStyleSheet( RiuGuiTheme::ThemeEnum theme, QString& styleSheet )
|
void RiuGuiTheme::preparseStyleSheet( RiaDefines::ThemeEnum theme, QString& styleSheet )
|
||||||
{
|
{
|
||||||
QRegularExpression variableRegExp(
|
QRegularExpression variableRegExp(
|
||||||
"[ \\t]*(?<name>\\$[a-zA-z0-9_]+)[ \\t]*:[ \\t]*(?<value>[a-zA-Z-_0-9#]+);[ \\t]*(\\/\\/[ "
|
"[ \\t]*(?<name>\\$[a-zA-z0-9_]+)[ \\t]*:[ \\t]*(?<value>[a-zA-Z-_0-9#]+);[ \\t]*(\\/\\/[ "
|
||||||
@ -811,9 +795,9 @@ void RiuGuiTheme::preparseStyleSheet( RiuGuiTheme::ThemeEnum theme, QString& sty
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RiuGuiTheme::getStyleSheetPath( ThemeEnum theme )
|
QString RiuGuiTheme::getStyleSheetPath( RiaDefines::ThemeEnum theme )
|
||||||
{
|
{
|
||||||
return QString( ":/themes/%0.qss" ).arg( caf::AppEnum<RiuGuiTheme::ThemeEnum>( theme ).text().toLower() );
|
return QString( ":/themes/%0.qss" ).arg( caf::AppEnum<RiaDefines::ThemeEnum>( theme ).text().toLower() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@ -34,27 +36,21 @@ class QwtSymbol;
|
|||||||
class QwtPlotMarker;
|
class QwtPlotMarker;
|
||||||
class QwtPlotCurve;
|
class QwtPlotCurve;
|
||||||
class QwtPicker;
|
class QwtPicker;
|
||||||
|
class QwtText;
|
||||||
|
|
||||||
typedef std::function<void( QRegularExpressionMatch& )> CustomStyleSheetApplicator;
|
typedef std::function<void( QRegularExpressionMatch& )> CustomStyleSheetApplicator;
|
||||||
|
|
||||||
class RiuGuiTheme
|
class RiuGuiTheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class ThemeEnum
|
static void updateGuiTheme( RiaDefines::ThemeEnum theme );
|
||||||
{
|
static bool applyStyleSheet( RiaDefines::ThemeEnum theme );
|
||||||
DEFAULT,
|
static void changeVariableValue( RiaDefines::ThemeEnum theme, const QString& variableName, const QString& newValue );
|
||||||
DARK,
|
static QMap<QString, QString> getVariableValueMap( RiaDefines::ThemeEnum theme );
|
||||||
LIGHT
|
static QMap<QString, QString> getVariableGuiTextMap( RiaDefines::ThemeEnum theme );
|
||||||
};
|
static QString applyVariableValueMapToStyleSheet( RiaDefines::ThemeEnum theme );
|
||||||
|
static bool writeStyleSheetToFile( RiaDefines::ThemeEnum theme, const QString& styleSheet );
|
||||||
static void updateGuiTheme( ThemeEnum theme );
|
static QString loadStyleSheet( RiaDefines::ThemeEnum theme );
|
||||||
static bool applyStyleSheet( ThemeEnum theme );
|
|
||||||
static void changeVariableValue( RiuGuiTheme::ThemeEnum theme, const QString& variableName, const QString& newValue );
|
|
||||||
static QMap<QString, QString> getVariableValueMap( RiuGuiTheme::ThemeEnum theme );
|
|
||||||
static QMap<QString, QString> getVariableGuiTextMap( RiuGuiTheme::ThemeEnum theme );
|
|
||||||
static QString applyVariableValueMapToStyleSheet( RiuGuiTheme::ThemeEnum theme );
|
|
||||||
static bool writeStyleSheetToFile( RiuGuiTheme::ThemeEnum theme, const QString& styleSheet );
|
|
||||||
static QString loadStyleSheet( RiuGuiTheme::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, int theme = -1 );
|
||||||
static QString
|
static QString
|
||||||
@ -63,8 +59,8 @@ public:
|
|||||||
static void styleQwtItem( QwtPicker* item );
|
static void styleQwtItem( QwtPicker* item );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void preparseStyleSheet( RiuGuiTheme::ThemeEnum theme, QString& styleSheet );
|
static void preparseStyleSheet( RiaDefines::ThemeEnum theme, QString& styleSheet );
|
||||||
static QString getStyleSheetPath( RiuGuiTheme::ThemeEnum theme );
|
static QString getStyleSheetPath( RiaDefines::ThemeEnum theme );
|
||||||
static void storeQwtStyleSheetProperty( const QString& plotName,
|
static void storeQwtStyleSheetProperty( const QString& plotName,
|
||||||
const QString& itemType,
|
const QString& itemType,
|
||||||
const QString& itemName,
|
const QString& itemName,
|
||||||
@ -75,8 +71,8 @@ private:
|
|||||||
static QwtSymbol* cloneCurveSymbol( QwtPlotCurve* curve );
|
static QwtSymbol* cloneCurveSymbol( QwtPlotCurve* curve );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
|
static QMap<RiaDefines::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
|
||||||
static QMap<RiuGuiTheme::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;
|
||||||
static QMap<QString, CustomStyleSheetApplicator> s_customStyleSheetApplicators;
|
static QMap<QString, CustomStyleSheetApplicator> s_customStyleSheetApplicators;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user