Discussion:
Global shortcut proposal
Mark
2011-10-18 18:33:57 UTC
Permalink
Hi,

I want to adjust QShortcut to use it for global shortcuts as well and would
like to lay out my idea on how i intend to do that. Any feedback on it would
be more then welcome.

The first thing to do is add an enum value to Qt::ShortcutContext
http://doc.qt.nokia.com/latest/qt.html#ShortcutContext-enum:
Qt::SystemShortcut (that becomes value 5) with the description: "The
shortcut is active in a system wide context when the application is
running."

Next up is probably (being optimistic here) tweaking the eventFilter of the
QShortcut class to act on global shortcuts for Windows, Linux and MAC when
the Qt::SystemShortcut enum is set.

Now some questions pop up. It has been said that (global) shortcuts should
probably be handled through the window manager. In Qt's case that means (?)
through LightHouse right?
But how am i supposed to do that? Where is lighthouse even hidden?
And what happened to QtCore? Is that now QtBase?

So where do i get started with this?
And I've never build Qt 5 yet nor did i ever contribute actual code to it..
so that's gonna be interesting.

A lot of questions ;)

Thanx in favor,
Mark
Mark
2011-10-21 17:50:33 UTC
Permalink
Post by Mark
Hi,
I want to adjust QShortcut to use it for global shortcuts as well and would
like to lay out my idea on how i intend to do that. Any feedback on it would
be more then welcome.
The first thing to do is add an enum value to Qt::ShortcutContext
Qt::SystemShortcut (that becomes value 5) with the description: "The
shortcut is active in a system wide context when the application is
running."
Next up is probably (being optimistic here) tweaking the eventFilter of the
QShortcut class to act on global shortcuts for Windows, Linux and MAC when
the Qt::SystemShortcut enum is set.
Now some questions pop up. It has been said that (global) shortcuts should
probably be handled through the window manager. In Qt's case that means (?)
through LightHouse right?
But how am i supposed to do that? Where is lighthouse even hidden?
And what happened to QtCore? Is that now QtBase?
So where do i get started with this?
And I've never build Qt 5 yet nor did i ever contribute actual code to it..
so that's gonna be interesting.
A lot of questions ;)
Thanx in favor,
Mark
Anyone?
Olivier Goffart
2011-10-21 20:02:49 UTC
Permalink
Post by Mark
Hi,
I want to adjust QShortcut to use it for global shortcuts as well and
would like to lay out my idea on how i intend to do that. Any feedback
on it would be more then welcome.
The first thing to do is add an enum value to Qt::ShortcutContext
Qt::SystemShortcut (that becomes value 5) with the description: "The
shortcut is active in a system wide context when the application is
running."
Next up is probably (being optimistic here) tweaking the eventFilter of
the QShortcut class to act on global shortcuts for Windows, Linux and
MAC when the Qt::SystemShortcut enum is set.
This was discussed before, and the problem is that one would want a framework
to register the global shortcut into a central place on the system that handle
conflicts in shortcut and proper configuration.
KDE has such a thing, i don't know about the other systems.
Post by Mark
Now some questions pop up. It has been said that (global) shortcuts
should probably be handled through the window manager. In Qt's case
that means (?) through LightHouse right?
Not really.
Qt application need to work on all the platform and window manager.
Post by Mark
But how am i supposed to do that? Where is lighthouse even hidden?
And what happened to QtCore? Is that now QtBase?
Lighthouse is the codename for QPA. That is, the windowing system abstraction
layer and its plugins.
The abstraction layer is in QtGui (all the files with _qpa), the plugins are
in src/plugins/platforms

Considering global shortcut is part of that, i guess you need to add some
interface in the abstraction layer, and then a specific implementation for
each platform in the plugins.
Note that this would only be the "client" code.


The server side framework to handle the registration or the conflicts is
outside of the scope of Qt.
Post by Mark
So where do i get started with this?
Checkout the code, open the editor :-)
Post by Mark
And I've never build Qt 5 yet nor did i ever contribute actual code to
it.. so that's gonna be interesting.
Everything has a begining :-)


But you should definitively look at previous implemntations (such as the one
in qxt). And in particular how the kde infrastructure works, because it would
be nice if it was integrated into it.

