| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- /******************************************************************************
- Copyright (C) 2023 by Dennis Sädtler <[email protected]>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- ******************************************************************************/
- #pragma once
- #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 <QMouseEvent>
- #include <QScrollArea>
- #include <QWidget>
- namespace idian {
- // Base class mostly so adding stuff to a list is easier
- class GenericRow : public QFrame, public OBSIdianUtils {
- Q_OBJECT
- public:
- GenericRow(QWidget *parent = nullptr) : QFrame(parent), OBSIdianUtils(this) { setAccessibleName(""); };
- };
- // Row widget containing one or more controls
- class Row : public GenericRow {
- Q_OBJECT
- public:
- 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_; }
- QWidget *prefix() const { return prefix_; }
- QWidget *suffix() const { return suffix_; }
- void setPrefixEnabled(bool enabled);
- void setSuffixEnabled(bool enabled);
- void setTitle(QString name);
- void setDescription(QString description);
- void showTitle(bool visible);
- void showDescription(bool visible);
- void setBuddy(QWidget *w);
- void setChangeCursor(bool change);
- signals:
- void clicked();
- protected:
- void enterEvent(QEnterEvent *) override;
- void leaveEvent(QEvent *) override;
- void mouseReleaseEvent(QMouseEvent *) override;
- void keyReleaseEvent(QKeyEvent *) override;
- bool hasDescription() const { return descriptionLabel != nullptr; }
- void focusInEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::showKeyFocused(event);
- QFrame::focusInEvent(event);
- }
- void focusOutEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::hideKeyFocused(event);
- QFrame::focusOutEvent(event);
- }
- private:
- QGridLayout *layout;
- QVBoxLayout *labelLayout = nullptr;
- QLabel *nameLabel = nullptr;
- QLabel *descriptionLabel = nullptr;
- QWidget *prefix_ = nullptr;
- QWidget *suffix_ = nullptr;
- QWidget *buddyWidget = nullptr;
- void connectBuddyWidget(QWidget *widget);
- bool changeCursor = false;
- };
- // Collapsible row expand button
- class ExpandButton : public QAbstractButton, public OBSIdianUtils {
- Q_OBJECT
- private:
- QPixmap extendDown;
- QPixmap extendUp;
- friend class CollapsibleRow;
- protected:
- explicit ExpandButton(QWidget *parent = nullptr);
- void paintEvent(QPaintEvent *) override;
- void focusInEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::showKeyFocused(event);
- QAbstractButton::focusInEvent(event);
- }
- void focusOutEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::hideKeyFocused(event);
- QAbstractButton::focusOutEvent(event);
- }
- };
- class RowFrame : protected QFrame, protected OBSIdianUtils {
- Q_OBJECT
- signals:
- void clicked();
- protected:
- explicit RowFrame(QWidget *parent = nullptr);
- void enterEvent(QEnterEvent *) override;
- void leaveEvent(QEvent *) override;
- void focusInEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::showKeyFocused(event);
- QWidget::focusInEvent(event);
- }
- void focusOutEvent(QFocusEvent *event) override
- {
- OBSIdianUtils::hideKeyFocused(event);
- QWidget::focusOutEvent(event);
- }
- private:
- friend class CollapsibleRow;
- };
- // Collapsible Generic OBS property container
- class CollapsibleRow : public GenericRow {
- Q_OBJECT
- public:
- 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(GenericRow *actionRow);
- private:
- void toggleVisibility();
- QPixmap extendDown;
- QPixmap extendUp;
- QVBoxLayout *layout;
- RowFrame *rowWidget;
- QHBoxLayout *rowLayout;
- Row *actionRow;
- QFrame *expandFrame;
- QHBoxLayout *btnLayout;
- ExpandButton *expandButton;
- PropertiesList *propertyList;
- OBSToggleSwitch *toggleSwitch = nullptr;
- bool checkable = false;
- };
- } // namespace idian
|