Skip to content

Commit d3ae6e2

Browse files
Merge pull request #15849 from iwoithe/fix-15779-add-rest-section-to-properties
Fix #15779: Add rest section to properties panel
2 parents dedff32 + 9d39bac commit d3ae6e2

21 files changed

+386
-8
lines changed

fonts/mscore/MusescoreIcon.ttf

2.29 KB
Binary file not shown.

src/framework/ui/view/iconcodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ class IconCode
379379
PLUGIN = 0xF440,
380380
LYRICS = 0xF441,
381381

382+
QUAVER_REST = 0xF44C,
383+
382384
NONE = 0xFFFF
383385
};
384386

src/inspector/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ set(MODULE_SRC
104104
${CMAKE_CURRENT_LIST_DIR}/models/notation/barlines/barlinesettingsmodel.h
105105
${CMAKE_CURRENT_LIST_DIR}/models/notation/barlines/barlinesettingsproxymodel.cpp
106106
${CMAKE_CURRENT_LIST_DIR}/models/notation/barlines/barlinesettingsproxymodel.h
107+
${CMAKE_CURRENT_LIST_DIR}/models/notation/beams/beammodesmodel.cpp
108+
${CMAKE_CURRENT_LIST_DIR}/models/notation/beams/beammodesmodel.h
107109
${CMAKE_CURRENT_LIST_DIR}/models/notation/bends/bendsettingsmodel.cpp
108110
${CMAKE_CURRENT_LIST_DIR}/models/notation/bends/bendsettingsmodel.h
109111
${CMAKE_CURRENT_LIST_DIR}/models/notation/brackets/bracketsettingsmodel.cpp
@@ -178,8 +180,6 @@ set(MODULE_SRC
178180
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/notesettingsproxymodel.h
179181
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/beams/beamsettingsmodel.cpp
180182
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/beams/beamsettingsmodel.h
181-
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/beams/internal/beammodesmodel.cpp
182-
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/beams/internal/beammodesmodel.h
183183
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/chords/chordsettingsmodel.cpp
184184
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/chords/chordsettingsmodel.h
185185
${CMAKE_CURRENT_LIST_DIR}/models/notation/notes/hooks/hooksettingsmodel.cpp
@@ -198,6 +198,10 @@ set(MODULE_SRC
198198
${CMAKE_CURRENT_LIST_DIR}/models/notation/tuplets/tupletsettingsmodel.h
199199
${CMAKE_CURRENT_LIST_DIR}/models/notation/instrumentname/instrumentnamesettingsmodel.cpp
200200
${CMAKE_CURRENT_LIST_DIR}/models/notation/instrumentname/instrumentnamesettingsmodel.h
201+
${CMAKE_CURRENT_LIST_DIR}/models/notation/rests/beams/restbeamsettingsmodel.cpp
202+
${CMAKE_CURRENT_LIST_DIR}/models/notation/rests/beams/restbeamsettingsmodel.h
203+
${CMAKE_CURRENT_LIST_DIR}/models/notation/rests/restsettingsproxymodel.cpp
204+
${CMAKE_CURRENT_LIST_DIR}/models/notation/rests/restsettingsproxymodel.h
201205
${CMAKE_CURRENT_LIST_DIR}/models/inspectorpopupcontroller.cpp
202206
${CMAKE_CURRENT_LIST_DIR}/models/inspectorpopupcontroller.h
203207
${CMAKE_CURRENT_LIST_DIR}/internal/services/elementrepositoryservice.cpp

src/inspector/internal/services/elementrepositoryservice.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ QList<mu::engraving::EngravingItem*> ElementRepositoryService::findElementsByTyp
8989
case mu::engraving::ElementType::TEXT: return findTexts();
9090
case mu::engraving::ElementType::TREMOLO: return findTremolos();
9191
case mu::engraving::ElementType::BRACKET: return findBrackets();
92+
case mu::engraving::ElementType::REST: return findRests();
9293
case mu::engraving::ElementType::PEDAL:
9394
case mu::engraving::ElementType::GLISSANDO:
9495
case mu::engraving::ElementType::VIBRATO:
@@ -436,3 +437,16 @@ QList<mu::engraving::EngravingItem*> ElementRepositoryService::findBrackets() co
436437

437438
return resultList;
438439
}
440+
441+
QList<mu::engraving::EngravingItem*> ElementRepositoryService::findRests() const
442+
{
443+
QList<mu::engraving::EngravingItem*> resultList;
444+
445+
for (mu::engraving::EngravingItem* element : m_exposedElementList) {
446+
if (element->isRest()) {
447+
resultList << element;
448+
}
449+
}
450+
451+
return resultList;
452+
}

src/inspector/internal/services/elementrepositoryservice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ElementRepositoryService : public QObject, public IElementRepositoryServic
6565
QList<mu::engraving::EngravingItem*> findTremolos() const;
6666
QList<mu::engraving::EngravingItem*> findBrackets() const;
6767
QList<mu::engraving::EngravingItem*> findLines(mu::engraving::ElementType lineType) const;
68+
QList<mu::engraving::EngravingItem*> findRests() const;
6869

6970
QList<mu::engraving::EngravingItem*> m_exposedElementList;
7071
QList<mu::engraving::EngravingItem*> m_rawElementList;

src/inspector/models/abstractinspectormodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ static const QMap<mu::engraving::ElementType, InspectorModelType> NOTATION_ELEME
9090
{ mu::engraving::ElementType::GRADUAL_TEMPO_CHANGE, InspectorModelType::TYPE_GRADUAL_TEMPO_CHANGE },
9191
{ mu::engraving::ElementType::GRADUAL_TEMPO_CHANGE_SEGMENT, InspectorModelType::TYPE_GRADUAL_TEMPO_CHANGE },
9292
{ mu::engraving::ElementType::INSTRUMENT_NAME, InspectorModelType::TYPE_INSTRUMENT_NAME },
93-
{ mu::engraving::ElementType::LYRICS, InspectorModelType::TYPE_LYRICS }
93+
{ mu::engraving::ElementType::LYRICS, InspectorModelType::TYPE_LYRICS },
94+
{ mu::engraving::ElementType::REST, InspectorModelType::TYPE_REST }
9495
};
9596

9697
static QMap<mu::engraving::HairpinType, InspectorModelType> HAIRPIN_ELEMENT_MODEL_TYPES = {

src/inspector/models/abstractinspectormodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class AbstractInspectorModel : public QObject, public async::Asyncable
122122
TYPE_GRADUAL_TEMPO_CHANGE,
123123
TYPE_INSTRUMENT_NAME,
124124
TYPE_LYRICS,
125+
TYPE_REST,
126+
TYPE_REST_BEAM,
125127
};
126128
Q_ENUM(InspectorModelType)
127129

src/inspector/models/inspectormodelcreator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#include "notation/tuplets/tupletsettingsmodel.h"
7070
#include "notation/instrumentname/instrumentnamesettingsmodel.h"
7171
#include "notation/lyrics/lyricssettingsmodel.h"
72+
#include "notation/rests/beams/restbeamsettingsmodel.h"
73+
#include "notation/rests/restsettingsproxymodel.h"
7274

7375
using namespace mu::inspector;
7476

@@ -178,6 +180,10 @@ AbstractInspectorModel* InspectorModelCreator::newInspectorModel(InspectorModelT
178180
return new InstrumentNameSettingsModel(parent, repository);
179181
case InspectorModelType::TYPE_LYRICS:
180182
return new LyricsSettingsModel(parent, repository);
183+
case InspectorModelType::TYPE_REST:
184+
return new RestSettingsProxyModel(parent, repository);
185+
case InspectorModelType::TYPE_REST_BEAM:
186+
return new RestBeamSettingsModel(parent, repository);
181187
case InspectorModelType::TYPE_BREATH:
182188
case InspectorModelType::TYPE_ARPEGGIO:
183189
case InspectorModelType::TYPE_DYNAMIC:

src/inspector/models/notation/notes/beams/internal/beammodesmodel.cpp renamed to src/inspector/models/notation/beams/beammodesmodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void BeamModesModel::createProperties()
3838

3939
void BeamModesModel::requestElements()
4040
{
41-
m_elementList = m_repository->findElementsByType(mu::engraving::ElementType::CHORD);
41+
m_elementList = m_repository->findElementsByType(mu::engraving::ElementType::CHORD) << m_repository->findElementsByType(
42+
mu::engraving::ElementType::REST);
4243
}
4344

4445
void BeamModesModel::loadProperties()

src/inspector/models/notation/notes/beams/beamsettingsmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define BEAMSETTINGSMODEL_H
2424

2525
#include "models/abstractinspectormodel.h"
26-
#include "internal/beammodesmodel.h"
26+
#include "models/notation/beams/beammodesmodel.h"
2727
#include "types/beamtypes.h"
2828

2929
namespace mu::inspector {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA and others
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 3 as
12+
* published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
#include "restbeamsettingsmodel.h"
23+
24+
#include "translation.h"
25+
#include "dataformatter.h"
26+
27+
using namespace mu::inspector;
28+
using namespace mu::engraving;
29+
30+
RestBeamSettingsModel::RestBeamSettingsModel(QObject* parent, IElementRepositoryService* repository)
31+
: AbstractInspectorModel(parent, repository)
32+
{
33+
setModelType(InspectorModelType::TYPE_BEAM);
34+
setTitle(qtrc("inspector", "Beam"));
35+
setBeamModesModel(new BeamModesModel(this, repository));
36+
}
37+
38+
QObject* RestBeamSettingsModel::beamModesModel() const
39+
{
40+
return m_beamModesModel;
41+
}
42+
43+
void RestBeamSettingsModel::setBeamModesModel(BeamModesModel* beamModesModel)
44+
{
45+
m_beamModesModel = beamModesModel;
46+
47+
connect(m_beamModesModel->mode(), &PropertyItem::propertyModified, this, &AbstractInspectorModel::requestReloadPropertyItems);
48+
49+
emit beamModesModelChanged(m_beamModesModel);
50+
}
51+
52+
void RestBeamSettingsModel::requestElements()
53+
{
54+
m_elementList = m_repository->findElementsByType(mu::engraving::ElementType::REST);
55+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA and others
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 3 as
12+
* published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
#ifndef MU_INSPECTOR_RESTBEAMSETTINGSMODEL_H
23+
#define MU_INSPECTOR_RESTBEAMSETTINGSMODEL_H
24+
25+
#include "models/abstractinspectormodel.h"
26+
#include "models/notation/beams/beammodesmodel.h"
27+
#include "types/beamtypes.h"
28+
29+
namespace mu::inspector {
30+
class RestBeamSettingsModel : public AbstractInspectorModel
31+
{
32+
Q_OBJECT
33+
34+
Q_PROPERTY(QObject * beamModesModel READ beamModesModel NOTIFY beamModesModelChanged)
35+
36+
public:
37+
explicit RestBeamSettingsModel(QObject* parent, IElementRepositoryService* repository);
38+
39+
QObject* beamModesModel() const;
40+
41+
public slots:
42+
void setBeamModesModel(BeamModesModel* beamModesModel);
43+
44+
signals:
45+
void beamModesModelChanged(QObject* beamModesModel);
46+
47+
private:
48+
void createProperties() override {}
49+
void requestElements() override;
50+
void loadProperties() override {}
51+
void resetProperties() override {}
52+
53+
BeamModesModel* m_beamModesModel = nullptr;
54+
};
55+
}
56+
57+
#endif // MU_INSPECTOR_RESTBEAMSETTINGSMODEL_H
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA and others
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 3 as
12+
* published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
#include "restsettingsproxymodel.h"
23+
24+
#include "translation.h"
25+
26+
using namespace mu::inspector;
27+
28+
static const QMap<mu::engraving::ElementType, InspectorModelType> REST_PART_TYPES {
29+
{ mu::engraving::ElementType::REST, InspectorModelType::TYPE_REST_BEAM }
30+
};
31+
32+
RestSettingsProxyModel::RestSettingsProxyModel(QObject* parent, IElementRepositoryService* repository)
33+
: AbstractInspectorProxyModel(parent, repository)
34+
{
35+
setModelType(InspectorModelType::TYPE_REST);
36+
setTitle(qtrc("inspector", "Rest"));
37+
setIcon(ui::IconCode::Code::QUAVER_REST);
38+
39+
QList<AbstractInspectorModel*> models;
40+
for (InspectorModelType modelType : REST_PART_TYPES) {
41+
models << inspectorModelCreator()->newInspectorModel(modelType, this, repository);
42+
}
43+
44+
setModels(models);
45+
46+
connect(m_repository->getQObject(), SIGNAL(elementsUpdated(const QList<mu::engraving::EngravingItem*>&)), this,
47+
SLOT(onElementsUpdated(const QList<mu::engraving::EngravingItem*>&)));
48+
}
49+
50+
void RestSettingsProxyModel::onElementsUpdated(const QList<mu::engraving::EngravingItem*>& newElements)
51+
{
52+
InspectorModelType defaultType = resolveDefaultSubModelType(newElements);
53+
54+
setDefaultSubModelType(defaultType);
55+
}
56+
57+
InspectorModelType RestSettingsProxyModel::resolveDefaultSubModelType(const QList<mu::engraving::EngravingItem*>& newElements) const
58+
{
59+
InspectorModelType defaultModelType = InspectorModelType::TYPE_REST;
60+
61+
for (const mu::engraving::EngravingItem* element : newElements) {
62+
if (REST_PART_TYPES.contains(element->type())) {
63+
defaultModelType = REST_PART_TYPES[element->type()];
64+
}
65+
}
66+
67+
return defaultModelType;
68+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2023 MuseScore BVBA and others
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 3 as
12+
* published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
#ifndef MU_INSPECTOR_RESTSETTINGSPROXYMODEL_H
23+
#define MU_INSPECTOR_RESTSETTINGSPROXYMODEL_H
24+
25+
#include "models/abstractinspectorproxymodel.h"
26+
27+
namespace mu::inspector {
28+
class RestSettingsProxyModel : public AbstractInspectorProxyModel
29+
{
30+
Q_OBJECT
31+
32+
public:
33+
explicit RestSettingsProxyModel(QObject* parent, IElementRepositoryService* repository);
34+
35+
private slots:
36+
void onElementsUpdated(const QList<mu::engraving::EngravingItem*>& newElements);
37+
38+
private:
39+
InspectorModelType resolveDefaultSubModelType(const QList<mu::engraving::EngravingItem*>& newElements) const;
40+
};
41+
}
42+
43+
#endif // MU_INSPECTOR_RESTSETTINGSPROXYMODEL_H

src/inspector/view/inspector_resources.qrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<file>qml/MuseScore/Inspector/notation/notes/internal/NoteheadGroupSelector.qml</file>
1111
<file>qml/MuseScore/Inspector/notation/notes/internal/NoteheadTypeSelector.qml</file>
1212
<file>qml/MuseScore/Inspector/notation/notes/BeamSettings.qml</file>
13-
<file>qml/MuseScore/Inspector/notation/notes/internal/BeamTypeSelector.qml</file>
13+
<file>qml/MuseScore/Inspector/notation/beams/BeamTypeSelector.qml</file>
1414
<file>qml/MuseScore/Inspector/general/playback/PlaybackSettings.qml</file>
1515
<file>qml/MuseScore/Inspector/general/playback/PlaybackGeneralSettings.qml</file>
1616
<file>qml/MuseScore/Inspector/general/playback/internal/NoteExpandableBlank.qml</file>
@@ -97,5 +97,7 @@
9797
<file>qml/MuseScore/Inspector/general/appearance/AppearanceSettings.qml</file>
9898
<file>qml/MuseScore/Inspector/text/TextSettings.qml</file>
9999
<file>qml/MuseScore/Inspector/notation/lyrics/LyricsSettings.qml</file>
100+
<file>qml/MuseScore/Inspector/notation/rests/RestBeamSettings.qml</file>
101+
<file>qml/MuseScore/Inspector/notation/rests/RestSettings.qml</file>
100102
</qresource>
101103
</RCC>

src/inspector/view/qml/MuseScore/Inspector/notation/NotationInspectorSectionLoader.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import "measurerepeats"
5757
import "tuplets"
5858
import "instrumentname"
5959
import "lyrics"
60+
import "rests"
6061

6162
Loader {
6263
id: root
@@ -126,6 +127,8 @@ Loader {
126127
case Inspector.TYPE_TUPLET: return tupletComp
127128
case Inspector.TYPE_INSTRUMENT_NAME: return instrumentNameComp
128129
case Inspector.TYPE_LYRICS: return lyricsComp
130+
case Inspector.TYPE_REST: return restComp
131+
case Inspector.TYPE_REST_BEAM: return restComp
129132
}
130133

131134
return null
@@ -319,4 +322,9 @@ Loader {
319322
id: lyricsComp
320323
LyricsSettings {}
321324
}
325+
326+
Component {
327+
id: restComp
328+
RestSettings {}
329+
}
322330
}

0 commit comments

Comments
 (0)