We first open up the plasma-workspace repo, and navigate to dataengines/weather/ions/envcan. This will be the folder we’ll try to compile by itself.
To get started, we can take a look at the templates/ion-dataengine folder, which contains a template for creating a new weather ion (data source) for the weather widget. More info on the template can be found on frinring’s blog post.
Open up envcan/CmakeLists.txt and add the following to the beginning of the file:
Standard cmake stuff to begin with. The project name doesn’t really matter.
This is almost standard. This imports the extra cmake files from ${CMAKE_CURRENT_SOURCE_DIR}/cmake, templates/ion-dataengine/ contains the cmake/FindPlasmaWeatherIon.cmake file which is used for importing the Plasma Weather Ion headers/library. So we need to copy the cmake/ with the cmake/FindPlasmaWeatherIon.cmake into the envcan/ folder.
Next up we find_package() for various Qt5 and KF5 modules. The template is missing the KF5::KIO and KF5::I18n components though.
The above uses the cmake/FindPlasmaWeatherIon.cmake to import the PlasmaWeatherIon library.
More standard KDE cmake stuff, though the ECMQtDeclareLoggingCategory was not included in the template.
We took this from dataengines/weather/CMakeLists.txt (link) in order to reuse the existing KDE translations. If we we’re making a new weather ion, we’d create a new translation domain like in the template.
That’s all we need to add to the begining of the envcan/CMakeLists.txt.
We need to make 2 edits to the existing code to get this to compile.
First we need to add KF5::KIOWidgets and KF5::Plasma to
Then open up envcan/ion_envcan.h and remove the #include "../ion.h" line and add #include <plasma/weather/ion.h> in it’s place. This imports from the PlasmaWeatherIon library instead of trying to import the ion.h one directory up which we’re pretending doesn’t exist so we can compile just this folder.
Here’s the complete diff:
Compiling
You might be interested in my kmake script here. If not, just run the following:
Test it worked with:
Patching
Now we can get started on modifying the Weather Ion code without worrying about other stuff in kdeplasma-addons breaking.