Debugger: Add setting to change UI refresh interval

This commit is contained in:
chaoticgd 2025-04-06 15:29:00 +01:00 committed by Ty
parent 99ecb0b60f
commit c359c0e747
4 changed files with 77 additions and 26 deletions

View File

@ -120,11 +120,7 @@ DebuggerWindow::DebuggerWindow(QWidget* parent)
R5900SymbolImporter.OnDebuggerOpened();
});
QTimer* refresh_timer = new QTimer(this);
connect(refresh_timer, &QTimer::timeout, this, []() {
DebuggerWidget::broadcastEvent(DebuggerEvents::Refresh());
});
refresh_timer->start(1000);
updateFromSettings();
}
DebuggerWindow* DebuggerWindow::getInstance()
@ -285,6 +281,25 @@ bool DebuggerWindow::shouldSaveWindowGeometry()
return Host::GetBaseBoolSettingValue("Debugger/UserInterface", "SaveWindowGeometry", true);
}
void DebuggerWindow::updateFromSettings()
{
const int refresh_interval = Host::GetBaseIntSettingValue("Debugger/UserInterface", "RefreshInterval", 1000);
const int effective_refresh_interval = std::clamp(refresh_interval, 10, 100000);
if (!m_refresh_timer)
{
m_refresh_timer = new QTimer(this);
connect(m_refresh_timer, &QTimer::timeout, this, []() {
DebuggerWidget::broadcastEvent(DebuggerEvents::Refresh());
});
m_refresh_timer->start(effective_refresh_interval);
}
else
{
m_refresh_timer->setInterval(effective_refresh_interval);
}
}
void DebuggerWindow::onVMStarting()
{
m_ui.actionRun->setEnabled(true);

View File

@ -8,6 +8,7 @@
#include "DebugTools/DebugInterface.h"
#include <kddockwidgets/MainWindow.h>
#include <QtCore/QTimer>
class DockManager;
@ -37,6 +38,8 @@ public:
void restoreWindowGeometry();
bool shouldSaveWindowGeometry();
void updateFromSettings();
public slots:
void onVMStarting();
void onVMPaused();
@ -67,6 +70,7 @@ private:
DockManager* m_dock_manager;
QByteArray m_default_toolbar_state;
QTimer* m_refresh_timer = nullptr;
int m_font_size;
static const constexpr int DEFAULT_FONT_SIZE = 10;

View File

@ -4,6 +4,7 @@
#include "DebugUserInterfaceSettingsWidget.h"
#include "SettingWidgetBinder.h"
#include "Debugger/DebuggerWindow.h"
static const char* s_drop_indicators[] = {
QT_TRANSLATE_NOOP("DebugUserInterfaceSettingsWidget", "Classic"),
@ -19,32 +20,40 @@ DebugUserInterfaceSettingsWidget::DebugUserInterfaceSettingsWidget(SettingsWindo
m_ui.setupUi(this);
SettingWidgetBinder::BindWidgetToBoolSetting(
sif, m_ui.showOnStartupCheckBox, "Debugger/UserInterface", "ShowOnStartup", false);
SettingWidgetBinder::BindWidgetToIntSetting(
sif, m_ui.refreshInterval, "Debugger/UserInterface", "RefreshInterval", 1000);
connect(m_ui.refreshInterval, &QSpinBox::valueChanged, this, []() {
if (g_debugger_window)
g_debugger_window->updateFromSettings();
});
dialog->registerWidgetHelp(
m_ui.showOnStartupCheckBox, tr("Show On Startup"), tr("Unchecked"),
m_ui.refreshInterval, tr("Refresh Interval"), tr("1000ms"),
tr("The amount of time to wait between subsequent attempts to update the user interface to reflect the state "
"of the virtual machine."));
SettingWidgetBinder::BindWidgetToBoolSetting(
sif, m_ui.showOnStartup, "Debugger/UserInterface", "ShowOnStartup", false);
dialog->registerWidgetHelp(
m_ui.showOnStartup, tr("Show On Startup"), tr("Unchecked"),
tr("Open the debugger window automatically when PCSX2 starts."));
SettingWidgetBinder::BindWidgetToBoolSetting(
sif, m_ui.saveWindowGeometryCheckBox, "Debugger/UserInterface", "SaveWindowGeometry", true);
sif, m_ui.saveWindowGeometry, "Debugger/UserInterface", "SaveWindowGeometry", true);
dialog->registerWidgetHelp(
m_ui.saveWindowGeometryCheckBox, tr("Save Window Geometry"), tr("Checked"),
m_ui.saveWindowGeometry, tr("Save Window Geometry"), tr("Checked"),
tr("Save the position and size of the debugger window when it is closed so that it can be restored later."));
SettingWidgetBinder::BindWidgetToEnumSetting(
sif,
m_ui.dropIndicatorCombo,
m_ui.dropIndicator,
"Debugger/UserInterface",
"DropIndicatorStyle",
s_drop_indicators,
s_drop_indicators,
s_drop_indicators[0],
"DebugUserInterfaceSettingsWidget");
dialog->registerWidgetHelp(
m_ui.dropIndicatorCombo, tr("Drop Indicator Style"), tr("Classic"),
m_ui.dropIndicator, tr("Drop Indicator Style"), tr("Classic"),
tr("Choose how the drop indicators that appear when you drag dock windows in the debugger are styled. "
"You will have to restart the debugger for this option to take effect."));
}

View File

@ -38,15 +38,8 @@
<string>Debugger Window</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QCheckBox" name="saveWindowGeometryCheckBox">
<property name="text">
<string>Save Window Geometry</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="showOnStartupCheckBox">
<item row="1" column="0">
<widget class="QCheckBox" name="showOnStartup">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -58,6 +51,36 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="saveWindowGeometry">
<property name="text">
<string>Save Window Geometry</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="refreshIntervalLabel">
<property name="text">
<string>Refresh Interval:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="refreshInterval">
<property name="suffix">
<string>ms</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -76,12 +99,12 @@
<item row="0" column="0">
<widget class="QLabel" name="dropIndicatorLabel">
<property name="text">
<string>Drop Indicator Style</string>
<string>Drop Indicator Style:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="dropIndicatorCombo"/>
<widget class="QComboBox" name="dropIndicator"/>
</item>
</layout>
</widget>