UI: Keep prop. view scroll positions if modified
If the properties view is scrolled down or right and a widget triggers it to repaint, it would reset its scroll position, making editing a bit awkward. This simply saved/restores the position before and after rebuilding the properties view.
This commit is contained in:
parent
4983aaa586
commit
efe31c9fe9
@ -1,4 +1,5 @@
|
||||
#include <QFormLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QFont>
|
||||
@ -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_)
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user