未验证 提交 75d62a8d 编写于 作者: J Jim 提交者: GitHub

Merge pull request #1623 from SuslikV/patch-11

UI: Correct custom property implementation
...@@ -904,8 +904,8 @@ FocusList::item { ...@@ -904,8 +904,8 @@ FocusList::item {
/* Preview background color */ /* Preview background color */
* [themeID="displayBackgroundColor"] { OBSQTDisplay {
qproperty-displayBackgroundColor: #28282A; qproperty-displayBackgroundColor: #28282A;
} }
/* Preview/Program labels */ /* Preview/Program labels */
......
...@@ -695,8 +695,8 @@ QLabel#errorLabel { ...@@ -695,8 +695,8 @@ QLabel#errorLabel {
/* Preview background color */ /* Preview background color */
* [themeID="displayBackgroundColor"] { OBSQTDisplay {
qproperty-displayBackgroundColor: rgb(76, 76, 76); qproperty-displayBackgroundColor: rgb(76, 76, 76);
} }
/* Preview/Program labels */ /* Preview/Program labels */
......
...@@ -1260,8 +1260,8 @@ QToolTip { ...@@ -1260,8 +1260,8 @@ QToolTip {
/* Preview background color */ /* Preview background color */
* [themeID="displayBackgroundColor"] { OBSQTDisplay {
qproperty-displayBackgroundColor: rgb(35, 38, 41); qproperty-displayBackgroundColor: rgb(35, 38, 41);
} }
/* Preview/Program labels */ /* Preview/Program labels */
......
...@@ -138,8 +138,8 @@ QLabel#errorLabel { ...@@ -138,8 +138,8 @@ QLabel#errorLabel {
/* Preview background color */ /* Preview background color */
* [themeID="displayBackgroundColor"] { OBSQTDisplay {
qproperty-displayBackgroundColor: rgb(76, 76, 76); qproperty-displayBackgroundColor: rgb(76, 76, 76);
} }
/* Preview/Program labels */ /* Preview/Program labels */
......
...@@ -19,6 +19,13 @@ static inline long long color_to_int(QColor color) ...@@ -19,6 +19,13 @@ static inline long long color_to_int(QColor color)
shift(color.alpha(), 24); shift(color.alpha(), 24);
} }
static inline QColor rgba_to_color(uint32_t rgba)
{
return QColor::fromRgb(rgba & 0xFF,
(rgba >> 8) & 0xFF,
(rgba >> 16) & 0xFF,
(rgba >> 24) & 0xFF);
}
OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags) OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
: QWidget(parent, flags) : QWidget(parent, flags)
...@@ -53,13 +60,25 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags) ...@@ -53,13 +60,25 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
connect(windowHandle(), &QWindow::visibleChanged, windowVisible); connect(windowHandle(), &QWindow::visibleChanged, windowVisible);
connect(windowHandle(), &QWindow::screenChanged, sizeChanged); connect(windowHandle(), &QWindow::screenChanged, sizeChanged);
}
this->setProperty("themeID", "displayBackgroundColor"); QColor OBSQTDisplay::GetDisplayBackgroundColor() const
{
return rgba_to_color(backgroundColor);
} }
void OBSQTDisplay::SetDisplayBackgroundColor(const QColor &color) void OBSQTDisplay::SetDisplayBackgroundColor(const QColor &color)
{ {
backgroundColor = (uint32_t)color_to_int(color); uint32_t newBackgroundColor = (uint32_t)color_to_int(color);
if (newBackgroundColor != backgroundColor) {
backgroundColor = newBackgroundColor;
UpdateDisplayBackgroundColor();
}
}
void OBSQTDisplay::UpdateDisplayBackgroundColor()
{
obs_display_set_background_color(display, backgroundColor); obs_display_set_background_color(display, backgroundColor);
} }
......
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
#include <QWidget> #include <QWidget>
#include <obs.hpp> #include <obs.hpp>
#define GREY_COLOR_BACKGROUND 0xFF4C4C4C
class OBSQTDisplay : public QWidget { class OBSQTDisplay : public QWidget {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor
READ GetDisplayBackgroundColor
WRITE SetDisplayBackgroundColor) WRITE SetDisplayBackgroundColor)
OBSDisplay display; OBSDisplay display;
...@@ -27,8 +30,9 @@ public: ...@@ -27,8 +30,9 @@ public:
inline obs_display_t *GetDisplay() const {return display;} inline obs_display_t *GetDisplay() const {return display;}
uint32_t backgroundColor; uint32_t backgroundColor = GREY_COLOR_BACKGROUND;
private slots: QColor GetDisplayBackgroundColor() const;
void SetDisplayBackgroundColor(const QColor &color); void SetDisplayBackgroundColor(const QColor &color);
void UpdateDisplayBackgroundColor();
}; };
...@@ -67,7 +67,6 @@ OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor, ...@@ -67,7 +67,6 @@ OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
obs_display_add_draw_callback(GetDisplay(), obs_display_add_draw_callback(GetDisplay(),
isMultiview ? OBSRenderMultiview : OBSRender, isMultiview ? OBSRenderMultiview : OBSRender,
this); this);
obs_display_set_background_color(GetDisplay(), 0x000000);
}; };
connect(this, &OBSQTDisplay::DisplayCreated, addDrawCallback); connect(this, &OBSQTDisplay::DisplayCreated, addDrawCallback);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册