Commit 75d44872 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] changed text color of deeper nested prop groups

parent ccc03d36
......@@ -266,6 +266,16 @@ void WMTemplate::properties()
m_group1a = m_group1->addPropertyGroup( "Group 1a", "A group nested into \"Group 1\"." );
m_group2 = m_properties->addPropertyGroup( "Second Group", "Another nice group for grouping stuff." );
// You can nest property groups arbitrarily deep. ( But as with a good text, a chapter number 1.23.23.5.73.1.5 is useless. Avoid nesting too
// deep and avoid groups with only one or two properties. )
WPropGroup group = m_properties->addPropertyGroup( "Group Nesting - Level 0", "Demo for intensive group nesting." );
for( int d = 1; d <= 20; ++d )
{
std::string depth = string_utils::toString( d );
group = group->addPropertyGroup( "Group Nesting - Level " + depth, "A nested group." );
// NOTE: the last group will be deleted as we do not keep its shared_ptr.
}
// To understand how the groups can be used, you should consider that m_properties itself is a WPropGroup! This means, you can use your newly
// created groups exactly in the same way as you would use m_properties.
m_group1Bool = m_group1->addProperty( "Funny stuff", "A grouped property", true );
......
......@@ -30,7 +30,9 @@
#define WPREFERRED_LABEL_LENGTH 15
#define WMIN_WIDGET_HEIGHT 28
// Property specific minimum sizes
#define WMIN_WIDGET_HEIGHT 26
#define WMIN_PROPGROUP_HEAD_HEIGHT 26
#define WMIN_SLIDER_WIDTH 60
#endif // WGUICONSTS_H
......@@ -226,6 +226,7 @@ QWidget* WQtPropertyGroupWidget::createPropertyGroupBox( WQtPropertyGroupWidget*
boxLayout->addWidget( boxContent, 1, 0 );
// set the button up
boxTitle->setMinimumHeight( WMIN_PROPGROUP_HEAD_HEIGHT );
boxTitle->setSizePolicy( sizePolicy );
boxTitle->setAutoRaise( true );
boxTitle->setAutoFillBackground( true );
......@@ -243,40 +244,52 @@ QWidget* WQtPropertyGroupWidget::createPropertyGroupBox( WQtPropertyGroupWidget*
// some styling
QPalette palette; // the palette is used to get default colors of the style/system
QColor defaultCol = palette.window().color().darker( 120 );
QColor defaultCol = QColor( "#b9b9b9" ); // palette.window().color().darker( 120 );
QColor brightTextCol = QColor( "#eeeeee" );
QColor darkTextCol = QColor( "#444444" );
QColor defaultTextCol = darkTextCol; // palette.windowText().color();
switch( widget->m_nestingDepth % 10 ) // NOTE: the first level 0 does not need a color as it does not provide a boxtitle, so we begin with 1
{
// All these colors are taken from the solarized pallette http://ethanschoonover.com/solarized
case 1:
defaultCol = palette.window().color().darker( 150 );
defaultCol = QColor( "#949494" ); // palette.window().color().darker( 150 );
defaultTextCol = darkTextCol;
break;
case 2:
defaultCol = QColor( "#268bd2" );
defaultTextCol = brightTextCol;
break;
case 3:
defaultCol = QColor( "#2aa198" );
defaultTextCol = brightTextCol;
break;
case 4:
defaultCol = QColor( "#859900" );
defaultTextCol = brightTextCol;
break;
case 5:
defaultCol = QColor( "#b58900" );
defaultTextCol = brightTextCol;
break;
case 6:
defaultCol = QColor( "#cb4b16" );
defaultTextCol = brightTextCol;
break;
case 7:
defaultCol = QColor( "#dc322f" );
defaultTextCol = brightTextCol;
break;
case 8:
defaultCol = QColor( "#d33682" );
defaultTextCol = brightTextCol;
break;
case 9:
defaultCol = QColor( "#6c71c4" );
defaultTextCol = brightTextCol;
break;
}
boxTitle->setStyleSheet( "background-color: " + defaultCol.name() + "; font-weight:bold;" );
boxTitle->setStyleSheet( "background-color: " + defaultCol.name() + "; font-weight:bold; color: " + defaultTextCol.name() + ";" );
box->setStyleSheet( "QFrame#PropertyGroupBox{background-color: " + defaultCol.name() + ";}" );
content->setStyleSheet( "#PropertyGroupContent{ background-color: "+ palette.window().color().name() +";}" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment