Style sheet now applied to PdmUiTreeViewEditor.

Move some classes from PdmUiTreeViewEditor.cpp to the header file in order to make them available in RiuGuiTheme to adjust the style of tree views and keep the drag&drop styling. 
Removed getStyleSheet function.
This commit is contained in:
Ruben Thoms 2020-09-29 17:57:02 +02:00 committed by Magne Sjaastad
parent a68598fd16
commit 0f92ad13ad
12 changed files with 170 additions and 141 deletions

View File

@ -5,8 +5,11 @@ $backgroundColor3: #5a6067; // Background color layer 3
$backgroundColor4: #89939d; // Background color layer 4
$backgroundColor5: #adbac6; // Background color layer 5
$textColor: #e6e7ea; // Main text color
$primaryColor: #018fa3; // Primary color (buttons etc)
$secondaryColor: #e82257; // Secondary color
$inputColor: #394046; // Input background color
$buttonColor: #0a639d; // Button color
$buttonHoverColor: #136fa3; // Button hover color
$primaryColor: #084771; // Primary color
$secondaryColor: #cc6632; // Secondary color
$tertiaryColor: #ffc50d; // Tertiary color
$quaternaryColor: #36b27e; // Quaternary color
$quinaryColor: #0ce5d5; // Quinary color
@ -24,38 +27,39 @@ $plotGridColor: #394046; // Plot grid color
$auxiliaryCurveColor: #000000; // Auxiliary curve color
$externalInputColor: #e82257; // External input background color
QCheckBox::indicator, QTreeView::indicator, QTableView::indicator {
background-color: $backgroundColor1;
border-radius: 3px;
width: 16px;
height: 16px;
}
QCheckBox::indicator:unchecked, QTreeView::indicator:unchecked, QTableView::indicator:unchecked
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-unchecked.svg);
}
QCheckBox::indicator:checked, QTreeView::indicator:checked, QTableView::indicator:checked
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-checked.svg);
}
QCheckBox::indicator:indeterminate, QTreeView::indicator:indeterminate, QTableView::indicator:indeterminate
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-indeterminate.svg);
}
QCheckBox::indicator:unchecked:disabled, QTreeView::indicator:unchecked:disabled, QTableView::indicator:unchecked:disabled
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-unchecked-disabled.svg);
}
QCheckBox::indicator:checked:disabled, QTreeView::indicator:checked:disabled, QTableView::indicator:checked:disabled
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-checked-disabled.svg);
}
QCheckBox::indicator:indeterminate:disabled, QTreeView::indicator:indeterminate:disabled, QTableView::indicator:indeterminate:disabled
{
background-color: $backgroundColor1;
image: url(:/themes/dark/checkbox-indeterminate-disabled.svg);
}
@ -142,7 +146,7 @@ QToolButton {
padding: 3px;
}
QLabel, QCheckBox {
QLabel {
background-color: transparent;
}
@ -150,6 +154,7 @@ QWidget {
background-color: $mainBackgroundColor;
color: $textColor;
border-color: $borderColor;
selection-background-color: $primaryColor;
}
QProgressBar {
@ -252,12 +257,16 @@ QMenu::item:selected {
QLineEdit, QComboBox, QSpinBox,
QDoubleSpinBox, QDateEdit, QDateTimeEdit {
background-color: $backgroundColor1;
background-color: $inputColor;
color: $textColor;
border-color: $borderColor;
border-width : 1.5px;
border-style: solid;
border: 0;
padding: 3px;
border: 2px solid $inputColor;
}
QLineEdit:focus, QComboBox:focus, QSpinBox:focus,
QDoubleSpinBox:focus, QDateEdit:focus, QDateTimeEdit:focus {
border: 2px solid $primaryColor;
}
QToolBar {
@ -283,11 +292,13 @@ QLCDNumber {
QPushButton {
color: $textColor;
border-color: $borderColor;
background-color: $backgroundColor1;
border-width: 1.5px;
border-style: solid;
padding: 5px;
font-weight: bold;
background-color: $buttonColor;
border: 0px;
padding: 8px;
}
QPushButton:hover {
background-color: $buttonHoverColor;
}
QTabWidget {
@ -426,3 +437,20 @@ QWidget:readonly {
background-color: $backgroundColor1;
color: $backgroundColor3;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 18px;
border: 0px;
}
QComboBox QAbstractItemView {
background-color: $inputColor;
}
QComboBox::down-arrow {
image: url(:/themes/dark/expanded.svg);
width: 18px;
height: 16px;
}

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#5B6068;stroke-miterlimit:10;}
.st1{fill:none;stroke:#5B6068;stroke-width:1.5;stroke-miterlimit:10;}
.st2{display:none;fill:#E7E8EA;}
.st0{display:none;fill:#394046;}
.st1{fill:none;stroke:#5C6169;stroke-width:1.5;stroke-miterlimit:10;}
.st2{display:none;fill:#5C6169;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="3" y="3" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 691 B

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#E8E8EA;stroke-miterlimit:10;}
.st0{display:none;fill:#394046;}
.st1{fill:none;stroke:#E8E8EA;stroke-width:1.5;stroke-miterlimit:10;}
.st2{display:none;fill:#E7E8EA;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="2.9" y="2.9" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 695 B

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#5B6068;stroke-miterlimit:10;}
.st1{display:none;fill:none;stroke:#5B6068;stroke-miterlimit:10;}
.st0{display:none;fill:#394046;}
.st1{display:none;fill:none;stroke:#E8E8EA;stroke-width:1.5;stroke-miterlimit:10;}
.st2{fill:#5C6169;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="3" y="3" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 691 B

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#E8E8EA;stroke-miterlimit:10;}
.st1{display:none;fill:none;stroke:#5B6068;stroke-miterlimit:10;}
.st0{display:none;fill:#394046;}
.st1{display:none;fill:none;stroke:#E8E8EA;stroke-width:1.5;stroke-miterlimit:10;}
.st2{fill:#E7E8EA;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="3" y="3" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 691 B

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#5B6068;stroke-miterlimit:10;}
.st1{display:none;fill:none;stroke:#5B6068;stroke-miterlimit:10;}
.st2{fill:#5B6068;}
</style>
<rect x="1.6" y="1.6" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="4.2,8.4 7.2,11.3 12.9,5.6 "/>
<rect x="4.5" y="4.5" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 710 B

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#E7E8EA;stroke-miterlimit:10;}
.st1{display:none;fill:none;stroke:#5B6068;stroke-miterlimit:10;}
.st2{fill:#E7E8EA;}
</style>
<rect x="1.6" y="1.6" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="4.2,8.4 7.2,11.3 12.9,5.6 "/>
<rect x="4.5" y="4.5" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 710 B

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#5B6068;stroke-miterlimit:10;}
.st1{display:none;fill:none;stroke:#5B6068;stroke-miterlimit:10;}
.st2{display:none;fill:#5C6169;}
.st0{display:none;fill:#394046;}
.st1{display:none;fill:none;stroke:#E8E8EA;stroke-width:1.5;stroke-miterlimit:10;}
.st2{display:none;fill:#E7E8EA;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="3" y="3" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 704 B

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 13.9 13.9" style="enable-background:new 0 0 13.9 13.9;" xml:space="preserve">
viewBox="0 0 12.9 12.9" style="enable-background:new 0 0 12.9 12.9;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394046;stroke:#E8E8EA;stroke-miterlimit:10;}
.st0{display:none;fill:#394046;}
.st1{display:none;fill:none;stroke:#E8E8EA;stroke-width:1.5;stroke-miterlimit:10;}
.st2{display:none;fill:#E7E8EA;}
</style>
<rect x="0.5" y="0.5" class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="3.2,7.3 6.1,10.2 11.8,4.6 "/>
<rect x="3.4" y="3.4" class="st2" width="7" height="7"/>
<rect class="st0" width="12.9" height="12.9"/>
<polyline class="st1" points="2.7,6.8 5.6,9.7 11.3,4.1 "/>
<rect x="3" y="3" class="st2" width="7" height="7"/>
</svg>

Before

Width:  |  Height:  |  Size: 748 B

After

Width:  |  Height:  |  Size: 704 B

View File

@ -22,7 +22,9 @@
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RiuThemesDirectory.h"
#include "cafAppEnum.h"
#include "cafPdmUiTreeViewEditor.h"
#include <QAbstractItemModel>
#include <QColor>
@ -362,6 +364,10 @@ void RiuGuiTheme::updateGuiTheme( RiaDefines::ThemeEnum theme )
{
widget->style()->unpolish( widget );
widget->style()->polish( widget );
if ( caf::PdmUiTreeViewWidget* treeViewWidget = dynamic_cast<caf::PdmUiTreeViewWidget*>( widget ) )
{
treeViewWidget->setStyle( new caf::PdmUiTreeViewStyle );
}
}
}

View File

@ -64,87 +64,78 @@
namespace caf
{
class PdmUiTreeViewStyle : public QProxyStyle
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewStyle::drawPrimitive( QStyle::PrimitiveElement element,
const QStyleOption* option,
QPainter* painter,
const QWidget* widget ) const
{
public:
void drawPrimitive( PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget ) const override
if ( element == QStyle::PE_IndicatorItemViewItemDrop )
{
if ( element == QStyle::PE_IndicatorItemViewItemDrop )
painter->setRenderHint( QPainter::Antialiasing, true );
if ( option->rect.height() == 0 )
{
painter->setRenderHint( QPainter::Antialiasing, true );
QPalette palette;
QColor c = QApplication::palette().color( QPalette::Highlight ).darker( 150 );
QPen pen( c );
pen.setWidth( 2 );
QBrush brush( c );
if ( option->rect.height() == 0 )
{
QPalette palette;
QColor c = QApplication::palette().color( QPalette::Highlight ).darker( 150 );
QPen pen( c );
pen.setWidth( 2 );
QBrush brush( c );
painter->setPen( pen );
painter->setBrush( brush );
painter->setPen( pen );
painter->setBrush( brush );
painter->drawEllipse( option->rect.topLeft(), 3, 3 );
painter->drawLine( QPoint( option->rect.topLeft().x() + 3, option->rect.topLeft().y() ),
option->rect.topRight() );
}
else
{
QPalette palette;
QColor c = QApplication::palette().color( QPalette::Highlight ).darker( 150 );
QPen pen( c );
pen.setWidth( 2 );
painter->setPen( pen );
painter->drawRoundedRect( option->rect, 4, 4 );
}
painter->drawEllipse( option->rect.topLeft(), 3, 3 );
painter->drawLine( QPoint( option->rect.topLeft().x() + 3, option->rect.topLeft().y() ),
option->rect.topRight() );
}
else
{
QProxyStyle::drawPrimitive( element, option, painter, widget );
QPalette palette;
QColor c = QApplication::palette().color( QPalette::Highlight ).darker( 150 );
QPen pen( c );
pen.setWidth( 2 );
painter->setPen( pen );
painter->drawRoundedRect( option->rect, 4, 4 );
}
}
};
else
{
QProxyStyle::drawPrimitive( element, option, painter, widget );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiTreeViewWidget : public QTreeView
void PdmUiTreeViewWidget::dragMoveEvent( QDragMoveEvent* event )
{
public:
explicit PdmUiTreeViewWidget( QWidget* parent = nullptr )
: QTreeView( parent )
caf::PdmUiTreeViewQModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewQModel*>( model() );
if ( treeViewModel && treeViewModel->dragDropInterface() )
{
setStyle( new PdmUiTreeViewStyle );
};
~PdmUiTreeViewWidget() override{};
bool isTreeItemEditWidgetActive() const { return state() == QAbstractItemView::EditingState; }
protected:
void dragMoveEvent( QDragMoveEvent* event ) override
{
caf::PdmUiTreeViewQModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewQModel*>( model() );
if ( treeViewModel && treeViewModel->dragDropInterface() )
{
treeViewModel->dragDropInterface()->onProposedDropActionUpdated( event->proposedAction() );
}
QTreeView::dragMoveEvent( event );
treeViewModel->dragDropInterface()->onProposedDropActionUpdated( event->proposedAction() );
}
void dragLeaveEvent( QDragLeaveEvent* event ) override
{
caf::PdmUiTreeViewQModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewQModel*>( model() );
if ( treeViewModel && treeViewModel->dragDropInterface() )
{
treeViewModel->dragDropInterface()->onDragCanceled();
}
QTreeView::dragMoveEvent( event );
}
QTreeView::dragLeaveEvent( event );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewWidget::dragLeaveEvent( QDragLeaveEvent* event )
{
caf::PdmUiTreeViewQModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewQModel*>( model() );
if ( treeViewModel && treeViewModel->dragDropInterface() )
{
treeViewModel->dragDropInterface()->onDragCanceled();
}
};
QTreeView::dragLeaveEvent( event );
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -46,6 +46,7 @@
#include <QColor>
#include <QItemSelectionModel>
#include <QPointer>
#include <QProxyStyle>
#include <QStyledItemDelegate>
#include <QTreeView>
#include <QWidget>
@ -68,6 +69,35 @@ class PdmUiTreeViewEditor;
class PdmUiTreeViewQModel;
class PdmUiTreeViewWidget;
class PdmUiTreeViewStyle : public QProxyStyle
{
public:
void drawPrimitive( QStyle::PrimitiveElement element,
const QStyleOption* option,
QPainter* painter,
const QWidget* widget ) const override;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiTreeViewWidget : public QTreeView
{
public:
explicit PdmUiTreeViewWidget( QWidget* parent = nullptr )
: QTreeView( parent )
{
setStyle( new PdmUiTreeViewStyle );
};
~PdmUiTreeViewWidget() override{};
bool isTreeItemEditWidgetActive() const { return state() == QAbstractItemView::EditingState; }
protected:
void dragMoveEvent( QDragMoveEvent* event ) override;
void dragLeaveEvent( QDragLeaveEvent* event ) override;
};
class PdmUiTreeViewItemAttribute : public PdmUiEditorAttribute
{
public: