Parameters to filters

Boudewijn Rempt boud at valdyas.org
Thu Aug 23 08:39:29 BST 2012


On Wednesday 22 August 2012 Aug, Inge Wallin wrote:
> I would like to add the ability to parameters to filters. My usecase is that I 
> want the user to be able to specify a path to a book cover image (normally an 
> SVG file) and have the epub filter add that to the epub file.
> 
> I wonder if anybody else have thought about this and maybe even has a design 
> thought out already.  The problem is slightly complex, involving at least the 
> following aspects:
> 
>  - In the general case we can have a whole chain of filters and it's possible 
> that more than one filter wants an option with the same name. So we need to be 
> able to specify which filter should receive each parameter.
> 
>  - We may want to send several different data types. I guess the most common 
> one would be a string or a number but in the general case it could be 
> anything. So I think a QVariant should be involved somewhere (but see below).
> 
>  - We need some code in calligraconverter to parse command line options and 
> create parameters. This would speak against using anything but strings.

I would suggest to create xml-based files that contain the settings for a filter and pass that file's name to calligraconverter, instead of specifying all params on the commandline.

>  - We need to be able to create a UI using tools or general dockers so the 
> user can control the parameters from the applications. The values need then be 
> transferred to the filters somehow.

For krita, the filter dialogs themselves make their settings persistent. Choose a quality percentage in the jpeg filter and it will get saved in the kritarc config file and restored when the dialog shows up again. Like this:

ExportConfiguration-TIFF=<!DOCTYPE params>\n<params>\n <param name="alpha">false</param>\n <param name="compressiontype">0</param>\n <param name="deflate">6</param>\n <param name="faxmode">0</param>\n <param name="flatten">true</param>\n <param name="pixarlog">6</param>\n <param name="predictor">0</param>\n <param name="quality">80</param>\n</params>\n

This is done using a serializable properties class we use everywhere in Krita.

-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl



More information about the calligra-devel mailing list