Skip to content

Commit

Permalink
Revert "set bg color from parent base color"
Browse files Browse the repository at this point in the history
This reverts commit ec81d43.
  • Loading branch information
napaalm committed Mar 23, 2023
1 parent 3105f3d commit e802889
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
29 changes: 6 additions & 23 deletions src/widget/wvumeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@
#define DEFAULT_HOLDTIME 400
#define DEFAULT_HOLDSIZE 5

namespace {
QColor findBaseColor(QWidget* pWidget) {
int i = 0;

while (pWidget) {
if (pWidget->palette().isBrushSet(QPalette::Normal, QPalette::Base)) {
return pWidget->palette().color(QPalette::Base);
}
i++;
pWidget = qobject_cast<QWidget*>(pWidget->parent());
}
return QColor(0, 0, 0);
}
} // namespace

WVuMeter::WVuMeter(QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WBaseWidget(this),
Expand Down Expand Up @@ -174,14 +159,12 @@ void WVuMeter::updateState(mixxx::Duration elapsed) {
m_dPeakParameter = math_clamp(m_dPeakParameter, 0.0, 1.0);
}

void WVuMeter::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
void WVuMeter::initializeGL() {
glClearColor(0.0, 0.0, 0.0, 1.0);
}

void WVuMeter::showEvent(QShowEvent* e) {
void WVuMeter::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
// find the base color recursively in parent widget
m_qBgColor = findBaseColor(this);
}

void WVuMeter::render(VSyncThread* /* UNUSED vSyncThread */) {
Expand All @@ -202,9 +185,9 @@ void WVuMeter::render(VSyncThread* /* UNUSED vSyncThread */) {
}

QPainter p(this);
// fill the background, in case the image contains transparency
p.fillRect(rect(), m_qBgColor);
QColor oc = m_qBgColor;

// draw a black background, in case the image contains transparency
p.fillRect(rect(), QColor(0, 0, 0));

if (!m_pPixmapBack.isNull()) {
// Draw background.
Expand Down
4 changes: 1 addition & 3 deletions src/widget/wvumeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class WVuMeter : public QGLWidget, public WBaseWidget {
void updateState(mixxx::Duration elapsed);

private:
void initializeGL() override;
void paintEvent(QPaintEvent * /*unused*/) override;
void showEvent(QShowEvent* /*unused*/) override;
void setPeak(double parameter);

// To make sure we render at least once even when we have no signal
Expand Down Expand Up @@ -75,6 +75,4 @@ class WVuMeter : public QGLWidget, public WBaseWidget {
double m_dPeakHoldCountdownMs;

PerformanceTimer m_timer;

QColor m_qBgColor;
};

0 comments on commit e802889

Please sign in to comment.