Skip to content

Commit 5020852

Browse files
committed
Merge pull request #1746 from andreituicu/fix_5358
Fix 5358 : Play whole chord when adding note
2 parents 061bc0f + 504267b commit 5020852

File tree

7 files changed

+93
-73
lines changed

7 files changed

+93
-73
lines changed

libmscore/edit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ Note* Score::addNote(Chord* chord, NoteVal& noteVal)
360360
note->setNval(noteVal);
361361
undoAddElement(note);
362362
_playNote = true;
363+
_playChord = true;
363364
select(note, SelectType::SINGLE, 0);
364365
if (!chord->staff()->isTabStaff())
365366
_is.moveToNextInputPos();

libmscore/score.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ void Score::init()
295295
layoutFlags = 0;
296296
_undoRedo = false;
297297
_playNote = false;
298+
_playChord = false;
298299
_excerptsChanged = false;
299300
_instrumentsChanged = false;
300301
_selectionChanged = false;

libmscore/score.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ class Score : public QObject {
349349

350350
bool _undoRedo; ///< true if in processing a undo/redo
351351
bool _playNote; ///< play selected note after command
352+
bool _playChord; ///< play whole chord for the selected note
352353

353354
bool _excerptsChanged;
354355
bool _instrumentsChanged;
@@ -954,6 +955,8 @@ class Score : public QObject {
954955
const QList<MuseScoreView*>& getViewer() const { return viewer; }
955956
bool playNote() const { return _playNote; }
956957
void setPlayNote(bool v) { _playNote = v; }
958+
bool playChord() const { return _playChord; }
959+
void setPlayChord(bool v) { _playChord = v; }
957960
bool excerptsChanged() const { return _excerptsChanged; }
958961
void setExcerptsChanged(bool val) { _excerptsChanged = val; }
959962
bool instrumentsChanged() const { return _instrumentsChanged; }

mscore/musescore.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3904,9 +3904,13 @@ void MuseScore::endCmd()
39043904
updateUndoRedo();
39053905
dirtyChanged(cs);
39063906
Element* e = cs->selection().element();
3907-
if (e && cs->playNote()) {
3908-
play(e);
3907+
if (e && (cs->playNote() || cs->playChord())) {
3908+
if (cs->playChord() && preferences.playChordOnAddNote && e->type() == Element::Type::NOTE)
3909+
play(static_cast<Note*>(e)->chord());
3910+
else
3911+
play(e);
39093912
cs->setPlayNote(false);
3913+
cs->setPlayChord(false);
39103914
}
39113915
if (cs->rootScore()->excerptsChanged()) {
39123916
//Q_ASSERT(cs == cs->rootScore());

mscore/preferences.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void Preferences::init()
104104

105105
enableMidiInput = true;
106106
playNotes = true;
107+
playChordOnAddNote = true;
107108

108109
showNavigator = false;
109110
showPlayPanel = false;
@@ -246,6 +247,7 @@ void Preferences::write()
246247
s.setValue("defaultColor", MScore::defaultColor);
247248
s.setValue("enableMidiInput", enableMidiInput);
248249
s.setValue("playNotes", playNotes);
250+
s.setValue("playChordOnAddNote", playChordOnAddNote);
249251

250252
s.setValue("showNavigator", showNavigator);
251253
s.setValue("showPlayPanel", showPlayPanel);
@@ -395,6 +397,7 @@ void Preferences::read()
395397

396398
enableMidiInput = s.value("enableMidiInput", enableMidiInput).toBool();
397399
playNotes = s.value("playNotes", playNotes).toBool();
400+
playChordOnAddNote = s.value("playChordOnAddNote", playChordOnAddNote).toBool();
398401

399402
showNavigator = s.value("showNavigator", showNavigator).toBool();
400403
showSplashScreen = s.value("showSplashScreen", showSplashScreen).toBool();
@@ -801,6 +804,7 @@ void PreferenceDialog::updateValues()
801804

802805
enableMidiInput->setChecked(prefs.enableMidiInput);
803806
playNotes->setChecked(prefs.playNotes);
807+
playChordOnAddNote->setChecked(prefs.playChordOnAddNote);
804808

805809
//Update
806810
checkUpdateStartup->clear();
@@ -1272,6 +1276,7 @@ void PreferenceDialog::apply()
12721276
prefs.fgUseColor = fgColorButton->isChecked();
12731277
prefs.enableMidiInput = enableMidiInput->isChecked();
12741278
prefs.playNotes = playNotes->isChecked();
1279+
prefs.playChordOnAddNote = playChordOnAddNote->isChecked();
12751280

12761281
prefs.showNavigator = navigatorShow->isChecked();
12771282
prefs.showPlayPanel = playPanelShow->isChecked();

mscore/preferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct Preferences {
9090
QColor dropColor;
9191
bool enableMidiInput;
9292
bool playNotes; // play notes on click
93+
bool playChordOnAddNote;
9394
bool showNavigator;
9495
bool showPlayPanel;
9596
bool showStatusBar;

mscore/prefsdialog.ui

Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,73 +1181,77 @@
11811181
</widget>
11821182
</item>
11831183
<item>
1184-
<layout class="QHBoxLayout" name="horizontalLayout_4">
1185-
<item>
1186-
<widget class="QCheckBox" name="playNotes">
1187-
<property name="accessibleName">
1188-
<string>Play notes when editing</string>
1189-
</property>
1190-
<property name="text">
1191-
<string>Play notes when editing</string>
1192-
</property>
1193-
</widget>
1194-
</item>
1195-
<item>
1196-
<spacer name="horizontalSpacer_2">
1197-
<property name="orientation">
1198-
<enum>Qt::Horizontal</enum>
1199-
</property>
1200-
<property name="sizeHint" stdset="0">
1201-
<size>
1202-
<width>40</width>
1203-
<height>20</height>
1204-
</size>
1205-
</property>
1206-
</spacer>
1207-
</item>
1208-
<item>
1209-
<widget class="QLabel" name="label_37">
1210-
<property name="text">
1211-
<string>Default duration:</string>
1212-
</property>
1213-
</widget>
1214-
</item>
1215-
<item>
1216-
<widget class="QSpinBox" name="defaultPlayDuration">
1217-
<property name="accessibleName">
1218-
<string>Default duration</string>
1219-
</property>
1220-
<property name="suffix">
1221-
<string>ms</string>
1222-
</property>
1223-
<property name="minimum">
1224-
<number>20</number>
1225-
</property>
1226-
<property name="maximum">
1227-
<number>2000</number>
1228-
</property>
1229-
<property name="singleStep">
1230-
<number>100</number>
1231-
</property>
1232-
<property name="value">
1233-
<number>300</number>
1234-
</property>
1235-
</widget>
1236-
</item>
1237-
<item>
1238-
<spacer name="horizontalSpacer_3">
1239-
<property name="orientation">
1240-
<enum>Qt::Horizontal</enum>
1241-
</property>
1242-
<property name="sizeHint" stdset="0">
1243-
<size>
1244-
<width>40</width>
1245-
<height>20</height>
1246-
</size>
1247-
</property>
1248-
</spacer>
1249-
</item>
1250-
</layout>
1184+
<widget class="QGroupBox" name="playNotes">
1185+
<property name="mouseTracking">
1186+
<bool>true</bool>
1187+
</property>
1188+
<property name="accessibleName">
1189+
<string>Play notes when editing</string>
1190+
</property>
1191+
<property name="title">
1192+
<string>Play notes when editing</string>
1193+
</property>
1194+
<property name="checkable">
1195+
<bool>true</bool>
1196+
</property>
1197+
<property name="checked">
1198+
<bool>true</bool>
1199+
</property>
1200+
<layout class="QGridLayout" name="gridLayout_4">
1201+
<item row="0" column="0">
1202+
<widget class="QLabel" name="label_37">
1203+
<property name="text">
1204+
<string>Default duration:</string>
1205+
</property>
1206+
</widget>
1207+
</item>
1208+
<item row="0" column="1">
1209+
<widget class="QSpinBox" name="defaultPlayDuration">
1210+
<property name="accessibleName">
1211+
<string>Default duration</string>
1212+
</property>
1213+
<property name="suffix">
1214+
<string>ms</string>
1215+
</property>
1216+
<property name="minimum">
1217+
<number>20</number>
1218+
</property>
1219+
<property name="maximum">
1220+
<number>2000</number>
1221+
</property>
1222+
<property name="singleStep">
1223+
<number>100</number>
1224+
</property>
1225+
<property name="value">
1226+
<number>300</number>
1227+
</property>
1228+
</widget>
1229+
</item>
1230+
<item row="1" column="0">
1231+
<widget class="QCheckBox" name="playChordOnAddNote">
1232+
<property name="accessibleName">
1233+
<string>Play whole chord when adding note</string>
1234+
</property>
1235+
<property name="text">
1236+
<string>Play whole chord when adding note</string>
1237+
</property>
1238+
</widget>
1239+
</item>
1240+
<item row="0" column="2">
1241+
<spacer name="horizontalSpacer_2">
1242+
<property name="orientation">
1243+
<enum>Qt::Horizontal</enum>
1244+
</property>
1245+
<property name="sizeHint" stdset="0">
1246+
<size>
1247+
<width>40</width>
1248+
<height>20</height>
1249+
</size>
1250+
</property>
1251+
</spacer>
1252+
</item>
1253+
</layout>
1254+
</widget>
12511255
</item>
12521256
<item>
12531257
<widget class="QCheckBox" name="warnPitchRange">
@@ -3560,8 +3564,6 @@
35603564
<tabstop>autoSaveTime</tabstop>
35613565
<tabstop>oscServer</tabstop>
35623566
<tabstop>oscPort</tabstop>
3563-
<tabstop>resetToDefault</tabstop>
3564-
<tabstop>buttonBox</tabstop>
35653567
<tabstop>bgColorButton</tabstop>
35663568
<tabstop>bgWallpaperButton</tabstop>
35673569
<tabstop>bgColorLabel</tabstop>
@@ -3572,11 +3574,10 @@
35723574
<tabstop>fgColorLabel</tabstop>
35733575
<tabstop>fgWallpaper</tabstop>
35743576
<tabstop>fgWallpaperSelect</tabstop>
3575-
<tabstop>drawAntialiased</tabstop>
3576-
<tabstop>proximity</tabstop>
35773577
<tabstop>enableMidiInput</tabstop>
35783578
<tabstop>playNotes</tabstop>
35793579
<tabstop>defaultPlayDuration</tabstop>
3580+
<tabstop>playChordOnAddNote</tabstop>
35803581
<tabstop>warnPitchRange</tabstop>
35813582
<tabstop>rcGroup</tabstop>
35823583
<tabstop>rewindActive</tabstop>
@@ -3662,6 +3663,10 @@
36623663
<tabstop>defineShortcut</tabstop>
36633664
<tabstop>printShortcuts</tabstop>
36643665
<tabstop>checkUpdateStartup</tabstop>
3666+
<tabstop>resetToDefault</tabstop>
3667+
<tabstop>buttonBox</tabstop>
3668+
<tabstop>drawAntialiased</tabstop>
3669+
<tabstop>proximity</tabstop>
36653670
</tabstops>
36663671
<resources/>
36673672
<connections/>

0 commit comments

Comments
 (0)