-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Accessibility Panel - Score Style Preset option
- Loading branch information
Showing
20 changed files
with
6,559 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
install(FILES | ||
16mm_MSN.mss | ||
18mm_MSN.mss | ||
20mm_MSN.mss | ||
24mm_MSN.mss | ||
25mm_MSN.mss | ||
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}styles/MSN | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,6 +447,7 @@ enum class Pid { | |
SCORE_FONT, | ||
SYMBOLS_SIZE, | ||
SYMBOL_ANGLE, | ||
SCORE_STYLE_PRESET, | ||
|
||
APPLY_TO_ALL_STAVES, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2021 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 "scorestylepreset.h" | ||
|
||
using namespace mu::engraving; | ||
|
||
muse::io::path_t ScoreStylePresetHelper::getStyleFilePath(ScoreStylePreset preset) const | ||
{ | ||
muse::io::path_t basePath = globalConfiguration()->appDataPath() + "styles/MSN/"; | ||
switch (preset) { | ||
case ScoreStylePreset::DEFAULT: | ||
return notationConfiguration()->defaultStyleFilePath(); | ||
case ScoreStylePreset::MSN_16MM: | ||
return basePath + "16mm_MSN.mss"; | ||
case ScoreStylePreset::MSN_18MM: | ||
return basePath + "18mm_MSN.mss"; | ||
case ScoreStylePreset::MSN_20MM: | ||
return basePath + "20mm_MSN.mss"; | ||
case ScoreStylePreset::MSN_24MM: | ||
return basePath + "24mm_MSN.mss"; | ||
case ScoreStylePreset::MSN_25MM: | ||
return basePath + "25mm_MSN.mss"; | ||
default: | ||
return muse::io::path_t(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2021 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/>. | ||
*/ | ||
#ifndef MU_ENGRAVING_SCORESTYLEPRESET_H | ||
#define MU_ENGRAVING_SCORESTYLEPRESET_H | ||
|
||
#include "global/iglobalconfiguration.h" | ||
#include "notation/inotationconfiguration.h" | ||
#include "modularity/ioc.h" | ||
|
||
namespace mu::engraving { | ||
enum class ScoreStylePreset { | ||
CUSTOM, | ||
DEFAULT, | ||
MSN_16MM, | ||
MSN_18MM, | ||
MSN_20MM, | ||
MSN_24MM, | ||
MSN_25MM | ||
}; | ||
|
||
class ScoreStylePresetHelper | ||
{ | ||
INJECT(muse::IGlobalConfiguration, globalConfiguration); | ||
INJECT(notation::INotationConfiguration, notationConfiguration) | ||
public: | ||
muse::io::path_t getStyleFilePath(ScoreStylePreset preset) const; | ||
}; | ||
} // namespace mu::engraving | ||
|
||
#endif // MU_ENGRAVING_SCORESTYLEPRESET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
src/inspector/models/score/scoreaccessibilitysettingsmodel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2021 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 "scoreaccessibilitysettingsmodel.h" | ||
|
||
#include "translation.h" | ||
#include "log.h" | ||
|
||
using namespace mu::inspector; | ||
using namespace mu::notation; | ||
|
||
ScoreAccessibilitySettingsModel::ScoreAccessibilitySettingsModel(QObject* parent, IElementRepositoryService* repository) | ||
: AbstractInspectorModel(parent, repository) | ||
{ | ||
setSectionType(InspectorSectionType::SECTION_SCORE_ACCESSIBILITY); | ||
setTitle(muse::qtrc("inspector", "Accessibility")); | ||
createProperties(); | ||
connect(m_scoreStylePreset, &PropertyItem::valueChanged, this, [this]() { | ||
if (!m_ignoreStyleChange) { | ||
setScoreStylePreset(m_scoreStylePreset); | ||
} | ||
}); | ||
|
||
globalContext()->currentNotation()->style()->styleChanged().onNotify(this, [this]() { | ||
if (!m_ignoreStyleChange && m_scoreStylePreset->value().toInt() != static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM)) { | ||
m_scoreStylePreset->setValue(static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM)); | ||
emit scoreStylePresetChanged(); | ||
} | ||
}); | ||
} | ||
|
||
PropertyItem* ScoreAccessibilitySettingsModel::scoreStylePreset() const | ||
{ | ||
return m_scoreStylePreset; | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::setScoreStylePreset(PropertyItem* preset) | ||
{ | ||
m_ignoreStyleChange = true; | ||
m_scoreStylePreset = preset; | ||
loadStyle(preset); | ||
emit scoreStylePresetChanged(); | ||
m_ignoreStyleChange = false; | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::createProperties() | ||
{ | ||
m_scoreStylePreset = buildPropertyItem(mu::engraving::Pid::SCORE_STYLE_PRESET); | ||
m_scoreStylePreset->setDefaultValue(static_cast<int>(mu::engraving::ScoreStylePreset::DEFAULT)); | ||
m_scoreStylePreset->setValue(static_cast<int>(mu::engraving::ScoreStylePreset::DEFAULT)); | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::requestElements() | ||
{ | ||
// Placeholder | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::loadProperties() | ||
{ | ||
static PropertyIdSet propertyIdSet { | ||
Pid::SCORE_STYLE_PRESET | ||
}; | ||
|
||
loadProperties(propertyIdSet); | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet) | ||
{ | ||
if (muse::contains(propertyIdSet, Pid::SCORE_STYLE_PRESET)) { | ||
loadPropertyItem(m_scoreStylePreset); | ||
} | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::resetProperties() | ||
{ | ||
m_scoreStylePreset->resetToDefault(); | ||
emit scoreStylePresetChanged(); | ||
} | ||
|
||
QVariantList ScoreAccessibilitySettingsModel::possibleScoreStylePreset() const | ||
{ | ||
QMap<mu::engraving::ScoreStylePreset, QString> types { | ||
{ mu::engraving::ScoreStylePreset::DEFAULT, muse::qtrc("inspector", "Default") }, | ||
{ mu::engraving::ScoreStylePreset::MSN_16MM, muse::qtrc("inspector", "16mm MSN") }, | ||
{ mu::engraving::ScoreStylePreset::MSN_18MM, muse::qtrc("inspector", "18mm MSN") }, | ||
{ mu::engraving::ScoreStylePreset::MSN_20MM, muse::qtrc("inspector", "20mm MSN") }, | ||
{ mu::engraving::ScoreStylePreset::MSN_24MM, muse::qtrc("inspector", "24mm MSN") }, | ||
{ mu::engraving::ScoreStylePreset::MSN_25MM, muse::qtrc("inspector", "25mm MSN") } | ||
}; | ||
|
||
QVariantList result; | ||
|
||
if (m_scoreStylePreset->value().toInt() == static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM)) { | ||
QVariantMap customObj; | ||
customObj["text"] = muse::qtrc("inspector", "Custom"); | ||
customObj["value"] = static_cast<int>(mu::engraving::ScoreStylePreset::CUSTOM); | ||
result << customObj; | ||
} | ||
|
||
for (mu::engraving::ScoreStylePreset type : types.keys()) { | ||
QVariantMap obj; | ||
obj["text"] = types[type]; | ||
obj["value"] = static_cast<int>(type); | ||
result << obj; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void ScoreAccessibilitySettingsModel::loadStyle(PropertyItem* preset) | ||
{ | ||
int presetValue = preset->value().toInt(); | ||
|
||
mu::engraving::ScoreStylePreset stylePreset = static_cast<mu::engraving::ScoreStylePreset>(presetValue); | ||
|
||
mu::engraving::ScoreStylePresetHelper scoreStylePresetHelper; | ||
muse::io::path_t filePath = scoreStylePresetHelper.getStyleFilePath(stylePreset); | ||
|
||
if (stylePreset == mu::engraving::ScoreStylePreset::DEFAULT) { | ||
if (filePath.empty()) { | ||
mu::engraving::StyleIdSet emptySet; | ||
globalContext()->currentNotation()->style()->resetAllStyleValues(emptySet); | ||
} else { | ||
globalContext()->currentNotation()->style()->loadStyle(filePath, true); | ||
} | ||
} else if (!filePath.empty()) { | ||
LOGI() << "Loading style from filePath:" << filePath; | ||
globalContext()->currentNotation()->style()->loadStyle(filePath, true); | ||
} else { | ||
LOGI() << "filePath is empty"; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/inspector/models/score/scoreaccessibilitysettingsmodel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2021 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/>. | ||
*/ | ||
#ifndef MU_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H | ||
#define MU_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H | ||
|
||
#include "models/abstractinspectormodel.h" | ||
#include "models/propertyitem.h" | ||
#include "async/asyncable.h" | ||
#include "context/iglobalcontext.h" | ||
#include "engraving/style/scorestylepreset.h" | ||
|
||
namespace mu::inspector { | ||
class ScoreAccessibilitySettingsModel : public AbstractInspectorModel | ||
{ | ||
Q_OBJECT | ||
INJECT(mu::context::IGlobalContext, globalContext) | ||
Q_PROPERTY(PropertyItem * scoreStylePreset READ scoreStylePreset WRITE setScoreStylePreset NOTIFY scoreStylePresetChanged) | ||
|
||
public: | ||
explicit ScoreAccessibilitySettingsModel(QObject* parent, IElementRepositoryService* repository); | ||
|
||
void createProperties() override; | ||
void requestElements() override; | ||
void loadProperties() override; | ||
void resetProperties() override; | ||
|
||
PropertyItem* scoreStylePreset() const; | ||
void setScoreStylePreset(PropertyItem* preset); | ||
Q_INVOKABLE QVariantList possibleScoreStylePreset() const; | ||
void loadStyle(PropertyItem* preset); | ||
|
||
void loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet); | ||
|
||
signals: | ||
void scoreStylePresetChanged(); | ||
private: | ||
PropertyItem* m_scoreStylePreset = nullptr; | ||
bool m_ignoreStyleChange = false; | ||
}; | ||
} | ||
|
||
#endif // MU_INSPECTOR_SCOREACCESSIBILITYSETTINGSMODEL_H |
Oops, something went wrong.