From 2a65e009882fff9a56b2ef6f9599caa0eee6825b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 12 Jun 2024 17:45:01 +0200 Subject: [PATCH] WaveRubber: Remove trailing whitespaces and fix formatting --- src/analyzer/waverubber.cpp | 19 +++++++++---------- src/analyzer/waverubber.h | 4 +--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/analyzer/waverubber.cpp b/src/analyzer/waverubber.cpp index eac42e6c3..478f4f2f2 100644 --- a/src/analyzer/waverubber.cpp +++ b/src/analyzer/waverubber.cpp @@ -24,11 +24,12 @@ const char *WaveRubber::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "WaveRubber"); WaveRubber::WaveRubber(QWidget *parent) - : AnalyzerBase(parent, 9) {} + : AnalyzerBase(parent, 9) {} void WaveRubber::resizeEvent(QResizeEvent *e) { Q_UNUSED(e) + canvas_ = QPixmap(size()); canvas_.fill(palette().color(QPalette::AlternateBase)); @@ -49,12 +50,12 @@ void WaveRubber::analyze(QPainter &p, const Scope &s, bool new_frame) { // Set the pen color to the QT palette highlight color canvas_painter.setPen(palette().color(QPalette::Highlight)); - // Get pointer to amplitude data + // Get pointer to amplitude data const float *amplitude_data = s.data(); - + int mid_y = height() / 4; int num_samples = s.size(); - + float x_scale = static_cast(width()) / num_samples; float prev_y = mid_y; @@ -68,13 +69,12 @@ void WaveRubber::analyze(QPainter &p, const Scope &s, bool new_frame) { // Blend blue and green with highlight color from QT palette based on amplitude QColor blended_color = QColor(rgb_value, highlight_color.green(), highlight_color.blue()); canvas_painter.setPen(blended_color); - - int x = static_cast(i * x_scale ); - int y = static_cast(mid_y - (s[i] * mid_y)); - canvas_painter.drawLine(x, prev_y + mid_y, x + x_scale, y + mid_y); // Draw + int x = static_cast(i * x_scale); + int y = static_cast(mid_y - (s[i] * mid_y)); + + canvas_painter.drawLine(x, prev_y + mid_y, x + x_scale, y + mid_y); // Draw prev_y = y; - } canvas_painter.end(); @@ -90,4 +90,3 @@ void WaveRubber::transform(Scope &s) { void WaveRubber::demo(QPainter &p) { analyze(p, Scope(fht_->size(), 0), new_frame_); } - diff --git a/src/analyzer/waverubber.h b/src/analyzer/waverubber.h index ae60f8d89..12246e0e5 100644 --- a/src/analyzer/waverubber.h +++ b/src/analyzer/waverubber.h @@ -23,8 +23,8 @@ #include "analyzerbase.h" class WaveRubber : public AnalyzerBase { - Q_OBJECT + public: Q_INVOKABLE explicit WaveRubber(QWidget *parent); @@ -38,6 +38,4 @@ class WaveRubber : public AnalyzerBase { private: QPixmap canvas_; - }; -