That said, being perfect the first time is not possible.
Mark
2011-10-21 21:50:29 UTC
Permalink
Post by Olivier Goffart
Post by Mark
Hi,
I want to adjust QShortcut to use it for global shortcuts as well and
would like to lay out my idea on how i intend to do that. Any feedback
on it would be more then welcome.
The first thing to do is add an enum value to Qt::ShortcutContext
Qt::SystemShortcut (that becomes value 5) with the description: "The
shortcut is active in a system wide context when the application is
running."
Next up is probably (being optimistic here) tweaking the eventFilter of
the QShortcut class to act on global shortcuts for Windows, Linux and
MAC when the Qt::SystemShortcut enum is set.
This was discussed before, and the problem is that one would want a framework
to register the global shortcut into a central place on the system that handle
conflicts in shortcut and proper configuration.
KDE has such a thing, i don't know about the other systems.
Post by Mark
Now some questions pop up. It has been said that (global) shortcuts
should probably be handled through the window manager. In Qt's case
that means (?) through LightHouse right?
Not really.
Qt application need to work on all the platform and window manager.
Post by Mark
But how am i supposed to do that? Where is lighthouse even hidden?
And what happened to QtCore? Is that now QtBase?
Lighthouse is the codename for QPA. That is, the windowing system abstraction
layer and its plugins.
The abstraction layer is in QtGui (all the files with _qpa), the plugins are
in src/plugins/platforms
Considering global shortcut is part of that, i guess you need to add some
interface in the abstraction layer, and then a specific implementation for
each platform in the plugins.
Note that this would only be the "client" code.
I don't get what you mean here.. Don't you just mean QShortcut?
The server side framework to handle the registration or the conflicts is
outside of the scope of Qt.
Post by Mark
So where do i get started with this?
Checkout the code, open the editor :-)
Post by Mark
And I've never build Qt 5 yet nor did i ever contribute actual code to
it.. so that's gonna be interesting.
Everything has a begining :-)
But you should definitively look at previous implemntations (such as the one
in qxt). And in particular how the kde infrastructure works, because it would
be nice if it was integrated into it.
That said, being perfect the first time is not possible.
I'm kinda confused and don't know if i get you or not :p
Are you suggesting to:
- have a client app (the one KDE has for defining global key shortcuts)
- have the Qt app (the app itself so i guess you can call this "server") to
"define" which keys can be set as global keys..?

Am i interpreting it correctly?

Right now i make a todo application and i want a new window to pop up when i
press the CTRL + ALT + T combination (that stands for creating a new task in
my app). And i really just want to do that in pure Qt and that app only, not
by having a client - server model like described above..

On the other hand, if Linux, Windows and Mac all had some app like KDE's
global shortcut manager then i would certainly like to use it. But that's
not the case for at least Windows. KDE has it, don't know for mac.

Regards,
Mark
Olivier Goffart
2011-10-21 23:08:42 UTC
Permalink
Post by Mark
I'm kinda confused and don't know if i get you or not :p
That's fine, i'm confused too, i don't know if i get myself.
Post by Mark
- have a client app (the one KDE has for defining global key shortcuts)
- have the Qt app (the app itself so i guess you can call this "server") to
"define" which keys can be set as global keys..?
Am i interpreting it correctly?
Basically, but i meant it the other way.
The Qt application is the client.
Post by Mark
Right now i make a todo application and i want a new window to pop up when i
press the CTRL + ALT + T combination (that stands for creating a new task
in my app). And i really just want to do that in pure Qt and that app only,
not by having a client - server model like described above..
Yes of course.
Post by Mark
On the other hand, if Linux, Windows and Mac all had some app like KDE's
global shortcut manager then i would certainly like to use it. But that's
not the case for at least Windows. KDE has it, don't know for mac.
Yes, if Windows don't have it, then it is not Qt's scope to implement it. and
you can just register your shortcut as global just like that.

We just need to integrate into existing infrastructure.
l***@nokia.com
2011-10-22 08:49:39 UTC
Permalink
A few additional comments from my side:

* Global shortcuts need to be registered with the windowing system. That
implies that we'll need an API in Lighthouse (QPlatform* classes). The
default implementation could simply register the shortcut as an
application global shortcut as the best fallback.

* The QShortcut class will stay in libQtWidgets. But QShortcutMap is in
Gui (pending a few changes I have open in gerrit), and should be the
integration point. It's private API, but I'd like to add a QML object for
registering shortcuts on top of it to complement the QWidget based
QShortcut.

* As someone already noted, we'll most likely need a slightly different
API for registering global shortcuts than the existing one, as the
registration can fail if another app has already grabbed that shortcut.
One option, could be to clean up the existing QShortcutMap API, add code
for global shortcuts to it and make it accessible through QGuiApplication.
But I'm not yet sure this would be the best option.

Cheers,
Lars
Post by Olivier Goffart
Post by Mark
I'm kinda confused and don't know if i get you or not :p
That's fine, i'm confused too, i don't know if i get myself.
Post by Mark
- have a client app (the one KDE has for defining global key shortcuts)
- have the Qt app (the app itself so i guess you can call this "server") to
"define" which keys can be set as global keys..?
Am i interpreting it correctly?
Basically, but i meant it the other way.
The Qt application is the client.
Post by Mark
Right now i make a todo application and i want a new window to pop up when i
press the CTRL + ALT + T combination (that stands for creating a new task
in my app). And i really just want to do that in pure Qt and that app only,
not by having a client - server model like described above..
Yes of course.
Post by Mark
On the other hand, if Linux, Windows and Mac all had some app like KDE's
global shortcut manager then i would certainly like to use it. But that's
not the case for at least Windows. KDE has it, don't know for mac.
Yes, if Windows don't have it, then it is not Qt's scope to implement it. and
you can just register your shortcut as global just like that.
We just need to integrate into existing infrastructure.
_______________________________________________
Qt5-feedback mailing list
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
Robin Burchell
2011-10-21 18:07:06 UTC
Permalink
Hi Mark,

