From c5dc75da5d1a425a7d74658129b999816db86918 Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 23 Jun 2020 14:00:34 +0530 Subject: [PATCH] Gradient can be toggled and color can be changed. --- data/themes/classic/style.css | 5 +++++ data/themes/default/style.css | 5 +++++ include/SongEditor.h | 15 ++++++++++++++ src/gui/editors/SongEditor.cpp | 38 +++++++++++++++++++++++++++------- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index cf609066a81..a19547989bf 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -118,6 +118,11 @@ QMenu::indicator:selected { background-color: #747474; } +positionLine { + qproperty-tailGradient: false; + qproperty-lineColor: rgba(255, 255, 255, 153); +} + PianoRoll { background-color: rgb(0, 0, 0); qproperty-backgroundShade: rgba( 255, 255, 255, 10 ); diff --git a/data/themes/default/style.css b/data/themes/default/style.css index feb85a612b0..4c698a9e239 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -150,6 +150,11 @@ QMenu::indicator:selected { background-color: #101213; } +positionLine { + qproperty-tailGradient: true; + qproperty-lineColor: rgb(255, 255, 255); +} + PianoRoll { background-color: #141616; qproperty-backgroundShade: rgba(255, 255, 255, 10); diff --git a/include/SongEditor.h b/include/SongEditor.h index 9621bcc23d8..a668d2f3651 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -28,6 +28,7 @@ #define SONG_EDITOR_H #include +#include #include "ActionGroup.h" #include "Editor.h" @@ -45,13 +46,27 @@ class Song; class TextFloat; class TimeLineWidget; +Q_DECLARE_METATYPE(QLinearGradient) + class positionLine : public QWidget { + Q_OBJECT + Q_PROPERTY( bool tailGradient READ tailGradient WRITE setTailGradient ) + Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor ) public: positionLine( QWidget * parent ); + + // qproperty access functions + bool tailGradient() const; + void setTailGradient( const bool & g ); + QColor lineColor() const; + void setLineColor( const QColor & c ); private: void paintEvent( QPaintEvent * pe ) override; + + bool m_tailGradient; + QColor m_lineColor; } ; diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index ab04a98a87b..dc97f8c1777 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -53,24 +53,36 @@ #include "Track.h" positionLine::positionLine( QWidget * parent ) : - QWidget( parent ) + QWidget( parent ), + m_tailGradient ( false ), + m_lineColor (0, 0, 0, 0) { setFixedWidth( 8 ); setAttribute( Qt::WA_NoSystemBackground, true ); } - - - void positionLine::paintEvent( QPaintEvent * pe ) { QPainter p( this ); // Create the gradient trail behind the line QLinearGradient gradient(rect().bottomLeft(), rect().bottomRight()); - gradient.setColorAt(0, QColor (255, 255, 255, 0) ); - gradient.setColorAt(0.875, QColor (255, 255, 255, 60) ); - gradient.setColorAt(1, QColor (255, 255, 255, 153) ); + + gradient.setColorAt(0, + QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 0) ); + gradient.setColorAt(1, + QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 153) ); + + if (m_tailGradient) + { + gradient.setColorAt(0.875, + QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 60) ); + } + else + { + gradient.setColorAt(0.875, + QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 0) ); + } // Fill line p.fillRect( rect(), gradient ); @@ -1139,3 +1151,15 @@ void SongEditorWindow::keyReleaseEvent( QKeyEvent *ke ) } } } + +bool positionLine::tailGradient() const +{ return m_tailGradient; } + +void positionLine::setTailGradient( const bool & g ) +{ m_tailGradient = g; } + +QColor positionLine::lineColor() const +{ return m_lineColor; } + +void positionLine::setLineColor( const QColor & c ) +{ m_lineColor = c; }