dlangui icon indicating copy to clipboard operation
dlangui copied to clipboard

Consider changing the way of Action class usage

Open FreeSlave opened this issue 6 years ago • 2 comments

The current Action class has that big problem that it requires user-provided id forcing a user to use magic numbers or declare constants. Both are bad. Magic numbers are bad for obvious reason and named constants are bad because user has to declare a constant and use almost the same name for Action variable anyway. Also both are not scalable.

So for the version 1.0 please consider the changing of Action in the way that it will not require user-provided id. Also would be much better if user could connect Action to the delegate instead of using of action listener with switch-case.

FreeSlave avatar Oct 08 '17 00:10 FreeSlave

Good idea. But it's hard to propose good solution.

buggins avatar Oct 09 '17 06:10 buggins

Maybe using signals? With variant-like argument which replaces the current *Param properties. This should allow to separate action from the passed data. I.e. arguments should not be stored (or at least should not persist) in Action object.

As for default action ids the new entity can be created - ActionInfo which will contain such information as translatable text, system-dependent shortcut and icon (resource id?). Then add Action constructor specially for default action ids and/or for ActionInfo(and add function like getActionInfoForDefaultId). The idea is to distinguish between actions and related data.

FreeSlave avatar Oct 09 '17 09:10 FreeSlave