mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
committed by
Gaute Lindkvist
parent
66ec3212c0
commit
87bc6acd65
@@ -45,7 +45,9 @@
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QResizeEvent>
|
||||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -150,6 +152,12 @@ static const QIcon& expandUpIcon()
|
||||
QMinimizePanel::QMinimizePanel( QWidget* parent /*=0*/ )
|
||||
: QFrame( parent )
|
||||
{
|
||||
m_titleBackground =
|
||||
"qlineargradient(spread:pad, x1:0 y1:0, x2:0 y2:1, stop:0 rgba(150, 150, 150, 20), stop:1 rgba(0, 0, 0, 50))";
|
||||
m_border = "1px solid darkgray";
|
||||
m_background = "rgba(255, 250, 250, 85)";
|
||||
m_collapseIcon = expandUpIcon();
|
||||
m_expandIcon = expandDownIcon();
|
||||
this->initialize( "" );
|
||||
}
|
||||
|
||||
@@ -224,6 +232,121 @@ bool QMinimizePanel::isExpanded() const
|
||||
return !m_contentFrame->isHidden();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getBackground() const
|
||||
{
|
||||
return m_background;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setBackground( QString background )
|
||||
{
|
||||
m_background = background;
|
||||
m_contentFrame->setStyleSheet( contentFrameStyleSheet() );
|
||||
m_contentFrame->style()->unpolish( m_contentFrame );
|
||||
m_contentFrame->style()->polish( m_contentFrame );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getTitleBackground() const
|
||||
{
|
||||
return m_titleBackground;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setTitleBackground( QString background )
|
||||
{
|
||||
m_titleBackground = background;
|
||||
m_titleFrame->setStyleSheet( titleFrameStyleSheet() );
|
||||
m_titleFrame->style()->unpolish( m_titleFrame );
|
||||
m_titleFrame->style()->polish( m_titleFrame );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getBorder() const
|
||||
{
|
||||
return m_border;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setBorder( QString border )
|
||||
{
|
||||
m_border = border;
|
||||
m_contentFrame->setStyleSheet( contentFrameStyleSheet() );
|
||||
m_contentFrame->style()->unpolish( m_contentFrame );
|
||||
m_contentFrame->style()->polish( m_contentFrame );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getExpandIconPath() const
|
||||
{
|
||||
return m_expandIconPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setExpandIconPath( QString path )
|
||||
{
|
||||
m_expandIconPath = path;
|
||||
m_expandIcon = QIcon( path );
|
||||
if ( !isExpanded() ) m_collapseButton->setIcon( m_expandIcon );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getCollapseIconPath() const
|
||||
{
|
||||
return m_expandIconPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setCollapseIconPath( QString path )
|
||||
{
|
||||
m_collapseIconPath = path;
|
||||
m_collapseIcon = QIcon( path );
|
||||
if ( isExpanded() ) m_collapseButton->setIcon( m_collapseIcon );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString QMinimizePanel::getIconSize() const
|
||||
{
|
||||
return m_iconSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QMinimizePanel::setIconSize( QString size )
|
||||
{
|
||||
m_iconSize = size;
|
||||
QRegularExpression sizeRegExp = QRegularExpression( "\\s*([0-9]+)px\\s*" );
|
||||
if ( sizeRegExp.match( size ).hasMatch() )
|
||||
{
|
||||
m_collapseButton->setIconSize(
|
||||
QSize( sizeRegExp.match( size ).captured( 1 ).toInt(), sizeRegExp.match( size ).captured( 1 ).toInt() ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -234,12 +357,12 @@ void QMinimizePanel::setExpanded( bool isExpanded )
|
||||
m_contentFrame->setVisible( isExpanded );
|
||||
if ( isExpanded )
|
||||
{
|
||||
m_collapseButton->setIcon( expandUpIcon() );
|
||||
m_collapseButton->setIcon( m_collapseIcon );
|
||||
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_collapseButton->setIcon( expandDownIcon() );
|
||||
m_collapseButton->setIcon( m_expandIcon );
|
||||
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
||||
}
|
||||
|
||||
@@ -287,7 +410,7 @@ void QMinimizePanel::initialize( const QString& title )
|
||||
{
|
||||
m_collapseButton = new QPushButton();
|
||||
m_collapseButton->setFlat( true );
|
||||
m_collapseButton->setIcon( expandUpIcon() );
|
||||
m_collapseButton->setIcon( m_collapseIcon );
|
||||
m_collapseButton->setDefault( false );
|
||||
m_collapseButton->setAutoDefault( false );
|
||||
m_collapseButton->setIconSize( QSize( 16, 16 ) );
|
||||
@@ -314,9 +437,9 @@ QString QMinimizePanel::titleFrameStyleSheet()
|
||||
return QString( "QFrame#GroupTitleFrame "
|
||||
"{"
|
||||
" border-top: none; border-left: none; border-right: none; border-bottom: none;"
|
||||
" background: qlineargradient(spread:pad, x1:0 y1:0, x2:0 y2:1,"
|
||||
" stop:0 rgba(150, 150, 150, 20), stop:1 rgba(0, 0, 0, 50));"
|
||||
"}" );
|
||||
" background: %0;"
|
||||
"}" )
|
||||
.arg( m_titleBackground );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -326,11 +449,12 @@ QString QMinimizePanel::contentFrameStyleSheet()
|
||||
{
|
||||
return QString( "QFrame#FramedGroupContent"
|
||||
"{"
|
||||
" border-top: 1px solid darkgray; border-left: none; border-right: none; border-bottom: none; "
|
||||
" background: rgba(255, 250, 250, 85)"
|
||||
" border-top: %0; border-left: none; border-right: none; border-bottom: none; "
|
||||
" background: %1;"
|
||||
"}"
|
||||
"QFrame#UnframedGroupContent"
|
||||
"{"
|
||||
" border-top: none; border-left: none; border-right: none; border-bottom: none; "
|
||||
"}" );
|
||||
"}" )
|
||||
.arg( m_border, m_background );
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QIcon>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
@@ -49,6 +50,12 @@ class QPushButton;
|
||||
class QMinimizePanel : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString background READ getBackground WRITE setBackground DESIGNABLE true )
|
||||
Q_PROPERTY( QString titleBackground READ getTitleBackground WRITE setTitleBackground DESIGNABLE true )
|
||||
Q_PROPERTY( QString border READ getBorder WRITE setBorder DESIGNABLE true )
|
||||
Q_PROPERTY( QString expandIconPath READ getExpandIconPath WRITE setExpandIconPath DESIGNABLE true )
|
||||
Q_PROPERTY( QString collapseIconPath READ getCollapseIconPath WRITE setCollapseIconPath DESIGNABLE true )
|
||||
Q_PROPERTY( QString iconSize READ getIconSize WRITE setIconSize DESIGNABLE true )
|
||||
public:
|
||||
explicit QMinimizePanel( QWidget* parent = nullptr );
|
||||
explicit QMinimizePanel( const QString& title, QWidget* parent = nullptr );
|
||||
@@ -59,6 +66,25 @@ public:
|
||||
QString title() const;
|
||||
void enableFrame( bool showFrame );
|
||||
bool isExpanded() const;
|
||||
|
||||
QString getBackground() const;
|
||||
void setBackground( QString background );
|
||||
|
||||
QString getTitleBackground() const;
|
||||
void setTitleBackground( QString background );
|
||||
|
||||
QString getBorder() const;
|
||||
void setBorder( QString border );
|
||||
|
||||
QString getExpandIconPath() const;
|
||||
void setExpandIconPath( QString path );
|
||||
|
||||
QString getCollapseIconPath() const;
|
||||
void setCollapseIconPath( QString path );
|
||||
|
||||
QString getIconSize() const;
|
||||
void setIconSize( QString size );
|
||||
|
||||
public slots:
|
||||
void setExpanded( bool isExpanded );
|
||||
void toggleExpanded();
|
||||
@@ -77,4 +103,13 @@ private:
|
||||
|
||||
QString titleFrameStyleSheet();
|
||||
QString contentFrameStyleSheet();
|
||||
|
||||
QString m_background;
|
||||
QString m_titleBackground;
|
||||
QString m_border;
|
||||
QString m_expandIconPath;
|
||||
QString m_collapseIconPath;
|
||||
QString m_iconSize;
|
||||
QIcon m_expandIcon;
|
||||
QIcon m_collapseIcon;
|
||||
};
|
||||
|
||||
@@ -179,15 +179,6 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
|
||||
QPalette myPalette;
|
||||
|
||||
if ( attributes.m_baseColor == myPalette.color( QPalette::Active, QPalette::Base ) )
|
||||
{
|
||||
m_listView->setStyleSheet( "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_listView->setStyleSheet( "background-color: " + attributes.m_baseColor.name() + ";" );
|
||||
}
|
||||
|
||||
m_listView->setHeightHint( attributes.m_heightHint );
|
||||
if ( !attributes.m_allowHorizontalScrollBar )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user