提交 efe31c9f 编写于 作者: J jp9000

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.
上级 4983aaa5
#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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册