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:
jp9000
2015-03-25 10:03:23 -07:00
parent 606d72b1fe
commit 53a98ecbe5
6 changed files with 57 additions and 0 deletions
+2
View File
@@ -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

+2
View File
@@ -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>
+36
View 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));
}
+17
View File
@@ -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;
};