Fix #20826 - Numpad numbers no longer work to select note duration.

Fixed by blocking the creation (and pooling) of QAction creation for shortcuts with multiple alternatives in different states (like the 'common' and TAB-specific variants of "pad-note-..." shortcuts)

A rather detailed description of the implementation (regarding both the original, faulty, implementation and this fix) has been added to the mscore/shortcut.h file
This commit is contained in:
Maurizio M. Gavioli 2013-04-27 00:42:55 +02:00
parent 5786bb4b43
commit df32dee74c
3 changed files with 53 additions and 1 deletions

View file

@ -491,7 +491,8 @@ MuseScore::MuseScore()
ag->setExclusive(false);
foreach(const Shortcut* s, Shortcut::shortcuts()) {
QAction* a = s->action();
ag->addAction(a);
if (a)
ag->addAction(a);
}
addActions(ag->actions());
connect(ag, SIGNAL(triggered(QAction*)), SLOT(cmd(QAction*)));

View file

@ -235,6 +235,9 @@ QAction* Shortcut::action() const
if (_action)
return _action;
if (_state == STATE_NEVER)
return 0;
_action = new QAction(_text, 0);
_action->setData(_key);

View file

@ -14,6 +14,54 @@
#ifndef __SHORTCUT_H__
#define __SHORTCUT_H__
/*---------------------------------------------------------
NOTE ON ARCHITECTURE
The Shortcut class describes the basic configurable shortcut element.
'Real' data are contained in 2 static member variables:
1) sc[], an array of Shortcut: contains the default, built-in data for each shortcut
except the key sequences; it is initialized at startup (code at the begining of
mscore/actions.cpp)
2) _shortcuts, a QMap using the shortcut xml tag name as hash value: is initialized from
data in sc via a call to Shortcut::init() in program main() (mscore/musescore.cpp).
This also load actual key sequences either from an external, hard-coded, file with
user customizations or from a resource (<= mscore/data/shortcuts.xml), if there are
no customizations.
Later during startup, QAction's are derived from each of its elements and pooled
in a single QActionGroup during MuseScore::MuseScore() costructor (mscore/musescore.cpp)
ShortcutFlags:
To be documented
State flags:
Defined in mscore/global.h (ScoreState enum): each shortcut is ignored if its _flags mask
does not include the current score state. This is different from (and additional to)
QAction processing performed by the Qt framework and happens only after the action has
been forwarded to the application (the action must be enabled).
The STATE_NEVER requires an explanation. It has been introduced to mark shortcuts
which need to be recorded (and possibly customized) but are never used directly.
Currently, this applies to a number of shortcuts which:
- have been split between a common and a TAB-specific variant AND
- are linked to tool bar buttons or menu items
If QAction's are created for both, Qt blocks either as duplicate; in addition, the button
or menu item may become disabled on state change. The currently implemented solution is
to create a QAction only for one of them (the common one) and swap the key sequences when
entering or leaving the relevant state.
Swapping is implemented in MuseScore::changeState() (mscore/musescore.cpp).
QAction creation for the 'other' shortcut is blocked in Shortcut::action() (mscore/shortcut.cpp).
This means that Shortcut::action() may return 0. When scanning the whole
shortcuts[] array, this has to be taken into account; currently it happens in two
cases:
- in MuseScore::MuseScore() constructor (mscore/musescore.cpp)
- in MuseScore::changeState() method (mscore/musescore.cpp)
Shortcuts marked with the STATE_NEVER state should NEVER used directly as shortcuts!
---------------------------------------------------------*/
class Xml;
class XmlReader;