Use QBrush instead of QColor on some theme properties

Apparently, we can use QBrush -typed properties in the CSS. This just never occured to me before!
So, this has several benefits. A QColor property only allows a singular RGB value, but a QBrush allows the same plus also qgradients, RGBA-colours and maybe even bitmap patterns. So I'm changing some properties to QBrush, where it makes sense to allow this additional functionality - no need to enable it for simple things like text colours or such.

- Song editor background: instead of the earlier hack with 7 qproperties just to set a limited background gradient, we can use only 2 properties and allow much more flexibility with Qt's own qgradient syntax
- Automation editor: background, graph colour, and the sidebar colour - @musikBear recently complained not seeing the grid through the graph, so transparency can help there, and qlineargradients in the graph can produce very cool visual effects. Grid is pointless to change, it should stay single-colour for now.
- Piano roll: here, I only made the background use QBrush - we don't really have much else here that can utilize QBrush, the notes have their own gradient system... maybe the 2nd colour of the note gradient could be customizable though.

There are probably more places where this change makes sense...
This commit is contained in:
Vesa
2014-06-08 18:06:09 +03:00
parent dba1e75a53
commit 2fa7892542
6 changed files with 54 additions and 134 deletions

View File

@@ -51,9 +51,9 @@ class AutomationEditor : public QWidget, public JournallingObject
{
Q_OBJECT
Q_PROPERTY( QColor gridColor READ gridColor WRITE setGridColor )
Q_PROPERTY( QColor graphColor READ graphColor WRITE setGraphColor )
Q_PROPERTY( QColor vertexColor READ vertexColor WRITE setVertexColor )
Q_PROPERTY( QColor scaleColor READ scaleColor WRITE setScaleColor )
Q_PROPERTY( QBrush scaleColor READ scaleColor WRITE setScaleColor )
Q_PROPERTY( QBrush graphColor READ graphColor WRITE setGraphColor )
public:
void setCurrentPattern( AutomationPattern * _new_pattern );
@@ -81,13 +81,13 @@ public:
// qproperty access methods
QColor gridColor() const;
QColor graphColor() const;
QBrush graphColor() const;
QColor vertexColor() const;
QColor scaleColor() const;
QBrush scaleColor() const;
void setGridColor( const QColor & c );
void setGraphColor( const QColor & c );
void setGraphColor( const QBrush & c );
void setVertexColor( const QColor & c );
void setScaleColor( const QColor & c );
void setScaleColor( const QBrush & c );
public slots:
void update();
@@ -266,9 +266,9 @@ private:
bool inBBEditor();
QColor m_gridColor;
QColor m_graphColor;
QBrush m_graphColor;
QColor m_vertexColor;
QColor m_scaleColor;
QBrush m_scaleColor;
friend class engine;

View File

@@ -251,15 +251,8 @@ class trackContentWidget : public QWidget, public JournallingObject
Q_OBJECT
// qproperties for track background gradients
Q_PROPERTY( QColor darkerColor1 READ darkerColor1 WRITE setDarkerColor1 )
Q_PROPERTY( QColor darkerColor2 READ darkerColor2 WRITE setDarkerColor2 )
Q_PROPERTY( QColor darkerColor3 READ darkerColor3 WRITE setDarkerColor3 )
Q_PROPERTY( QColor lighterColor1 READ lighterColor1 WRITE setLighterColor1 )
Q_PROPERTY( QColor lighterColor2 READ lighterColor2 WRITE setLighterColor2 )
Q_PROPERTY( QColor lighterColor3 READ lighterColor3 WRITE setLighterColor3 )
Q_PROPERTY( float gradMidPoint READ gradMidPoint WRITE setGradMidPoint )
Q_PROPERTY( QBrush darkerColor READ darkerColor WRITE setDarkerColor )
Q_PROPERTY( QBrush lighterColor READ lighterColor WRITE setLighterColor )
public:
trackContentWidget( trackView * _parent );
@@ -282,25 +275,11 @@ public:
// qproperty access methods
QColor darkerColor1() const;
QColor darkerColor2() const;
QColor darkerColor3() const;
QBrush darkerColor() const;
QBrush lighterColor() const;
QColor lighterColor1() const;
QColor lighterColor2() const;
QColor lighterColor3() const;
float gradMidPoint() const;
void setDarkerColor1( const QColor & _c );
void setDarkerColor2( const QColor & _c );
void setDarkerColor3( const QColor & _c );
void setLighterColor1( const QColor & _c );
void setLighterColor2( const QColor & _c );
void setLighterColor3( const QColor & _c );
void setGradMidPoint( float _g );
void setDarkerColor( const QBrush & _c );
void setLighterColor( const QBrush & _c );
public slots:
void update();
@@ -343,13 +322,8 @@ private:
QPixmap m_background;
// qproperty fields
QColor m_darkerColor1;
QColor m_darkerColor2;
QColor m_darkerColor3;
QColor m_lighterColor1;
QColor m_lighterColor2;
QColor m_lighterColor3;
float m_gradMidPoint;
QBrush m_darkerColor;
QBrush m_lighterColor;
} ;