I may not have blogged in a while, but I’m still programming. last week I was obsessing over keyboard shortcuts; I was bloody sick of having to use my mouse so much in plasma, especially since my poor laptop mousepad isn’t as reliable as it used to be. I was also annoyed at all the different scraps of code I saw scattered everywhere for common actions like “zoom out” and “configure $foo”. after thinking about these two problems for a while, I realised that they were actually one. I spent some time pondering the interconnectedness of all things, but eventually realised I was going to have to *write* some code instead of just thinking about it. ;)
Anyways, the root of the problem is that hardly anyone was using QActions, and where they were using them, they were just creating their own and then throwing them away. silly and wasteful. so, I gave each Applet a KActionCollection, and dropped some useful actions in there. I rounded up a bunch of code that had been creating its own actions, and made it just grab the ones from the collection. I added keyboard shortcuts to the actions. I even added some new actions for stuff like moving focus to different applets and different containments – those are only used for their keyboard shortcuts, but they go in the same little collection where I can keep an eye on them. :) Oh, and the toolbox also uses these actions now. hooray, less duplicate code!
Now, with all these actions rounded up and duplicates removed, I only needed one block of code for each change to them. when you lock plasma, the “lock widgets” text changes to “unlock widgets”, and the icon changes too. I now just have one place where this happens, and instantly the change applies to the toolbox and the contextmenu – previously the toolbox lock button didn’t change its icon at all, but now little inconsistencies like that are gone. When you lock plasma, the “add widgets” action is disabled too – one line of code and it’s gone from the toolbox and the contextmenu, and the keyboard shortcut goes away too.
Of course, I did run into a few little problems while doing this. QGrapphicsView and co. haven’t really got proper keyboard shortcut support. I can’t seem to add actions to QGraphics items. luckily, KActionCollection has a handy function to associate a widget with its actions – so, I cheat and associate an applet’s actions with the view while it has keyboard focus. The next problem was that clicking a proxywidget can give it text focus, but doesn’t give any notice of this to the rest of the graphicsscene – so, if you’re using plasma keyboard shortcuts on one applet, then click on another applet and happen to click a proxywidget (like the text entry part of the notes applet), plasma shortcuts will still apply to the previous applet. I haven’t thought of a way around that, so it’ll probably be that way until qt brings a fix. :( Then there was the realization that since the panel refuses to take focus, I can’t really use the keyboard with it. Yuck. The solution to that seems to involve changes to kwin, but I was busy and then that feature freeze snuck up and hit me over the head… so… no keyboard accessibility for the panel until 4.2 :(
There are some other things I was hoping to do that’ll have to wait until 4.2 as well. the most glaring omission is that you can’t configure the keyboard shortcuts. :/ sorry. I was so busy making them actually *work* that I didn’t have time to make them configurable, and since I bet that’d involve adding strings and other such non-freeze-compatible changes, I doubt I’d be allowed to do it while this damn freeze is in place. The next biggest thing is that we were planning to have shortcuts to jump to specific applets. that part kinda slipped my mind too, and I think it’s probably too late now. maybe it’d be possible for certain applets to put in hardcoded shortcuts (I’m thinking kickoff here) but you won’t see user-settable ones until 4.2.
Some of these shortcuts are discoverable by looking at contextmenus, but others are very well hidden. their default values are pretty arbitrary, too. so… well, here’s a list.
add widgets: ctrl-a
lock widgets: ctrl-l
zoom out: ctrl--
zoom in: ctrl-= or ctrl-+
next applet: ctrl-n
prev applet: ctrl-p
next containment: shift-ctrl-n
prev containment: shift-ctrl-p
applet settings: ctrl-s
containment settings: shift-ctrl-s (doesn't work on the default containment yet. should be fixed soon.)
remove applet: ctrl-r
add activity: shift-ctrl-a
I really wish I’d been able to get more code written… but some keyboard accessibility is better than none. :)