Skip to content

Commit

Permalink
UI: Allow volume peak to be customized via .qss
Browse files Browse the repository at this point in the history
With the addition of the peak volume indicator, themes may wish to change
these colors but there was no way to do so. This change updates the
VolumeControl widget to allow a stylesheet to adjust all possible colors
for the volume bar. In addtion, the Rachni theme is updated to demonstrate
this new capability.
  • Loading branch information
Fenrirthviti committed Aug 12, 2017
1 parent d3c163b commit 5576823
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 5 additions & 5 deletions UI/data/themes/Rachni.qss
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,11 @@ QProgressBar::chunk {

VolumeMeter {
qproperty-bkColor: rgb(35, 38, 41); /* Dark Gray */
qproperty-magColor: rgb(186, 45, 101); /* Dark Pink (Secondary Dark) */
qproperty-peakColor: rgb(240, 98, 146); /* Pink (Secondary) */
qproperty-peakHoldColor: rgb(255, 148, 194); /* Light Pink (Secondary Light) */
qproperty-magColor: rgb(153, 204, 0);
qproperty-peakColor: rgb(96, 128, 0);
qproperty-peakHoldColor: rgb(210, 255, 77);
qproperty-clipColor1: rgb(230, 40, 50);
qproperty-clipColor2: rgb(140, 0, 40);
}

/*******************/
Expand Down Expand Up @@ -719,8 +721,6 @@ QPushButton:disabled {
color: rgb(162, 161, 162); /* Lighter Gray */
}



/******************************/
/* --- Dialog Box Buttons --- */
/******************************/
Expand Down
20 changes: 20 additions & 0 deletions UI/volume-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,26 @@ void VolumeMeter::setPeakHoldColor(QColor c)
peakHoldColor = c;
}

QColor VolumeMeter::getClipColor1() const
{
return clipColor1;
}

void VolumeMeter::setClipColor1(QColor c)
{
clipColor1 = c;
}

QColor VolumeMeter::getClipColor2() const
{
return clipColor2;
}

void VolumeMeter::setClipColor2(QColor c)
{
clipColor2 = c;
}


VolumeMeter::VolumeMeter(QWidget *parent)
: QWidget(parent)
Expand Down
6 changes: 6 additions & 0 deletions UI/volume-control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class VolumeMeter : public QWidget
Q_PROPERTY(QColor magColor READ getMagColor WRITE setMagColor DESIGNABLE true)
Q_PROPERTY(QColor peakColor READ getPeakColor WRITE setPeakColor DESIGNABLE true)
Q_PROPERTY(QColor peakHoldColor READ getPeakHoldColor WRITE setPeakHoldColor DESIGNABLE true)
Q_PROPERTY(QColor clipColor1 READ getClipColor1 WRITE setClipColor1 DESIGNABLE true)
Q_PROPERTY(QColor clipColor2 READ getClipColor2 WRITE setClipColor2 DESIGNABLE true)

private:
static QWeakPointer<VolumeMeterTimer> updateTimer;
Expand Down Expand Up @@ -46,6 +48,10 @@ class VolumeMeter : public QWidget
void setPeakColor(QColor c);
QColor getPeakHoldColor() const;
void setPeakHoldColor(QColor c);
QColor getClipColor1() const;
void setClipColor1(QColor c);
QColor getClipColor2() const;
void setClipColor2(QColor c);

protected:
void paintEvent(QPaintEvent *event);
Expand Down

0 comments on commit 5576823

Please sign in to comment.