modifying the drawer menus

Dirk Hohndel dirk at hohndel.org
Wed Jan 6 22:09:57 UTC 2016


On Wed, Jan 06, 2016 at 01:49:28PM -0800, Dirk Hohndel wrote:
> On Wed, Jan 06, 2016 at 10:32:59PM +0100, Marco Martin wrote:
> > > > so, if it depends from pages, you just define a different
> > > > contextualactions list for every page definition...
> > > 
> > > Currently we have one page that has two different states. You view a dive
> > > or you edit a dive. Depending on that state I want different context
> > > menus. Maybe what you are saying is "no, that really should've two
> > > different pages". Because then this would be easy and your answer shows
> > > how to do that. The challenge is that right now we do both on the same
> > > pageants simply change the visibility of some elements of the page
> > > depending on state. But I can't change the context menu depending on state
> > > 
> > > Makes sense now?
> > 
> > ok, understood.
> > having two different pages may indeed be a solution.. depends how much code 
> > duplication this leads to (in general "modes" in an ui are discouraged, but of 
> > course depends case by case).
> > 
> > or maybe you can do something on the lines:
> > 
> > Page {
> > 
> >     proeprty var viewActions: [
> >          Action {}, Action{}...
> >     ]
> >     proeprty var editActions: [
> >          Action {}, Action{}...
> >     ]
> > 
> >     contextualActions: editMode ? editActions : viewActions
> > }
> 
> That's very close to the code that I had and it didn't work, i.e. the
> context drawer always showed the first list of actions assigned. Since my
> syntax was a bit different from what you show here I'll try this, just to
> make sure I didn't stumble about my lack of QML skill
> (that, after all, was why I asked)

Sorry, should have tested first before sending the previous response.
I implemented exactly what you show above (except for the spelling of
"property", I guess), and that does not work. It tells me that it wants a
',' after the first "Action" before the '{'

If I write this as 

property list<Action> viewActions: [
	Action { }, Action { }
	]
property list<Action> editActions: [
	Action { }, Action { }
	]

it doesn't fail on syntax, but doesn't work. It always shows the
viewActions as context menu (as "view" is the initial state).

/D


More information about the Plasma-devel mailing list