PDA

View Full Version : Do we need 'QMouseShortcut', or does 'QAction' suffice ?



rickst29
13th August 2012, 03:49
Having completed 'more mouse buttons' for Qt5, I want to create 'mouse shortcuts' for Qt 5.1.

Here is first queston for more experienced USERS of Qt: Do we even need me to create a 'QMouseShortcut' class? Mouse buttons are like gestures, I think, and with the capability to keep gesture Actions invisible (if you don't want them appearing in menus, butons, etc.) then they can work just like shortcuts? Am I right about that? Or does QMouseSHortcut still provide something which is impossible to duplicate via QAction?

Here is my second question: Do I need to define a class, QMouseSequence, withe the ability to create and destory sequences without reference to an Action? In my scenario, the API for QMouseSHortcuts would be managed by the QMouseSHortcutMap class. That's a singleton class created by a QtGuiApplication, which keeps track of MouseSequences, their owning Actions, and organizes them into tables for fast lookup. The only public method involving the individual Class instance would be:

QMouseShortcutEntry* QMouseShortcutMap::getShortcutEntry(Qt::Mousebutto n button, bool doubleClick, Qt::MouseButtons heldButtons, Qt::Modifiers heldModifiers);
The map will search the tables and return a reference to the the existing instance, if it has already been built. If it doesn't yet exist, then it will be created, and a reference to the new entry will be returned.
(Managed this way, the tables within QMouseShortcutMap will have no duplicates, and entries live for the life of the application -- destruction will occur from within the QMouseShortcutMapPrivate destructor.)

As you can tell form that signature, A unique QMouseSequence doesn't have to consist of only a button click Action: You will be able to have many different Actions involving Qt:BackButton, by like this:
- one seuqence for Qt::BackButton clicked alone.
- another sequence for Qt::BackButton doublclicked alone.
- more sequences for clicking Qt::BackButton, while HOLDING DOWN Qt::LeftButton (and/or Qt::RightButton, and or Qt::MiddleButton).
- more sequences for double-clicking Qt::BackButton, with held mouse buttons.
- Sequences for single-click with any combination of kebyarod modifiers (Qt::ShiftModifier, and/or Qt::AltModifier .... ) and more Sequences for doublecick while holding keyboard modifier(s) with your other hand....


But I think that they can be defined in QActions. Getting a reference is only a convenience, allowing the programmer to specify a QAction's MouseSequnce via address reference, instead of typing the whole specification every time.

Does this work, or am I missing something? I don't think that there's any i10n involvement in pressing mouse buttons, and I don't want to get into 'Standard Buttons' which self-modify the sequence according to platform (Windows, OS-X, X11/XCB).