{February 7, 2009}   adventures in plasmaland, part 4

tokamak is going well, and I’m hacking again. I decided it’s time for my victorycalendar plasmoid to get a config dialog. to start off, we’ll just try to configure the text of the label.

[oops. it seems I forgot to blog about my last bit of work. quick detour: it now uses flag icons and cycles between three colours when clicked. didn’t take much code. here’s the diff.]

sooo… we need a config file. from the package spec we see that it should be at config/main.xml and from the kconfigxt tutorial we’ll learn what to put in it.

I’m not going to repeat that tutorial, so go read it. at least the bit on the contents of the xml file. ignore the c++ generation stuff – obviously we’re not using c++. :)

so I’ve written a very simple config file now (I copied the crud at the top from an existing file). all it has is an entry for the label. next step: making a config ui to set it with.

this one goes in ui/config.ui, and of course I’ll be making it in Designer.

it’s pretty easy: a label and a lineedit. the important bit is that the linedit is called kcfg_label, to match the “label” name in main.xml.

so… er… I have these files. now what?
now it crashes, that’s what. :) kconfigdialogmanager doesn’t seem to like my config ui.
…turned out to be something that needed adding in libplasma, and aaron fixed it for me. :)

anyways. now we have a config dialog, and it saves its one setting… time to actually *use* that setting. :)

taskName.text = plasmoid.readConfig("label");

that gets us the right value on startup. now we need it to update when hte config is changed. for this, we implement the configChanged function, and… umm… do something. something like this:

plasmoid.configChanged = function()
taskName.text = plasmoid.readConfig("label");

except… that function isn’t getting called. looks like I hit another bug. aaand that’s fixed too now. :)

whee! now the text is all nice and configurable. I think the next step will be to add multiple rows.

oh, btw – I won’t be working on the kconfigmenu plasmoid any more. sebsauer beat me to it: if you add the traditional app launcher and configure it to hte system settings view, you get exactly what I was aiming for. :) this is a good thing; I have no shortage of stuff I want to work on.

finto says:

it would be nice to have this as a tutorial for qtscript plasmoids!

Jesper says:

Man! With more people like you KDE might even end up being useful!!!

Why? The “I-pretend-to-be-semi-clueless-user-that-expect-things-to-work” approach combined with clued-in bug reports. Perfect tester. Too few of those in the FOSS world….

Keep it up!

[…] dot article. the first day was all presenations. the second day was (for me) all scripting, which I already blogged about, and I also repeated my presentation for some locals who missed […]

Comments are closed.

et cetera
%d bloggers like this: