helloSystem / QKeySequenceOverride

Override the QKeySequence::toString() function in Qt to represent keyboard shortcuts with graphical symbols
2 stars 2 forks source link

Find a way to do this without LD_PRELOAD #3

Open probonopd opened 2 years ago

probonopd commented 2 years ago

Since @antony-jr has been injecting menu items using Qt plugins rather than LD_PRELOAD I wonder if it would be possible to do what this repo does but as a Qt plugin. Would feel a bit cleaner to me, although the current solution appears to work fine.

antony-jr commented 2 years ago

Qt plugins are meant for that. If you have a main program which would look into some specific directory and check for certain metadata to be present in the qt plugin then you can simply load it and run it. The plugin will have access to the main program's memory and context.

This is what the Qt Creator does for changing styles when you put a style plugin near it.

The logic is that the qt plugin implements a abstract class. You should have definition to this abstract class and can cast it to check if the correct type of plugin you desire is loaded.

probonopd commented 2 years ago

Thanks @antony-jr so do you think we could override QKeySequence::toString() in https://github.com/helloSystem/QtPlugin/? Where would we need to put the code? Or would we need another type of Qt Plugin, not a Qt Platform Plugin?

antony-jr commented 2 years ago

Thanks @antony-jr so do you think we could override QKeySequence::toString() in https://github.com/helloSystem/QtPlugin/? Where would we need to put the code? Or would we need another type of Qt Plugin, not a Qt Platform Plugin?

We could try.

probonopd commented 2 years ago

Where would one have to put the code?