Skip to content
Quinn Ouyang edited this page Apr 18, 2022 · 3 revisions

Shortcuts

A keyboard shortcut is a series of one or several keys that invoke to perform an UI Actions (see Interact workflow)
The same keyboard shortcut can perform different actions depending on the context in which we are now, for example, one combination of Ctrl+B performs the action add a measure if something is selected in the notation or make the text bold if we are editing text.

Implementation

The general idea is that we load a list of shortcuts from a file, look for shortcuts corresponding to sequence, and depending on UI Action available ( maintly depending on current UI Context (see UI Actions )), we perform the corresponding action (or do nothing if the current UI context does not correspond to the assigned action)

We want to keep the keyboard shortcut compatible with MuseScore 3.0. So, decisions on how to implement shortcuts in MuseScore 4.0 are mainly dictated by this requirement.

Shortcut declaration

The shortcuts are declared in the shortcuts.xml file. (for MacOS a separate file with the shortcuts-Mac.xml and for a separate one for the shortcuts_AZERTY.xml layout)
For example:

  <SC>
    <key>text-b</key>
    <seq>Ctrl+b</seq>
    </SC>
  <SC>
    <key>text-word-left</key>
    <seq>Ctrl+Left</seq>
    </SC>
  <SC>
    <key>text-word-right</key>
    <seq>Ctrl+Right</seq>
    </SC>

key - action name
seq - keyboard shortcut

These files correspond to MuseScore 3.0 unchanged.

Shortcut activation

When we press the keyboard shortcuts, the method is called: void ShortcutsController::activate(const std::string& sequence).
The shortcut controller getting a list of shortcuts from the shortcut registry (loaded from a file) for the given sequence. For each shortcut found, we get an UI Action to be performed. For the getted UI Actions, we get their current state (availability), if the action is available, then we dispatch the action through the action dispatcher.

Testing

Translation

Compilation

  1. Set up developer environment
  2. Install Qt and Qt Creator
  3. Get MuseScore's source code
  4. Install dependencies
  5. Compile on the command line
  6. Compile in Qt Creator

Beyond compiling

  1. Find your way around the code
  2. Submit a Pull Request
  3. Fix the CI checks

Misc. development

Architecture general

Audio

Engraving

Extensions

Google Summer of Code

References

Clone this wiki locally