mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-27 09:46:20 -04:00
UI: Add 'visibility' checkbox
This checkbox gives an 'eye' icon that indicates whether something is visible or not. The color of the icon is influenced by the current style's foreground color.
This commit is contained in:
@@ -107,6 +107,7 @@ set(obs_SOURCES
|
||||
double-slider.cpp
|
||||
volume-control.cpp
|
||||
adv-audio-control.cpp
|
||||
visibility-checkbox.cpp
|
||||
vertical-scroll-area.cpp
|
||||
source-list-widget.cpp
|
||||
crash-report.cpp
|
||||
@@ -135,6 +136,7 @@ set(obs_HEADERS
|
||||
double-slider.hpp
|
||||
volume-control.hpp
|
||||
adv-audio-control.hpp
|
||||
visibility-checkbox.hpp
|
||||
vertical-scroll-area.hpp
|
||||
source-list-widget.hpp
|
||||
qt-display.hpp
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
Binary file not shown.
|
After Width: | Height: | Size: 254 B |
@@ -1,6 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/res">
|
||||
<file>images/configuration21_16.png</file>
|
||||
<file>images/invisible_mask.png</file>
|
||||
<file>images/visible_mask.png</file>
|
||||
<file>images/list_remove.png</file>
|
||||
<file>images/add.png</file>
|
||||
<file>images/down.png</file>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <QPaintEvent>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include "visibility-checkbox.hpp"
|
||||
|
||||
#include <util/c99defs.h>
|
||||
|
||||
VisibilityCheckBox::VisibilityCheckBox() : QCheckBox()
|
||||
{
|
||||
checkedImage =
|
||||
QPixmap::fromImage(QImage(":/res/images/visible_mask.png"));
|
||||
uncheckedImage =
|
||||
QPixmap::fromImage(QImage(":/res/images/invisible_mask.png"));
|
||||
setMinimumSize(16, 16);
|
||||
|
||||
setStyleSheet("outline: none;");
|
||||
}
|
||||
|
||||
void VisibilityCheckBox::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
UNUSED_PARAMETER(event);
|
||||
|
||||
QPixmap &pixmap = isChecked() ? checkedImage : uncheckedImage;
|
||||
QImage image(pixmap.size(), QImage::Format_ARGB32);
|
||||
|
||||
QPainter draw(&image);
|
||||
draw.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
draw.drawPixmap(0, 0, pixmap.width(), pixmap.height(), pixmap);
|
||||
draw.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
draw.fillRect(QRectF(QPointF(0.0f, 0.0f), pixmap.size()),
|
||||
palette().color(foregroundRole()));
|
||||
|
||||
QPainter p(this);
|
||||
p.drawPixmap(0, 0, image.width(), image.height(),
|
||||
QPixmap::fromImage(image));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <QCheckBox>
|
||||
#include <QPixmap>
|
||||
|
||||
class QPaintEvernt;
|
||||
|
||||
class VisibilityCheckBox : public QCheckBox {
|
||||
Q_OBJECT
|
||||
|
||||
QPixmap checkedImage;
|
||||
QPixmap uncheckedImage;
|
||||
|
||||
public:
|
||||
VisibilityCheckBox();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
};
|
||||
Reference in New Issue
Block a user