4.4 API: AbstractToolBox::ToolType

Aaron J. Seigo aseigo at kde.org
Mon Jan 4 06:35:08 CET 2010


hi ...

this one is probably more for Marco and Chani as they are the two other people 
who have touched the action and toolbox code the most :)

right now it's impossible to order the actions shown in toolboxes in any sane 
fashion since we don't know what the actions do and therefore how to order 
them.

the actions added to the toolboxes come from all over the place and are 
sometimes added by code very far from that which created the actions, meaning 
that the knowledge of what the action is no longer exists at the moment it is 
added to the toolbox.

after playing around with a few different approaches this evening (with the 
first two attempts running into brick walls due to the rather crazy nature of 
"actions created by various plugins/classes" combined with "actions assembled 
by various other plugins/classes"), i settled on an enum in AbstractToolBox:

    enum ToolType {
        AddTool = 0,
        ConfigureTool = 100,
        ControlTool = 200,
        MiscTool = 300,
        DestructiveTool = 400,
        LastToolType = DestructiveTool + 1
    };

then one sets the data on a QAction with one of these values and the toolbox 
can use it to figure out what to do. this prevents any changes in the Plasma 
API, does not require a QAction subclass and seems to work pretty well.

i now have an orderly toolbox on my desktop.

i am not overly satisfied with using QAction::data() as such a metadata 
dumping ground but i couldn't think of another more elegant solution. anyone 
else have ideas?

i'd like this to go into 4.4 as the desktop toolbox is a right mess at the 
moment.

(as a side bonus, i've removed a number of uses of the deprecatd 
Plasma::Animator API from the desktop toolbox :)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list