From e1164c4fa3a872a368bb7aef24063b607af559ff Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:02:04 +0200 Subject: [PATCH] Refactor help icon usage --- lib/macro/macro-action-variable.cpp | 14 +++++--------- lib/utils/auto-update-tooltip-label.cpp | 12 ++++++------ lib/utils/auto-update-tooltip-label.hpp | 11 +++++------ lib/utils/temp-variable.cpp | 11 ++--------- lib/utils/temp-variable.hpp | 2 +- plugins/base/macro-condition-streaming.cpp | 9 +-------- 6 files changed, 20 insertions(+), 39 deletions(-) diff --git a/lib/macro/macro-action-variable.cpp b/lib/macro/macro-action-variable.cpp index ca1cfca6..8b76fb1a 100644 --- a/lib/macro/macro-action-variable.cpp +++ b/lib/macro/macro-action-variable.cpp @@ -1,4 +1,5 @@ #include "macro-action-variable.hpp" +#include "help-icon.hpp" #include "json-helpers.hpp" #include "layout-helpers.hpp" #include "macro-condition-edit.hpp" @@ -828,7 +829,10 @@ MacroActionVariableEdit::MacroActionVariableEdit( this)), _randomLayout(new QVBoxLayout()), _jsonQuery(new VariableLineEdit(this)), - _jsonQueryHelp(new QLabel(this)), + _jsonQueryHelp(new HelpIcon( + obs_module_text( + "AdvSceneSwitcher.action.variable.type.queryJson.info"), + this)), _jsonIndex(new VariableSpinBox(this)), _entryLayout(new QHBoxLayout()) { @@ -859,14 +863,6 @@ MacroActionVariableEdit::MacroActionVariableEdit( _randomNumberStart->setMaximum(9999999999); _randomNumberEnd->setMinimum(-9999999999); _randomNumberEnd->setMaximum(9999999999); - const QString path = GetThemeTypeName() == "Light" - ? ":/res/images/help.svg" - : ":/res/images/help_light.svg"; - const QIcon icon(path); - const QPixmap pixmap = icon.pixmap(QSize(16, 16)); - _jsonQueryHelp->setPixmap(pixmap); - _jsonQueryHelp->setToolTip(obs_module_text( - "AdvSceneSwitcher.action.variable.type.queryJson.info")); _jsonIndex->setMaximum(999); QWidget::connect(_variables, SIGNAL(SelectionChanged(const QString &)), diff --git a/lib/utils/auto-update-tooltip-label.cpp b/lib/utils/auto-update-tooltip-label.cpp index fcd8ea6b..3a02e2ab 100644 --- a/lib/utils/auto-update-tooltip-label.cpp +++ b/lib/utils/auto-update-tooltip-label.cpp @@ -2,31 +2,31 @@ namespace advss { -AutoUpdateTooltipLabel::AutoUpdateTooltipLabel( +AutoUpdateHelpIcon::AutoUpdateHelpIcon( QWidget *parent, const std::function &updateTooltipCallback, int updateIntervalMs) - : QLabel(parent), + : HelpIcon("", parent), _callback(updateTooltipCallback), _timer(new QTimer(this)), _updateIntervalMs(updateIntervalMs) { connect(_timer, &QTimer::timeout, this, - &AutoUpdateTooltipLabel::UpdateTooltip); + &AutoUpdateHelpIcon::UpdateTooltip); } -void AutoUpdateTooltipLabel::enterEvent(QEnterEvent *event) +void AutoUpdateHelpIcon::enterEvent(QEnterEvent *event) { _timer->start(_updateIntervalMs); QLabel::enterEvent(event); } -void AutoUpdateTooltipLabel::leaveEvent(QEvent *event) +void AutoUpdateHelpIcon::leaveEvent(QEvent *event) { _timer->stop(); QLabel::leaveEvent(event); } -void AutoUpdateTooltipLabel::UpdateTooltip() +void AutoUpdateHelpIcon::UpdateTooltip() { setToolTip(_callback()); } diff --git a/lib/utils/auto-update-tooltip-label.hpp b/lib/utils/auto-update-tooltip-label.hpp index 8ac4c122..70d3f083 100644 --- a/lib/utils/auto-update-tooltip-label.hpp +++ b/lib/utils/auto-update-tooltip-label.hpp @@ -1,20 +1,19 @@ #pragma once #include "export-symbol-helper.hpp" +#include "help-icon.hpp" #include -#include #include namespace advss { -class ADVSS_EXPORT AutoUpdateTooltipLabel : public QLabel { +class ADVSS_EXPORT AutoUpdateHelpIcon : public HelpIcon { Q_OBJECT public: - AutoUpdateTooltipLabel( - QWidget *parent, - const std::function &updateTooltipCallback, - int updateIntervalMs = 300); + AutoUpdateHelpIcon(QWidget *parent, + const std::function &updateTooltipCallback, + int updateIntervalMs = 300); protected: void enterEvent(QEnterEvent *event) override; diff --git a/lib/utils/temp-variable.cpp b/lib/utils/temp-variable.cpp index e07c5d25..2a7f26a4 100644 --- a/lib/utils/temp-variable.cpp +++ b/lib/utils/temp-variable.cpp @@ -404,9 +404,8 @@ TempVariableSelection::TempVariableSelection(QWidget *parent) : QWidget(parent), _selection(new FilterComboBox( this, obs_module_text("AdvSceneSwitcher.tempVar.select"))), - _info(new AutoUpdateTooltipLabel(this, [this]() { - return SetupInfoLabel(); - })) + _info(new AutoUpdateHelpIcon(this, + [this]() { return SetupInfoLabel(); })) { MacroEdit *edit = findMacroEditParent(parent); @@ -416,12 +415,6 @@ TempVariableSelection::TempVariableSelection(QWidget *parent) _macroEdits.push_back(edit); } - QString path = GetThemeTypeName() == "Light" - ? ":/res/images/help.svg" - : ":/res/images/help_light.svg"; - QIcon icon(path); - QPixmap pixmap = icon.pixmap(QSize(16, 16)); - _info->setPixmap(pixmap); _info->hide(); _selection->setSizeAdjustPolicy(QComboBox::AdjustToContents); diff --git a/lib/utils/temp-variable.hpp b/lib/utils/temp-variable.hpp index 8b89fb6e..5b7a19b1 100644 --- a/lib/utils/temp-variable.hpp +++ b/lib/utils/temp-variable.hpp @@ -105,7 +105,7 @@ private: MacroSegment *GetSegment() const; FilterComboBox *_selection; - AutoUpdateTooltipLabel *_info; + AutoUpdateHelpIcon *_info; std::vector _macroEdits; }; diff --git a/plugins/base/macro-condition-streaming.cpp b/plugins/base/macro-condition-streaming.cpp index abaf3747..8517cb74 100644 --- a/plugins/base/macro-condition-streaming.cpp +++ b/plugins/base/macro-condition-streaming.cpp @@ -242,7 +242,7 @@ MacroConditionStreamEdit::MacroConditionStreamEdit( _keyFrameInterval(new VariableSpinBox()), _streamKey(new VariableLineEdit(this)), _serviceName(new VariableLineEdit(this)), - _currentService(new AutoUpdateTooltipLabel( + _currentService(new AutoUpdateHelpIcon( this, []() { QString formatString = obs_module_text( @@ -255,13 +255,6 @@ MacroConditionStreamEdit::MacroConditionStreamEdit( _keyFrameInterval->setMinimum(0); _keyFrameInterval->setMaximum(25); - QString path = GetThemeTypeName() == "Light" - ? ":/res/images/help.svg" - : ":/res/images/help_light.svg"; - QIcon icon(path); - QPixmap pixmap = icon.pixmap(QSize(16, 16)); - _currentService->setPixmap(pixmap); - _streamKey->setEchoMode(QLineEdit::PasswordEchoOnEdit); populateConditionSelection(_conditions);