Sven Langkamp sven.langkamp at
Mon May 14 22:45:11 UTC 2012

On Sat, May 12, 2012 at 4:54 PM, Dmitry Kazakov <dimula73 at> wrote:

> The commands at I was talking about are not QUndoCommands. It's also not
>> on the same level as the strokes framework.
>> QUndoCommand is too low-level. Action might map undo commands that are
>> missing information that is needed for recording e.g. the selection tools
>> use a normal transaction. Beside that I don't want to add xml loading and
>> saving code to every undo command.
> I agree that QUndoCommand might be a bit too lowlevel thing. But I think
> it can be (and should be) done in the constraints of the strokes framework
> as far as possible. We don't have enough manpower to introduce one more
> huge system on the top of the strokes.
> What I want to say is that while designing this system I thought about the
> recording as well. But there was one flaw: I was thinking about usual tool
> strokes and processings mostly, and I didn't think about our command-based
> actions that much. That is why the interface of the commands didn't change
> much since the introduction of the strokes. As a result, the strokes fit
> perfectly for recording of the tool strokes and processings, but there are
> still several flaws with recording of commands and emitting commands'
> dialogs (about both you wrote about).
> Runners are on a much higher level than the strokes framework. For example
>> a possible runner could be the current KisLayerManager.
> The only thing that is higher than the strokes framework is configuration
> Dialog for an action. All the rest is exactly what the framework was
> designed for. Yes, currently, the commands are handled separately and you
> would have to introduce toXML/fromXML methods for each command to record
> them. I totally agree that this is not the best way to record it. But we
> can easily change it to any way we need. This is a matter of adding one
> strategy class to the strokes system. We just need to agree what we need
> and design it.
>> For example if you want to scale a layer:
>> 1) Dialog saves the values into a KisPropertiesConfiguration of a
>> command, id is set to e.g. "scaleLayer"
>> 2) Command is then send to the "command switch", that looks at the and
>> looks up the runner for id "scaleLayer"
>> 3) Command is then send to the KisLayerManager, which reads command id
>> "scaleLayer" from which is knows the function to call and the values to read
>> 4) KisLayerManager reads the values and calls KisLayerManager::scaleLayer
>> Recording happens in step 2, when the command goes through the "command
>> switch". Recording can't happen in step 4 as we have just transactions at
>> that point and no information about the original dialog values anymore.
> Yes, it is a good point that we lose original dialog values. Still there
> is no need to implement one new system as most of this can be done using
> strokes. The point is that it does already implement most the terms you
> wrote about. We just don't use it yet.
> How it can be achieved in the constraints of the strokes [0]:
> 1) The caller asks KisStrokeStrategyFactoryRegistry for the factory of
> "ScaleLayer" stroke.
> 2) The factory does the following: i) calls image->barrierLock() to fetch
> right size information about the image; ii) calls image->unlock(); iii)
> fires up the configuration dialog.
> 3) The factory creates the stroke strategy for the "ScaleLayer" stroke
> (usual undo command based stroke)
> 4) The factory uploads the XML data about the stroke into the strategy
> 4) The factory starts a new stroke and populates it with commands
> 5) The strokes system calls the stroke strategy's method toXML, which
> saves the data
> Comment:
> For each action we create one (!) class only: KisStrokeStrategyFactory.
> The factory creates a simple undo-command-based stroke, forms XML, passes
> it to the stroke strategy, then populates the strategy with the commands.
> Later, when the stroke is finished, the framework asks the strategy for the
> XML and it returns the value formed by the factory.
> The advantage of this approach is that we shouldn't change anything and
> only need to add one class per action. More than that this approach will
> not demand us to add toXML/fromXML to the undo commands: you are right,
> commands are too lowlevel for that.
> Btw, take into account, that the strokes framework is capable of canceling
> the tasks! It works right now (and is tested in unittests), but it isn't
> connected anywhere to the UI because of the problems with shortcuts in our
> tools.
> If you agree that we implement it this way we can discuss it further and
> assign the tasks ;). I can do the work of adding gathering the XML into the
> stroke system (it shouldn't be much of work) and create base classes for
> the factories.
> [0] -

I'm not sure why you want to do step 1. The stroke would be empty at that
point and only be used much later.

The XML data you mention could be much easier be done with the
KisPropertiesConfiguration. There is no way around it as we have to save
the input values at some point. This should also be used by scripts and
macros I think.

I'm not sold on the undo command based stroke. These tend to really make
the code more complicated and I would prefer if we could make this more
simple. Might be better to base it on KisStrokeJob. Btw we really need more
documentation for the Strokes system, without it's pretty hard to grasp
what the classes do or what sequentiality and exclusivity do.

One class for each action sounds very heavy. We have probably over a
hundred action that are possible and I think we should keep the needed code
to a minimum. Maybe we need to pick some simple action and then think it
through and check which changes would be needed. We really need to get it
right before the big porting starts.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the kimageshop mailing list