Patch Plugin for KDevelop

Ever since I first wrote about KDevelop I've been using and contributing to this great IDE. While contributing, I have been focusing on making KDE Development as simple and integrated as possible, patching and improving the ReviewBoard plugin, the KDE provider for project imports, and other things here and there. But I had never really done a plugin from scratch, so I started looking for missing functionallity that could be provided through a plugin. At the same time, I was having trouble managing the large set of patches I have collected while maintaining Kig and trying out new patches for KDevelop itself, and that meant dropping to a Konsole and patching the sources. I then figured out I could write a plugin that would do that for me inside a KDevelop project.

The base layout of the code was taken from the KDE Examples repository, but it didn't really provide good example code for integrating a context menu item on the project view, so if for anything, this plugin could serve as an example of how to do this.  I initially had the idea to provide a UI where to select a patch, a spin box to select the number of path components to strip and apply that patch. That worked out ok, but I figured out it would be better to provide the user with feedback about the patch being selected.  I then hacked my way through Kompare's code to show a nice display of the patch content.

The code is now available at my scratch repository (yes, I have a scratch repository :) expect to see more projects there soon). After building and installing the plugin, you can start KDevelop and right click on a folder in the project view, then click on the Apply Patch menu item.

Screenshot of the Apply Patch menu item

Right click on a folder in the project view and select the Apply Patch menu item


You will now get a UI where you can select a file, select the number of path components to strip, and apply that patch. When you select a file, a Kompare view will show you the contents of that patch, which will be applied in the context of the folder you selected with the right click. Applying patches is just cool, but the real feature of this plugin is to be able to apply a patch directly from the web. In particular, this plugin allows you to apply a patch from the Review Board or BKO directly by pasting the URL into the file selection box, as shown in the screenshot below.

UI for applying a patch

Applying a patch directly from the web

After applying the patch, a new output view will show the output of the patch call. Thanks, by the way, to Millian Wolff for a fix that made it possible to display this view without crashes.

I really hope this plugin will help KDE developers when reviewing patches or applying fixes from bko. Feel free to comment and ask for features or report bugs.