-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Actions
Actions
are intentions that are sent from the view to the model. The model processes the action, changes its state and sends a notification of changes. See interact workwlow.
The action consists of a name and a title (other properties may be added in the future)
struct Action {
ActionName name;
std::string title;
bool isValid() const { return !name.empty(); }
};
Each module has its own list of actions; there is no one global place with all actions.
The name of the action consists of the namespace and the name of the action itself.
Actions can be without arguments (most) and with arguments. For actions with arguments, you need to write a list of arguments in the comment - their order, type, names.
For example, actions processed by notation are in the file /domain/notation/notationactions.cpp
//! NOTE Only actions processed by notation
static const std::vector<Action> m_actions = {
{
"domain/notation/note-input",
QT_TRANSLATE_NOOP("action", "Note Input")
},
{
"domain/notation/pad-note-4",
QT_TRANSLATE_NOOP("action", "Quarter Note")
},
{
"domain/notation/pad-note-8",
QT_TRANSLATE_NOOP("action", "8th Note")
},
...
{
"domain/notation/put-note", // args: QPoint pos, bool replace, bool insert
QT_TRANSLATE_NOOP("action", "Put Note")
}
...
};
To send actions, use the Action Dispatcher
.
At the moment, you can use the dispatcher only in C++ code and we do not plan to add the ability to use the dispatcher in Qml directly.
Adding a dispatcher dependency:
...
#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
...
class NotationToolBarModel
{
INJECT(notation_scene, actions::IActionsDispatcher, dispatcher)
...
}
Submit Actions
// without arguments
dispatcher()->dispatch("domain/notation/note-input");
// with arguments
dispatcher()->dispatch("domain/notation/put-note", ActionData::make_arg3<QPoint, bool, bool>(logicPos, replace, insert));
Handler Registration
// without arguments (like Qt connect)
dispatcher()->reg("domain/notation/note-input", this, &NotationActionController::toggleNoteInput);
dispatcher()->reg("domain/notation/pad-note-4", [this]() { padNote(Pad::NOTE4); });
// with argumens
dispatcher()->reg("domain/notation/put-note", this, &NotationActionController::putNote);
// Where
void NotationActionController::putNote(const actions::ActionData& data)
{
...
QPoint pos = data.arg<QPoint>(0);
bool replace = data.arg<bool>(1);
bool insert = data.arg<bool>(2);
notation->putNote(pos, replace, insert);
}
Testing
- Manual testing
- Automatic testing
Translation
Compilation
- Set up developer environment
- Install Qt and Qt Creator
- Get MuseScore's source code
- Install dependencies
- Compile on the command line
- Compile in Qt Creator
Beyond compiling
Misc. development
Architecture general
- Architecture overview
- AppShell
- Modularity
- Interact workflow
- Channels and Notifications
- Settings and Configuration
- Error handling
- Launcher and Interactive
- Keyboard Navigation
Audio
Engraving
- Style settings
- Working with style files
- Style parameter changes for 4.0
- Style parameter changes for 4.1
- Style parameter changes for 4.2
- Style parameter changes for 4.3
- Style parameter changes for 4.4
Extensions
- Extensions overview
- Manifest
- Forms
- Macros
- Api
- Legacy plugin API
Google Summer of Code
References