Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace qstylepainter with qpainter in vumeterlegacy, use by default #11722

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/util/cmdlineargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CmdlineArgs::CmdlineArgs()
m_controllerAbortOnWarning(false),
m_developer(false),
m_safeMode(false),
m_useVuMeterGL(true),
m_useVuMeterGL(false),
m_debugAssertBreak(false),
m_settingsPathSet(false),
m_scaleFactor(1.0),
Expand Down Expand Up @@ -172,15 +172,11 @@ bool CmdlineArgs::parse(const QStringList& arguments, CmdlineArgs::ParseMode mod
parser.addOption(timelinePath);
parser.addOption(timelinePathDeprecated);

const QCommandLineOption disableVuMeterGL(QStringLiteral("disable-vumetergl"),
const QCommandLineOption enableVuMeterGL(QStringLiteral("enable-vumetergl"),
forUserFeedback ? QCoreApplication::translate("CmdlineArgs",
"Do not use OpenGL vu meter")
"Use OpenGL vu meter")
: QString());
QCommandLineOption disableVuMeterGLDeprecated(
QStringLiteral("disableVuMeterGL"), disableVuMeterGL.description());
disableVuMeterGLDeprecated.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(disableVuMeterGL);
parser.addOption(disableVuMeterGLDeprecated);
parser.addOption(enableVuMeterGL);

const QCommandLineOption controllerDebug(QStringLiteral("controller-debug"),
forUserFeedback ? QCoreApplication::translate("CmdlineArgs",
Expand Down Expand Up @@ -342,7 +338,7 @@ bool CmdlineArgs::parse(const QStringList& arguments, CmdlineArgs::ParseMode mod
m_timelinePath = parser.value(timelinePathDeprecated);
}

m_useVuMeterGL = !(parser.isSet(disableVuMeterGL) || parser.isSet(disableVuMeterGLDeprecated));
m_useVuMeterGL = parser.isSet(enableVuMeterGL);
m_controllerDebug = parser.isSet(controllerDebug) || parser.isSet(controllerDebugDeprecated);
m_controllerAbortOnWarning = parser.isSet(controllerAbortOnWarning);
m_developer = parser.isSet(developer);
Expand Down
22 changes: 15 additions & 7 deletions src/widget/wvumeterlegacy.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "widget/wvumeterlegacy.h"

#include <QStyleOption>
#include <QStylePainter>

#include "moc_wvumeterlegacy.cpp"
#include "util/math.h"
#include "util/timer.h"
#include "util/widgethelper.h"
#include "widget/wpixmapstore.h"

#define DEFAULT_FALLTIME 20
Expand All @@ -27,6 +25,7 @@ WVuMeterLegacy::WVuMeterLegacy(QWidget* pParent)
m_iPeakFallTime(0),
m_dPeakHoldCountdownMs(0) {
m_timer.start();
setAutoFillBackground(true);
}

void WVuMeterLegacy::setup(const QDomNode& node, const SkinContext& context) {
Expand Down Expand Up @@ -152,13 +151,22 @@ void WVuMeterLegacy::maybeUpdate() {
}
}

void WVuMeterLegacy::showEvent(QShowEvent* e) {
Q_UNUSED(e);
WWidget::showEvent(e);
// Find the base color recursively in parent widget.
const auto bgColor = mixxx::widgethelper::findBaseColor(this);
QPalette pal = QPalette();

pal.setColor(QPalette::Window, bgColor);

setPalette(pal);
}

void WVuMeterLegacy::paintEvent(QPaintEvent* /*unused*/) {
ScopedTimer t("WVuMeterLegacy::paintEvent");

QStyleOption option;
option.initFrom(this);
QStylePainter p(this);
p.drawPrimitive(QStyle::PE_Widget, option);
QPainter p(this);

if (!m_pPixmapBack.isNull() && !m_pPixmapBack->isNull()) {
// Draw background. DrawMode takes care of whether to stretch or not.
Expand Down
1 change: 1 addition & 0 deletions src/widget/wvumeterlegacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WVuMeterLegacy : public WWidget {

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

// Current parameter and peak parameter.
Expand Down