Skip to content

Commit

Permalink
fix #59171: Pressing a key in Piano Keyboard window sustains indefini…
Browse files Browse the repository at this point in the history
…tely (if sound supports it)
  • Loading branch information
lasconic committed May 10, 2015
1 parent f44a313 commit 506e5e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3485,7 +3485,8 @@ void MuseScore::showPianoKeyboard(bool on)
QAction* a = getAction("toggle-piano");
_pianoTools = new PianoTools(this);
addDockWidget(Qt::BottomDockWidgetArea, _pianoTools);
connect(_pianoTools, SIGNAL(keyPressed(int, bool)), SLOT(midiNoteReceived(int, bool)));
connect(_pianoTools, SIGNAL(keyPressed(int, bool, int)), SLOT(midiNoteReceived(int, bool, int)));
connect(_pianoTools, SIGNAL(keyReleased(int, bool, int)), SLOT(midiNoteReceived(int, bool, int)));
connect(_pianoTools, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
}
if (on) {
Expand Down Expand Up @@ -3564,10 +3565,10 @@ PaletteBox* MuseScore::getPaletteBox()
// midiNoteReceived
//---------------------------------------------------------

void MuseScore::midiNoteReceived(int pitch, bool ctrl)
void MuseScore::midiNoteReceived(int pitch, bool ctrl, int vel)
{
if (cv)
cv->midiNoteReceived(pitch, ctrl, 80);
cv->midiNoteReceived(pitch, ctrl, vel);
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
void checkForUpdate();
QMenu* fileMenu() const { return _fileMenu; }
void midiNoteReceived(int channel, int pitch, int velo);
void midiNoteReceived(int pitch, bool ctrl);
void midiNoteReceived(int pitch, bool ctrl, int velo);
void instrumentChanged();
void showMasterPalette(const QString& = 0);
void selectionChanged(SelState);
Expand Down
6 changes: 4 additions & 2 deletions mscore/pianotools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void PianoKeyItem::mousePressEvent(QGraphicsSceneMouseEvent*)
_pressed = true;
update();
bool ctrl = qApp->keyboardModifiers() & Qt::ControlModifier;
emit piano->keyPressed(_pitch, ctrl);
emit piano->keyPressed(_pitch, ctrl, 80);
}

//---------------------------------------------------------
Expand All @@ -276,6 +276,7 @@ void PianoKeyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent*)
{
_pressed = false;
update();
emit piano->keyReleased(_pitch, false, 0);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -314,7 +315,8 @@ PianoTools::PianoTools(QWidget* parent)
_piano->setFocusPolicy(Qt::ClickFocus);
setWidget(_piano);

connect(_piano, SIGNAL(keyPressed(int, bool)), SIGNAL(keyPressed(int, bool)));
connect(_piano, SIGNAL(keyPressed(int, bool, int)), SIGNAL(keyPressed(int, bool, int)));
connect(_piano, SIGNAL(keyReleased(int, bool, int)), SIGNAL(keyReleased(int, bool, int)));
}

//---------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions mscore/pianotools.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class HPiano : public QGraphicsView {
void setScale(qreal);

signals:
void keyPressed(int pitch, bool chord);
void keyPressed(int pitch, bool chord, int velo);
void keyReleased(int pitch, bool chord, int velo);

public:
HPiano(QWidget* parent = 0);
Expand All @@ -82,7 +83,8 @@ class PianoTools : public QDockWidget {
HPiano* _piano;

signals:
void keyPressed(int pitch, bool ctrl);
void keyPressed(int pitch, bool ctrl, int vel);
void keyReleased(int pitch, bool ctrl, int vel);

public:
PianoTools(QWidget* parent = 0);
Expand Down

0 comments on commit 506e5e8

Please sign in to comment.