(note: now that http://qt-project.org is up and running, I'd suggest
you subscribe there and start directing questions to those MLs,
hopefully e.g. the development list will see some activity..)
Post by Mark
I want to adjust QShortcut to use it for global shortcuts as well
Nice one!
Post by Mark
Now some questions pop up. It has been said that (global) shortcuts should
probably be handled through the window manager. In Qt's case that means (?)
through LightHouse right?
This is going to be platform-dependent, which will definitely involve
lighthouse.
Post by Mark
But how am i supposed to do that? Where is lighthouse even hidden?
You probably want to be looking at the qtbase repository,
specifically, qtbase/src/plugins/platforms/.
Post by Mark
And what happened to QtCore? Is that now QtBase?
Modules and repositories are not a 1:1 mapping, for various reasons
and I'm not the best person to talk about that. But basically, qtbase
is where an awful lot of stuff like qtcore and the platform plugins
live, so that's a good first bet fore 'core' functionality. Most of
the others are fairly self-explanatory, I think, perhaps with the
exception of 'qtpim' which appears to contain the Contacts, Organizer,
etc functionality formerly from Mobility.
Post by Mark
So where do i get started with this?
Assuming you have a working Qt5 build already: have at it. Hack away,
write autotests for your code as much as possible, test your
functionality by writing an example app(s) using it... whatever you
want.

If you don't, then take a look at the README in the Qt5 repo for help
on getting set up (note: you apparently also need to pass '-qpa' to
configure as of recently, I plan to submit a change adding some more
docs to all of that. If configure fails, try adding a '-v' parameter,
too, to see why.)

Pop onto #qt-labs on freenode if you aren't there already, too. Lots
of helpful folks around, just be a bit patient for answers,
particularly if you're asking outside of european office hours.. :)

BR,

Robin
Mark
2011-10-21 18:54:10 UTC
Permalink
Post by Robin Burchell
Hi Mark,
(note: now that http://qt-project.org is up and running, I'd suggest
you subscribe there and start directing questions to those MLs,
hopefully e.g. the development list will see some activity..)
Another ml..
Post by Robin Burchell
Post by Mark
I want to adjust QShortcut to use it for global shortcuts as well
Nice one!
Post by Mark
Now some questions pop up. It has been said that (global) shortcuts
should
Post by Mark
probably be handled through the window manager. In Qt's case that means
(?)
Post by Mark
through LightHouse right?
This is going to be platform-dependent, which will definitely involve
lighthouse.
Post by Mark
But how am i supposed to do that? Where is lighthouse even hidden?
You probably want to be looking at the qtbase repository,
specifically, qtbase/src/plugins/platforms/.
oke, cool. Good to see that all key shortcuts are already in those platform
plugins. Now i guess i need to figure out where you guys have hidden the
QShortcut source ;) and just start hacking and trying.
Post by Robin Burchell
Post by Mark
And what happened to QtCore? Is that now QtBase?
Modules and repositories are not a 1:1 mapping, for various reasons
and I'm not the best person to talk about that. But basically, qtbase
is where an awful lot of stuff like qtcore and the platform plugins
live, so that's a good first bet fore 'core' functionality. Most of
the others are fairly self-explanatory, I think, perhaps with the
exception of 'qtpim' which appears to contain the Contacts, Organizer,
etc functionality formerly from Mobility.
Thanx for explaining that.
Post by Mark
So where do i get started with this?
Assuming you have a working Qt5 build already: have at it. Hack away,
write autotests for your code as much as possible, test your
functionality by writing an example app(s) using it... whatever you
want.
Nope, not done a thing with it yet.
Post by Robin Burchell
If you don't, then take a look at the README in the Qt5 repo for help
on getting set up (note: you apparently also need to pass '-qpa' to
configure as of recently, I plan to submit a change adding some more
docs to all of that. If configure fails, try adding a '-v' parameter,
too, to see why.)
Ahh, black magic ;) Will do.
Post by Robin Burchell
Pop onto #qt-labs on freenode if you aren't there already, too. Lots
of helpful folks around, just be a bit patient for answers,
particularly if you're asking outside of european office hours.. :)
Will do as well. Haven't been there in a while.

BR,
Post by Robin Burchell
Robin
Thank you for your reply.
Robin Burchell
2011-10-21 18:57:02 UTC
Permalink
Post by Mark
Post by Robin Burchell
(note: now that http://qt-project.org is up and running, I'd suggest
you subscribe there and start directing questions to those MLs,
hopefully e.g. the development list will see some activity..)
Another ml..
Well, yeah, change is annoying. It's been coming a long while, and
it's a good thing it's here though. :)

See Lars' mail at
http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-October/001969.html
for info.
Post by Mark
Thank you for your reply.
NP!
Loading...