modifying the drawer menus

Marco Martin notmart at gmail.com
Wed Jan 6 20:29:45 UTC 2016


On Wednesday 06 January 2016, Dirk Hohndel wrote:
> I'm sure this email will mostly just expose my ignorance - but I'm OK with
> that :-)   --   I asked on IRC but I think no one was around who knew.
> 
> I want to be able to change the content of the context menu, depending on,
> err, context. Seems like a reasonable thing to want to do. So I'm sure
> there must be an easy way to do this. But that's where I'm getting stuck.

I had a particular use case in mind when i designed its api, so perhaps yours 
is slightly different.. exactly what would define the "context" you're in in 
subsurface?

the contextual actions list at the moment is done by page, ie every page (in 
subsurface the dives list would be one, dives details would be another)

so each page would have a different:

Page {
    contextualActions: [
        Controls.Action {
            text:"Action 1"
            onTriggered: print("Action 1 clicked")
        },
        Controls.Action {
            text:"Action 2"
            iconName: "folder"
        }
    ]

would this be good for your use case or you need something different?

If what you need is something different, you can go in your application main 
qml file at the declaration of ContextDrawer

contextDrawer: MobileComponents.ContextDrawer {
      id: contextDrawer
      actions: [
          Controls.Action {
                   text: "action 1"
           },
	 Controls.Action {
                   text: "action 2"
           },
         ......
      ]
}

that would override the "actions-per-page" behavior.

Lists defined this way in qml can't have elements dinamically added or 
removed, but also because of that it should also support either arrays of 
actions built in javascript, or if you need particular flexibility, a 
QLists<QAction *> arriving from the C++ part.. I have the suspicion that in 
this particular case it *may* be the most immediate way?

-- 
Marco Martin


More information about the Plasma-devel mailing list