Add MiniQtHelper functions for scrolling widgets

This commit is contained in:
baldurk
2026-08-31 11:26:05 +01:00
parent 6b02191629
commit da8132b69c
4 changed files with 44 additions and 0 deletions
+14
View File
@@ -695,6 +695,20 @@ add text next to it.
)");
virtual rdcstr GetWidgetText(QWidget *widget) = 0;
DOCUMENT(R"(Scroll the widget's vertical scrollbar to the top. If the widget has no scrollbar
this will do nothing
:param QWidget widget: The widget to scroll in.
)");
virtual void ScrollToTop(QWidget *widget) = 0;
DOCUMENT(R"(Scroll the widget's vertical scrollbar to the bottom. If the widget has no scrollbar
this will do nothing
:param QWidget widget: The widget to scroll in.
)");
virtual void ScrollToBottom(QWidget *widget) = 0;
DOCUMENT(R"(Change the font properties of a widget.
:param QWidget widget: The widget to change font of.
+21
View File
@@ -32,6 +32,7 @@
#include <QProgressBar>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QWidget>
#include "Code/QRDUtils.h"
@@ -412,6 +413,26 @@ rdcstr MiniQtHelper::GetWidgetText(QWidget *widget)
return widget->windowTitle();
}
void MiniQtHelper::ScrollToTop(QWidget *widget)
{
if(!widget)
return;
QAbstractScrollArea *w = qobject_cast<QAbstractScrollArea *>(widget);
if(w)
w->verticalScrollBar()->setSliderPosition(w->verticalScrollBar()->minimum());
}
void MiniQtHelper::ScrollToBottom(QWidget *widget)
{
if(!widget)
return;
QAbstractScrollArea *w = qobject_cast<QAbstractScrollArea *>(widget);
if(w)
w->verticalScrollBar()->setSliderPosition(w->verticalScrollBar()->maximum());
}
void MiniQtHelper::SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold,
bool italic)
{
+3
View File
@@ -74,6 +74,9 @@ public:
void SetWidgetText(QWidget *widget, const rdcstr &text) override;
rdcstr GetWidgetText(QWidget *widget) override;
void ScrollToTop(QWidget *widget) override;
void ScrollToBottom(QWidget *widget) override;
void SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold,
bool italic) override;
@@ -182,6 +182,12 @@ struct MiniQtInvoker : UIThreadInvoker<IMiniQtHelper>
return InvokeRetFunction<rdcstr>(&IMiniQtHelper::GetWidgetText, widget);
}
void ScrollToTop(QWidget *widget) { InvokeVoidFunction(&IMiniQtHelper::ScrollToTop, widget); }
void ScrollToBottom(QWidget *widget)
{
InvokeVoidFunction(&IMiniQtHelper::ScrollToBottom, widget);
}
void SetWidgetFont(QWidget *widget, const rdcstr &font, int32_t fontSize, bool bold, bool italic)
{
InvokeVoidFunction(&IMiniQtHelper::SetWidgetFont, widget, font, fontSize, bold, italic);