Skip to content

Commit

Permalink
Debugger: Add some more user interface settings
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Mar 1, 2025
1 parent d6e67b2 commit ed3e7d3
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 142 deletions.
3 changes: 3 additions & 0 deletions pcsx2-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ target_sources(pcsx2-qt PRIVATE
Settings/DebugAnalysisSettingsWidget.cpp
Settings/DebugAnalysisSettingsWidget.h
Settings/DebugAnalysisSettingsWidget.ui
Settings/DebugUserInterfaceSettingsWidget.cpp
Settings/DebugUserInterfaceSettingsWidget.h
Settings/DebugUserInterfaceSettingsWidget.ui
Settings/DebugSettingsWidget.cpp
Settings/DebugSettingsWidget.h
Settings/DebugSettingsWidget.ui
Expand Down
19 changes: 18 additions & 1 deletion pcsx2-qt/Debugger/DebuggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ void DebuggerWindow::destroyInstance()
g_debugger_window->close();
}

bool DebuggerWindow::shouldShowOnStartup()
{
return Host::GetBaseBoolSettingValue("Debugger/UserInterface", "ShowOnStartup", false);
}

DockManager& DebuggerWindow::dockManager()
{
return *m_dock_manager;
Expand Down Expand Up @@ -230,7 +235,11 @@ void DebuggerWindow::updateStyleSheets()
void DebuggerWindow::saveWindowGeometry()
{
std::string old_geometry = Host::GetBaseStringSettingValue("Debugger/UserInterface", "WindowGeometry");
std::string geometry = saveGeometry().toBase64().toStdString();

std::string geometry;
if (shouldSaveWindowGeometry())
geometry = saveGeometry().toBase64().toStdString();

if (geometry != old_geometry)
{
Host::SetBaseStringSettingValue("Debugger/UserInterface", "WindowGeometry", geometry.c_str());
Expand All @@ -240,10 +249,18 @@ void DebuggerWindow::saveWindowGeometry()

void DebuggerWindow::restoreWindowGeometry()
{
if (!shouldSaveWindowGeometry())
return;

std::string geometry = Host::GetBaseStringSettingValue("Debugger/UserInterface", "WindowGeometry");
restoreGeometry(QByteArray::fromBase64(QByteArray::fromStdString(geometry)));
}

bool DebuggerWindow::shouldSaveWindowGeometry()
{
return Host::GetBaseBoolSettingValue("Debugger/UserInterface", "SaveWindowGeometry", true);
}

void DebuggerWindow::onVMStateChanged()
{
if (!QtHost::IsVMPaused())
Expand Down
2 changes: 2 additions & 0 deletions pcsx2-qt/Debugger/DebuggerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DebuggerWindow : public KDDockWidgets::QtWidgets::MainWindow
static DebuggerWindow* getInstance();
static DebuggerWindow* createInstance();
static void destroyInstance();
static bool shouldShowOnStartup();

DockManager& dockManager();

Expand All @@ -34,6 +35,7 @@ class DebuggerWindow : public KDDockWidgets::QtWidgets::MainWindow

void saveWindowGeometry();
void restoreWindowGeometry();
bool shouldSaveWindowGeometry();

public slots:
void onVMStateChanged();
Expand Down
8 changes: 6 additions & 2 deletions pcsx2-qt/Debugger/Docking/DockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ DockManager::DockManager(QObject* parent)

void DockManager::configureDockingSystem()
{
std::string indicator = Host::GetStringSettingValue("Debugger/UserInterface", "DropIndicator", "Classic");
if (indicator == "Segmented")
KDDockWidgets::Core::ViewFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;
else
KDDockWidgets::Core::ViewFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Classic;

static bool done = false;
if (done)
return;
Expand All @@ -53,8 +59,6 @@ void DockManager::configureDockingSystem()
KDDockWidgets::Config::self().setDragAboutToStartFunc(&DockManager::dragAboutToStart);
KDDockWidgets::Config::self().setStartDragDistance(std::max(QApplication::startDragDistance(), 32));

KDDockWidgets::Core::ViewFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;

done = true;
}

Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/Docking/DockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DockManager : public QObject

void switchToLayout(DockLayout::Index layout_index);
bool switchToLayoutWithCPU(BreakPointCpu cpu);
void reloadCurrentLayout();

void loadLayouts();
bool saveLayouts();
Expand Down
100 changes: 51 additions & 49 deletions pcsx2-qt/QtHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0+

#include "AutoUpdaterDialog.h"
#include "Debugger/DebuggerWindow.h"
#include "DisplayWidget.h"
#include "GameList/GameListWidget.h"
#include "LogWindow.h"
Expand Down Expand Up @@ -1064,12 +1065,12 @@ void EmuThread::updatePerformanceMetrics(bool force)
Q_ARG(const QString&, tr("VPS: %1 ").arg(vfps, 0, 'f', 0)));
m_last_video_fps = vfps;

if (speed != m_last_speed || force)
{
QMetaObject::invokeMethod(g_main_window->getStatusSpeedWidget(), "setText", Qt::QueuedConnection,
Q_ARG(const QString&, tr("Speed: %1% ").arg(speed, 0, 'f', 0)));
m_last_speed = speed;
}
if (speed != m_last_speed || force)
{
QMetaObject::invokeMethod(g_main_window->getStatusSpeedWidget(), "setText", Qt::QueuedConnection,
Q_ARG(const QString&, tr("Speed: %1% ").arg(speed, 0, 'f', 0)));
m_last_speed = speed;
}
}
}
}
Expand Down Expand Up @@ -1712,57 +1713,58 @@ void Host::SetMouseMode(bool relative_mode, bool hide_cursor)
emit g_emu_thread->onMouseModeRequested(relative_mode, hide_cursor);
}

