From 354614a7e8ebefbdb5ebb506571c6c6c3d5bb6be Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 27 Aug 2014 18:18:26 -0700 Subject: [PATCH] Basic UI: Signal resize of properties view If the properties view changed in the properties window, the viewport of the properties would not trigger a resize because the size of the window itself does not change. This creates a signal that allows the parent to know whether or not to update a viewport, if any. --- obs/properties-view.cpp | 6 ++++++ obs/properties-view.hpp | 5 +++++ obs/window-basic-properties.cpp | 10 ++++++++++ obs/window-basic-properties.hpp | 3 +++ 4 files changed, 24 insertions(+) diff --git a/obs/properties-view.cpp b/obs/properties-view.cpp index da2dd4081..cee1671a9 100644 --- a/obs/properties-view.cpp +++ b/obs/properties-view.cpp @@ -92,6 +92,12 @@ OBSPropertiesView::OBSPropertiesView(OBSData settings_, RefreshProperties(); } +void OBSPropertiesView::resizeEvent(QResizeEvent *event) +{ + emit PropertiesResized(); + UNUSED_PARAMETER(event); +} + QWidget *OBSPropertiesView::NewWidget(obs_property_t prop, QWidget *widget, const char *signal) { diff --git a/obs/properties-view.hpp b/obs/properties-view.hpp index 010e4289f..a077560c8 100644 --- a/obs/properties-view.hpp +++ b/obs/properties-view.hpp @@ -74,9 +74,14 @@ private: void AddProperty(obs_property_t property, QFormLayout *layout); + void resizeEvent(QResizeEvent *event) override; + public slots: void RefreshProperties(); +signals: + void PropertiesResized(); + public: OBSPropertiesView(OBSData settings, obs_properties_t properties, diff --git a/obs/window-basic-properties.cpp b/obs/window-basic-properties.cpp index 9727e681b..eaefbb121 100644 --- a/obs/window-basic-properties.cpp +++ b/obs/window-basic-properties.cpp @@ -58,6 +58,9 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) view->setMinimumHeight(150); view->show(); + connect(view, SIGNAL(PropertiesResized()), + this, SLOT(OnPropertiesResized())); + connect(windowHandle(), &QWindow::screenChanged, [this]() { if (resizeTimer) killTimer(resizeTimer); @@ -107,6 +110,13 @@ void OBSBasicProperties::DrawPreview(void *data, uint32_t cx, uint32_t cy) gs_viewport_pop(); } +void OBSBasicProperties::OnPropertiesResized() +{ + if (resizeTimer) + killTimer(resizeTimer); + resizeTimer = startTimer(100); +} + void OBSBasicProperties::resizeEvent(QResizeEvent *event) { if (isVisible()) { diff --git a/obs/window-basic-properties.hpp b/obs/window-basic-properties.hpp index fd0fb5da6..943a81320 100644 --- a/obs/window-basic-properties.hpp +++ b/obs/window-basic-properties.hpp @@ -44,6 +44,9 @@ private: static void SourceRemoved(void *data, calldata_t params); static void DrawPreview(void *data, uint32_t cx, uint32_t cy); +private slots: + void OnPropertiesResized(); + public: OBSBasicProperties(QWidget *parent, OBSSource source_);