Skip to content

Commit 127996b

Browse files
committed
Exposing default rest offset to Style dialog
1 parent 723bccb commit 127996b

File tree

8 files changed

+160
-16
lines changed

8 files changed

+160
-16
lines changed

src/notation/notationmodule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474
#include "view/styledialog/styleitem.h"
7575
#include "view/styledialog/notespagemodel.h"
76+
#include "view/styledialog/restspagemodel.h"
7677
#include "view/styledialog/beamspagemodel.h"
7778

7879
#include "diagnostics/idiagnosticspathsregister.h"
@@ -194,6 +195,7 @@ void NotationModule::registerUiTypes()
194195

195196
qmlRegisterUncreatableType<StyleItem>("MuseScore.NotationScene", 1, 0, "StyleItem", "Cannot create StyleItem from QML");
196197
qmlRegisterType<NotesPageModel>("MuseScore.NotationScene", 1, 0, "NotesPageModel");
198+
qmlRegisterType<RestsPageModel>("MuseScore.NotationScene", 1, 0, "RestsPageModel");
197199
qmlRegisterType<BeamsPageModel>("MuseScore.NotationScene", 1, 0, "BeamsPageModel");
198200

199201
qRegisterMetaType<EditStyle>("EditStyle");

src/notation/notationscene.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
<file>qml/MuseScore/NotationScene/internal/NoteInputBarCustomisePopup.qml</file>
3636
<file>qml/MuseScore/NotationScene/internal/NotationScrollBar.qml</file>
3737
<file>qml/MuseScore/NotationScene/PianoKeyboardPanel.qml</file>
38+
<file>qml/MuseScore/NotationScene/internal/EditStyle/RestOffsetSelector.qml</file>
3839
</qresource>
3940
</RCC>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-only
3+
* MuseScore-CLA-applies
4+
*
5+
* MuseScore
6+
* Music Composition & Notation
7+
*
8+
* Copyright (C) 2021 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+
23+
import QtQuick 2.15
24+
25+
import MuseScore.NotationScene 1.0
26+
import MuseScore.UiComponents 1.0
27+
import MuseScore.Ui 1.0
28+
29+
Rectangle {
30+
anchors.fill: parent
31+
color: ui.theme.backgroundPrimaryColor
32+
33+
RestsPageModel {
34+
id: restsPageModel
35+
}
36+
37+
RadioButtonGroup {
38+
width: 224
39+
height: 30
40+
spacing: 12
41+
42+
model: [
43+
{ text: qsTrc("notation", "1 space"), value: false },
44+
{ text: qsTrc("notation", "2 spaces"), value: true }
45+
]
46+
47+
delegate: FlatRadioButton {
48+
width: 106
49+
height: 30
50+
51+
checked: modelData.value === restsPageModel.multiVoiceRestTwoSpaceOffset.value
52+
53+
Column {
54+
anchors.centerIn: parent
55+
height: childrenRect.height
56+
spacing: 8
57+
58+
StyledIconLabel {
59+
anchors.horizontalCenter: parent.horizontalCenter
60+
iconCode: modelData.iconCode
61+
font.pixelSize: 32
62+
}
63+
64+
StyledTextLabel {
65+
anchors.horizontalCenter: parent.horizontalCenter
66+
text: modelData.text
67+
}
68+
}
69+
70+
onToggled: {
71+
restsPageModel.multiVoiceRestTwoSpaceOffset.value = modelData.value
72+
}
73+
}
74+
}
75+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "restspagemodel.h"
2+
3+
using namespace mu::notation;
4+
5+
RestsPageModel::RestsPageModel(QObject* parent)
6+
: AbstractStyleDialogModel(parent, {
7+
StyleId::multiVoiceRestTwoSpaceOffset
8+
})
9+
{
10+
}
11+
12+
StyleItem* RestsPageModel::multiVoiceRestTwoSpaceOffset() const
13+
{
14+
return styleItem(StyleId::multiVoiceRestTwoSpaceOffset);
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef RESTSPAGEMODEL_H
2+
#define RESTSPAGEMODEL_H
3+
4+
#include "abstractstyledialogmodel.h"
5+
6+
namespace mu::notation {
7+
class RestsPageModel : public AbstractStyleDialogModel
8+
{
9+
Q_OBJECT
10+
11+
Q_PROPERTY(StyleItem * multiVoiceRestTwoSpaceOffset READ multiVoiceRestTwoSpaceOffset CONSTANT)
12+
13+
public:
14+
explicit RestsPageModel(QObject* parent = nullptr);
15+
16+
StyleItem* multiVoiceRestTwoSpaceOffset() const;
17+
};
18+
}
19+
20+
#endif // RESTSPAGEMODEL_H

src/notation/view/styledialog/styledialog.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set(STYLEDIALOG_SRC
66

77
${CMAKE_CURRENT_LIST_DIR}/notespagemodel.cpp
88
${CMAKE_CURRENT_LIST_DIR}/notespagemodel.h
9+
${CMAKE_CURRENT_LIST_DIR}/restspagemodel.cpp
10+
${CMAKE_CURRENT_LIST_DIR}/restspagemodel.h
911
${CMAKE_CURRENT_LIST_DIR}/beamspagemodel.cpp
1012
${CMAKE_CURRENT_LIST_DIR}/beamspagemodel.h
1113
)

src/notation/view/widgets/editstyle.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,19 @@ EditStyle::EditStyle(QWidget* parent)
726726
noteFlagsTypeSelector->setResizeMode(QQuickWidget::SizeRootObjectToView);
727727
groupBox_noteFlags->layout()->addWidget(noteFlagsTypeSelector);
728728

729+
// ====================================================
730+
// Rests (QML)
731+
// ====================================================
732+
733+
QQuickWidget* restOffsetSelector = new QQuickWidget(/*QmlEngine*/ uiEngine()->qmlEngine(),
734+
/*parent*/ groupBox_rests);
735+
restOffsetSelector->setObjectName("restOffsetSelector_QQuickWidget");
736+
restOffsetSelector->setSource(
737+
QUrl(QString::fromUtf8("qrc:/qml/MuseScore/NotationScene/internal/EditStyle/RestOffsetSelector.qml")));
738+
restOffsetSelector->setMinimumSize(224, 30);
739+
restOffsetSelector->setResizeMode(QQuickWidget::SizeRootObjectToView);
740+
groupBox_rests->layout()->addWidget(restOffsetSelector);
741+
729742
// ====================================================
730743
// Notes (QML)
731744
// ====================================================

src/notation/view/widgets/editstyle.ui

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@
315315
<rect>
316316
<x>0</x>
317317
<y>0</y>
318-
<width>673</width>
319-
<height>638</height>
318+
<width>592</width>
319+
<height>441</height>
320320
</rect>
321321
</property>
322322
<layout class="QVBoxLayout" name="verticalLayout_10">
@@ -899,8 +899,8 @@
899899
<rect>
900900
<x>0</x>
901901
<y>0</y>
902-
<width>673</width>
903-
<height>674</height>
902+
<width>408</width>
903+
<height>484</height>
904904
</rect>
905905
</property>
906906
<layout class="QGridLayout" name="gridLayout_4">
@@ -2213,8 +2213,8 @@
22132213
<rect>
22142214
<x>0</x>
22152215
<y>0</y>
2216-
<width>737</width>
2217-
<height>674</height>
2216+
<width>685</width>
2217+
<height>298</height>
22182218
</rect>
22192219
</property>
22202220
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -3933,8 +3933,8 @@ By default, they will be placed such as that their right end are at the same lev
39333933
<rect>
39343934
<x>0</x>
39353935
<y>0</y>
3936-
<width>369</width>
3937-
<height>882</height>
3936+
<width>239</width>
3937+
<height>593</height>
39383938
</rect>
39393939
</property>
39403940
<layout class="QGridLayout" name="gridLayout_56">
@@ -5350,6 +5350,22 @@ By default, they will be placed such as that their right end are at the same lev
53505350
</widget>
53515351
<widget class="QWidget" name="PageRests">
53525352
<layout class="QVBoxLayout" name="verticalLayout_8">
5353+
<item>
5354+
<widget class="QGroupBox" name="groupBox_rests">
5355+
<property name="title">
5356+
<string>Rests (multiple voices)</string>
5357+
</property>
5358+
<layout class="QVBoxLayout" name="verticalLayout_36">
5359+
<item>
5360+
<widget class="QLabel" name="label_46">
5361+
<property name="text">
5362+
<string>Default vertical offset:</string>
5363+
</property>
5364+
</widget>
5365+
</item>
5366+
</layout>
5367+
</widget>
5368+
</item>
53535369
<item>
53545370
<widget class="QGroupBox" name="multiMeasureRests">
53555371
<property name="title">
@@ -5941,8 +5957,8 @@ By default, they will be placed such as that their right end are at the same lev
59415957
<rect>
59425958
<x>0</x>
59435959
<y>0</y>
5944-
<width>579</width>
5945-
<height>527</height>
5960+
<width>364</width>
5961+
<height>386</height>
59465962
</rect>
59475963
</property>
59485964
<layout class="QGridLayout" name="gridLayout_54">
@@ -9699,8 +9715,8 @@ By default, they will be placed such as that their right end are at the same lev
96999715
<rect>
97009716
<x>0</x>
97019717
<y>0</y>
9702-
<width>585</width>
9703-
<height>465</height>
9718+
<width>380</width>
9719+
<height>324</height>
97049720
</rect>
97059721
</property>
97069722
<layout class="QGridLayout" name="gridLayout_57">
@@ -10995,8 +11011,8 @@ By default, they will be placed such as that their right end are at the same lev
1099511011
<rect>
1099611012
<x>0</x>
1099711013
<y>0</y>
10998-
<width>568</width>
10999-
<height>551</height>
11014+
<width>384</width>
11015+
<height>422</height>
1100011016
</rect>
1100111017
</property>
1100211018
<layout class="QGridLayout" name="gridLayout_55">
@@ -11916,8 +11932,8 @@ By default, they will be placed such as that their right end are at the same lev
1191611932
<rect>
1191711933
<x>0</x>
1191811934
<y>0</y>
11919-
<width>531</width>
11920-
<height>481</height>
11935+
<width>354</width>
11936+
<height>385</height>
1192111937
</rect>
1192211938
</property>
1192311939
<layout class="QVBoxLayout" name="verticalLayout_40">

0 commit comments

Comments
 (0)