Added a GUI theme selector in preferences and a new class for handling GUI changes.

Added a new feature for editing style sheets and variable colors and see immediately the result.
Made Qwt plots (and items) stylable.
Added icons, improved styling possibilities of QMinimizePanel, fixed minor bugs in RicThemeColorEditorFeature.
This commit is contained in:
Ruben Manuel Thoms
2020-09-04 17:10:55 +02:00
committed by Gaute Lindkvist
parent 66ec3212c0
commit 87bc6acd65
50 changed files with 3178 additions and 308 deletions

View File

@@ -417,6 +417,8 @@ void RiaGuiApplication::initialize()
{
RiaApplication::initialize();
RiuGuiTheme::updateGuiTheme( m_preferences->guiTheme() );
applyGuiPreferences( nullptr );
// Create main windows

View File

@@ -384,6 +384,8 @@ RiaPreferences::RiaPreferences( void )
"",
"Defines preferred minimum distance between surface points in XY-plane",
"" );
CAF_PDM_InitFieldNoDefault( &m_guiTheme, "guiTheme", "GUI theme", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
@@ -595,6 +597,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.add( &m_showTestToolbar );
uiOrdering.add( &m_includeFractureDebugInfoFile );
uiOrdering.add( &m_holoLensExportFolder );
uiOrdering.add( &m_guiTheme );
}
uiOrdering.skipRemainingFields( true );
@@ -681,6 +684,11 @@ void RiaPreferences::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
m_pageTopMargin = defaultMarginSize( m_pageSize() );
m_pageBottomMargin = defaultMarginSize( m_pageSize() );
}
if ( changedField == &m_guiTheme )
{
RiuGuiTheme::updateGuiTheme( m_guiTheme() );
}
}
//--------------------------------------------------------------------------------------------------
///
@@ -991,6 +999,14 @@ bool RiaPreferences::openExportedPdfInViewer() const
return m_openExportedPdfInViewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGuiTheme::ThemeEnum RiaPreferences::guiTheme() const
{
return m_guiTheme();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -25,6 +25,7 @@
#include "RiaFontCache.h"
#include "RiaGuiApplication.h"
#include "RiaQDateTimeTools.h"
#include "RiuGuiTheme.h"
#include "cafAppEnum.h"
#include "cafPdmChildField.h"
@@ -112,6 +113,8 @@ public:
bool showProgressBar() const;
bool openExportedPdfInViewer() const;
RiuGuiTheme::ThemeEnum guiTheme() const;
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
void writePreferencesToApplicationStore();
@@ -212,6 +215,8 @@ private:
caf::PdmField<bool> m_showProgressBar;
caf::PdmField<QString> m_gtestFilter;
caf::PdmField<caf::AppEnum<RiuGuiTheme::ThemeEnum>> m_guiTheme;
caf::PdmField<PageSizeEnum> m_pageSize;
caf::PdmField<PageOrientationEnum> m_pageOrientation;
caf::PdmField<double> m_pageLeftMargin;

View File

@@ -25,6 +25,8 @@
#include <algorithm>
#include <cmath>
#include <QPalette>
//--------------------------------------------------------------------------------------------------
/// Uses W3.org relative luminance calculation taking into account the different luminance of the different colors
/// https://www.w3.org/TR/WCAG20-TECHS/G18.html
@@ -141,6 +143,24 @@ cvf::Color3f RiaColorTools::fromQColorTo3f( QColor color )
return cvf::Color3f( color.redF(), color.greenF(), color.blueF() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RiaColorTools::systemPaletteTextColor()
{
QPalette systemPalette;
return systemPalette.color( QPalette::Text );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RiaColorTools::systemPaletteTextColor3f()
{
return fromQColorTo3f( systemPaletteTextColor() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -42,6 +42,9 @@ public:
static QColor toQColor( cvf::Color4f color );
static cvf::Color3f fromQColorTo3f( QColor );
static QColor systemPaletteTextColor();
static cvf::Color3f systemPaletteTextColor3f();
static cvf::Color3f
blendCvfColors( const cvf::Color3f& color1, const cvf::Color3f& color2, int weight1 = 1, int weight2 = 1 );
static QColor blendQColors( const QColor& color1, const QColor& color2, int weight1 = 1, int weight2 = 1 );