mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
UI: Correct custom property implementation
- Fixes Q_PROPERTY macro syntax - Removes excessive notification declaration and slot - Removes unneeded dynamic property - Improves Themes versatility
This commit is contained in:
parent
975431a7c7
commit
e2be33956b
|
@ -904,8 +904,8 @@ FocusList::item {
|
|||
|
||||
/* Preview background color */
|
||||
|
||||
* [themeID="displayBackgroundColor"] {
|
||||
qproperty-displayBackgroundColor: #28282A;
|
||||
OBSQTDisplay {
|
||||
qproperty-displayBackgroundColor: #28282A;
|
||||
}
|
||||
|
||||
/* Preview/Program labels */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue