4.4 API: AbstractToolBox::ToolType

Marco Martin notmart at gmail.com
Mon Jan 4 10:13:54 CET 2010


On Monday 04 January 2010, Aaron J. Seigo wrote:
> 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
>     };

hmm, why increments of 100 each one? also LastToolType -> UserTool?

> 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?

well, the abstracttoolbox is new in 4.4, so its api can still be changed, we 
could have addAction(action, type);
or what about a simple addAction(action, int weight)? but it would give users 
too much power and everyone would think his action is more important than the 
others i guess...

> 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 :)
> 
yay!

-- 
Marco Martin


More information about the Plasma-devel mailing list