Skip to content

Commit

Permalink
Merge pull request #25810 from mathesoncalum/percussions_refinements_3
Browse files Browse the repository at this point in the history
Percussion panel - refinements round 3
  • Loading branch information
mathesoncalum authored Dec 20, 2024
2 parents e9e061b + a728361 commit 689fd84
Show file tree
Hide file tree
Showing 39 changed files with 1,090 additions and 77 deletions.
2 changes: 2 additions & 0 deletions src/appshell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/view/preferences/importpreferencesmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/audiomidipreferencesmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/preferences/audiomidipreferencesmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/percussionpreferencesmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/preferences/percussionpreferencesmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/commonaudioapiconfigurationmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/preferences/commonaudioapiconfigurationmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/braillepreferencesmodel.cpp
Expand Down
1 change: 1 addition & 0 deletions src/appshell/appshell.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
<file>qml/Preferences/internal/MixerSection.qml</file>
<file>qml/DevTools/Extensions/ExtensionsListView.qml</file>
<file>qml/platform/PlatformMenuBar.qml</file>
<file>qml/Preferences/PercussionPreferencesPage.qml</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions src/appshell/appshellmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "view/preferences/scorepreferencesmodel.h"
#include "view/preferences/importpreferencesmodel.h"
#include "view/preferences/audiomidipreferencesmodel.h"
#include "view/preferences/percussionpreferencesmodel.h"
#include "view/preferences/commonaudioapiconfigurationmodel.h"
#include "view/preferences/braillepreferencesmodel.h"
#include "view/framelesswindow/framelesswindowmodel.h"
Expand Down Expand Up @@ -150,6 +151,7 @@ void AppShellModule::registerUiTypes()
qmlRegisterType<ScorePreferencesModel>("MuseScore.Preferences", 1, 0, "ScorePreferencesModel");
qmlRegisterType<ImportPreferencesModel>("MuseScore.Preferences", 1, 0, "ImportPreferencesModel");
qmlRegisterType<AudioMidiPreferencesModel>("MuseScore.Preferences", 1, 0, "AudioMidiPreferencesModel");
qmlRegisterType<PercussionPreferencesModel>("MuseScore.Preferences", 1, 0, "PercussionPreferencesModel");
qmlRegisterType<CommonAudioApiConfigurationModel>("MuseScore.Preferences", 1, 0, "CommonAudioApiConfigurationModel");
qmlRegisterType<BraillePreferencesModel>("MuseScore.Preferences", 1, 0, "BraillePreferencesModel");

Expand Down
174 changes: 174 additions & 0 deletions src/appshell/qml/Preferences/PercussionPreferencesPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2024 MuseScore Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import QtQuick 2.15

import Muse.Ui 1.0
import Muse.UiComponents 1.0
import MuseScore.Preferences 1.0

import "internal"

PreferencesPage {
id: root

PercussionPreferencesModel {
id: percussionPreferencesModel
}

Component.onCompleted: {
percussionPreferencesModel.init()
}

BaseSection {
id: percussionPanelPreferences

title: qsTrc("appshell/preferences", "Percussion")

navigation.section: root.navigationSection

CheckBox {
id: unpitchedSelectedCheckbox

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

text: qsTrc("appshell/preferences", "Open the percussion panel when an unpitched staff is selected")

navigation.name: "UnpitchedSelectedCheckbox"
navigation.panel: percussionPanelPreferences.navigation
navigation.row: 0

checked: percussionPreferencesModel.autoShowPercussionPanel

onClicked: {
percussionPreferencesModel.autoShowPercussionPanel = !unpitchedSelectedCheckbox.checked
}
}

StyledTextLabel {
id: padSwapInfo

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
text: qsTrc("notation/percussion", "When swapping the positions of two drum pads:")
}

RadioButtonGroup {
id: radioButtons

property int navigationRowStart: unpitchedSelectedCheckbox.navigation.row + 1
property int navigationRowEnd: radioButtons.navigationRowStart + model.length

visible: percussionPreferencesModel.useNewPercussionPanel

width: parent.width
spacing: percussionPanelPreferences.spacing

orientation: ListView.Vertical

model: [
{ text: qsTrc("notation/percussion", "Move MIDI notes and keyboard shortcuts with their sounds"), value: true },
{ text: qsTrc("notation/percussion", "Leave MIDI notes and keyboard shortcuts fixed to original pad positions"), value: false }
]

delegate: Row {
width: parent.width
spacing: 6

RoundedRadioButton {
id: radioButton

anchors.verticalCenter: parent.verticalCenter

navigation.name: modelData.text
navigation.panel: percussionPanelPreferences.navigation
navigation.row: radioButtons.navigationRowStart + model.index

checked: modelData.value === percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts

onToggled: {
percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts = modelData.value
}
}

//! NOTE: Can't use radioButton.text because it won't wrap
StyledTextLabel {
width: parent.width - parent.spacing - radioButton.width

anchors.verticalCenter: parent.verticalCenter

horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
text: modelData.text

MouseArea {
id: mouseArea

anchors.fill: parent

onClicked: {
percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts = modelData.value
}
}
}
}
}

CheckBox {
id: alwaysAsk

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

text: qsTrc("global", "Always ask")

navigation.name: "AlwaysAskCheckBox"
navigation.panel: percussionPanelPreferences.navigation
navigation.row: radioButtons.navigationRowEnd

checked: percussionPreferencesModel.showPercussionPanelPadSwapDialog

onClicked: {
percussionPreferencesModel.showPercussionPanelPadSwapDialog = !alwaysAsk.checked
}
}

FlatButton {
id: useNewPercussionPanel

text: percussionPreferencesModel.useNewPercussionPanel ? qsTrc("notation/percussion", "Switch to old percussion panel")
: qsTrc("notation/percussion", "Switch to new percussion panel")

navigation.name: "SwitchPercussionPanels"
navigation.panel: percussionPanelPreferences.navigation
navigation.row: alwaysAsk.navigation.row + 1

onClicked: {
percussionPreferencesModel.useNewPercussionPanel = !percussionPreferencesModel.useNewPercussionPanel
}
}
}
}
7 changes: 5 additions & 2 deletions src/appshell/view/notationpagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void NotationPageModel::init()

