Skip to content

Commit

Permalink
Merge pull request #3426 from mattmcclinch/non-breaking-spaces
Browse files Browse the repository at this point in the history
fix #268842: Need a space option in lyrics paste that doesn't advance to new note
  • Loading branch information
lasconic committed Jan 30, 2018
2 parents 1813e87 + 0171cfc commit 9fe0b0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ void Lyrics::paste(MuseScoreView* scoreview)
QClipboard::Mode mode = QClipboard::Selection;
#endif
QString txt = QApplication::clipboard()->text(mode);
QStringList sl = txt.split(QRegExp("\\s+"), QString::SkipEmptyParts);
QString regex = QString("[^\\S") + QChar(0xa0) + QChar(0x202F) + "]+";
QStringList sl = txt.split(QRegExp(regex), QString::SkipEmptyParts);
if (sl.isEmpty())
return;

Expand Down
14 changes: 13 additions & 1 deletion libmscore/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

namespace Ms {

#ifdef Q_OS_MAC
#define CONTROL_MODIFIER Qt::AltModifier
#else
#define CONTROL_MODIFIER Qt::ControlModifier
#endif

static const qreal subScriptSize = 0.6;
static const qreal subScriptOffset = 0.5; // of x-height
static const qreal superScriptOffset = -.9; // of x-height
Expand Down Expand Up @@ -1810,10 +1816,16 @@ bool Text::edit(MuseScoreView*, Grip, int key, Qt::KeyboardModifiers modifiers,
break;

case Qt::Key_Tab:
case Qt::Key_Space:
s = " ";
modifiers = 0;
break;
case Qt::Key_Space:
if (modifiers & CONTROL_MODIFIER)
s = QString(QChar(0xa0)); // non-breaking space
else
s = " ";
modifiers = 0;
break;

case Qt::Key_Minus:
if (modifiers == 0)
Expand Down

0 comments on commit 9fe0b0b

Please sign in to comment.