Skip to content

Commit f8f71bc

Browse files
committed
Change piano key 'display style' to 'black key length ratio'
1 parent bcd7a05 commit f8f71bc

7 files changed

Lines changed: 41 additions & 37 deletions

File tree

src/plugins/visualeditor/core/PianoRollPanelInterface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,10 @@ namespace VisualEditor {
240240
void PianoRollPanelInterfacePrivate::bindClavierInteractionController() const {
241241
Q_Q(const PianoRollPanelInterface);
242242
auto applyStyle = [=, this] {
243-
auto simple = Internal::EditorPreference::pianoKeyboardUseSimpleStyle();
244-
clavierInteractionController->setDisplayStyle(simple ? sflow::ClavierInteractionController::Simple : sflow::ClavierInteractionController::Realistic);
243+
clavierInteractionController->setBlackKeyLengthRatio(Internal::EditorPreference::pianoKeyboardBlackKeyLengthRatio());
245244
};
246245
applyStyle();
247-
QObject::connect(Internal::EditorPreference::instance(), &Internal::EditorPreference::pianoKeyboardUseSimpleStyleChanged, clavierInteractionController, applyStyle);
246+
QObject::connect(Internal::EditorPreference::instance(), &Internal::EditorPreference::pianoKeyboardBlackKeyLengthRatioChanged, clavierInteractionController, applyStyle);
248247

249248
auto applyLabelStrategy = [=, this] {
250249
auto policy = Internal::EditorPreference::pianoKeyboardLabelPolicy();

src/plugins/visualeditor/internal/EditorPreference.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <QSettings>
44

5+
#include <QtGlobal>
6+
57
#include <CoreApi/runtimeinterface.h>
68

79
namespace VisualEditor::Internal {
@@ -18,7 +20,7 @@ namespace VisualEditor::Internal {
1820
int autoDurationPositionAlignment{24};
1921
bool enableTemporarySnapOff{true};
2022
bool trackListOnRight{};
21-
bool pianoKeyboardUseSimpleStyle{};
23+
double pianoKeyboardBlackKeyLengthRatio{0.6};
2224
EditorPreference::PianoKeyboardLabelPolicy pianoKeyboardLabelPolicy{};
2325
bool displayPronunciationBelowNote{};
2426
int shortNoteThreshold{30};
@@ -60,8 +62,8 @@ namespace VisualEditor::Internal {
6062
emit enableTemporarySnapOffChanged();
6163
d->trackListOnRight = settings->value("trackListOnRight", false).toBool();
6264
emit trackListOnRightChanged();
63-
d->pianoKeyboardUseSimpleStyle = settings->value("pianoKeyboardUseSimpleStyle", false).toBool();
64-
emit pianoKeyboardUseSimpleStyleChanged();
65+
d->pianoKeyboardBlackKeyLengthRatio = settings->value("pianoKeyboardBlackKeyLengthRatio", 0.6).toDouble();
66+
emit pianoKeyboardBlackKeyLengthRatioChanged();
6567
d->pianoKeyboardLabelPolicy = settings->value("pianoKeyboardLabelPolicy", QVariant::fromValue(LP_All)).value<PianoKeyboardLabelPolicy>();
6668
emit pianoKeyboardLabelPolicyChanged();
6769
d->displayPronunciationBelowNote = settings->value("displayPronunciationBelowNote", false).toBool();
@@ -85,7 +87,7 @@ namespace VisualEditor::Internal {
8587
settings->setValue("autoDurationPositionAlignment", d->autoDurationPositionAlignment);
8688
settings->setValue("enableTemporarySnapOff", d->enableTemporarySnapOff);
8789
settings->setValue("trackListOnRight", d->trackListOnRight);
88-
settings->setValue("pianoKeyboardUseSimpleStyle", d->pianoKeyboardUseSimpleStyle);
90+
settings->setValue("pianoKeyboardBlackKeyLengthRatio", d->pianoKeyboardBlackKeyLengthRatio);
8991
settings->setValue("pianoKeyboardLabelPolicy", static_cast<int>(d->pianoKeyboardLabelPolicy));
9092
settings->setValue("displayPronunciationBelowNote", d->displayPronunciationBelowNote);
9193
settings->setValue("shortNoteThreshold", d->shortNoteThreshold);
@@ -201,17 +203,17 @@ namespace VisualEditor::Internal {
201203
emit m_instance->trackListOnRightChanged();
202204
}
203205

204-
bool EditorPreference::pianoKeyboardUseSimpleStyle() {
206+
double EditorPreference::pianoKeyboardBlackKeyLengthRatio() {
205207
M_INSTANCE_D;
206-
return d->pianoKeyboardUseSimpleStyle;
208+
return d->pianoKeyboardBlackKeyLengthRatio;
207209
}
208210

209-
void EditorPreference::setPianoKeyboardUseSimpleStyle(bool pianoKeyboardUseSimpleStyle) {
211+
void EditorPreference::setPianoKeyboardBlackKeyLengthRatio(double pianoKeyboardBlackKeyLengthRatio) {
210212
M_INSTANCE_D;
211-
if (d->pianoKeyboardUseSimpleStyle == pianoKeyboardUseSimpleStyle)
213+
if (qFuzzyCompare(d->pianoKeyboardBlackKeyLengthRatio, pianoKeyboardBlackKeyLengthRatio))
212214
return;
213-
d->pianoKeyboardUseSimpleStyle = pianoKeyboardUseSimpleStyle;
214-
emit m_instance->pianoKeyboardUseSimpleStyleChanged();
215+
d->pianoKeyboardBlackKeyLengthRatio = pianoKeyboardBlackKeyLengthRatio;
216+
emit m_instance->pianoKeyboardBlackKeyLengthRatioChanged();
215217
}
216218

217219
EditorPreference::PianoKeyboardLabelPolicy EditorPreference::pianoKeyboardLabelPolicy() {

src/plugins/visualeditor/internal/EditorPreference.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace VisualEditor::Internal {
2727
Q_PROPERTY(int autoDurationPositionAlignment READ autoDurationPositionAlignment WRITE setAutoDurationPositionAlignment NOTIFY autoDurationPositionAlignmentChanged)
2828
Q_PROPERTY(bool enableTemporarySnapOff READ enableTemporarySnapOff WRITE setEnableTemporarySnapOff NOTIFY enableTemporarySnapOffChanged)
2929
Q_PROPERTY(bool trackListOnRight READ trackListOnRight WRITE setTrackListOnRight NOTIFY trackListOnRightChanged)
30-
Q_PROPERTY(bool pianoKeyboardUseSimpleStyle READ pianoKeyboardUseSimpleStyle WRITE setPianoKeyboardUseSimpleStyle NOTIFY pianoKeyboardUseSimpleStyleChanged)
30+
Q_PROPERTY(double pianoKeyboardBlackKeyLengthRatio READ pianoKeyboardBlackKeyLengthRatio WRITE setPianoKeyboardBlackKeyLengthRatio NOTIFY pianoKeyboardBlackKeyLengthRatioChanged)
3131
Q_PROPERTY(EditorPreference::PianoKeyboardLabelPolicy pianoKeyboardLabelPolicy READ pianoKeyboardLabelPolicy WRITE setPianoKeyboardLabelPolicy NOTIFY pianoKeyboardLabelPolicyChanged)
3232
Q_PROPERTY(bool displayPronunciationBelowNote READ displayPronunciationBelowNote WRITE setDisplayPronunciationBelowNote NOTIFY displayPronunciationBelowNoteChanged)
3333
Q_PROPERTY(int shortNoteThreshold READ shortNoteThreshold WRITE setShortNoteThreshold NOTIFY shortNoteThresholdChanged)
@@ -83,8 +83,8 @@ namespace VisualEditor::Internal {
8383
static bool trackListOnRight();
8484
static void setTrackListOnRight(bool trackListOnRight);
8585

86-
static bool pianoKeyboardUseSimpleStyle();
87-
static void setPianoKeyboardUseSimpleStyle(bool pianoKeyboardUseSimpleStyle);
86+
static double pianoKeyboardBlackKeyLengthRatio();
87+
static void setPianoKeyboardBlackKeyLengthRatio(double pianoKeyboardBlackKeyLengthRatio);
8888

8989
static PianoKeyboardLabelPolicy pianoKeyboardLabelPolicy();
9090
static void setPianoKeyboardLabelPolicy(PianoKeyboardLabelPolicy pianoKeyboardLabelPolicy);
@@ -107,7 +107,7 @@ namespace VisualEditor::Internal {
107107
void autoDurationPositionAlignmentChanged();
108108
void enableTemporarySnapOffChanged();
109109
void trackListOnRightChanged();
110-
void pianoKeyboardUseSimpleStyleChanged();
110+
void pianoKeyboardBlackKeyLengthRatioChanged();
111111
void pianoKeyboardLabelPolicyChanged();
112112
void displayPronunciationBelowNoteChanged();
113113
void shortNoteThresholdChanged();

src/plugins/visualeditor/internal/settings/EditorPage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ namespace VisualEditor::Internal {
6161
qCDebug(lcEditorPage) << m_widget->property("enableTemporarySnapOff");
6262
m_widget->setProperty("trackListOnRight", EditorPreference::instance()->property("trackListOnRight"));
6363
qCDebug(lcEditorPage) << m_widget->property("trackListOnRight");
64-
m_widget->setProperty("pianoKeyboardUseSimpleStyle", EditorPreference::instance()->property("pianoKeyboardUseSimpleStyle"));
65-
qCDebug(lcEditorPage) << m_widget->property("pianoKeyboardUseSimpleStyle");
64+
m_widget->setProperty("pianoKeyboardBlackKeyLengthRatio", EditorPreference::instance()->property("pianoKeyboardBlackKeyLengthRatio"));
65+
qCDebug(lcEditorPage) << m_widget->property("pianoKeyboardBlackKeyLengthRatio");
6666
m_widget->setProperty("pianoKeyboardLabelPolicy", EditorPreference::instance()->property("pianoKeyboardLabelPolicy"));
6767
qCDebug(lcEditorPage) << m_widget->property("pianoKeyboardLabelPolicy");
6868
m_widget->setProperty("displayPronunciationBelowNote", EditorPreference::instance()->property("displayPronunciationBelowNote"));
@@ -93,8 +93,8 @@ namespace VisualEditor::Internal {
9393
EditorPreference::instance()->setProperty("enableTemporarySnapOff", m_widget->property("enableTemporarySnapOff"));
9494
qCDebug(lcEditorPage) << "trackListOnRight" << m_widget->property("trackListOnRight");
9595
EditorPreference::instance()->setProperty("trackListOnRight", m_widget->property("trackListOnRight"));
96-
qCDebug(lcEditorPage) << "pianoKeyboardUseSimpleStyle" << m_widget->property("pianoKeyboardUseSimpleStyle");
97-
EditorPreference::instance()->setProperty("pianoKeyboardUseSimpleStyle", m_widget->property("pianoKeyboardUseSimpleStyle"));
96+
qCDebug(lcEditorPage) << "pianoKeyboardBlackKeyLengthRatio" << m_widget->property("pianoKeyboardBlackKeyLengthRatio");
97+
EditorPreference::instance()->setProperty("pianoKeyboardBlackKeyLengthRatio", m_widget->property("pianoKeyboardBlackKeyLengthRatio"));
9898
qCDebug(lcEditorPage) << "pianoKeyboardLabelPolicy" << m_widget->property("pianoKeyboardLabelPolicy");
9999
EditorPreference::instance()->setProperty("pianoKeyboardLabelPolicy", m_widget->property("pianoKeyboardLabelPolicy"));
100100
qCDebug(lcEditorPage) << "displayPronunciationBelowNote" << m_widget->property("displayPronunciationBelowNote");

src/plugins/visualeditor/qml/settings/EditorPage.qml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ScrollView {
2121
property double autoDurationPositionAlignment: 32
2222
property bool enableTemporarySnapOff: false
2323
property bool trackListOnRight: false
24-
property bool pianoKeyboardUseSimpleStyle: false
24+
property double pianoKeyboardBlackKeyLengthRatio: 0.6
2525
property int pianoKeyboardLabelPolicy: 0
2626
property bool displayPronunciationBelowNote: false
2727
property int shortNoteThreshold: 30
@@ -35,7 +35,7 @@ ScrollView {
3535
onAutoDurationPositionAlignmentChanged: if (started) pageHandle.markDirty()
3636
onEnableTemporarySnapOffChanged: if (started) pageHandle.markDirty()
3737
onTrackListOnRightChanged: if (started) pageHandle.markDirty()
38-
onPianoKeyboardUseSimpleStyleChanged: if (started) pageHandle.markDirty()
38+
onPianoKeyboardBlackKeyLengthRatioChanged: if (started) pageHandle.markDirty()
3939
onPianoKeyboardLabelPolicyChanged: if (started) pageHandle.markDirty()
4040
onDisplayPronunciationBelowNoteChanged: if (started) pageHandle.markDirty()
4141
onShortNoteThresholdChanged: if (started) pageHandle.markDirty()
@@ -151,10 +151,12 @@ ScrollView {
151151
}
152152
Slider {
153153
Layout.fillWidth: true
154-
from: 0
155-
to: 1
156-
value: Math.log10(page.autoDurationPositionAlignment) - 0.9
157-
onMoved: page.autoDurationPositionAlignment = Math.pow(10, value + 0.9)
154+
from: 0.9 - Math.log10(32)
155+
to: 1.9 - Math.log10(32)
156+
ThemedItem.sliderTrackStartType: SVS.TS_Begin
157+
value: Math.log10(page.autoDurationPositionAlignment) - Math.log10(32)
158+
onMoved: page.autoDurationPositionAlignment = Math.pow(10, value + Math.log10(32))
159+
ThemedItem.onDoubleClickReset: moved()
158160
}
159161
Label {
160162
text: qsTr("More spacious")
@@ -210,18 +212,19 @@ ScrollView {
210212
columns: 3
211213

212214
Label {
213-
text: qsTr("Piano keyboard style")
215+
text: qsTr("Black key width")
214216
TextMatcherItem on text { matcher: page.matcher }
215217
}
216-
Item {
218+
Slider {
217219
Layout.fillWidth: true
220+
Layout.columnSpan: 2
221+
from: -0.1
222+
to: 0.4
223+
ThemedItem.sliderTrackStartType: SVS.TS_Begin
224+
value: page.pianoKeyboardBlackKeyLengthRatio - 0.6
225+
onMoved: page.pianoKeyboardBlackKeyLengthRatio = value + 0.6
226+
ThemedItem.onDoubleClickReset: moved()
218227
}
219-
ComboBox {
220-
model: [qsTr("Realistic"), qsTr("Simple")]
221-
currentIndex: page.pianoKeyboardUseSimpleStyle ? 1 : 0
222-
onActivated: (index) => page.pianoKeyboardUseSimpleStyle = (index === 1)
223-
}
224-
225228
Label {
226229
text: qsTr("Display piano key label on")
227230
TextMatcherItem on text { matcher: page.matcher }

0 commit comments

Comments
 (0)