Expose the background color of the text labels in the style sheet

Add a new property "textBackgroundColor" to TrackContentObjectView to
expose the property to the style sheets. Use this property in the code
that renders the text labels.

Adjust the two existing style sheets.
This commit is contained in:
Michael Gregorius
2017-07-16 16:21:33 +02:00
parent a23e344886
commit f15fe18360
4 changed files with 17 additions and 2 deletions

View File

@@ -613,6 +613,7 @@ TrackContentObjectView {
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-BBPatternBackground: rgb( 80, 80, 80 );
qproperty-textColor: rgb( 255, 255, 255 );
qproperty-textBackgroundColor: rgba(0, 0, 0, 75);
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true; /* boolean property, set true to have a gradient */

View File

@@ -620,6 +620,7 @@ TrackContentObjectView {
qproperty-selectedColor: #006B65;
qproperty-BBPatternBackground: #373d48;
qproperty-textColor: #fff;
qproperty-textBackgroundColor: rgba(0, 0, 0, 75);
qproperty-textShadowColor: rgb(0,0,0,200);
qproperty-gradient: false; /* boolean property, set true to have a gradient */

View File

@@ -196,6 +196,7 @@ class TrackContentObjectView : public selectableObject, public ModelView
Q_PROPERTY( QColor mutedBackgroundColor READ mutedBackgroundColor WRITE setMutedBackgroundColor )
Q_PROPERTY( QColor selectedColor READ selectedColor WRITE setSelectedColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
Q_PROPERTY( QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor )
Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor )
Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground )
Q_PROPERTY( bool gradient READ gradient WRITE setGradient )
@@ -215,6 +216,7 @@ public:
QColor mutedBackgroundColor() const;
QColor selectedColor() const;
QColor textColor() const;
QColor textBackgroundColor() const;
QColor textShadowColor() const;
QColor BBPatternBackground() const;
bool gradient() const;
@@ -222,6 +224,7 @@ public:
void setMutedBackgroundColor( const QColor & c );
void setSelectedColor( const QColor & c );
void setTextColor( const QColor & c );
void setTextBackgroundColor( const QColor & c );
void setTextShadowColor( const QColor & c );
void setBBPatternBackground( const QColor & c );
void setGradient( const bool & b );
@@ -299,6 +302,7 @@ private:
QColor m_mutedBackgroundColor;
QColor m_selectedColor;
QColor m_textColor;
QColor m_textBackgroundColor;
QColor m_textShadowColor;
QColor m_BBPatternBackground;
bool m_gradient;

View File

@@ -354,6 +354,11 @@ QColor TrackContentObjectView::selectedColor() const
QColor TrackContentObjectView::textColor() const
{ return m_textColor; }
QColor TrackContentObjectView::textBackgroundColor() const
{
return m_textBackgroundColor;
}
QColor TrackContentObjectView::textShadowColor() const
{ return m_textShadowColor; }
@@ -376,6 +381,11 @@ void TrackContentObjectView::setSelectedColor( const QColor & c )
void TrackContentObjectView::setTextColor( const QColor & c )
{ m_textColor = QColor( c ); }
void TrackContentObjectView::setTextBackgroundColor( const QColor & c )
{
m_textBackgroundColor = c;
}
void TrackContentObjectView::setTextShadowColor( const QColor & c )
{ m_textShadowColor = QColor( c ); }
@@ -646,8 +656,7 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai
QFontMetrics fontMetrics(labelFont);
QString elidedPatternName = fontMetrics.elidedText(text, Qt::ElideMiddle, width() - 2 * textLeft);
QColor transparentBlack(0, 0, 0, 75);
painter.fillRect(QRect(0, 0, width(), fontMetrics.height() + 2 * textTop), transparentBlack);
painter.fillRect(QRect(0, 0, width(), fontMetrics.height() + 2 * textTop), textBackgroundColor());
painter.setPen( textColor() );
painter.drawText( textLeft, textTop + fontMetrics.ascent(), elidedPatternName );