diff --git a/obs/properties-view.cpp b/obs/properties-view.cpp index aca053d4a..17220763b 100644 --- a/obs/properties-view.cpp +++ b/obs/properties-view.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -54,6 +55,9 @@ void OBSPropertiesView::ReloadProperties() void OBSPropertiesView::RefreshProperties() { + int h, v; + GetScrollPos(h, v); + children.clear(); if (widget) widget->deleteLater(); @@ -79,6 +83,7 @@ void OBSPropertiesView::RefreshProperties() setWidgetResizable(true); setWidget(widget); + SetScrollPos(h, v); setSizePolicy(mainPolicy); lastFocused.clear(); @@ -88,6 +93,30 @@ void OBSPropertiesView::RefreshProperties() } } +void OBSPropertiesView::SetScrollPos(int h, int v) +{ + QScrollBar *scroll = horizontalScrollBar(); + if (scroll) + scroll->setValue(h); + + scroll = verticalScrollBar(); + if (scroll) + scroll->setValue(v); +} + +void OBSPropertiesView::GetScrollPos(int &h, int &v) +{ + h = v = 0; + + QScrollBar *scroll = horizontalScrollBar(); + if (scroll) + h = scroll->value(); + + scroll = verticalScrollBar(); + if (scroll) + v = scroll->value(); +} + OBSPropertiesView::OBSPropertiesView(OBSData settings_, void *obj_, PropertiesReloadCallback reloadCallback, PropertiesUpdateCallback callback_, int minSize_) diff --git a/obs/properties-view.hpp b/obs/properties-view.hpp index 5e0fe91b2..718fa1467 100644 --- a/obs/properties-view.hpp +++ b/obs/properties-view.hpp @@ -84,6 +84,9 @@ private: void resizeEvent(QResizeEvent *event) override; + void GetScrollPos(int &h, int &v); + void SetScrollPos(int h, int v); + public slots: void ReloadProperties(); void RefreshProperties();