updateDrumsetPanelVisibility();
updatePercussionPanelVisibility();

notationConfiguration()->useNewPercussionPanelChanged().onNotify(this, [this]() {
updateDrumsetPanelVisibility();
updatePercussionPanelVisibility();
});
}

QString NotationPageModel::notationToolBarName() const
Expand Down Expand Up @@ -150,7 +155,6 @@ void NotationPageModel::onNotationChanged()
return;
}

// TODO: Delete when the new percussion panel is finished
if (!notationConfiguration()->useNewPercussionPanel()) {
INotationNoteInputPtr noteInput = notation->interaction()->noteInput();
noteInput->stateChanged().onNotify(this, [this]() {
Expand Down Expand Up @@ -235,7 +239,6 @@ void NotationPageModel::updatePercussionPanelVisibility()
};

// This should never be open when the old drumset panel is in use...
// TODO: Delete when the new percussion panel is finished
if (!notationConfiguration()->useNewPercussionPanel()) {
setPercussionPanelOpen(false);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/notationpagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class NotationPageModel : public QObject, public muse::Injectable, public muse::

void toggleDock(const QString& name);

void updateDrumsetPanelVisibility(); // TODO: Delete when the new percussion panel is finished
void updateDrumsetPanelVisibility();
void updatePercussionPanelVisibility();
};
}
Expand Down
87 changes: 87 additions & 0 deletions src/appshell/view/preferences/percussionpreferencesmodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2024 MuseScore Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "percussionpreferencesmodel.h"

PercussionPreferencesModel::PercussionPreferencesModel(QObject* parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
}

void PercussionPreferencesModel::init()
{
configuration()->useNewPercussionPanelChanged().onNotify(this, [this]() {
emit useNewPercussionPanelChanged();
});

configuration()->autoShowPercussionPanelChanged().onNotify(this, [this]() {
emit autoShowPercussionPanelChanged();
});

configuration()->showPercussionPanelPadSwapDialogChanged().onNotify(this, [this]() {
emit showPercussionPanelPadSwapDialogChanged();
});

configuration()->percussionPanelMoveMidiNotesAndShortcutsChanged().onNotify(this, [this]() {
emit percussionPanelMoveMidiNotesAndShortcutsChanged();
});
}

bool PercussionPreferencesModel::useNewPercussionPanel() const
{
return configuration()->useNewPercussionPanel();
}

void PercussionPreferencesModel::setUseNewPercussionPanel(bool use)
{
configuration()->setUseNewPercussionPanel(use);
}

bool PercussionPreferencesModel::autoShowPercussionPanel() const
{
return configuration()->autoShowPercussionPanel();
}

void PercussionPreferencesModel::setAutoShowPercussionPanel(bool autoShow)
{
configuration()->setAutoShowPercussionPanel(autoShow);
}

bool PercussionPreferencesModel::showPercussionPanelPadSwapDialog() const
{
return configuration()->showPercussionPanelPadSwapDialog();
}

void PercussionPreferencesModel::setShowPercussionPanelPadSwapDialog(bool show)
{
configuration()->setShowPercussionPanelPadSwapDialog(show);
}

bool PercussionPreferencesModel::percussionPanelMoveMidiNotesAndShortcuts() const
{
return configuration()->percussionPanelMoveMidiNotesAndShortcuts();
}

void PercussionPreferencesModel::setPercussionPanelMoveMidiNotesAndShortcuts(bool move)
{
configuration()->setPercussionPanelMoveMidiNotesAndShortcuts(move);
}
Loading

0 comments on commit 689fd84

Please sign in to comment.