Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: Redesign UI based on docking system #12241

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

chaoticgd
Copy link
Contributor

@chaoticgd chaoticgd commented Jan 27, 2025

Description of Changes

I have redesigned the debugger's UI based on the KDDockWidgets docking system library.

Screenshot:

Screenshot_20250226_221845

Highlights:

  • Users can now create custom layouts and switch between them using the tabs to the right of the menu bar.
  • Layouts are saved as JSON as this is the format that KDDockWidgets uses. In addition, individual dock widgets can save their own custom JSON properties e.g. the start address of the memory view.
  • Each dock widget has its own debug interface pointer. By default, this is inherited from the layout, but you can override this on a per-dock widget basis.
  • The CpuWidget class has been removed. Dock widgets don't know about other dock widgets, and there's no central location where you have to rig them up with a hundred connect calls to make them work together.
  • It's possible to open multiple dock widgets of the same type, and I've added an event system that allows these widgets to communicate. One feature of this is that if you open a context menu to go to an address, you can choose which dock widget you want to send the event to. For example, you could have two different memory views looking at two different areas of memory.
  • The debugger no longer has to be restarted when changing themes. The issue was that the the stylesheet used to apply the monospace font wasn't being reapplied.
  • You can now increase and decrease the font size.
  • KDDockWidgets uses RTTI (dynamic_cast). I briefly discussed this with some of the other contributors and everyone seemed to be okay with enabling RTTI, so that's what I've done. Since RTTI was available I also used it in the events system, but I could pretty easily rewrite that if it ends up being a problem (although removing RTTI from KDDW would probably be more involved).
  • I made a prototype version using Qt Advanced Docking System which featured a fancy stylesheet. It would be possible to implement such a theme using KDDW too, although the developer recommends against using stylesheets so I think it would be better left for a future PR.

Rationale behind Changes

I feel like the current design has been limiting the kind of improvements I can make to the debugger.

As for the choice of library, there were three to pick from: Qt's own QDockWidget class, Qt Advanced Docking System and KDDockWidgets.

QDockWidget isn't really appropriate since the dock widgets behave more like oversized toolbars surrounding an unmoving central widget rather than a tree of splitters.

I evaluated Qt Advanced Docking System but dropped it due to poor Linux compatibility and extremely poor Wayland compatibility.

KDDockWidgets seems like the overall best pick. Best feature set, best platform compatibility, and it's backed up by KDAB.

Suggested Testing Steps

Go through all the features in the debugger, and make sure they all still work. I've rewritten a lot of code, and I'm sure I've forgotten something.

@TellowKrinkle
Copy link
Member

BTW for the final version, you should link to kddockwidgets as a system library and add it to the dependency build scripts instead of including the source here. This should also allow you to not enable rtti/exceptions on the rest of PCSX2.

@chaoticgd
Copy link
Contributor Author

BTW for the final version, you should link to kddockwidgets as a system library and add it to the dependency build scripts instead of including the source here. This should also allow you to not enable rtti/exceptions on the rest of PCSX2.

This is a good idea.

@chaoticgd chaoticgd force-pushed the debugger_docking branch 2 times, most recently from de69dba to cdc89aa Compare January 29, 2025 15:45
@chaoticgd
Copy link
Contributor Author

chaoticgd commented Jan 29, 2025

I've switched to pulling in KDDockWidgets in the build-dependencies scripts, and I agree that regardless it's better, but it doesn't seem to be solving the problem with exceptions/RTTI. Whenever it enters a dynamic_cast in KDDW it just aborts with RTTI disabled. Does anyone have experience with this? Note that while I'm not currently doing this, it may be necessary to inherit from some of the KDDW types to customize some of the docking widgets in the future. If it's not feasible I could just develop a patch.

@TheLastRar
Copy link
Contributor

A google search found this stackoverflow answer,
Based on the above, any PCSX2 classes that inherit from KDDW would lack the RTTI information, but KDDW might expect it as the base classes would have RTTI info.

You are inheriting a KDDW class from within PCSX2 (DebuggerWindow inherits from KDDockWidgets::QtWidgets::MainWindow)
Is KDDW using RTTI functions on this class?

@chaoticgd
Copy link
Contributor Author

chaoticgd commented Jan 29, 2025

You are inheriting a KDDW class from within PCSX2 (DebuggerWindow inherits from KDDockWidgets::QtWidgets::MainWindow) Is KDDW using RTTI functions on this class?

Ah yes, I forgot about that. It does.

@chaoticgd
Copy link
Contributor Author

It seems we have two options: Either I develop a patch for KDDockWidgets to remove the uses of dynamic_cast, or we enable RTTI for pcsx2-qt. What would you all prefer I do?

@chaoticgd chaoticgd force-pushed the debugger_docking branch 11 times, most recently from dbee3aa to f4790f9 Compare February 5, 2025 18:53
@chaoticgd chaoticgd force-pushed the debugger_docking branch 5 times, most recently from ef51360 to 44d7331 Compare February 13, 2025 02:12
@chaoticgd
Copy link
Contributor Author

This is now ready for testing and review!

@chaoticgd chaoticgd marked this pull request as ready for review February 26, 2025 23:52
Copy link
Contributor

@TheLastRar TheLastRar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I spotted a while back

@@ -30,6 +30,9 @@
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QtToolOutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QtIncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QtIncludeDir)\QtCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QtIncludeDir)\QtGui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QtIncludeDir)\QtWidgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming kddockwidgets needs this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I could make a PR to KDDW to fix it later but for now I think this is okay.

@chaoticgd chaoticgd force-pushed the debugger_docking branch 3 times, most recently from 083b189 to a07ee99 Compare February 27, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants