Switch QPushButton to QToolButton

This will be more consistent with the widget styles used throughout OBS
and solves a few layout issues
This commit is contained in:
WarmUpTill
2024-06-11 19:56:35 +02:00
committed by WarmUpTill
parent d77101b6aa
commit 3bc15e585c
20 changed files with 198 additions and 547 deletions

View File

@@ -0,0 +1,44 @@
#include "list-controls.hpp"
#include "obs-module-helper.hpp"
#include "ui-helpers.hpp"
#include <QLayout>
#include <QToolButton>
namespace advss {
ListControls::ListControls(QWidget *parent, bool reorder) : QToolBar(parent)
{
setObjectName("listControls");
setStyleSheet("#listControls { background-color: transparent; }");
setIconSize({16, 16});
AddActionHelper("addIconSmall", "AdvSceneSwitcher.listControls.add",
[this]() { Add(); });
AddActionHelper("removeIconSmall",
"AdvSceneSwitcher.listControls.remove",
[this]() { Remove(); });
if (reorder) {
addSeparator();
AddActionHelper("upArrowIconSmall",
"AdvSceneSwitcher.listControls.up",
[this]() { Up(); });
AddActionHelper("downArrowIconSmall",
"AdvSceneSwitcher.listControls.down",
[this]() { Down(); });
}
}
void ListControls::AddActionHelper(const char *theme, const char *tooltip,
const std::function<void()> &signal)
{
auto button = new QToolButton(this);
button->setToolTip(obs_module_text(tooltip));
button->setProperty("themeID", QVariant(QString(theme)));
auto action = addWidget(button);
button->connect(button, &QToolButton::clicked, this, signal);
}
} // namespace advss