From dfae538154cfe7f2f813694650ace226c6ef3e60 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 4 Apr 2024 16:04:18 +0200 Subject: [PATCH 1/2] Controller settings: allow :hwbtn:`LABEL` syntax for styling Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Co-authored-by: Jan Holthuis --- src/controllers/legacycontrollersettings.cpp | 30 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/controllers/legacycontrollersettings.cpp b/src/controllers/legacycontrollersettings.cpp index 918e5ea9c99e..4b4a26a58ddd 100644 --- a/src/controllers/legacycontrollersettings.cpp +++ b/src/controllers/legacycontrollersettings.cpp @@ -11,6 +11,32 @@ #include "moc_legacycontrollersettings.cpp" +namespace { + +// Regex that allows to use :hwbtn:`LABELSTRING` in xml controller settings xml +const QRegularExpression kHwbtnRe(QStringLiteral(":hwbtn:`([^`]*)`")); + +const QString kHwbtnStyleWrapper = QStringLiteral( + " \\1 "); + +QString replaceMarkupStyleStr(QString str) { + return str.replace(kHwbtnRe, kHwbtnStyleWrapper); +} + +} // namespace + LegacyControllerSettingBuilder* LegacyControllerSettingBuilder::instance() { static LegacyControllerSettingBuilder* s_self = nullptr; @@ -32,11 +58,11 @@ LegacyControllerSettingBuilder::LegacyControllerSettingBuilder() { AbstractLegacyControllerSetting::AbstractLegacyControllerSetting(const QDomElement& element) { m_variableName = element.attribute("variable").trimmed(); - m_label = element.attribute("label", m_variableName).trimmed(); + m_label = replaceMarkupStyleStr(element.attribute("label", m_variableName).trimmed()); QDomElement description = element.firstChildElement("description"); if (!description.isNull()) { - m_description = description.text().trimmed(); + m_description = replaceMarkupStyleStr(description.text().trimmed()); } } From 81a41880f3d21e23cf24558b6c5f8638803a2462 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 4 Apr 2024 16:04:35 +0200 Subject: [PATCH 2/2] use :hwbtn: for Traktor S4 Mk3 settings --- .../Traktor Kontrol S4 MK3.hid.xml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/res/controllers/Traktor Kontrol S4 MK3.hid.xml b/res/controllers/Traktor Kontrol S4 MK3.hid.xml index 0c6f835c9723..615dd69b7818 100644 --- a/res/controllers/Traktor Kontrol S4 MK3.hid.xml +++ b/res/controllers/Traktor Kontrol S4 MK3.hid.xml @@ -102,9 +102,9 @@ variable="gridButtonBlinkOverBeat" type="boolean" default="false" - label="Make the <tt style='background-color: #111111; color: #d9d9d9;padding: 2px;'>GRID</tt> button blink over the beat"> + label="Make the :hwbtn:`GRID` button blink over the beat"> - This will make the <tt style="background-color: #111111; color: #d9d9d9;padding: 2px;">GRID</tt> button blink when the track is going over a detected beat. This can help adjusting the beat grid or BPM. + This will make the :hwbtn:`GRID` button blink when the track is going over a detected beat. This can help adjusting the beat grid or BPM.