Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percussion panel - refinements round 8 #26657

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,10 @@
<key>toggle-piano-keyboard</key>
<seq>P</seq>
</SC>
<SC>
<key>toggle-percussion-panel</key>
<seq>O</seq>
</SC>
<SC>
<key>next-score</key>
<std>20</std>
Expand Down
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts_azerty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,10 @@
<key>toggle-piano-keyboard</key>
<seq>P</seq>
</SC>
<SC>
<key>toggle-percussion-panel</key>
<seq>O</seq>
</SC>
<SC>
<key>next-score</key>
<std>20</std>
Expand Down
4 changes: 4 additions & 0 deletions src/app/configs/data/shortcuts_mac.xml
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,10 @@
<key>toggle-piano-keyboard</key>
<seq>P</seq>
</SC>
<SC>
<key>toggle-percussion-panel</key>
<seq>O</seq>
</SC>
<SC>
<key>next-score</key>
<std>20</std>
Expand Down
28 changes: 16 additions & 12 deletions src/appshell/internal/applicationuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ using namespace muse::dock;
static const ActionCode FULL_SCREEN_CODE("fullscreen");
static const ActionCode TOGGLE_NAVIGATOR_ACTION_CODE("toggle-navigator");
static const ActionCode TOGGLE_BRAILLE_ACTION_CODE("toggle-braille-panel");
static const ActionCode TOGGLE_PERCUSSION_PANEL_ACTION_CODE("toggle-percussion-panel");