namespace {
class QtHostProgressCallback final : public BaseProgressCallback
namespace
{
public:
QtHostProgressCallback();
~QtHostProgressCallback() override;
class QtHostProgressCallback final : public BaseProgressCallback
{
public:
QtHostProgressCallback();
~QtHostProgressCallback() override;

__fi const std::string& GetName() const { return m_name; }
__fi const std::string& GetName() const { return m_name; }

void PushState() override;
void PopState() override;
void PushState() override;
void PopState() override;

bool IsCancelled() const override;
bool IsCancelled() const override;

void SetCancellable(bool cancellable) override;
void SetTitle(const char* title) override;
void SetStatusText(const char* text) override;
void SetProgressRange(u32 range) override;
void SetProgressValue(u32 value) override;
void SetCancellable(bool cancellable) override;
void SetTitle(const char* title) override;
void SetStatusText(const char* text) override;
void SetProgressRange(u32 range) override;
void SetProgressValue(u32 value) override;

void DisplayError(const char* message) override;
void DisplayWarning(const char* message) override;
void DisplayInformation(const char* message) override;
void DisplayDebugMessage(const char* message) override;
void DisplayError(const char* message) override;
void DisplayWarning(const char* message) override;
void DisplayInformation(const char* message) override;
void DisplayDebugMessage(const char* message) override;

void ModalError(const char* message) override;
bool ModalConfirmation(const char* message) override;
void ModalInformation(const char* message) override;
void ModalError(const char* message) override;
bool ModalConfirmation(const char* message) override;
void ModalInformation(const char* message) override;

void SetCancelled();
void SetCancelled();

private:
struct SharedData
{
QProgressDialog* dialog = nullptr;
QString init_title;
QString init_status_text;
std::atomic_bool cancelled{false};
bool cancellable = true;
bool was_fullscreen = false;
private:
struct SharedData
{
QProgressDialog* dialog = nullptr;
QString init_title;
QString init_status_text;
std::atomic_bool cancelled{false};
bool cancellable = true;
bool was_fullscreen = false;
};

void EnsureHasData();
static void EnsureDialogVisible(const std::shared_ptr<SharedData>& data);
void Redraw(bool force);

std::string m_name;
std::shared_ptr<SharedData> m_data;
int m_last_progress_percent = -1;
};

void EnsureHasData();
static void EnsureDialogVisible(const std::shared_ptr<SharedData>& data);
void Redraw(bool force);

std::string m_name;
std::shared_ptr<SharedData> m_data;
int m_last_progress_percent = -1;
};
}
} // namespace

