mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-24 23:33:47 +08:00
shared/idian: Rename component classes
This commit is contained in:
committed by
Ryan Foster
parent
edb2c9ca48
commit
872ea5fb91
@@ -380,7 +380,7 @@ StatusBarWidget > QFrame {
|
||||
padding: 0px 12px 8px;
|
||||
}
|
||||
|
||||
OBSToggleSwitch {
|
||||
idian--ToggleSwitch {
|
||||
qproperty-handle: rgb(255, 255, 255);
|
||||
qproperty-backgroundActive: #284cb8;
|
||||
qproperty-backgroundInactive: #3c404b;
|
||||
|
||||
@@ -2242,7 +2242,7 @@ idian--Row > QLabel.description {
|
||||
color: var(--text_muted);
|
||||
}
|
||||
|
||||
OBSToggleSwitch {
|
||||
idian--ToggleSwitch {
|
||||
qproperty-background: var(--grey6);
|
||||
qproperty-background_hover: var(--grey7);
|
||||
qproperty-background_checked: var(--primary);
|
||||
@@ -2259,25 +2259,25 @@ OBSToggleSwitch {
|
||||
border: var(--highlight_width) solid transparent;
|
||||
}
|
||||
|
||||
OBSToggleSwitch:hover {
|
||||
idian--ToggleSwitch:hover {
|
||||
border-color: var(--grey4);
|
||||
}
|
||||
|
||||
OBSToggleSwitch:checked:hover {
|
||||
idian--ToggleSwitch:checked:hover {
|
||||
border-color: var(--white1);
|
||||
}
|
||||
|
||||
OBSToggleSwitch.keyFocus {
|
||||
idian--ToggleSwitch.keyFocus {
|
||||
border-color: var(--highlight_color);
|
||||
}
|
||||
|
||||
idian--Row OBSToggleSwitch:hover,
|
||||
idian--Row.hover > OBSToggleSwitch.row-buddy {
|
||||
idian--Row idian--ToggleSwitch:hover,
|
||||
idian--Row.hover > idian--ToggleSwitch.row-buddy {
|
||||
border-color: var(--grey1);
|
||||
}
|
||||
|
||||
idian--Row OBSToggleSwitch:checked:hover,
|
||||
idian--Row.hover OBSToggleSwitch.row-buddy:checked {
|
||||
idian--Row idian--ToggleSwitch:checked:hover,
|
||||
idian--Row.hover idian--ToggleSwitch.row-buddy:checked {
|
||||
border-color: var(--white1);
|
||||
}
|
||||
|
||||
@@ -2340,36 +2340,36 @@ idian--PropertiesListSpacer {
|
||||
background-color: var(--bg_window);
|
||||
}
|
||||
|
||||
idian--Row OBSCheckBox {
|
||||
idian--Row idian--CheckBox {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
idian--Row OBSCheckBox::indicator,
|
||||
idian--Row OBSCheckBox::indicator:unchecked:hover {
|
||||
idian--Row idian--CheckBox::indicator,
|
||||
idian--Row idian--CheckBox::indicator:unchecked:hover {
|
||||
border: var(--highlight_width) solid transparent;
|
||||
border-radius: var(--border_radius);
|
||||
}
|
||||
|
||||
idian--Row.hover > OBSCheckBox.row-buddy::indicator,
|
||||
idian--Row > OBSCheckBox::indicator:unchecked:hover,
|
||||
idian--Row > OBSCheckBox::indicator:hover {
|
||||
idian--Row.hover > idian--CheckBox.row-buddy::indicator,
|
||||
idian--Row > idian--CheckBox::indicator:unchecked:hover,
|
||||
idian--Row > idian--CheckBox::indicator:hover {
|
||||
border-color: var(--grey1);
|
||||
}
|
||||
|
||||
idian--Row.hover > OBSCheckBox.row-buddy::indicator:unchecked,
|
||||
OBSCheckBox.keyFocus::indicator:unchecked {
|
||||
idian--Row.hover > idian--CheckBox.row-buddy::indicator:unchecked,
|
||||
idian--CheckBox.keyFocus::indicator:unchecked {
|
||||
image: url(theme:Yami/checkbox_unchecked_focus.svg);
|
||||
}
|
||||
|
||||
idian--Row OBSCheckBox.keyFocus::indicator,
|
||||
idian--Row.hover > OBSCheckBox::indicator {
|
||||
idian--Row idian--CheckBox.keyFocus::indicator,
|
||||
idian--Row.hover > idian--CheckBox::indicator {
|
||||
image: url(theme:Yami/checkbox_checked_focus.svg);
|
||||
}
|
||||
|
||||
idian--Row OBSCheckBox.keyFocus::indicator,
|
||||
idian--Row OBSCheckBox.keyFocus::indicator:unchecked,
|
||||
idian--Row OBSCheckBox.keyFocus::indicator:hover,
|
||||
idian--Row OBSCheckBox.keyFocus::indicator:unchecked:hover {
|
||||
idian--Row idian--CheckBox.keyFocus::indicator,
|
||||
idian--Row idian--CheckBox.keyFocus::indicator:unchecked,
|
||||
idian--Row idian--CheckBox.keyFocus::indicator:hover,
|
||||
idian--Row idian--CheckBox.keyFocus::indicator:unchecked:hover {
|
||||
border-color: var(--highlight_color);
|
||||
}
|
||||
|
||||
@@ -2401,7 +2401,7 @@ idian--CollapsibleRow idian--Row.last {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
idian--CollapsibleRow idian--PropertiesList OBSToggleSwitch {
|
||||
idian--CollapsibleRow idian--PropertiesList idian--ToggleSwitch {
|
||||
qproperty-background: var(--grey7);
|
||||
qproperty-background_hover: var(--grey6);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
Group *test;
|
||||
Row *tmp;
|
||||
|
||||
OBSComboBox *cbox = new OBSComboBox;
|
||||
ComboBox *cbox = new ComboBox;
|
||||
cbox->addItem("Test 1");
|
||||
cbox->addItem("Test 2");
|
||||
|
||||
@@ -44,7 +44,7 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
tmp->setSuffix(cbox);
|
||||
test->properties()->addRow(tmp);
|
||||
|
||||
cbox = new OBSComboBox;
|
||||
cbox = new ComboBox;
|
||||
cbox->addItem("Test 3");
|
||||
cbox->addItem("Test 4");
|
||||
tmp = new Row();
|
||||
@@ -55,20 +55,20 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Toggle Switch");
|
||||
tmp->setSuffix(new OBSToggleSwitch());
|
||||
tmp->setSuffix(new ToggleSwitch());
|
||||
test->properties()->addRow(tmp);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(test);
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Delayed toggle switch");
|
||||
tmp->setDescription("The state can be set separately");
|
||||
auto tswitch = new OBSToggleSwitch;
|
||||
auto tswitch = new ToggleSwitch;
|
||||
tswitch->setDelayed(true);
|
||||
connect(tswitch, &OBSToggleSwitch::pendingChecked, this, [=]() {
|
||||
connect(tswitch, &ToggleSwitch::pendingChecked, this, [=]() {
|
||||
// Do async enable stuff, then set toggle status when complete
|
||||
QTimer::singleShot(1000, [=]() { tswitch->setStatus(true); });
|
||||
});
|
||||
connect(tswitch, &OBSToggleSwitch::pendingUnchecked, this, [=]() {
|
||||
connect(tswitch, &ToggleSwitch::pendingUnchecked, this, [=]() {
|
||||
// Do async disable stuff, then set toggle status when complete
|
||||
QTimer::singleShot(1000, [=]() { tswitch->setStatus(false); });
|
||||
});
|
||||
@@ -81,12 +81,12 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Box 1");
|
||||
tmp->setPrefix(new OBSCheckBox);
|
||||
tmp->setPrefix(new CheckBox);
|
||||
test->properties()->addRow(tmp);
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Box 2");
|
||||
tmp->setPrefix(new OBSCheckBox);
|
||||
tmp->setPrefix(new CheckBox);
|
||||
test->properties()->addRow(tmp);
|
||||
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(test);
|
||||
@@ -98,7 +98,7 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Placeholder");
|
||||
tmp->setSuffix(new OBSToggleSwitch);
|
||||
tmp->setSuffix(new ToggleSwitch);
|
||||
test->properties()->addRow(tmp);
|
||||
|
||||
CollapsibleRow *tmp2 = new CollapsibleRow("A Collapsible row!", this);
|
||||
@@ -107,17 +107,17 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Spin box demo");
|
||||
tmp->setSuffix(new OBSDoubleSpinBox());
|
||||
tmp->setSuffix(new DoubleSpinBox());
|
||||
tmp2->addRow(tmp);
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Just another placeholder");
|
||||
tmp->setSuffix(new OBSToggleSwitch(true));
|
||||
tmp->setSuffix(new ToggleSwitch(true));
|
||||
tmp2->addRow(tmp);
|
||||
|
||||
tmp = new Row();
|
||||
tmp->setTitle("Placeholder 2");
|
||||
tmp->setSuffix(new OBSToggleSwitch);
|
||||
tmp->setSuffix(new ToggleSwitch);
|
||||
test->properties()->addRow(tmp);
|
||||
|
||||
ui->scrollAreaWidgetContents->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
@@ -8,20 +8,21 @@ add_library(OBS::idian ALIAS idian)
|
||||
target_sources(
|
||||
idian
|
||||
PRIVATE
|
||||
components/CheckBox.cpp
|
||||
components/ComboBox.cpp
|
||||
components/DoubleSpinBox.cpp
|
||||
components/SpinBox.cpp
|
||||
components/ToggleSwitch.cpp
|
||||
include/Idian/CheckBox.hpp
|
||||
include/Idian/ComboBox.hpp
|
||||
include/Idian/DoubleSpinBox.hpp
|
||||
include/Idian/Group.hpp
|
||||
include/Idian/Idian.hpp
|
||||
include/Idian/PropertiesList.hpp
|
||||
include/Idian/Row.hpp
|
||||
OBSCheckBox.cpp
|
||||
OBSCheckBox.hpp
|
||||
OBSComboBox.cpp
|
||||
OBSComboBox.hpp
|
||||
OBSDoubleSpinBox.cpp
|
||||
OBSDoubleSpinBox.hpp
|
||||
include/Idian/SpinBox.hpp
|
||||
include/Idian/ToggleSwitch.hpp
|
||||
OBSIdianWidget.hpp
|
||||
OBSSpinBox.cpp
|
||||
OBSSpinBox.hpp
|
||||
OBSToggleSwitch.cpp
|
||||
OBSToggleSwitch.hpp
|
||||
widgets/Group.cpp
|
||||
widgets/PropertiesList.cpp
|
||||
widgets/Row.cpp
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "OBSCheckBox.hpp"
|
||||
#include <Idian/CheckBox.hpp>
|
||||
|
||||
OBSCheckBox::OBSCheckBox(QWidget *parent) : QCheckBox(parent), OBSIdianUtils(this) {}
|
||||
#include <Idian/moc_CheckBox.cpp>
|
||||
|
||||
using idian::CheckBox;
|
||||
|
||||
CheckBox::CheckBox(QWidget *parent) : QCheckBox(parent), OBSIdianUtils(this) {}
|
||||
@@ -15,13 +15,19 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include <Idian/ComboBox.hpp>
|
||||
|
||||
#include <Idian/Row.hpp>
|
||||
#include "OBSComboBox.hpp"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
OBSComboBox::OBSComboBox(QWidget *parent) : QComboBox(parent), OBSIdianUtils(this) {}
|
||||
#include <Idian/moc_ComboBox.cpp>
|
||||
|
||||
void OBSComboBox::showPopup()
|
||||
using idian::ComboBox;
|
||||
|
||||
ComboBox::ComboBox(QWidget *parent) : QComboBox(parent), OBSIdianUtils(this) {}
|
||||
|
||||
void ComboBox::showPopup()
|
||||
{
|
||||
if (allowOpeningPopup) {
|
||||
allowOpeningPopup = false;
|
||||
@@ -29,7 +35,7 @@ void OBSComboBox::showPopup()
|
||||
}
|
||||
}
|
||||
|
||||
void OBSComboBox::hidePopup()
|
||||
void ComboBox::hidePopup()
|
||||
{
|
||||
// It would be nice to find a better way to do this.
|
||||
//
|
||||
@@ -46,16 +52,16 @@ void OBSComboBox::hidePopup()
|
||||
QComboBox::hidePopup();
|
||||
}
|
||||
|
||||
void OBSComboBox::mousePressEvent(QMouseEvent *event)
|
||||
void ComboBox::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QComboBox::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void OBSComboBox::togglePopup()
|
||||
void ComboBox::togglePopup()
|
||||
{
|
||||
if (view()->isVisible()) {
|
||||
OBSComboBox::hidePopup();
|
||||
ComboBox::hidePopup();
|
||||
} else {
|
||||
OBSComboBox::showPopup();
|
||||
ComboBox::showPopup();
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,13 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "OBSDoubleSpinBox.hpp"
|
||||
#include <Idian/DoubleSpinBox.hpp>
|
||||
|
||||
OBSDoubleSpinBox::OBSDoubleSpinBox(QWidget *parent) : QFrame(parent)
|
||||
#include <Idian/moc_DoubleSpinBox.cpp>
|
||||
|
||||
using idian::DoubleSpinBox;
|
||||
|
||||
DoubleSpinBox::DoubleSpinBox(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
layout = new QHBoxLayout();
|
||||
setLayout(layout);
|
||||
@@ -15,9 +15,13 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "OBSSpinBox.hpp"
|
||||
#include <Idian/SpinBox.hpp>
|
||||
|
||||
OBSSpinBox::OBSSpinBox(QWidget *parent) : QFrame(parent)
|
||||
#include <Idian/moc_SpinBox.cpp>
|
||||
|
||||
using idian::SpinBox;
|
||||
|
||||
SpinBox::SpinBox(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
layout = new QHBoxLayout();
|
||||
setLayout(layout);
|
||||
@@ -15,9 +15,14 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "OBSToggleSwitch.hpp"
|
||||
#include <Idian/ToggleSwitch.hpp>
|
||||
|
||||
static QColor blendColors(const QColor &color1, const QColor &color2, float ratio)
|
||||
#include <Idian/moc_ToggleSwitch.cpp>
|
||||
|
||||
using idian::ToggleSwitch;
|
||||
|
||||
namespace {
|
||||
QColor blendColors(const QColor &color1, const QColor &color2, float ratio)
|
||||
{
|
||||
int r = color1.red() * (1 - ratio) + color2.red() * ratio;
|
||||
int g = color1.green() * (1 - ratio) + color2.green() * ratio;
|
||||
@@ -25,8 +30,9 @@ static QColor blendColors(const QColor &color1, const QColor &color2, float rati
|
||||
|
||||
return QColor(r, g, b, 255);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
OBSToggleSwitch::OBSToggleSwitch(QWidget *parent)
|
||||
ToggleSwitch::ToggleSwitch(QWidget *parent)
|
||||
: QAbstractButton(parent),
|
||||
animHandle(new QPropertyAnimation(this, "xpos", this)),
|
||||
animBgColor(new QPropertyAnimation(this, "blend", this)),
|
||||
@@ -42,13 +48,13 @@ OBSToggleSwitch::OBSToggleSwitch(QWidget *parent)
|
||||
|
||||
installEventFilter(this);
|
||||
|
||||
connect(this, &OBSToggleSwitch::clicked, this, &OBSToggleSwitch::onClicked);
|
||||
connect(this, &ToggleSwitch::clicked, this, &ToggleSwitch::onClicked);
|
||||
|
||||
connect(animHandle, &QVariantAnimation::valueChanged, this, &OBSToggleSwitch::updateBackgroundColor);
|
||||
connect(animBgColor, &QVariantAnimation::valueChanged, this, &OBSToggleSwitch::updateBackgroundColor);
|
||||
connect(animHandle, &QVariantAnimation::valueChanged, this, &ToggleSwitch::updateBackgroundColor);
|
||||
connect(animBgColor, &QVariantAnimation::valueChanged, this, &ToggleSwitch::updateBackgroundColor);
|
||||
}
|
||||
|
||||
OBSToggleSwitch::OBSToggleSwitch(bool defaultState, QWidget *parent) : OBSToggleSwitch(parent)
|
||||
ToggleSwitch::ToggleSwitch(bool defaultState, QWidget *parent) : ToggleSwitch(parent)
|
||||
{
|
||||
setChecked(defaultState);
|
||||
if (defaultState) {
|
||||
@@ -56,7 +62,7 @@ OBSToggleSwitch::OBSToggleSwitch(bool defaultState, QWidget *parent) : OBSToggle
|
||||
}
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::animateHandlePosition()
|
||||
void ToggleSwitch::animateHandlePosition()
|
||||
{
|
||||
animHandle->setStartValue(xPos);
|
||||
|
||||
@@ -71,7 +77,7 @@ void OBSToggleSwitch::animateHandlePosition()
|
||||
animHandle->start();
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::updateBackgroundColor()
|
||||
void ToggleSwitch::updateBackgroundColor()
|
||||
{
|
||||
QColor offColor = underMouse() ? backgroundInactiveHover : backgroundInactive;
|
||||
QColor onColor = underMouse() ? backgroundActiveHover : backgroundActive;
|
||||
@@ -89,7 +95,7 @@ void OBSToggleSwitch::updateBackgroundColor()
|
||||
setStyleSheet("background: " + bg.name());
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::changeEvent(QEvent *event)
|
||||
void ToggleSwitch::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::EnabledChange) {
|
||||
OBSIdianUtils::toggleClass("disabled", !isEnabled());
|
||||
@@ -97,7 +103,7 @@ void OBSToggleSwitch::changeEvent(QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::paintEvent(QPaintEvent *)
|
||||
void ToggleSwitch::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOptionButton opt;
|
||||
opt.initFrom(this);
|
||||
@@ -121,7 +127,7 @@ void OBSToggleSwitch::paintEvent(QPaintEvent *)
|
||||
p.drawEllipse(QRectF(xPos, margin, handleSize, handleSize));
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::showEvent(QShowEvent *e)
|
||||
void ToggleSwitch::showEvent(QShowEvent *e)
|
||||
{
|
||||
margin = (rect().height() - handleSize) / 2;
|
||||
|
||||
@@ -136,7 +142,7 @@ void OBSToggleSwitch::showEvent(QShowEvent *e)
|
||||
QAbstractButton::showEvent(e);
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::click()
|
||||
void ToggleSwitch::click()
|
||||
{
|
||||
if (!isDelayed())
|
||||
QAbstractButton::click();
|
||||
@@ -145,7 +151,7 @@ void OBSToggleSwitch::click()
|
||||
setPending(!isChecked());
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::onClicked(bool checked)
|
||||
void ToggleSwitch::onClicked(bool checked)
|
||||
{
|
||||
if (delayed)
|
||||
return;
|
||||
@@ -153,7 +159,7 @@ void OBSToggleSwitch::onClicked(bool checked)
|
||||
setPending(checked);
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::setStatus(bool status)
|
||||
void ToggleSwitch::setStatus(bool status)
|
||||
{
|
||||
if (status == isChecked() && status == pendingStatus)
|
||||
return;
|
||||
@@ -174,7 +180,7 @@ void OBSToggleSwitch::setStatus(bool status)
|
||||
animBgColor->start();
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::setPending(bool pending)
|
||||
void ToggleSwitch::setPending(bool pending)
|
||||
{
|
||||
pendingStatus = pending;
|
||||
animateHandlePosition();
|
||||
@@ -189,26 +195,26 @@ void OBSToggleSwitch::setPending(bool pending)
|
||||
}
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::setDelayed(bool state)
|
||||
void ToggleSwitch::setDelayed(bool state)
|
||||
{
|
||||
delayed = state;
|
||||
pendingStatus = isChecked();
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::enterEvent(QEnterEvent *e)
|
||||
void ToggleSwitch::enterEvent(QEnterEvent *e)
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
updateBackgroundColor();
|
||||
QAbstractButton::enterEvent(e);
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::leaveEvent(QEvent *e)
|
||||
void ToggleSwitch::leaveEvent(QEvent *e)
|
||||
{
|
||||
updateBackgroundColor();
|
||||
QAbstractButton::leaveEvent(e);
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::keyReleaseEvent(QKeyEvent *e)
|
||||
void ToggleSwitch::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (!isDelayed()) {
|
||||
QAbstractButton::keyReleaseEvent(e);
|
||||
@@ -222,7 +228,7 @@ void OBSToggleSwitch::keyReleaseEvent(QKeyEvent *e)
|
||||
click();
|
||||
}
|
||||
|
||||
void OBSToggleSwitch::mouseReleaseEvent(QMouseEvent *e)
|
||||
void ToggleSwitch::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!isDelayed()) {
|
||||
QAbstractButton::mouseReleaseEvent(e);
|
||||
@@ -236,7 +242,7 @@ void OBSToggleSwitch::mouseReleaseEvent(QMouseEvent *e)
|
||||
click();
|
||||
}
|
||||
|
||||
QSize OBSToggleSwitch::sizeHint() const
|
||||
QSize ToggleSwitch::sizeHint() const
|
||||
{
|
||||
return QSize(2 * handleSize, handleSize);
|
||||
}
|
||||
@@ -17,15 +17,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../OBSIdianWidget.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "OBSIdianWidget.hpp"
|
||||
namespace idian {
|
||||
|
||||
class OBSCheckBox : public QCheckBox, public OBSIdianUtils {
|
||||
class CheckBox : public QCheckBox, public OBSIdianUtils {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OBSCheckBox(QWidget *parent = nullptr);
|
||||
CheckBox(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e) override
|
||||
@@ -40,3 +42,5 @@ protected:
|
||||
QAbstractButton::focusOutEvent(e);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace idian
|
||||
@@ -17,16 +17,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../OBSIdianWidget.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QAbstractItemView>
|
||||
|
||||
#include "OBSIdianWidget.hpp"
|
||||
namespace idian {
|
||||
|
||||
class OBSComboBox : public QComboBox, public OBSIdianUtils {
|
||||
class ComboBox : public QComboBox, public OBSIdianUtils {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OBSComboBox(QWidget *parent = nullptr);
|
||||
ComboBox(QWidget *parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
void togglePopup();
|
||||
@@ -52,3 +54,5 @@ protected:
|
||||
QComboBox::focusOutEvent(e);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace idian
|
||||
+7
-3
@@ -19,14 +19,16 @@
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLayout>
|
||||
#include <QSpinBox>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
class OBSDoubleSpinBox : public QFrame {
|
||||
namespace idian {
|
||||
|
||||
class DoubleSpinBox : public QFrame {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OBSDoubleSpinBox(QWidget *parent = nullptr);
|
||||
DoubleSpinBox(QWidget *parent = nullptr);
|
||||
|
||||
QDoubleSpinBox *spinBox() const { return sbox; }
|
||||
|
||||
@@ -36,3 +38,5 @@ private:
|
||||
QPushButton *incr;
|
||||
QDoubleSpinBox *sbox;
|
||||
};
|
||||
|
||||
} // namespace idian
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <Idian/PropertiesList.hpp>
|
||||
#include <Idian/Row.hpp>
|
||||
#include "../../OBSToggleSwitch.hpp"
|
||||
#include <Idian/ToggleSwitch.hpp>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
|
||||
PropertiesList *propertyList = nullptr;
|
||||
|
||||
OBSToggleSwitch *toggleSwitch = nullptr;
|
||||
ToggleSwitch *toggleSwitch = nullptr;
|
||||
bool checkable = false;
|
||||
};
|
||||
} // namespace idian
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
//
|
||||
// (OBS Idian, get it?)
|
||||
|
||||
#include "../../OBSCheckBox.hpp"
|
||||
#include "../../OBSComboBox.hpp"
|
||||
#include "../../OBSDoubleSpinBox.hpp"
|
||||
#include "../../OBSSpinBox.hpp"
|
||||
#include "../../OBSToggleSwitch.hpp"
|
||||
#include <Idian/CheckBox.hpp>
|
||||
#include <Idian/ComboBox.hpp>
|
||||
#include <Idian/DoubleSpinBox.hpp>
|
||||
#include <Idian/Group.hpp>
|
||||
#include <Idian/PropertiesList.hpp>
|
||||
#include <Idian/Row.hpp>
|
||||
#include <Idian/SpinBox.hpp>
|
||||
#include <Idian/ToggleSwitch.hpp>
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Idian/ComboBox.hpp>
|
||||
#include <Idian/DoubleSpinBox.hpp>
|
||||
#include <Idian/PropertiesList.hpp>
|
||||
#include <Idian/SpinBox.hpp>
|
||||
#include <Idian/ToggleSwitch.hpp>
|
||||
#include "../../OBSIdianWidget.hpp"
|
||||
#include "../../OBSToggleSwitch.hpp"
|
||||
#include "../../OBSComboBox.hpp"
|
||||
#include "../../OBSSpinBox.hpp"
|
||||
#include "../../OBSDoubleSpinBox.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QFrame>
|
||||
@@ -195,7 +195,7 @@ private:
|
||||
ExpandButton *expandButton;
|
||||
PropertiesList *propertyList;
|
||||
|
||||
OBSToggleSwitch *toggleSwitch = nullptr;
|
||||
ToggleSwitch *toggleSwitch = nullptr;
|
||||
bool checkable = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,14 +19,16 @@
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLayout>
|
||||
#include <QSpinBox>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
class OBSSpinBox : public QFrame {
|
||||
namespace idian {
|
||||
|
||||
class SpinBox : public QFrame {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OBSSpinBox(QWidget *parent = nullptr);
|
||||
SpinBox(QWidget *parent = nullptr);
|
||||
|
||||
QSpinBox *spinBox() const { return sbox; }
|
||||
|
||||
@@ -36,3 +38,5 @@ private:
|
||||
QPushButton *incr;
|
||||
QSpinBox *sbox;
|
||||
};
|
||||
|
||||
} // namespace idian
|
||||
+15
-11
@@ -17,19 +17,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QEvent>
|
||||
#include <QBrush>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include "../OBSIdianWidget.hpp"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QStyleOptionButton>
|
||||
#include <QAccessibleWidget>
|
||||
#include <QBrush>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QStyleOptionButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "OBSIdianWidget.hpp"
|
||||
namespace idian {
|
||||
|
||||
class OBSToggleSwitch : public QAbstractButton, public OBSIdianUtils {
|
||||
class ToggleSwitch : public QAbstractButton, public OBSIdianUtils {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int xpos MEMBER xPos WRITE setPos)
|
||||
Q_PROPERTY(QColor background MEMBER backgroundInactive DESIGNABLE true)
|
||||
@@ -41,8 +43,8 @@ class OBSToggleSwitch : public QAbstractButton, public OBSIdianUtils {
|
||||
Q_PROPERTY(float blend MEMBER blend WRITE setBlend DESIGNABLE false)
|
||||
|
||||
public:
|
||||
OBSToggleSwitch(QWidget *parent = nullptr);
|
||||
OBSToggleSwitch(bool defaultState, QWidget *parent = nullptr);
|
||||
ToggleSwitch(QWidget *parent = nullptr);
|
||||
ToggleSwitch(bool defaultState, QWidget *parent = nullptr);
|
||||
|
||||
QSize sizeHint() const override;
|
||||
|
||||
@@ -119,3 +121,5 @@ private:
|
||||
QPropertyAnimation *animHandle = nullptr;
|
||||
QPropertyAnimation *animBgColor = nullptr;
|
||||
};
|
||||
|
||||
} // namespace idian
|
||||
@@ -113,9 +113,9 @@ void Group::setCheckable(bool check)
|
||||
checkable = check;
|
||||
|
||||
if (checkable && !toggleSwitch) {
|
||||
toggleSwitch = new OBSToggleSwitch(true);
|
||||
toggleSwitch = new ToggleSwitch(true);
|
||||
controlLayout->addWidget(toggleSwitch);
|
||||
connect(toggleSwitch, &OBSToggleSwitch::toggled, this,
|
||||
connect(toggleSwitch, &ToggleSwitch::toggled, this,
|
||||
[=](bool checked) { propertyList->setEnabled(checked); });
|
||||
}
|
||||
|
||||
|
||||
@@ -206,11 +206,11 @@ void Row::connectBuddyWidget(QWidget *widget)
|
||||
setBuddy(widget);
|
||||
|
||||
// If element is a ToggleSwitch and checkable, forward clicks to the widget
|
||||
OBSToggleSwitch *obsToggle = dynamic_cast<OBSToggleSwitch *>(widget);
|
||||
ToggleSwitch *obsToggle = dynamic_cast<ToggleSwitch *>(widget);
|
||||
if (obsToggle && obsToggle->isCheckable()) {
|
||||
setChangeCursor(true);
|
||||
|
||||
connect(this, &Row::clicked, obsToggle, &OBSToggleSwitch::click);
|
||||
connect(this, &Row::clicked, obsToggle, &ToggleSwitch::click);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,11 +224,11 @@ void Row::connectBuddyWidget(QWidget *widget)
|
||||
}
|
||||
|
||||
// If element is an ComboBox, clicks toggle the dropdown.
|
||||
OBSComboBox *obsCombo = dynamic_cast<OBSComboBox *>(widget);
|
||||
ComboBox *obsCombo = dynamic_cast<ComboBox *>(widget);
|
||||
if (obsCombo) {
|
||||
setChangeCursor(true);
|
||||
|
||||
connect(this, &Row::clicked, obsCombo, &OBSComboBox::togglePopup);
|
||||
connect(this, &Row::clicked, obsCombo, &ComboBox::togglePopup);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -318,10 +318,10 @@ void CollapsibleRow::setCheckable(bool check)
|
||||
propertyList->setEnabled(false);
|
||||
OBSIdianUtils::polishChildren(propertyList);
|
||||
|
||||
toggleSwitch = new OBSToggleSwitch(false);
|
||||
toggleSwitch = new ToggleSwitch(false);
|
||||
|
||||
actionRow->setSuffix(toggleSwitch, false);
|
||||
connect(toggleSwitch, &OBSToggleSwitch::toggled, propertyList, &PropertiesList::setEnabled);
|
||||
connect(toggleSwitch, &ToggleSwitch::toggled, propertyList, &PropertiesList::setEnabled);
|
||||
}
|
||||
|
||||
if (!checkable && toggleSwitch) {
|
||||
|
||||
Reference in New Issue
Block a user