const UiActionList ApplicationUiActions::m_actions = {
UiAction("quit",
Expand Down Expand Up @@ -194,14 +195,13 @@ const UiActionList ApplicationUiActions::m_actions = {
TranslatableString("action", "Show/hide piano keyboard"),
Checkable::Yes
),
// still in development
// UiAction("toggle-percussion-panel",
// mu::context::UiCtxNotationOpened,
// mu::context::CTX_ANY,
// TranslatableString("action", "Percussion"),
// TranslatableString("action", "Show/hide percussion panel"),
// Checkable::Yes
// ),
UiAction(TOGGLE_PERCUSSION_PANEL_ACTION_CODE,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Percussion"),
TranslatableString("action", "Show/hide percussion panel"),
Checkable::Yes
),
UiAction("toggle-scorecmp-tool",
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
Expand Down Expand Up @@ -248,6 +248,10 @@ void ApplicationUiActions::init()
dockWindowProvider()->windowChanged().onNotify(this, [this]() {
listenOpenedDocksChanged(dockWindowProvider()->window());
});

notationConfiguration()->useNewPercussionPanelChanged().onNotify(this, [this]() {
m_actionEnabledChanged.send({ TOGGLE_PERCUSSION_PANEL_ACTION_CODE });
});
}

void ApplicationUiActions::listenOpenedDocksChanged(IDockWindow* window)
Expand Down Expand Up @@ -280,11 +284,11 @@ const muse::ui::UiActionList& ApplicationUiActions::actionsList() const

bool ApplicationUiActions::actionEnabled(const UiAction& act) const
{
if (!m_controller->canReceiveAction(act.code)) {
return false;
if (act.code == TOGGLE_PERCUSSION_PANEL_ACTION_CODE) {
return notationConfiguration()->useNewPercussionPanel();
}

return true;
return m_controller->canReceiveAction(act.code);
}

bool ApplicationUiActions::actionChecked(const UiAction& act) const
Expand Down Expand Up @@ -340,7 +344,7 @@ const QMap<ActionCode, DockName>& ApplicationUiActions::toggleDockActions()
{ "toggle-timeline", TIMELINE_PANEL_NAME },
{ "toggle-mixer", MIXER_PANEL_NAME },
{ "toggle-piano-keyboard", PIANO_KEYBOARD_PANEL_NAME },
{ "toggle-percussion-panel", PERCUSSION_PANEL_NAME },
{ TOGGLE_PERCUSSION_PANEL_ACTION_CODE, PERCUSSION_PANEL_NAME },

{ "toggle-statusbar", NOTATION_STATUSBAR_NAME },
};
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/internal/applicationuiactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "async/asyncable.h"
#include "ui/imainwindow.h"
#include "view/preferences/braillepreferencesmodel.h"
#include "notation/inotationconfiguration.h"

#include "dockwindow/idockwindowprovider.h"

Expand All @@ -39,6 +40,7 @@ class ApplicationUiActions : public muse::ui::IUiActionsModule, public muse::Inj
muse::Inject<muse::dock::IDockWindowProvider> dockWindowProvider = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<braille::IBrailleConfiguration> brailleConfiguration = { this };
muse::Inject<mu::notation::INotationConfiguration> notationConfiguration = { this };

public:
ApplicationUiActions(std::shared_ptr<ApplicationActionController> controller, const muse::modularity::ContextPtr& iocCtx);
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ MenuItem* AppMenuModel::makeViewMenu()
makeMenuItem("toggle-timeline"),
makeMenuItem("toggle-mixer"),
makeMenuItem("toggle-piano-keyboard"),
// makeMenuItem("toggle-percussion-panel"), // still in development
makeMenuItem("toggle-percussion-panel"),
makeMenuItem("playback-setup"),
//makeMenuItem("toggle-scorecmp-tool"), // not implemented
makeSeparator(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Item {

signal saveRequested()
signal cancelRequested()
signal clearRequested()
signal keyPressed(var event)

anchors.fill: parent
Expand Down Expand Up @@ -138,6 +139,17 @@ Item {
navigationPanel.section: root.navigationSection
navigationPanel.order: 2

FlatButton {
text: qsTrc("global", "Clear")
buttonRole: ButtonBoxModel.CustomRole
buttonId: ButtonBoxModel.Clear
isLeftSide: true

onClicked: {
root.clearRequested()
}
}

onStandardButtonClicked: function(buttonId) {
if (buttonId === ButtonBoxModel.Cancel) {
root.cancelRequested()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ StyledDialogView {

headerText: qsTrc("shortcuts", "Define keyboard shortcut")

originShortcutText: editShortcutModel.originSequence
//! NOTE: There's no need to actually clear the origin shortcut, we can simply hide it for aesthetic purposes...
originShortcutText: !editShortcutModel.cleared ? editShortcutModel.originSequence : ""
newShortcutText: editShortcutModel.newSequence
informationText: editShortcutModel.conflictWarning

Expand All @@ -76,6 +77,10 @@ StyledDialogView {
root.reject()
}

onClearRequested: {
editShortcutModel.clear()
}

onKeyPressed: function(event) {
editShortcutModel.inputKey(event.key, event.modifiers)
}
Expand Down
15 changes: 13 additions & 2 deletions src/framework/shortcuts/view/editshortcutmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ void EditShortcutModel::load(const QVariant& originShortcut, const QVariantList&
m_originSequence = originShortcutMap.value("sequence").toString();
m_originShortcutTitle = originShortcutMap.value("title").toString();

m_cleared = false;

emit originSequenceChanged();
emit clearedChanged();
}

void EditShortcutModel::clearNewSequence()
Expand Down Expand Up @@ -110,6 +113,14 @@ void EditShortcutModel::inputKey(Qt::Key key, Qt::KeyboardModifiers modifiers)
emit newSequenceChanged();
}

void EditShortcutModel::clear()
{
clearNewSequence();
m_cleared = true;
emit originSequenceChanged();
emit clearedChanged();
}

bool EditShortcutModel::isShiftAllowed(Qt::Key key)
{
if (key >= Qt::Key_A && key <= Qt::Key_Z) {
Expand Down Expand Up @@ -215,8 +226,8 @@ QString EditShortcutModel::conflictWarning() const
void EditShortcutModel::trySave()
{
QString newSequence = this->newSequence();

if (m_originSequence == newSequence) {
const bool alreadyEmpty = originSequenceInNativeFormat().isEmpty() && m_cleared;
if (alreadyEmpty || m_originSequence == newSequence) {
return;
}

Expand Down
7 changes: 7 additions & 0 deletions src/framework/shortcuts/view/editshortcutmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class EditShortcutModel : public QObject, public Injectable
Q_PROPERTY(QString newSequence READ newSequenceInNativeFormat NOTIFY newSequenceChanged)
Q_PROPERTY(QString conflictWarning READ conflictWarning NOTIFY newSequenceChanged)

Q_PROPERTY(bool cleared READ cleared NOTIFY clearedChanged)

Inject<IInteractive> interactive = { this };

public:
Expand All @@ -47,15 +49,18 @@ class EditShortcutModel : public QObject, public Injectable
QString originSequenceInNativeFormat() const;
QString newSequenceInNativeFormat() const;
QString conflictWarning() const;
bool cleared() const { return m_cleared; }
bool isShiftAllowed(Qt::Key key);

Q_INVOKABLE void load(const QVariant& shortcut, const QVariantList& allShortcuts);
Q_INVOKABLE void inputKey(Qt::Key key, Qt::KeyboardModifiers modifiers);
Q_INVOKABLE void clear();
Q_INVOKABLE void trySave();

signals:
void originSequenceChanged();
void newSequenceChanged();
void clearedChanged();

void applyNewSequenceRequested(const QString& newSequence, int conflictShortcutIndex = -1);

Expand All @@ -74,6 +79,8 @@ class EditShortcutModel : public QObject, public Injectable
QVariantMap m_conflictShortcut;

QKeySequence m_newSequence;

bool m_cleared = false;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ StyledDialogView {

headerText: qsTrc("shortcuts", "Define percussion keyboard shortcut")

originShortcutText: model.originShortcutText
//! NOTE: There's no need to actually clear the origin shortcut, we can simply hide it for aesthetic purposes...
originShortcutText: !model.cleared ? model.originShortcutText : ""
newShortcutText: model.newShortcutText
informationText: model.informationText

Expand All @@ -86,6 +87,10 @@ StyledDialogView {
root.reject()
}

onClearRequested: {
model.clear()
}

onKeyPressed: function(event) {
model.inputKey(event.key)
}
Expand Down
15 changes: 2 additions & 13 deletions src/notation/qml/MuseScore/NotationScene/PercussionPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Item {
onNavigationEvent: {
// Use the last known "pad navigation row" and tab to the associated delete button if it exists
var padNavigationRow = navigationPrv.currentPadNavigationIndex[0]
if (padGrid.model.rowIsEmpty(padNavigationRow)) {
if (padGrid.numRows > 1) {
event.setData("controlIndex", [padNavigationRow, 0])
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right

visible: padGrid.numRows > 1 && padGrid.model.rowIsEmpty(model.index)
visible: padGrid.numRows > 1

icon: IconCode.DELETE_TANK
backgroundRadius: deleteButton.width / 2
Expand All @@ -214,17 +214,6 @@ Item {
onClicked: {
padGrid.model.deleteRow(model.index)
}

Connections {
target: padGrid.model

function onRowIsEmptyChanged(row, isEmpty) {
if (row !== model.index) {
return
}
deleteButton.visible = padGrid.numRows > 1 && isEmpty
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Column {

anchors.fill: parent
enabled: root.panelMode !== PanelMode.EDIT_LAYOUT
hoverEnabled: true

acceptedButtons: Qt.LeftButton | Qt.RightButton

Expand Down Expand Up @@ -226,5 +227,24 @@ Column {
root.padModel.handleMenuItem(itemId)
}
}

states: [
State {
name: "MOUSE_HOVERED"
when: footerMouseArea.containsMouse && !footerMouseArea.pressed
PropertyChanges {
target: footerArea
color: Utils.colorWithAlpha(ui.theme.buttonColor, ui.theme.buttonOpacityHover)
}
},
State {
name: "MOUSE_HIT"
when: footerMouseArea.pressed
PropertyChanges {
target: footerArea
color: Utils.colorWithAlpha(ui.theme.buttonColor, ui.theme.buttonOpacityHit)
}
}
]
}
}
8 changes: 5 additions & 3 deletions src/notation/utilities/percussionutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ std::shared_ptr<Chord> PercussionUtilities::getDrumNoteForPreview(const Drumset*
}

/// Opens the percussion shortcut dialog, modifies drumset with user input
void PercussionUtilities::editPercussionShortcut(Drumset& drumset, int originPitch)
bool PercussionUtilities::editPercussionShortcut(Drumset& drumset, int originPitch)
{
IF_ASSERT_FAILED(drumset.isValid(originPitch)) {
return;
return false;
}

const muse::RetVal<muse::Val> rv = openPercussionShortcutDialog(drumset, originPitch);
if (!rv.ret) {
return;
return false;
}

const QVariantMap vals = rv.val.toQVariant().toMap();
Expand All @@ -124,6 +124,8 @@ void PercussionUtilities::editPercussionShortcut(Drumset& drumset, int originPit
if (conflictShortcutPitch > -1 && drumset.isValid(conflictShortcutPitch)) {
drumset.drum(conflictShortcutPitch).shortcut.clear();
}

return true;
}

muse::RetVal<muse::Val> PercussionUtilities::openPercussionShortcutDialog(const Drumset& drumset, int originPitch)
Expand Down
2 changes: 1 addition & 1 deletion src/notation/utilities/percussionutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PercussionUtilities
public:
static void readDrumset(const muse::ByteArray& drumMapping, mu::engraving::Drumset& drumset);
static std::shared_ptr<mu::engraving::Chord> getDrumNoteForPreview(const mu::engraving::Drumset* drumset, int pitch);
static void editPercussionShortcut(mu::engraving::Drumset& drumset, int originPitch);
static bool editPercussionShortcut(mu::engraving::Drumset& drumset, int originPitch);

private:
static muse::RetVal<muse::Val> openPercussionShortcutDialog(const mu::engraving::Drumset& drumset, int originPitch);
Expand Down
Loading
Loading