mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-27 03:36:00 -05:00
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:
44
lib/utils/list-controls.cpp
Normal file
44
lib/utils/list-controls.cpp
Normal 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
|
||||
25
lib/utils/list-controls.hpp
Normal file
25
lib/utils/list-controls.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class ADVSS_EXPORT ListControls final : public QToolBar {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ListControls(QWidget *parent = nullptr, bool reorder = true);
|
||||
|
||||
signals:
|
||||
void Add();
|
||||
void Remove();
|
||||
void Up();
|
||||
void Down();
|
||||
|
||||
private:
|
||||
void AddActionHelper(const char *theme, const char *tooltip,
|
||||
const std::function<void()> &signal);
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
@@ -6,53 +6,19 @@ namespace advss {
|
||||
ListEditor::ListEditor(QWidget *parent, bool reorder)
|
||||
: QWidget(parent),
|
||||
_list(new QListWidget()),
|
||||
_add(new QPushButton()),
|
||||
_remove(new QPushButton()),
|
||||
_up(new QPushButton()),
|
||||
_down(new QPushButton()),
|
||||
_controlsLayout(new QHBoxLayout()),
|
||||
_controls(new ListControls(this, reorder)),
|
||||
_mainLayout(new QVBoxLayout())
|
||||
{
|
||||
_add->setMaximumWidth(22);
|
||||
_add->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("addIconSmall")));
|
||||
_add->setFlat(true);
|
||||
_remove->setMaximumWidth(22);
|
||||
_remove->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
_remove->setFlat(true);
|
||||
_up->setMaximumWidth(22);
|
||||
_up->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||
_up->setFlat(true);
|
||||
_down->setMaximumWidth(22);
|
||||
_down->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||
_down->setFlat(true);
|
||||
|
||||
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
||||
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
||||
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
||||
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
||||
QWidget::connect(_controls, SIGNAL(Add()), this, SLOT(Add()));
|
||||
QWidget::connect(_controls, SIGNAL(Remove()), this, SLOT(Remove()));
|
||||
QWidget::connect(_controls, SIGNAL(Up()), this, SLOT(Up()));
|
||||
QWidget::connect(_controls, SIGNAL(Down()), this, SLOT(Down()));
|
||||
QWidget::connect(_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||
this, SLOT(Clicked(QListWidgetItem *)));
|
||||
|
||||
_controlsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_controlsLayout->addWidget(_add);
|
||||
_controlsLayout->addWidget(_remove);
|
||||
if (reorder) {
|
||||
auto line = new QFrame();
|
||||
line->setFrameShape(QFrame::VLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
_controlsLayout->addWidget(line);
|
||||
_controlsLayout->addWidget(_up);
|
||||
_controlsLayout->addWidget(_down);
|
||||
}
|
||||
_controlsLayout->addStretch();
|
||||
|
||||
_mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_mainLayout->addWidget(_list);
|
||||
_mainLayout->addLayout(_controlsLayout);
|
||||
_mainLayout->addWidget(_controls);
|
||||
setLayout(_mainLayout);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "export-symbol-helper.hpp"
|
||||
#include "list-controls.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include <QLayout>
|
||||
|
||||
@@ -27,11 +27,7 @@ protected:
|
||||
void UpdateListSize();
|
||||
|
||||
QListWidget *_list;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
QPushButton *_up;
|
||||
QPushButton *_down;
|
||||
QHBoxLayout *_controlsLayout;
|
||||
ListControls *_controls;
|
||||
QVBoxLayout *_mainLayout;
|
||||
};
|
||||
|
||||
|
||||
@@ -88,12 +88,10 @@ RegexConfig RegexConfig::PartialMatchRegexConfig()
|
||||
|
||||
RegexConfigWidget::RegexConfigWidget(QWidget *parent, bool showEnable)
|
||||
: QWidget(parent),
|
||||
_openSettings(new QPushButton()),
|
||||
_openSettings(new QToolButton()),
|
||||
_enable(new QPushButton())
|
||||
{
|
||||
_openSettings->setMaximumWidth(22);
|
||||
SetButtonIcon(_openSettings, ":/settings/images/settings/general.svg");
|
||||
_openSettings->setFlat(true);
|
||||
_openSettings->setToolTip(
|
||||
obs_module_text("AdvSceneSwitcher.regex.configure"));
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <obs-data.h>
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -63,7 +64,7 @@ signals:
|
||||
private:
|
||||
void SetVisibility();
|
||||
|
||||
QPushButton *_openSettings;
|
||||
QToolButton *_openSettings;
|
||||
QPushButton *_enable;
|
||||
RegexConfig _config;
|
||||
};
|
||||
|
||||
@@ -15,20 +15,16 @@ ResourceTable::ResourceTable(QTabWidget *parent, const QString &help,
|
||||
const std::function<void()> &openSettings)
|
||||
: QWidget(parent),
|
||||
_table(new QTableWidget()),
|
||||
_add(new QPushButton()),
|
||||
_remove(new QPushButton()),
|
||||
_add(new QToolButton()),
|
||||
_remove(new QToolButton()),
|
||||
_help(new QLabel(help))
|
||||
{
|
||||
_add->setMaximumWidth(22);
|
||||
_add->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("addIconSmall")));
|
||||
_add->setFlat(true);
|
||||
_add->setToolTip(addToolTip);
|
||||
|
||||
_remove->setMaximumWidth(22);
|
||||
_remove->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
_remove->setFlat(true);
|
||||
_remove->setToolTip(removeToolTip);
|
||||
|
||||
_help->setWordWrap(true);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QToolButton>
|
||||
#include <QTableWidget>
|
||||
|
||||
class QResizeEvent;
|
||||
@@ -33,8 +33,8 @@ protected:
|
||||
|
||||
private:
|
||||
QTableWidget *_table;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
QToolButton *_add;
|
||||
QToolButton *_remove;
|
||||
QLabel *_help;
|
||||
|
||||
QObject *_highlightConnection = nullptr;
|
||||
|
||||
@@ -70,7 +70,7 @@ void SetHeightToContentHeight(QListWidget *list)
|
||||
list->setMaximumHeight(height);
|
||||
}
|
||||
|
||||
void SetButtonIcon(QPushButton *button, const char *path)
|
||||
void SetButtonIcon(QAbstractButton *button, const char *path)
|
||||
{
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(path), QSize(), QIcon::Normal,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QColor>
|
||||
#include <QComboBox>
|
||||
#include <QIcon>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <string>
|
||||
@@ -19,7 +19,7 @@ EXPORT QObject *HighlightWidget(QWidget *widget, QColor startColor,
|
||||
bool once = false);
|
||||
|
||||
EXPORT void SetHeightToContentHeight(QListWidget *list);
|
||||
EXPORT void SetButtonIcon(QPushButton *button, const char *path);
|
||||
EXPORT void SetButtonIcon(QAbstractButton *button, const char *path);
|
||||
EXPORT int
|
||||
FindIdxInRagne(QComboBox *list, int start, int stop, const std::string &value,
|
||||
Qt::MatchFlags = Qt::MatchExactly | Qt::MatchCaseSensitive);
|
||||
|
||||
Reference in New Issue
Block a user