diff --git a/UI/data/themes/Acri.qss b/UI/data/themes/Acri.qss index 1417da15df30074e7931dff4ee705f45ee88d7f6..62cbac30dc5ae1afe0dba79a571298f97432aea0 100644 --- a/UI/data/themes/Acri.qss +++ b/UI/data/themes/Acri.qss @@ -904,8 +904,8 @@ FocusList::item { /* Preview background color */ -* [themeID="displayBackgroundColor"] { - qproperty-displayBackgroundColor: #28282A; +OBSQTDisplay { + qproperty-displayBackgroundColor: #28282A; } /* Preview/Program labels */ diff --git a/UI/data/themes/Dark.qss b/UI/data/themes/Dark.qss index 8b50f7f65b0b3dfae0080a93f519c105933c9544..34fa8d73ce7796d033632fabf069999c7971b098 100644 --- a/UI/data/themes/Dark.qss +++ b/UI/data/themes/Dark.qss @@ -695,8 +695,8 @@ QLabel#errorLabel { /* Preview background color */ -* [themeID="displayBackgroundColor"] { - qproperty-displayBackgroundColor: rgb(76, 76, 76); +OBSQTDisplay { + qproperty-displayBackgroundColor: rgb(76, 76, 76); } /* Preview/Program labels */ diff --git a/UI/data/themes/Rachni.qss b/UI/data/themes/Rachni.qss index e3af6e16b492842fad301d67cc0f0b46c8dab59e..6855aa7b6e3ab95f7fe6cd905801e7abea25f069 100644 --- a/UI/data/themes/Rachni.qss +++ b/UI/data/themes/Rachni.qss @@ -1260,8 +1260,8 @@ QToolTip { /* Preview background color */ -* [themeID="displayBackgroundColor"] { - qproperty-displayBackgroundColor: rgb(35, 38, 41); +OBSQTDisplay { + qproperty-displayBackgroundColor: rgb(35, 38, 41); } /* Preview/Program labels */ diff --git a/UI/data/themes/System.qss b/UI/data/themes/System.qss index 2ea5c4ad4c30512b3c8ff046fbccf16d8ce5cab1..5436189244b9704b21fd8894346c85f95faa9b83 100644 --- a/UI/data/themes/System.qss +++ b/UI/data/themes/System.qss @@ -138,8 +138,8 @@ QLabel#errorLabel { /* Preview background color */ -* [themeID="displayBackgroundColor"] { - qproperty-displayBackgroundColor: rgb(76, 76, 76); +OBSQTDisplay { + qproperty-displayBackgroundColor: rgb(76, 76, 76); } /* Preview/Program labels */ diff --git a/UI/qt-display.cpp b/UI/qt-display.cpp index 0640ca32e2d2f165afafe58bb2aff403a5e286c3..f2ca5979ca84404a1557369e1a93b45b1b49b808 100644 --- a/UI/qt-display.cpp +++ b/UI/qt-display.cpp @@ -19,6 +19,13 @@ static inline long long color_to_int(QColor color) 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) : QWidget(parent, flags) @@ -53,13 +60,25 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags) connect(windowHandle(), &QWindow::visibleChanged, windowVisible); connect(windowHandle(), &QWindow::screenChanged, sizeChanged); +} - this->setProperty("themeID", "displayBackgroundColor"); +QColor OBSQTDisplay::GetDisplayBackgroundColor() const +{ + return rgba_to_color(backgroundColor); } 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); } diff --git a/UI/qt-display.hpp b/UI/qt-display.hpp index 94960b2a01b04921306e30a28baa40ce3f8a3e06..de4fdacc2d6f4be452e8a483d4299f783cfdd85f 100644 --- a/UI/qt-display.hpp +++ b/UI/qt-display.hpp @@ -8,6 +8,7 @@ class OBSQTDisplay : public QWidget { Q_OBJECT Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor + READ GetDisplayBackgroundColor WRITE SetDisplayBackgroundColor) OBSDisplay display; @@ -31,6 +32,7 @@ public: uint32_t backgroundColor = GREY_COLOR_BACKGROUND; -private slots: + QColor GetDisplayBackgroundColor() const; void SetDisplayBackgroundColor(const QColor &color); + void UpdateDisplayBackgroundColor(); };