Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local cursor instead of global one in PianoRoll #5200

Merged
merged 2 commits into from May 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 17 additions & 36 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke)
{
m_ctrlMode = m_editMode;
m_editMode = ModeSelect;
QApplication::changeOverrideCursor( Qt::ArrowCursor );
setCursor( Qt::ArrowCursor );
ke->accept();
}
break;
Expand Down Expand Up @@ -1458,11 +1458,6 @@ void PianoRoll::keyReleaseEvent(QKeyEvent* ke )

void PianoRoll::leaveEvent(QEvent * e )
{
while( QApplication::overrideCursor() != NULL )
{
QApplication::restoreOverrideCursor();
}

QWidget::leaveEvent( e );
s_textFloat->hide();
update(); // cleaning inner mouse-related graphics
Expand Down Expand Up @@ -1552,7 +1547,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
{
m_ctrlMode = m_editMode;
m_editMode = ModeSelect;
QApplication::changeOverrideCursor( QCursor( Qt::ArrowCursor ) );
setCursor( Qt::ArrowCursor );
update();
}

Expand Down Expand Up @@ -1770,8 +1765,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
m_action = ActionResizeNote;

// set resize-cursor
QCursor c( Qt::SizeHorCursor );
QApplication::setOverrideCursor( c );
setCursor( Qt::SizeHorCursor );
}
else
{
Expand All @@ -1784,8 +1778,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
m_action = ActionMoveNote;

// set move-cursor
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
setCursor( Qt::SizeAllCursor );

// if they're holding shift, copy all selected notes
if( ! is_new_note && me->modifiers() & Qt::ShiftModifier )
Expand Down Expand Up @@ -2213,7 +2206,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me )

if( m_editMode == ModeDraw )
{
QApplication::restoreOverrideCursor();
setCursor( Qt::ArrowCursor );
}

if( mustRepaint )
Expand All @@ -2237,8 +2230,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
{
if( me->y() > keyAreaBottom() && me->y() < noteEditTop() )
{
QApplication::setOverrideCursor(
QCursor( Qt::SizeVerCursor ) );
setCursor( Qt::SizeVerCursor );
return;
}
}
Expand Down Expand Up @@ -2451,37 +2443,19 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
bool atTail = note->length() > 0 && x > noteRightX -
RESIZE_AREA_WIDTH;
Qt::CursorShape cursorShape = atTail ? Qt::SizeHorCursor :
Qt::SizeAllCursor;
if( QApplication::overrideCursor() )
{
if( QApplication::overrideCursor()->shape() != cursorShape )
{
while( QApplication::overrideCursor() != NULL )
{
QApplication::restoreOverrideCursor();
}
QApplication::setOverrideCursor(QCursor(cursorShape));
}
}
else
{
QApplication::setOverrideCursor(QCursor(cursorShape));
}
Qt::SizeAllCursor;
setCursor( cursorShape );
}
else
{
// the cursor is over no note, so restore cursor
while( QApplication::overrideCursor() != NULL )
{
QApplication::restoreOverrideCursor();
}
setCursor( Qt::ArrowCursor );
}
}
else if( me->buttons() & Qt::LeftButton &&
m_editMode == ModeSelect &&
m_action == ActionSelectNotes )
{

// change size of selection

// get tick in which the cursor is posated
Expand Down Expand Up @@ -2553,6 +2527,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
}
}
}
else if (me->buttons() == Qt::NoButton &&
( m_editMode == ModeErase ||
m_editMode == ModeSelect ||
m_editMode == ModeEditDetuning))
This conversation was marked as resolved.
Show resolved Hide resolved
{
setCursor( Qt::ArrowCursor );
}
}
else
{
Expand Down Expand Up @@ -2631,7 +2612,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
--m_selectedKeys;
}
}
QApplication::restoreOverrideCursor();
setCursor( Qt::ArrowCursor );
}

m_lastMouseX = me->x();
Expand Down