shared/idian: Rename widget classes

This commit is contained in:
Sebastian Beckmann
2025-08-22 16:21:52 -04:00
committed by Ryan Foster
parent 5cda3d4e8e
commit edb2c9ca48
12 changed files with 284 additions and 285 deletions
+21 -21
View File
@@ -386,20 +386,20 @@ OBSToggleSwitch {
qproperty-backgroundInactive: #3c404b;
}
OBSGroupBox {
idian--Group {
border-radius: 4px;
font-weight: bold;
}
OBSGroupBox > QLabel.title {
idian--Group > QLabel.title {
font-weight: bold;
}
OBSGroupBox > QLabel.subtitle {
idian--Group > QLabel.subtitle {
color: palette(button-text);
}
OBSPropertiesList {
idian--PropertiesList {
background: palette(base);
border-radius: 4px;
border-width: 0px;
@@ -407,7 +407,7 @@ OBSPropertiesList {
margin: 0px;
}
OBSActionRow {
idian--GenericRow {
margin: 0;
padding: 0;
border-left: 3px solid transparent;
@@ -415,63 +415,63 @@ OBSActionRow {
background: transparent;
}
OBSActionRow:hover {
idian--GenericRow:hover {
background: palette(highlight);
border-left: 0;
}
OBSActionRow[last="true"]:hover {
idian--GenericRow[last="true"]:hover {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
OBSActionRow[first="true"]:hover {
idian--GenericRow[first="true"]:hover {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
OBSActionRow > QLabel {
idian--GenericRow > QLabel {
font-weight: 500;
}
OBSActionRow > QLabel.subtitle {
idian--GenericRow > QLabel.subtitle {
font-size: 9pt;
color: palette(button-text);
}
OBSActionRow QComboBox,
OBSActionRow QPushButton {
idian--GenericRow QComboBox,
idian--GenericRow QPushButton {
margin: 0;
}
OBSActionRow QComboBox,
OBSActionRow QComboBox:hover,
OBSActionRow QComboBox:selected,
OBSActionRow QComboBox::on {
idian--GenericRow QComboBox,
idian--GenericRow QComboBox:hover,
idian--GenericRow QComboBox:selected,
idian--GenericRow QComboBox::on {
background: transparent;
}
OBSActionRow QComboBox::drop-down {
idian--GenericRow QComboBox::drop-down {
border: none;
}
OBSActionRow QComboBox::down-arrow {
idian--GenericRow QComboBox::down-arrow {
image: url(./Light/collapse.svg);
}
OBSPropertiesListSpacer {
idian--PropertiesListSpacer {
max-height: 1px;
min-height: 1px;
background-color: palette(midlight);
}
OBSCollapsibleActionRow {
idian--CollapsibleRow {
margin: 0;
padding: 0;
border: none;
}
OBSCollapsibleActionRow OBSPropertiesList {
idian--CollapsibleRow idian--PropertiesList {
border-radius: 0;
background: palette(mid);
}
+60 -60
View File
@@ -2180,7 +2180,7 @@ OBSBasicAdvAudio #scrollAreaWidgetContents {
}
/* Idian Widgets */
OBSGroupBox {
idian--Group {
border-radius: var(--border_radius);
font-weight: bold;
margin: 0 0 var(--spacing_base);
@@ -2188,56 +2188,56 @@ OBSGroupBox {
max-width: 600px;
}
OBSGroupBox .header .title {
idian--Group .header .title {
font-weight: bold;
padding: var(--padding_large) 0;
}
OBSGroupBox .header .description {
idian--Group .header .description {
color: var(--text_muted);
padding: var(--spacing_small) 0;
}
OBSPropertiesList {
idian--PropertiesList {
border-width: 0;
padding: 0;
margin: var(--spacing_base) 0;
}
OBSActionRowWidget {
idian--Row {
background: var(--grey5);
margin: 0;
padding: var(--action_row_padding) var(--action_row_padding_x);
}
OBSActionRowWidget.keyFocus {
idian--Row.keyFocus {
background: var(--grey4);
border: var(--highlight_width) solid var(--grey4);
}
OBSActionRowWidget.cursor-pointer.hover {
idian--Row.cursor-pointer.hover {
background: var(--grey4);
border: var(--highlight_width) solid var(--grey1);
}
OBSActionRowWidget.first {
idian--Row.first {
border-top-left-radius: var(--border_radius);
border-top-right-radius: var(--border_radius);
}
OBSActionRowWidget.last {
idian--Row.last {
border-bottom-left-radius: var(--border_radius);
border-bottom-right-radius: var(--border_radius);
}
OBSActionRowWidget > QWidget QLabel {
idian--Row > QWidget QLabel {
background: red;
margin: 4px;
font-weight: 500;
max-height: var(--input_height);
}
OBSActionRowWidget > QLabel.description {
idian--Row > QLabel.description {
font-size: var(--font_small);
color: var(--text_muted);
}
@@ -2271,17 +2271,17 @@ OBSToggleSwitch.keyFocus {
border-color: var(--highlight_color);
}
OBSActionRowWidget OBSToggleSwitch:hover,
OBSActionRowWidget.hover > OBSToggleSwitch.row-buddy {
idian--Row OBSToggleSwitch:hover,
idian--Row.hover > OBSToggleSwitch.row-buddy {
border-color: var(--grey1);
}
OBSActionRowWidget OBSToggleSwitch:checked:hover,
OBSActionRowWidget.hover OBSToggleSwitch.row-buddy:checked {
idian--Row OBSToggleSwitch:checked:hover,
idian--Row.hover OBSToggleSwitch.row-buddy:checked {
border-color: var(--white1);
}
OBSActionRowWidget QComboBox {
idian--Row QComboBox {
background-color: transparent;
min-height: var(--action_row_base);
max-height: var(--action_row_base);
@@ -2292,98 +2292,98 @@ OBSActionRowWidget QComboBox {
margin: 0;
}
OBSActionRowWidget QComboBox:focus {
idian--Row QComboBox:focus {
border-color: transparent;
}
OBSActionRowWidget QComboBox:hover {
idian--Row QComboBox:hover {
border-color: var(--grey1);
}
OBSActionRowWidget QComboBox.keyFocus {
idian--Row QComboBox.keyFocus {
border-color: var(--highlight_color);
}
OBSActionRowWidget QComboBox::drop-down {
idian--Row QComboBox::drop-down {
border: none;
}
OBSActionRowWidget QComboBox::down-arrow {
idian--Row QComboBox::down-arrow {
image: url(theme:Dark/collapse.svg);
}
OBSActionRowWidget QComboBox QAbstractItemView {
idian--Row QComboBox QAbstractItemView {
outline: none;
}
OBSActionRowWidget QComboBox QAbstractItemView::item {
idian--Row QComboBox QAbstractItemView::item {
background-color: var(--bg_base);
padding: var(--padding_base) var(--padding_large);
}
OBSActionRowWidget QComboBox QAbstractItemView::item:hover,
OBSActionRowWidget QComboBox QAbstractItemView::item:selected {
idian--Row QComboBox QAbstractItemView::item:hover,
idian--Row QComboBox QAbstractItemView::item:selected {
background-color: var(--list_item_bg_selected);
padding: var(--padding_base) var(--padding_large);
}
OBSActionRowWidget QPushButton,
OBSActionRowWidget QSpinBox,
OBSActionRowWidget QDoubleSpinBox {
idian--Row QPushButton,
idian--Row QSpinBox,
idian--Row QDoubleSpinBox {
margin: 0;
padding: var(--padding_base) var(--action_row_padding_x);
}
OBSPropertiesListSpacer {
idian--PropertiesListSpacer {
max-height: var(--spacing_small);
min-height: var(--spacing_small);
background-color: var(--bg_window);
}
OBSActionRowWidget OBSCheckBox {
idian--Row OBSCheckBox {
outline: none;
}
OBSActionRowWidget OBSCheckBox::indicator,
OBSActionRowWidget OBSCheckBox::indicator:unchecked:hover {
idian--Row OBSCheckBox::indicator,
idian--Row OBSCheckBox::indicator:unchecked:hover {
border: var(--highlight_width) solid transparent;
border-radius: var(--border_radius);
}
OBSActionRowWidget.hover > OBSCheckBox.row-buddy::indicator,
OBSActionRowWidget > OBSCheckBox::indicator:unchecked:hover,
OBSActionRowWidget > OBSCheckBox::indicator:hover {
idian--Row.hover > OBSCheckBox.row-buddy::indicator,
idian--Row > OBSCheckBox::indicator:unchecked:hover,
idian--Row > OBSCheckBox::indicator:hover {
border-color: var(--grey1);
}
OBSActionRowWidget.hover > OBSCheckBox.row-buddy::indicator:unchecked,
idian--Row.hover > OBSCheckBox.row-buddy::indicator:unchecked,
OBSCheckBox.keyFocus::indicator:unchecked {
image: url(theme:Yami/checkbox_unchecked_focus.svg);
}
OBSActionRowWidget OBSCheckBox.keyFocus::indicator,
OBSActionRowWidget.hover > OBSCheckBox::indicator {
idian--Row OBSCheckBox.keyFocus::indicator,
idian--Row.hover > OBSCheckBox::indicator {
image: url(theme:Yami/checkbox_checked_focus.svg);
}
OBSActionRowWidget OBSCheckBox.keyFocus::indicator,
OBSActionRowWidget OBSCheckBox.keyFocus::indicator:unchecked,
OBSActionRowWidget OBSCheckBox.keyFocus::indicator:hover,
OBSActionRowWidget OBSCheckBox.keyFocus::indicator:unchecked:hover {
idian--Row OBSCheckBox.keyFocus::indicator,
idian--Row OBSCheckBox.keyFocus::indicator:unchecked,
idian--Row OBSCheckBox.keyFocus::indicator:hover,
idian--Row OBSCheckBox.keyFocus::indicator:unchecked:hover {
border-color: var(--highlight_color);
}
OBSCollapsibleRowWidget {
idian--CollapsibleRow {
margin: 0;
padding: 0;
border: none;
}
OBSCollapsibleRowWidget.keyFocus {
idian--CollapsibleRow.keyFocus {
border: var(--highlight_width) solid var(--highlight_color);
}
OBSCollapsibleRowWidget OBSPropertiesList {
idian--CollapsibleRow idian--PropertiesList {
border-radius: 0;
border-left: 1px solid var(--grey5);
border-right: 1px solid var(--grey5);
@@ -2391,22 +2391,22 @@ OBSCollapsibleRowWidget OBSPropertiesList {
margin: var(--spacing_small) 0px 0px;
}
OBSCollapsibleRowWidget OBSPropertiesList OBSActionRowWidget {
idian--CollapsibleRow idian--PropertiesList idian--Row {
background-color: var(--grey6);
padding-left: var(--action_row_padding_nested);
}
OBSCollapsibleRowWidget OBSActionRowWidget.first,
OBSCollapsibleRowWidget OBSActionRowWidget.last {
idian--CollapsibleRow idian--Row.first,
idian--CollapsibleRow idian--Row.last {
border-radius: 0;
}
OBSCollapsibleRowWidget OBSPropertiesList OBSToggleSwitch {
idian--CollapsibleRow idian--PropertiesList OBSToggleSwitch {
qproperty-background: var(--grey7);
qproperty-background_hover: var(--grey6);
}
OBSActionRowExpandButton {
idian--ExpandButton {
background: transparent;
min-width: var(--action_row_collapse);
max-width: var(--action_row_collapse);
@@ -2415,7 +2415,7 @@ OBSActionRowExpandButton {
border: none;
}
OBSActionRowExpandButton::indicator {
idian--ExpandButton::indicator {
background: var(--grey5);
border-radius: var(--action_row_collapse_radius);
padding: var(--padding_large);
@@ -2423,37 +2423,37 @@ OBSActionRowExpandButton::indicator {
border: var(--highlight_width) solid var(--grey5);
}
OBSActionRowExpandButton::indicator:checked {
idian--ExpandButton::indicator:checked {
image: url(theme:Dark/up.svg);
}
OBSActionRowExpandButton.keyFocus,
OBSActionRowExpandButton.keyFocus::indicator {
idian--ExpandButton.keyFocus,
idian--ExpandButton.keyFocus::indicator {
border-color: var(--highlight_color);
}
OBSCollapsibleRowFrame .btn-frame {
idian--RowFrame .btn-frame {
background: var(--grey5);
padding: var(--action_row_padding) var(--action_row_padding_x);
}
OBSCollapsibleRowFrame.hover .btn-frame {
idian--RowFrame.hover .btn-frame {
background: var(--grey4);
}
OBSCollapsibleRowFrame.hover OBSActionRowWidget,
OBSCollapsibleRowFrame.hover OBSActionRowWidget.hover {
idian--RowFrame.hover idian--Row,
idian--RowFrame.hover idian--Row.hover {
background: var(--grey4);
border: 2px solid var(--grey1);
border-right: none;
}
OBSCollapsibleRowFrame.hover .row-buddy {
idian--RowFrame.hover .row-buddy {
background: var(--grey4);
border: 2px solid var(--grey1);
border-left: none;
}
OBSCollapsibleRowFrame.hover OBSActionRowExpandButton::indicator {
idian--RowFrame.hover idian--ExpandButton::indicator {
border-color: var(--grey1);
}
+19 -17
View File
@@ -21,23 +21,25 @@
#include <QTimer>
using namespace idian;
OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(new Ui_OBSIdianPlayground)
{
ui->setupUi(this);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
OBSGroupBox *test;
OBSActionRowWidget *tmp;
Group *test;
Row *tmp;
OBSComboBox *cbox = new OBSComboBox;
cbox->addItem("Test 1");
cbox->addItem("Test 2");
// Group box 1
test = new OBSGroupBox(this);
test = new Group(this);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Row with a dropdown");
tmp->setSuffix(cbox);
test->properties()->addRow(tmp);
@@ -45,19 +47,19 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
cbox = new OBSComboBox;
cbox->addItem("Test 3");
cbox->addItem("Test 4");
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Row with a dropdown");
tmp->setDescription("And a subtitle!");
tmp->setSuffix(cbox);
test->properties()->addRow(tmp);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Toggle Switch");
tmp->setSuffix(new OBSToggleSwitch());
test->properties()->addRow(tmp);
ui->scrollAreaWidgetContents->layout()->addWidget(test);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Delayed toggle switch");
tmp->setDescription("The state can be set separately");
auto tswitch = new OBSToggleSwitch;
@@ -74,15 +76,15 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
test->properties()->addRow(tmp);
// Group box 2
test = new OBSGroupBox();
test = new Group();
test->setTitle("Just a few checkboxes");
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Box 1");
tmp->setPrefix(new OBSCheckBox);
test->properties()->addRow(tmp);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Box 2");
tmp->setPrefix(new OBSCheckBox);
test->properties()->addRow(tmp);
@@ -90,30 +92,30 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
ui->scrollAreaWidgetContents->layout()->addWidget(test);
// Group box 2
test = new OBSGroupBox();
test = new Group();
test->setTitle("Another Group");
test->setDescription("With a subtitle");
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Placeholder");
tmp->setSuffix(new OBSToggleSwitch);
test->properties()->addRow(tmp);
OBSCollapsibleRowWidget *tmp2 = new OBSCollapsibleRowWidget("A Collapsible row!", this);
CollapsibleRow *tmp2 = new CollapsibleRow("A Collapsible row!", this);
tmp2->setCheckable(true);
test->addRow(tmp2);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Spin box demo");
tmp->setSuffix(new OBSDoubleSpinBox());
tmp2->addRow(tmp);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Just another placeholder");
tmp->setSuffix(new OBSToggleSwitch(true));
tmp2->addRow(tmp);
tmp = new OBSActionRowWidget();
tmp = new Row();
tmp->setTitle("Placeholder 2");
tmp->setSuffix(new OBSToggleSwitch);
test->properties()->addRow(tmp);
@@ -124,7 +126,7 @@ OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(ne
ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
// Test Checkable Group
OBSGroupBox *test2 = new OBSGroupBox();
Group *test2 = new Group();
test2->setTitle("Checkable Group");
test2->setDescription("Description goes here");
test2->setCheckable(true);
+6 -6
View File
@@ -8,8 +8,9 @@ add_library(OBS::idian ALIAS idian)
target_sources(
idian
PRIVATE
OBSActionRow.cpp
OBSActionRow.hpp
include/Idian/Group.hpp
include/Idian/PropertiesList.hpp
include/Idian/Row.hpp
OBSCheckBox.cpp
OBSCheckBox.hpp
OBSComboBox.cpp
@@ -17,14 +18,13 @@ target_sources(
OBSDoubleSpinBox.cpp
OBSDoubleSpinBox.hpp
OBSIdianWidget.hpp
OBSGroupBox.cpp
OBSGroupBox.hpp
OBSPropertiesList.cpp
OBSPropertiesList.hpp
OBSSpinBox.cpp
OBSSpinBox.hpp
OBSToggleSwitch.cpp
OBSToggleSwitch.hpp
widgets/Group.cpp
widgets/PropertiesList.cpp
widgets/Row.cpp
)
target_sources(idian PUBLIC include/Idian/Idian.hpp)
+1 -1
View File
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "OBSActionRow.hpp"
#include <Idian/Row.hpp>
#include "OBSComboBox.hpp"
#include <QTimer>
@@ -17,24 +17,26 @@
#pragma once
#include <QLayout>
#include <Idian/PropertiesList.hpp>
#include <Idian/Row.hpp>
#include "../../OBSToggleSwitch.hpp"
#include <QLabel>
#include <QWidget>
#include <QLayout>
#include <QMouseEvent>
#include <QWidget>
#include "OBSActionRow.hpp"
#include "OBSPropertiesList.hpp"
#include "OBSToggleSwitch.hpp"
namespace idian {
class OBSGroupBox : public QFrame, public OBSIdianUtils {
class Group : public QFrame, public OBSIdianUtils {
Q_OBJECT
public:
OBSGroupBox(QWidget *parent = nullptr);
Group(QWidget *parent = nullptr);
OBSPropertiesList *properties() const { return propertyList; }
PropertiesList *properties() const { return propertyList; }
void addRow(OBSActionRow *actionRow) const;
void addRow(GenericRow *row) const;
void setTitle(QString name);
void setDescription(QString desc);
@@ -61,8 +63,9 @@ private:
QLabel *nameLabel = nullptr;
QLabel *descriptionLabel = nullptr;
OBSPropertiesList *propertyList = nullptr;
PropertiesList *propertyList = nullptr;
OBSToggleSwitch *toggleSwitch = nullptr;
bool checkable = false;
};
} // namespace idian
+3 -3
View File
@@ -21,11 +21,11 @@
//
// (OBS Idian, get it?)
#include "../../OBSActionRow.hpp"
#include "../../OBSCheckBox.hpp"
#include "../../OBSComboBox.hpp"
#include "../../OBSDoubleSpinBox.hpp"
#include "../../OBSGroupBox.hpp"
#include "../../OBSPropertiesList.hpp"
#include "../../OBSSpinBox.hpp"
#include "../../OBSToggleSwitch.hpp"
#include <Idian/Group.hpp>
#include <Idian/PropertiesList.hpp>
#include <Idian/Row.hpp>
@@ -17,41 +17,41 @@
#pragma once
#include "../OBSIdianWidget.hpp"
#include <QFrame>
#include <QWidget>
#include <QLayout>
#include <QWidget>
#include "OBSIdianWidget.hpp"
namespace idian {
class GenericRow;
class OBSActionRow;
class OBSPropertiesList : public QFrame {
class PropertiesList : public QFrame {
Q_OBJECT
public:
OBSPropertiesList(QWidget *parent = nullptr);
PropertiesList(QWidget *parent = nullptr);
void addRow(OBSActionRow *actionRow);
void addRow(GenericRow *row);
void clear();
QList<OBSActionRow *> rows() const { return rowsList; }
QList<GenericRow *> rows() const { return rowsList; }
private:
OBSActionRow *first = nullptr;
OBSActionRow *last = nullptr;
GenericRow *first = nullptr;
GenericRow *last = nullptr;
QVBoxLayout *layout;
QList<OBSActionRow *> rowsList;
QList<GenericRow *> rowsList;
};
/**
* Spacer with only cosmetic functionality
*/
class OBSPropertiesListSpacer : public QFrame {
// Spacer with only cosmetic functionality
class PropertiesListSpacer : public QFrame {
Q_OBJECT
public:
OBSPropertiesListSpacer(QWidget *parent = nullptr) : QFrame(parent)
PropertiesListSpacer(QWidget *parent = nullptr) : QFrame(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
};
} // namespace idian
@@ -17,57 +17,46 @@
#pragma once
#include <QWidget>
#include <Idian/PropertiesList.hpp>
#include "../../OBSIdianWidget.hpp"
#include "../../OBSToggleSwitch.hpp"
#include "../../OBSComboBox.hpp"
#include "../../OBSSpinBox.hpp"
#include "../../OBSDoubleSpinBox.hpp"
#include <QCheckBox>
#include <QFrame>
#include <QLabel>
#include <QLayout>
#include <QScrollArea>
#include <QMouseEvent>
#include <QCheckBox>
#include <QScrollArea>
#include <QWidget>
#include "OBSIdianWidget.hpp"
#include "OBSPropertiesList.hpp"
#include "OBSToggleSwitch.hpp"
#include "OBSComboBox.hpp"
#include "OBSSpinBox.hpp"
#include "OBSDoubleSpinBox.hpp"
namespace idian {
/**
* Base class mostly so adding stuff to a list is easier
*/
class OBSActionRow : public QFrame, public OBSIdianUtils {
// Base class mostly so adding stuff to a list is easier
class GenericRow : public QFrame, public OBSIdianUtils {
Q_OBJECT
public:
OBSActionRow(QWidget *parent = nullptr) : QFrame(parent), OBSIdianUtils(this) { setAccessibleName(""); };
GenericRow(QWidget *parent = nullptr) : QFrame(parent), OBSIdianUtils(this) { setAccessibleName(""); };
};
/**
* Proxy for QScrollArea for QSS styling
*/
class OBSScrollArea : public QScrollArea {
Q_OBJECT
public:
OBSScrollArea(QWidget *parent = nullptr) : QScrollArea(parent) {}
};
/**
* Generic OBS row widget containing one or more controls
*/
class OBSActionRowWidget : public OBSActionRow {
// Row widget containing one or more controls
class Row : public GenericRow {
Q_OBJECT
public:
OBSActionRowWidget(QWidget *parent = nullptr);
Row(QWidget *parent = nullptr);
void setPrefix(QWidget *w, bool autoConnect = true);
void setSuffix(QWidget *w, bool autoConnect = true);
bool hasPrefix() { return _prefix; }
bool hasSuffix() { return _suffix; }
bool hasPrefix() { return prefix_; }
bool hasSuffix() { return suffix_; }
QWidget *prefix() const { return _prefix; }
QWidget *suffix() const { return _suffix; }
QWidget *prefix() const { return prefix_; }
QWidget *suffix() const { return suffix_; }
void setPrefixEnabled(bool enabled);
void setSuffixEnabled(bool enabled);
@@ -112,8 +101,8 @@ private:
QLabel *nameLabel = nullptr;
QLabel *descriptionLabel = nullptr;
QWidget *_prefix = nullptr;
QWidget *_suffix = nullptr;
QWidget *prefix_ = nullptr;
QWidget *suffix_ = nullptr;
QWidget *buddyWidget = nullptr;
@@ -121,20 +110,18 @@ private:
bool changeCursor = false;
};
/**
* Collapsible row expand button
*/
class OBSActionRowExpandButton : public QAbstractButton, public OBSIdianUtils {
// Collapsible row expand button
class ExpandButton : public QAbstractButton, public OBSIdianUtils {
Q_OBJECT
private:
QPixmap extendDown;
QPixmap extendUp;
friend class OBSCollapsibleRowWidget;
friend class CollapsibleRow;
protected:
explicit OBSActionRowExpandButton(QWidget *parent = nullptr);
explicit ExpandButton(QWidget *parent = nullptr);
void paintEvent(QPaintEvent *) override;
@@ -151,14 +138,14 @@ protected:
}
};
class OBSCollapsibleRowFrame : protected QFrame, protected OBSIdianUtils {
class RowFrame : protected QFrame, protected OBSIdianUtils {
Q_OBJECT
signals:
void clicked();
protected:
explicit OBSCollapsibleRowFrame(QWidget *parent = nullptr);
explicit RowFrame(QWidget *parent = nullptr);
void enterEvent(QEnterEvent *) override;
void leaveEvent(QEvent *) override;
@@ -176,23 +163,21 @@ protected:
}
private:
friend class OBSCollapsibleRowWidget;
friend class CollapsibleRow;
};
/**
* Collapsible Generic OBS property container
*/
class OBSCollapsibleRowWidget : public OBSActionRow {
// Collapsible Generic OBS property container
class CollapsibleRow : public GenericRow {
Q_OBJECT
public:
OBSCollapsibleRowWidget(const QString &name, QWidget *parent = nullptr);
OBSCollapsibleRowWidget(const QString &name, const QString &desc = nullptr, QWidget *parent = nullptr);
CollapsibleRow(const QString &name, QWidget *parent = nullptr);
CollapsibleRow(const QString &name, const QString &desc = nullptr, QWidget *parent = nullptr);
void setCheckable(bool check);
bool isCheckable() { return checkable; }
void addRow(OBSActionRow *actionRow);
void addRow(GenericRow *actionRow);
private:
void toggleVisibility();
@@ -201,15 +186,17 @@ private:
QPixmap extendUp;
QVBoxLayout *layout;
OBSCollapsibleRowFrame *rowWidget;
RowFrame *rowWidget;
QHBoxLayout *rowLayout;
OBSActionRowWidget *actionRow;
Row *actionRow;
QFrame *expandFrame;
QHBoxLayout *btnLayout;
OBSActionRowExpandButton *expandButton;
OBSPropertiesList *propertyList;
ExpandButton *expandButton;
PropertiesList *propertyList;
OBSToggleSwitch *toggleSwitch = nullptr;
bool checkable = false;
};
} // namespace idian
@@ -15,10 +15,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "OBSIdianWidget.hpp"
#include "OBSGroupBox.hpp"
#include <Idian/Group.hpp>
OBSGroupBox::OBSGroupBox(QWidget *parent) : QFrame(parent), OBSIdianUtils(this)
#include "../OBSIdianWidget.hpp"
#include <Idian/moc_Group.cpp>
using idian::Group;
Group::Group(QWidget *parent) : QFrame(parent), OBSIdianUtils(this)
{
layout = new QVBoxLayout(this);
layout->setSpacing(0);
@@ -57,12 +62,11 @@ OBSGroupBox::OBSGroupBox(QWidget *parent) : QFrame(parent), OBSIdianUtils(this)
layout->addWidget(headerContainer);
layout->addWidget(contentsContainer);
propertyList = new OBSPropertiesList(this);
propertyList = new PropertiesList(this);
setLayout(layout);
contentsLayout->addWidget(propertyList);
/*contentsContainer->setSizePolicy(policy);*/
nameLabel = new QLabel();
OBSIdianUtils::addClass(nameLabel, "title");
@@ -75,36 +79,36 @@ OBSGroupBox::OBSGroupBox(QWidget *parent) : QFrame(parent), OBSIdianUtils(this)
labelLayout->addWidget(descriptionLabel);
}
void OBSGroupBox::addRow(OBSActionRow *actionRow) const
void Group::addRow(GenericRow *row) const
{
propertyList->addRow(actionRow);
propertyList->addRow(row);
}
void OBSGroupBox::setTitle(QString name)
void Group::setTitle(QString name)
{
nameLabel->setText(name);
setAccessibleName(name);
showTitle(true);
}
void OBSGroupBox::setDescription(QString desc)
void Group::setDescription(QString desc)
{
descriptionLabel->setText(desc);
setAccessibleDescription(desc);
showDescription(true);
}
void OBSGroupBox::showTitle(bool visible)
void Group::showTitle(bool visible)
{
nameLabel->setVisible(visible);
}
void OBSGroupBox::showDescription(bool visible)
void Group::showDescription(bool visible)
{
descriptionLabel->setVisible(visible);
}
void OBSGroupBox::setCheckable(bool check)
void Group::setCheckable(bool check)
{
checkable = check;
@@ -15,36 +15,41 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <Idian/PropertiesList.hpp>
#include <Idian/Row.hpp>
#include <QStyle>
#include "OBSPropertiesList.hpp"
#include "OBSActionRow.hpp"
#include <Idian/moc_PropertiesList.cpp>
OBSPropertiesList::OBSPropertiesList(QWidget *parent) : QFrame(parent)
using idian::PropertiesList;
PropertiesList::PropertiesList(QWidget *parent) : QFrame(parent)
{
layout = new QVBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
rowsList = QList<OBSActionRow *>();
rowsList = QList<GenericRow *>();
setLayout(layout);
}
/* Note: This function takes ownership of the added widget
* and it may be deleted when the properties list is destroyed
* or the clear() method is called! */
void OBSPropertiesList::addRow(OBSActionRow *actionRow)
// Note: This function takes ownership of the added widget
// and it may be deleted when the properties list is destroyed
// or the clear() method is called!
void PropertiesList::addRow(GenericRow *row)
{
// Add custom spacer once more than one element exists
if (layout->count() > 0)
layout->addWidget(new OBSPropertiesListSpacer(this));
layout->addWidget(new PropertiesListSpacer(this));
// Custom properties to work around :first and :last not existing.
if (!first) {
OBSIdianUtils::addClass(actionRow, "first");
first = actionRow;
OBSIdianUtils::addClass(row, "first");
first = row;
}
// Remove last property from existing last item
@@ -52,16 +57,16 @@ void OBSPropertiesList::addRow(OBSActionRow *actionRow)
OBSIdianUtils::removeClass(last, "last");
// Most recently added item is also always last
OBSIdianUtils::addClass(actionRow, "last");
last = actionRow;
OBSIdianUtils::addClass(row, "last");
last = row;
actionRow->setParent(this);
rowsList.append(actionRow);
layout->addWidget(actionRow);
row->setParent(this);
rowsList.append(row);
layout->addWidget(row);
adjustSize();
}
void OBSPropertiesList::clear()
void PropertiesList::clear()
{
rowsList.clear();
first = nullptr;
@@ -15,14 +15,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QComboBox>
#include <QApplication>
#include <QSizePolicy>
#include <Idian/Row.hpp>
#include "OBSActionRow.hpp"
#include <QApplication>
#include <QComboBox>
#include <QSizePolicy>
#include <QSvgRenderer>
OBSActionRowWidget::OBSActionRowWidget(QWidget *parent) : OBSActionRow(parent)
#include <Idian/moc_Row.cpp>
namespace idian {
Row::Row(QWidget *parent) : GenericRow(parent)
{
layout = new QGridLayout(this);
layout->setVerticalSpacing(0);
@@ -54,97 +58,97 @@ OBSActionRowWidget::OBSActionRowWidget(QWidget *parent) : OBSActionRow(parent)
layout->addLayout(labelLayout, 0, 1, Qt::AlignLeft);
}
void OBSActionRowWidget::setPrefix(QWidget *w, bool auto_connect)
void Row::setPrefix(QWidget *w, bool auto_connect)
{
setSuffixEnabled(false);
_prefix = w;
prefix_ = w;
if (auto_connect)
this->connectBuddyWidget(w);
_prefix->setParent(this);
layout->addWidget(_prefix, 0, 0, Qt::AlignLeft);
prefix_->setParent(this);
layout->addWidget(prefix_, 0, 0, Qt::AlignLeft);
layout->setColumnStretch(0, 3);
}
void OBSActionRowWidget::setSuffix(QWidget *w, bool auto_connect)
void Row::setSuffix(QWidget *w, bool auto_connect)
{
setPrefixEnabled(false);
_suffix = w;
suffix_ = w;
if (auto_connect)
this->connectBuddyWidget(w);
_suffix->setParent(this);
layout->addWidget(_suffix, 0, 2, Qt::AlignRight | Qt::AlignVCenter);
suffix_->setParent(this);
layout->addWidget(suffix_, 0, 2, Qt::AlignRight | Qt::AlignVCenter);
}
void OBSActionRowWidget::setPrefixEnabled(bool enabled)
void Row::setPrefixEnabled(bool enabled)
{
if (!_prefix)
if (!prefix_)
return;
if (enabled)
setSuffixEnabled(false);
if (enabled == _prefix->isEnabled() && enabled == _prefix->isVisible())
if (enabled == prefix_->isEnabled() && enabled == prefix_->isVisible())
return;
layout->setColumnStretch(0, enabled ? 3 : 0);
_prefix->setEnabled(enabled);
_prefix->setVisible(enabled);
prefix_->setEnabled(enabled);
prefix_->setVisible(enabled);
}
void OBSActionRowWidget::setSuffixEnabled(bool enabled)
void Row::setSuffixEnabled(bool enabled)
{
if (!_suffix)
if (!suffix_)
return;
if (enabled)
setPrefixEnabled(false);
if (enabled == _suffix->isEnabled() && enabled == _suffix->isVisible())
if (enabled == suffix_->isEnabled() && enabled == suffix_->isVisible())
return;
_suffix->setEnabled(enabled);
_suffix->setVisible(enabled);
suffix_->setEnabled(enabled);
suffix_->setVisible(enabled);
}
void OBSActionRowWidget::setTitle(QString name)
void Row::setTitle(QString name)
{
nameLabel->setText(name);
setAccessibleName(name);
showTitle(true);
}
void OBSActionRowWidget::setDescription(QString description)
void Row::setDescription(QString description)
{
descriptionLabel->setText(description);
setAccessibleDescription(description);
showDescription(true);
}
void OBSActionRowWidget::showTitle(bool visible)
void Row::showTitle(bool visible)
{
nameLabel->setVisible(visible);
}
void OBSActionRowWidget::showDescription(bool visible)
void Row::showDescription(bool visible)
{
descriptionLabel->setVisible(visible);
}
void OBSActionRowWidget::setBuddy(QWidget *widget)
void Row::setBuddy(QWidget *widget)
{
buddyWidget = widget;
OBSIdianUtils::addClass(widget, "row-buddy");
}
void OBSActionRowWidget::setChangeCursor(bool change)
void Row::setChangeCursor(bool change)
{
changeCursor = change;
OBSIdianUtils::toggleClass("cursor-pointer", change);
}
void OBSActionRowWidget::enterEvent(QEnterEvent *event)
void Row::enterEvent(QEnterEvent *event)
{
if (!isEnabled())
return;
@@ -162,10 +166,10 @@ void OBSActionRowWidget::enterEvent(QEnterEvent *event)
OBSIdianUtils::polishChildren();
}
OBSActionRow::enterEvent(event);
GenericRow::enterEvent(event);
}
void OBSActionRowWidget::leaveEvent(QEvent *event)
void Row::leaveEvent(QEvent *event)
{
OBSIdianUtils::removeClass("hover");
@@ -176,10 +180,10 @@ void OBSActionRowWidget::leaveEvent(QEvent *event)
OBSIdianUtils::polishChildren();
}
OBSActionRow::leaveEvent(event);
GenericRow::leaveEvent(event);
}
void OBSActionRowWidget::mouseReleaseEvent(QMouseEvent *event)
void Row::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() & Qt::LeftButton) {
emit clicked();
@@ -187,7 +191,7 @@ void OBSActionRowWidget::mouseReleaseEvent(QMouseEvent *event)
QFrame::mouseReleaseEvent(event);
}
void OBSActionRowWidget::keyReleaseEvent(QKeyEvent *event)
void Row::keyReleaseEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Space || event->key() == Qt::Key_Enter) {
emit clicked();
@@ -195,51 +199,47 @@ void OBSActionRowWidget::keyReleaseEvent(QKeyEvent *event)
QFrame::keyReleaseEvent(event);
}
void OBSActionRowWidget::connectBuddyWidget(QWidget *widget)
void Row::connectBuddyWidget(QWidget *widget)
{
setAccessibleName(nameLabel->text());
setFocusProxy(widget);
setBuddy(widget);
/* If element is an OBSToggleSwitch and checkable, forward
* clicks to the widget */
// If element is a ToggleSwitch and checkable, forward clicks to the widget
OBSToggleSwitch *obsToggle = dynamic_cast<OBSToggleSwitch *>(widget);
if (obsToggle && obsToggle->isCheckable()) {
setChangeCursor(true);
connect(this, &OBSActionRowWidget::clicked, obsToggle, &OBSToggleSwitch::click);
connect(this, &Row::clicked, obsToggle, &OBSToggleSwitch::click);
return;
}
/* If element is any other QAbstractButton subclass,
* and checkable, forward clicks to the widget. */
// If element is any other QAbstractButton subclass, and checkable, forward clicks to the widget.
QAbstractButton *button = dynamic_cast<QAbstractButton *>(widget);
if (button && button->isCheckable()) {
setChangeCursor(true);
connect(this, &OBSActionRowWidget::clicked, button, &QAbstractButton::click);
connect(this, &Row::clicked, button, &QAbstractButton::click);
return;
}
/* If element is an OBSComboBox, clicks toggle the dropdown. */
// If element is an ComboBox, clicks toggle the dropdown.
OBSComboBox *obsCombo = dynamic_cast<OBSComboBox *>(widget);
if (obsCombo) {
setChangeCursor(true);
connect(this, &OBSActionRowWidget::clicked, obsCombo, &OBSComboBox::togglePopup);
connect(this, &Row::clicked, obsCombo, &OBSComboBox::togglePopup);
return;
}
}
/*
* Button for expanding a collapsible ActionRow
*/
OBSActionRowExpandButton::OBSActionRowExpandButton(QWidget *parent) : QAbstractButton(parent), OBSIdianUtils(this)
// Button for expanding a collapsible ActionRow
ExpandButton::ExpandButton(QWidget *parent) : QAbstractButton(parent), OBSIdianUtils(this)
{
setCheckable(true);
}
void OBSActionRowExpandButton::paintEvent(QPaintEvent *)
void ExpandButton::paintEvent(QPaintEvent *)
{
QStyleOptionButton opt;
opt.initFrom(this);
@@ -259,29 +259,27 @@ void OBSActionRowExpandButton::paintEvent(QPaintEvent *)
style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &p, this);
}
/*
* ActionRow variant that can be expanded to show another properties list
*/
OBSCollapsibleRowWidget::OBSCollapsibleRowWidget(const QString &name, QWidget *parent) : OBSActionRow(parent)
// Row variant that can be expanded to show another properties list
CollapsibleRow::CollapsibleRow(const QString &name, QWidget *parent) : GenericRow(parent)
{
layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
setLayout(layout);
rowWidget = new OBSCollapsibleRowFrame();
rowWidget = new RowFrame();
rowLayout = new QHBoxLayout();
rowLayout->setContentsMargins(0, 0, 0, 0);
rowLayout->setSpacing(0);
rowWidget->setLayout(rowLayout);
actionRow = new OBSActionRowWidget();
actionRow = new Row();
actionRow->setTitle(name);
actionRow->setChangeCursor(false);
rowLayout->addWidget(actionRow);
propertyList = new OBSPropertiesList(this);
propertyList = new PropertiesList(this);
propertyList->setVisible(false);
expandFrame = new QFrame();
@@ -292,7 +290,7 @@ OBSCollapsibleRowWidget::OBSCollapsibleRowWidget(const QString &name, QWidget *p
OBSIdianUtils::addClass(expandFrame, "btn-frame");
actionRow->setBuddy(expandFrame);
expandButton = new OBSActionRowExpandButton(this);
expandButton = new ExpandButton(this);
btnLayout->addWidget(expandButton);
rowLayout->addWidget(expandFrame);
@@ -302,18 +300,17 @@ OBSCollapsibleRowWidget::OBSCollapsibleRowWidget(const QString &name, QWidget *p
actionRow->setFocusProxy(expandButton);
connect(expandButton, &QAbstractButton::clicked, this, &OBSCollapsibleRowWidget::toggleVisibility);
connect(expandButton, &QAbstractButton::clicked, this, &CollapsibleRow::toggleVisibility);
connect(actionRow, &OBSActionRowWidget::clicked, expandButton, &QAbstractButton::click);
connect(actionRow, &Row::clicked, expandButton, &QAbstractButton::click);
}
OBSCollapsibleRowWidget::OBSCollapsibleRowWidget(const QString &name, const QString &desc, QWidget *parent)
: OBSCollapsibleRowWidget(name, parent)
CollapsibleRow::CollapsibleRow(const QString &name, const QString &desc, QWidget *parent) : CollapsibleRow(name, parent)
{
actionRow->setDescription(desc);
}
void OBSCollapsibleRowWidget::setCheckable(bool check)
void CollapsibleRow::setCheckable(bool check)
{
checkable = check;
@@ -324,7 +321,7 @@ void OBSCollapsibleRowWidget::setCheckable(bool check)
toggleSwitch = new OBSToggleSwitch(false);
actionRow->setSuffix(toggleSwitch, false);
connect(toggleSwitch, &OBSToggleSwitch::toggled, propertyList, &OBSPropertiesList::setEnabled);
connect(toggleSwitch, &OBSToggleSwitch::toggled, propertyList, &PropertiesList::setEnabled);
}
if (!checkable && toggleSwitch) {
@@ -335,7 +332,7 @@ void OBSCollapsibleRowWidget::setCheckable(bool check)
}
}
void OBSCollapsibleRowWidget::toggleVisibility()
void CollapsibleRow::toggleVisibility()
{
bool visible = !propertyList->isVisible();
@@ -343,14 +340,14 @@ void OBSCollapsibleRowWidget::toggleVisibility()
expandButton->setChecked(visible);
}
void OBSCollapsibleRowWidget::addRow(OBSActionRow *actionRow)
void CollapsibleRow::addRow(GenericRow *actionRow)
{
propertyList->addRow(actionRow);
}
OBSCollapsibleRowFrame::OBSCollapsibleRowFrame(QWidget *parent) : QFrame(parent), OBSIdianUtils(this) {}
RowFrame::RowFrame(QWidget *parent) : QFrame(parent), OBSIdianUtils(this) {}
void OBSCollapsibleRowFrame::enterEvent(QEnterEvent *event)
void RowFrame::enterEvent(QEnterEvent *event)
{
setCursor(Qt::PointingHandCursor);
@@ -360,10 +357,11 @@ void OBSCollapsibleRowFrame::enterEvent(QEnterEvent *event)
QWidget::enterEvent(event);
}
void OBSCollapsibleRowFrame::leaveEvent(QEvent *event)
void RowFrame::leaveEvent(QEvent *event)
{
OBSIdianUtils::removeClass("hover");
OBSIdianUtils::polishChildren();
QWidget::leaveEvent(event);
}
} // namespace idian