From c6e7cd2e80c96535fc63ce500d2dd5f884e31561 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Mon, 14 Oct 2024 15:36:16 -0500 Subject: [PATCH] Fix QSS() implementation & try to avoid crash on a crappy laptop running OpenSUSE --- app/src/Misc/ThemeManager.h | 10 ++++++++-- app/src/UI/DeclarativeWidget.cpp | 2 ++ app/src/UI/Widgets/FFTPlot.cpp | 7 +++++-- app/src/UI/Widgets/Plot.cpp | 7 +++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/Misc/ThemeManager.h b/app/src/Misc/ThemeManager.h index 0f58971d..3d34e43b 100644 --- a/app/src/Misc/ThemeManager.h +++ b/app/src/Misc/ThemeManager.h @@ -61,8 +61,14 @@ template inline QString QSS(const QString &style, const Colors &...colors) { - QStringList colorNames = {colors.name()...}; - return QString(style).arg(colorNames.join(',')); + QStringList colorNames; + (colorNames << ... << colors.name()); + QString result = style; + for (int i = 0; i < colorNames.size(); ++i) + { + result = result.arg(colorNames[i]); + } + return result; } /** diff --git a/app/src/UI/DeclarativeWidget.cpp b/app/src/UI/DeclarativeWidget.cpp index 5387a631..65bf98ee 100644 --- a/app/src/UI/DeclarativeWidget.cpp +++ b/app/src/UI/DeclarativeWidget.cpp @@ -216,6 +216,7 @@ void UI::DeclarativeWidget::setWidget(QWidget *widget) delete m_widget; m_widget = widget; + m_widget->setAttribute(Qt::WA_UpdatesDisabled, true); Q_EMIT widgetChanged(); } } @@ -228,6 +229,7 @@ void UI::DeclarativeWidget::renderWidget() { if (widget() && isVisible()) { + widget()->update(); m_pixmap = widget()->grab(); update(); } diff --git a/app/src/UI/Widgets/FFTPlot.cpp b/app/src/UI/Widgets/FFTPlot.cpp index 4f649506..b39a2a10 100644 --- a/app/src/UI/Widgets/FFTPlot.cpp +++ b/app/src/UI/Widgets/FFTPlot.cpp @@ -133,10 +133,13 @@ void Widgets::FFTPlot::updateData() points[i] = QPointF(frequency, dB); } - // Plot obtained data + // Update curve with new data m_curve.setSamples(points); m_plot.setAxisScale(QwtPlot::xBottom, 0, m_samplingRate / 2); - m_plot.replot(); + + // Replot graph + if (isEnabled()) + m_plot.replot(); } } diff --git a/app/src/UI/Widgets/Plot.cpp b/app/src/UI/Widgets/Plot.cpp index fda163b1..9cdb6ed0 100644 --- a/app/src/UI/Widgets/Plot.cpp +++ b/app/src/UI/Widgets/Plot.cpp @@ -167,9 +167,12 @@ void Widgets::Plot::updateData() } } - // Replot graph + // Add new data to curve m_curve.setSamples(plotData.at(m_index)); - m_plot.replot(); + + // Replot graph + if (isEnabled()) + m_plot.replot(); } }