Devops and dev stuff

GSOC Update 1

GSOC is in full swing and here is my first progress update! I’ve been spending time getting familiar with the Krita code base. The first step in my project was making SVG appear as an export option to test start testing the export code. While this may seem straight forward (I certainly thought it would be) there are a few things that we’ll need to do.

First, how does Krita know what files it can import/export as? Well that is easy enough to answer, in a database. Specifically Krita has a class KisMimeDatabase that stores all available file formats Krita supports. Adding a new option to this database is fairly easy as there are plenty of examples in the KisMimeDatabase.cpp. We can mostly copy/paste how other options are added but replace that file name with svg. Neat :).

But just because its in the database doesn’t mean its a valid file format that Krita recognizes. All file formats need a corresponding impex plugin in plugins/impex/$FILE_FORMAT and to be included in plugins/impex/CMakeLists.txt. Thankfully for us since svg is already partially supported for Krita some of this work is already done. We can see in plugins/impex/svg/CMakeLists.txt that there is already definitions for svg import so now we just need to figure out the export. Thanks to wolthera (for linking) and amyspark (for creating) we have an example commit to figure out what needs to be added. Looking at that commit the additions we need to make for export are pretty similiar to whats already for import. It’s mostly the same except we add kritaimpex to the target libraries and krita_svg.desktop to the ${XDG_APPS_INSTALL_DIR}. I don’t think the .desktop file is strictly required (I think it informs linux desktops that Krita supports this file format) but we may as well add it while we’re here.

Now that we’ve added all these files to the CMakeLists we actually need to implement some of that code that Krita is looking for. Not everything, but just enough so Krita is happy and we can start testing and iterating. Outside the basic constructor/destructor we can see in other plugins that we need to implement KisImportExportErrorCode convert() and initializeCapabilities(). convert() is what actually converts between Krita’s .kra file and SVG, while initializeCapabilities() tells Krita what features SVG supports. We possibly need to implement createConfigurationWidget() but after some discovery this is used to create a pop-up widget that shows export options. We may need to implement it in the future (if converting between formats requires artists to make a decision) but thats uncertain right now. The convert and initializeCapabilities functions we add some basic stubs for so Krita finds what it expects. Finally, we also make and add plugins/impex/svg/krita_svg_export.json to the plugin ExportFactory. Honestly, this last part I am not totally sure how it works but seems it is also used to generate the export list.

OK! That’s mostly all I’ve been worked on for my gsoc project. There were many hours of troubleshooting, comparing, and testing involved but it was very satisfiying making every little bit of progress :). There are still many things to do so hopefully lots more to talk about next time!