Skip to content

Commit

Permalink
Implement Percussion Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Dec 17, 2024
1 parent 99531ef commit bd31f7f
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 45 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
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
53 changes: 33 additions & 20 deletions src/appshell/qml/Preferences/PercussionPreferencesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ import "internal"
PreferencesPage {
id: root

PercussionPreferencesModel {
id: percussionPreferencesModel
}

Component.onCompleted: {
percussionPreferencesModel.init()
}

BaseSection {
id: percussionPanelPreferences

Expand All @@ -40,6 +48,8 @@ PreferencesPage {

CheckBox {
id: unpitchedSelectedCheckbox

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

text: qsTrc("notation", "Open the percussion panel when an unpitched staff is selected")
Expand All @@ -48,14 +58,17 @@ PreferencesPage {
navigation.panel: percussionPanelPreferences.navigation
navigation.row: 0

checked: percussionPreferencesModel.autoShowPercussionPanel

onClicked: {
// TODO: configuration - toggle autoShowPercussionPanel
percussionPreferencesModel.autoShowPercussionPanel = !unpitchedSelectedCheckbox.checked
}
}

StyledTextLabel {
id: padSwapInfo

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

horizontalAlignment: Text.AlignLeft
Expand All @@ -69,6 +82,8 @@ PreferencesPage {
property int navigationRowStart: unpitchedSelectedCheckbox.navigation.row + 1
property int navigationRowEnd: radioButtons.navigationRowStart + model.length

visible: percussionPreferencesModel.useNewPercussionPanel

width: parent.width
spacing: percussionPanelPreferences.spacing

Expand All @@ -92,10 +107,10 @@ PreferencesPage {
navigation.panel: percussionPanelPreferences.navigation
navigation.row: radioButtons.navigationRowStart + model.index

// TODO: checked: modelData.value === pad swap preference
checked: modelData.value === percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts

onToggled: {
// TODO: configuration - change pad swap preference
percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts = modelData.value
}
}

Expand All @@ -115,7 +130,7 @@ PreferencesPage {
anchors.fill: parent

onClicked: {
// TODO: configuration - change pad swap preference
percussionPreferencesModel.percussionPanelMoveMidiNotesAndShortcuts = modelData.value
}
}
}
Expand All @@ -125,6 +140,7 @@ PreferencesPage {
CheckBox {
id: alwaysAsk

visible: percussionPreferencesModel.useNewPercussionPanel
width: parent.width

text: qsTrc("notation", "Always ask")
Expand All @@ -133,29 +149,26 @@ PreferencesPage {
navigation.panel: percussionPanelPreferences.navigation
navigation.row: radioButtons.navigationRowEnd

checked: percussionPreferencesModel.showPercussionPanelPadSwapDialog

onClicked: {
// TODO: configuration - toggle "show pad swap dialog"
percussionPreferencesModel.showPercussionPanelPadSwapDialog = !alwaysAsk.checked
}
}
}

FlatButton {
id: useNewPercussionPanel

anchors {
top: percussionPanelPreferences.bottom
topMargin: percussionPanelPreferences.spacing
left: parent.left
}
FlatButton {
id: useNewPercussionPanel

text: qsTrc("notation", "Switch to old percussion panel") // TODO: "old/new" depending on current configuration...
text: percussionPreferencesModel.useNewPercussionPanel ? qsTrc("notation", "Switch to old percussion panel")
: qsTrc("notation", "Switch to new percussion panel")

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

onClicked: {
// TODO: configuration - toggle use of new percussion panel
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);
}
70 changes: 70 additions & 0 deletions src/appshell/view/preferences/percussionpreferencesmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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/>.
*/

#pragma once

#include <QObject>

#include "modularity/ioc.h"
#include "notation/inotationconfiguration.h"

#include "async/asyncable.h"

class PercussionPreferencesModel : public QObject, public muse::Injectable, public muse::async::Asyncable
{
Q_OBJECT

Q_PROPERTY(bool useNewPercussionPanel READ useNewPercussionPanel WRITE setUseNewPercussionPanel NOTIFY useNewPercussionPanelChanged)

Q_PROPERTY(bool autoShowPercussionPanel READ autoShowPercussionPanel
WRITE setAutoShowPercussionPanel NOTIFY autoShowPercussionPanelChanged)

Q_PROPERTY(bool showPercussionPanelPadSwapDialog READ showPercussionPanelPadSwapDialog WRITE setShowPercussionPanelPadSwapDialog NOTIFY showPercussionPanelPadSwapDialogChanged)

Q_PROPERTY(bool percussionPanelMoveMidiNotesAndShortcuts READ percussionPanelMoveMidiNotesAndShortcuts
WRITE setPercussionPanelMoveMidiNotesAndShortcuts NOTIFY percussionPanelMoveMidiNotesAndShortcutsChanged)

muse::Inject<mu::notation::INotationConfiguration> configuration = { this };

public:
explicit PercussionPreferencesModel(QObject* parent = nullptr);

Q_INVOKABLE void init();

bool useNewPercussionPanel() const;
void setUseNewPercussionPanel(bool use);

bool autoShowPercussionPanel() const;
void setAutoShowPercussionPanel(bool autoShow);

bool showPercussionPanelPadSwapDialog() const;
void setShowPercussionPanelPadSwapDialog(bool show);

bool percussionPanelMoveMidiNotesAndShortcuts() const;
void setPercussionPanelMoveMidiNotesAndShortcuts(bool move);

signals:
void useNewPercussionPanelChanged();
void autoShowPercussionPanelChanged();
void showPercussionPanelPadSwapDialogChanged();
void percussionPanelMoveMidiNotesAndShortcutsChanged();
};
11 changes: 10 additions & 1 deletion src/notation/inotationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,21 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE
virtual muse::ValCh<bool> midiUseWrittenPitch() const = 0;
virtual void setMidiUseWrittenPitch(bool useWrittenPitch) = 0;

// TODO: Delete when the new percussion panel is finished
virtual bool useNewPercussionPanel() const = 0;
virtual void setUseNewPercussionPanel(bool use) = 0;
virtual muse::async::Notification useNewPercussionPanelChanged() const = 0;

virtual bool autoShowPercussionPanel() const = 0;
virtual void setAutoShowPercussionPanel(bool autoShow) = 0;
virtual muse::async::Notification autoShowPercussionPanelChanged() const = 0;

virtual bool showPercussionPanelPadSwapDialog() const = 0;
virtual void setShowPercussionPanelPadSwapDialog(bool show) = 0;
virtual muse::async::Notification showPercussionPanelPadSwapDialogChanged() const = 0;

virtual bool percussionPanelMoveMidiNotesAndShortcuts() const = 0;
virtual void setPercussionPanelMoveMidiNotesAndShortcuts(bool move) = 0;
virtual muse::async::Notification percussionPanelMoveMidiNotesAndShortcutsChanged() const = 0;

virtual muse::io::path_t styleFileImportPath() const = 0;
virtual void setStyleFileImportPath(const muse::io::path_t& path) = 0;
Expand Down
Loading

0 comments on commit bd31f7f

Please sign in to comment.