Add HelpIcon

A QLabel consisting of a question mark icon and tooltip
This commit is contained in:
WarmUpTill
2024-06-06 19:41:19 +02:00
committed by WarmUpTill
parent 0e4b000fb1
commit 7e1d20031c
13 changed files with 57 additions and 63 deletions

View File

@@ -168,6 +168,8 @@ target_sources(
lib/utils/file-selection.hpp
lib/utils/filter-combo-box.cpp
lib/utils/filter-combo-box.hpp
lib/utils/help-icon.hpp
lib/utils/help-icon.cpp
lib/utils/item-selection-helpers.cpp
lib/utils/item-selection-helpers.hpp
lib/utils/layout-helpers.cpp

View File

@@ -6,7 +6,6 @@
#include "macro.hpp"
#include "non-modal-dialog.hpp"
#include "source-helpers.hpp"
#include "ui-helpers.hpp"
#include "utility.hpp"
namespace advss {
@@ -644,7 +643,8 @@ MacroActionVariableEdit::MacroActionVariableEdit(
_scenes(new SceneSelectionWidget(this, true, false, true, true,
true)),
_tempVars(new TempVariableSelection(this)),
_tempVarsHelp(new QLabel()),
_tempVarsHelp(new HelpIcon(obs_module_text(
"AdvSceneSwitcher.action.variable.type.setToTempvar.help"))),
_sceneItemIndex(new VariableSpinBox()),
_direction(new QComboBox()),
_stringLength(new VariableSpinBox()),
@@ -672,15 +672,6 @@ MacroActionVariableEdit::MacroActionVariableEdit(
populateTypeSelection(_actions);
populateDirectionSelection(_direction);
QString path = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
_tempVarsHelp->setPixmap(pixmap);
_tempVarsHelp->setToolTip(obs_module_text(
"AdvSceneSwitcher.action.variable.type.setToTempvar.help"));
QWidget::connect(_variables, SIGNAL(SelectionChanged(const QString &)),
this, SLOT(VariableChanged(const QString &)));
QWidget::connect(_variables2, SIGNAL(SelectionChanged(const QString &)),

View File

@@ -1,5 +1,6 @@
#pragma once
#include "macro-action-edit.hpp"
#include "help-icon.hpp"
#include "macro-segment-selection.hpp"
#include "regex-config.hpp"
#include "resizing-text-edit.hpp"
@@ -186,7 +187,7 @@ private:
VariableLineEdit *_envVariable;
SceneSelectionWidget *_scenes;
TempVariableSelection *_tempVars;
QLabel *_tempVarsHelp;
HelpIcon *_tempVarsHelp;
VariableSpinBox *_sceneItemIndex;
QComboBox *_direction;
VariableSpinBox *_stringLength;

19
lib/utils/help-icon.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "help-icon.hpp"
#include "ui-helpers.hpp"
namespace advss {
HelpIcon::HelpIcon(const QString &tooltip, QWidget *parent) : QLabel(parent)
{
auto path = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
setPixmap(pixmap);
if (!tooltip.isEmpty()) {
setToolTip(tooltip);
}
}
} // namespace advss

15
lib/utils/help-icon.hpp Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include "export-symbol-helper.hpp"
#include <QLabel>
namespace advss {
class ADVSS_EXPORT HelpIcon : public QLabel {
Q_OBJECT
public:
HelpIcon(const QString &tooltip = "", QWidget *parent = nullptr);
};
} // namespace advss

View File

@@ -1,6 +1,5 @@
#include "macro-action-run.hpp"
#include "layout-helpers.hpp"
#include "ui-helpers.hpp"
#include <QProcess>
#include <QDesktopServices>
@@ -130,16 +129,10 @@ MacroActionRunEdit::MacroActionRunEdit(
_waitLayout(new QHBoxLayout()),
_wait(new QCheckBox()),
_timeout(new DurationSelection(this, true, 0.1)),
_waitHelp(new QLabel())
_waitHelp(new HelpIcon(obs_module_text(
"AdvSceneSwitcher.action.run.wait.help.tooltip")))
{
QString helpIconPath = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon helpIcon(helpIconPath);
_waitHelp->setPixmap(helpIcon.pixmap(QSize(16, 16)));
_waitHelp->hide();
_waitHelp->setToolTip(obs_module_text(
"AdvSceneSwitcher.action.run.wait.help.tooltip"));
QWidget::connect(_procConfig,
SIGNAL(ConfigChanged(const ProcessConfig &)), this,

View File

@@ -1,5 +1,6 @@
#pragma once
#include "macro-action-edit.hpp"
#include "help-icon.hpp"
#include "process-config.hpp"
#include "duration-control.hpp"
@@ -60,7 +61,7 @@ private:
QHBoxLayout *_waitLayout;
QCheckBox *_wait;
DurationSelection *_timeout;
QLabel *_waitHelp;
HelpIcon *_waitHelp;
std::shared_ptr<MacroActionRun> _entryData;
bool _loading = true;

View File

@@ -1,8 +1,8 @@
#include "macro-action-window.hpp"
#include "help-icon.hpp"
#include "layout-helpers.hpp"
#include "platform-funcs.hpp"
#include "selection-helpers.hpp"
#include "ui-helpers.hpp"
namespace advss {
@@ -177,14 +177,7 @@ MacroActionWindowEdit::MacroActionWindowEdit(
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation"));
_infoLayout->addWidget(focusLimitation);
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));
auto focusLimitationDetails = new QLabel();
focusLimitationDetails->setPixmap(pixmap);
focusLimitationDetails->setToolTip(obs_module_text(
auto focusLimitationDetails = new HelpIcon(obs_module_text(
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation.details"));
_infoLayout->addWidget(focusLimitationDetails);
_infoLayout->addStretch();

View File

@@ -1,6 +1,5 @@
#include "macro-condition-clipboard.hpp"
#include "layout-helpers.hpp"
#include "ui-helpers.hpp"
#include <QApplication>
#include <QClipboard>
@@ -197,19 +196,11 @@ MacroConditionClipboardEdit::MacroConditionClipboardEdit(
_conditions(new QComboBox(this)),
_text(new VariableTextEdit(this)),
_regex(new RegexConfigWidget(parent)),
_urlInfo(new QLabel())
_urlInfo(new HelpIcon(obs_module_text(
"AdvSceneSwitcher.condition.clipboard.urlTooltip")))
{
populateCompareModeselection(_conditions);
QString path = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
_urlInfo->setPixmap(pixmap);
_urlInfo->hide();
_urlInfo->setToolTip(obs_module_text(
"AdvSceneSwitcher.condition.clipboard.urlTooltip"));
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
SLOT(ConditionChanged(int)));

View File

@@ -1,6 +1,7 @@
#pragma once
#include "macro-condition-edit.hpp"
#include "filter-combo-box.hpp"
#include "help-icon.hpp"
#include "message-buffer.hpp"
#include "message-dispatcher.hpp"
#include "regex-config.hpp"
@@ -83,7 +84,7 @@ private:
QComboBox *_conditions;
VariableTextEdit *_text;
RegexConfigWidget *_regex;
QLabel *_urlInfo;
HelpIcon *_urlInfo;
std::shared_ptr<MacroConditionClipboard> _entryData;
bool _loading = true;

View File

@@ -1,7 +1,7 @@
#include "macro-condition-folder.hpp"
#include "help-icon.hpp"
#include "macro-helpers.hpp"
#include "layout-helpers.hpp"
#include "ui-helpers.hpp"
#include <QDir>
#include <QFileInfo>
@@ -282,16 +282,6 @@ MacroConditionFolderEdit::MacroConditionFolderEdit(
_regex(new RegexConfigWidget(this, false)),
_filter(new VariableLineEdit(this))
{
QString path = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
auto tooltipLabel = new QLabel(this);
tooltipLabel->setPixmap(pixmap);
tooltipLabel->setToolTip(
obs_module_text("AdvSceneSwitcher.condition.folder.tooltip"));
populateConditions(_conditions);
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
@@ -306,6 +296,9 @@ MacroConditionFolderEdit::MacroConditionFolderEdit(
QWidget::connect(_filter, SIGNAL(editingFinished()), this,
SLOT(FilterChanged()));
auto tooltipLabel = new HelpIcon(
obs_module_text("AdvSceneSwitcher.condition.folder.tooltip"));
const std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{conditions}}", _conditions}, {"{{folder}}", _folder},
{"{{tooltip}}", tooltipLabel}, {"{{regex}}", _regex},

View File

@@ -1,7 +1,6 @@
#include "source-setting.hpp"
#include "obs-module-helper.hpp"
#include "math-helpers.hpp"
#include "ui-helpers.hpp"
#include "utility.hpp"
#include <nlohmann/json.hpp>
@@ -233,14 +232,8 @@ SourceSettingSelection::SourceSettingSelection(QWidget *parent)
: QWidget(parent),
_settings(new FilterComboBox(
this, obs_module_text("AdvSceneSwitcher.setting.select"))),
_tooltip(new QLabel())
_tooltip(new HelpIcon())
{
QString path = GetThemeTypeName() == "Light"
? ":/res/images/help.svg"
: ":/res/images/help_light.svg";
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
_tooltip->setPixmap(pixmap);
_tooltip->hide();
_settings->setSizeAdjustPolicy(QComboBox::AdjustToContents);

View File

@@ -1,5 +1,6 @@
#pragma once
#include "filter-combo-box.hpp"
#include "help-icon.hpp"
#include <obs.hpp>
#include <optional>
@@ -52,7 +53,7 @@ private:
void Populate(const OBSWeakSource &);
FilterComboBox *_settings;
QLabel *_tooltip;
HelpIcon *_tooltip;
};
} // namespace advss