QtHostProgressCallback::QtHostProgressCallback()
: BaseProgressCallback()
Expand Down Expand Up @@ -1817,7 +1819,7 @@ void QtHostProgressCallback::SetTitle(const char* title)
void QtHostProgressCallback::SetStatusText(const char* text)
{
BaseProgressCallback::SetStatusText(text);

EnsureHasData();
QtHost::RunOnUIThread([data = m_data, text = QString::fromUtf8(text)]() {
if (data->dialog)
Expand Down Expand Up @@ -2372,7 +2374,7 @@ int main(int argc, char* argv[])
if (s_start_fullscreen_ui)
g_emu_thread->startFullscreenUI(s_start_fullscreen_ui_fullscreen);

if (s_boot_and_debug)
if (s_boot_and_debug || DebuggerWindow::shouldShowOnStartup())
{
DebugInterface::setPauseOnEntry(true);
g_main_window->openDebugger();
Expand Down
21 changes: 18 additions & 3 deletions pcsx2-qt/Settings/DebugSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "DebugSettingsWidget.h"

#include "DebugUserInterfaceSettingsWidget.h"
#include "DebugAnalysisSettingsWidget.h"
#include "QtUtils.h"
#include "SettingWidgetBinder.h"
Expand All @@ -20,6 +21,20 @@ DebugSettingsWidget::DebugSettingsWidget(SettingsWindow* dialog, QWidget* parent

m_ui.setupUi(this);

//////////////////////////////////////////////////////////////////////////
// User Interface Settings
//////////////////////////////////////////////////////////////////////////
if (!dialog->isPerGameSettings())
{
m_user_interface_settings = new DebugUserInterfaceSettingsWidget(dialog);
m_ui.userInterfaceTabWidget->setLayout(new QVBoxLayout());
m_ui.userInterfaceTabWidget->layout()->addWidget(m_user_interface_settings);
}
else
{
m_ui.debugTabs->removeTab(m_ui.debugTabs->indexOf(m_ui.userInterfaceTabWidget));
}

//////////////////////////////////////////////////////////////////////////
// Analysis Settings
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -141,9 +156,9 @@ DebugSettingsWidget::DebugSettingsWidget(SettingsWindow* dialog, QWidget* parent
connect(m_ui.chkEnable, &QCheckBox::checkStateChanged, this, &DebugSettingsWidget::onLoggingEnableChanged);
onLoggingEnableChanged();

#else
m_ui.debugTabs->removeTab(m_ui.debugTabs->indexOf(m_ui.traceLogTabWidget));
#endif
#else
m_ui.debugTabs->removeTab(m_ui.debugTabs->indexOf(m_ui.traceLogTabWidget));
#endif
}

DebugSettingsWidget::~DebugSettingsWidget() = default;
Expand Down
3 changes: 3 additions & 0 deletions pcsx2-qt/Settings/DebugSettingsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ui_DebugSettingsWidget.h"

class SettingsWindow;
class DebugUserInterfaceSettingsWidget;
class DebugAnalysisSettingsWidget;

class DebugSettingsWidget : public QWidget
Expand All @@ -26,6 +27,8 @@ private Q_SLOTS:

private:
SettingsWindow* m_dialog;

DebugUserInterfaceSettingsWidget* m_user_interface_settings;
DebugAnalysisSettingsWidget* m_analysis_settings;

Ui::DebugSettingsWidget m_ui;
Expand Down
31 changes: 18 additions & 13 deletions pcsx2-qt/Settings/DebugSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<width>647</width>
<height>501</height>
</rect>
</property>
Expand All @@ -31,6 +31,11 @@
<property name="documentMode">
<bool>true</bool>
</property>
<widget class="QWidget" name="userInterfaceTabWidget">
<attribute name="title">
<string>User Interface</string>
</attribute>
</widget>
<widget class="QWidget" name="analysisTabWidget">
<attribute name="title">
<string>Analysis</string>
Expand Down Expand Up @@ -58,8 +63,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>523</width>
<height>464</height>
<width>645</width>
<height>469</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -196,18 +201,18 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="saveAlpha">
<property name="text">
<string>Save Alpha</string>
</property>
</widget>
<widget class="QCheckBox" name="saveAlpha">
<property name="text">
<string>Save Alpha</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="saveInfo">
<property name="text">
<string>Save Info</string>
</property>
</widget>
<widget class="QCheckBox" name="saveInfo">
<property name="text">
<string>Save Info</string>
</property>
</widget>
</item>
</layout>
</item>
Expand Down
Loading

0 comments on commit ed3e7d3

Please sign in to comment.