0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 21:13:04 +02:00
obs-studio/obs/visibility-item-widget.hpp
jp9000 642aa7454f UI: Add list item widget w/ visibility checkbox
This is used to allow the user to temporarily disable sources/filters.

For each item in the list box, it displays a visibility checkbox (with
eye icon) that the user can click to disable/re-enable sources or
filters.

I did not end up using the Qt::ItemIsUserCheckable flag with the list
items for a few reasons:

- We could not style the checkbox indicator without qss screwing up
  other parts of the list widget style on certain operating systems

- We could not get the icon to properly invert on active selection like
  the text does on mac/linux, which made it look strange

- Clicking the checkbox too fast would cause it to signal a double-click
  on the icon, opening the properties for a source in the source list
2015-03-25 14:11:58 -07:00

66 lines
1.6 KiB
C++

#pragma once
#include <QWidget>
#include <QStyledItemDelegate>
#include <obs.hpp>
class QLabel;
class QLineEdit;
class QListWidget;
class QListWidgetItem;
class VisibilityCheckBox;
class VisibilityItemWidget : public QWidget {
Q_OBJECT
private:
OBSSceneItem item;
OBSSource source;
QLabel *label = nullptr;
VisibilityCheckBox *vis = nullptr;
QString oldName;
OBSSignal sceneRemoveSignal;
OBSSignal enabledSignal;
OBSSignal renamedSignal;
bool sceneRemoved = false;
bool active = false;
bool selected = false;
static void OBSSceneRemove(void *param, calldata_t *data);
static void OBSSceneItemRemove(void *param, calldata_t *data);
static void OBSSceneItemVisible(void *param, calldata_t *data);
static void OBSSourceEnabled(void *param, calldata_t *data);
static void OBSSourceRenamed(void *param, calldata_t *data);
void DisconnectItemSignals();
private slots:
void VisibilityClicked(bool visible);
void SourceEnabled(bool enabled);
void SourceRenamed(QString name);
public:
VisibilityItemWidget(obs_source_t *source);
VisibilityItemWidget(obs_sceneitem_t *item);
~VisibilityItemWidget();
void SetColor(const QColor &color, bool active, bool selected);
};
class VisibilityItemDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
VisibilityItemDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
};
void SetupVisibilityItem(QListWidget *list, QListWidgetItem *item,
obs_source_t *source);
void SetupVisibilityItem(QListWidget *list, QListWidgetItem *item,
obs_sceneitem_t *sceneItem);