Exemplo n.º 1
0
bool ScoreView::editKeyLyrics()
      {
      Q_ASSERT(editData.element->isLyrics());

      switch (editData.key) {
            case Qt::Key_Space:
                  if (!editData.control()) {
                        if (editData.s == "_")
                              lyricsUnderscore();
                        else // TODO: shift+tab events are filtered by qt
                              lyricsTab(editData.modifiers & Qt::ShiftModifier, true, false);
                        }
                  else
                        return false;
                  break;

            case Qt::Key_Left:
            case Qt::Key_Right:
                  if (!editData.control() && editData.element->edit(editData))
                        mscore->textTools()->updateTools(editData);
                  else {
                        bool kl = editData.key == Qt::Key_Left;
                        lyricsTab(kl, kl, true);      // go to previous/next lyrics
                        }
                  break;

            case Qt::Key_Up:
            case Qt::Key_Down:
                  lyricsUpDown(editData.key == Qt::Key_Up, true);
                  break;

            case Qt::Key_Return:
                  lyricsReturn();
                  break;

            case Qt::Key_Minus:
                  if (editData.control()) {
                        // change into normal minus
                        editData.modifiers &= ~CONTROL_MODIFIER;
                        return false;
                        }
                  else
                        lyricsMinus();
                  break;

            case Qt::Key_Underscore:
                  if (editData.control()) {
                        // change into normal underscore
                        editData.modifiers = 0; // &= ~CONTROL_MODIFIER;
                        return false;
                        }
                  else
                        lyricsUnderscore();
                  break;

            default:
                  return false;
            }
      return true;
      }
Exemplo n.º 2
0
bool ScoreView::editKeyLyrics(QKeyEvent* ev)
      {
      int key                         = ev->key();
      Qt::KeyboardModifiers modifiers = ev->modifiers();
      QString s                       = ev->text();
      bool ctrl                       = modifiers == Qt::ControlModifier;

      switch(key) {
            case Qt::Key_Space:
                  if (!(modifiers & CONTROL_MODIFIER)) {
                        if (s == "_")
                              lyricsUnderscore();
                        else // TODO: shift+tab events are filtered by qt
                              lyricsTab(modifiers & Qt::ShiftModifier, true, false);
                        }
                  else
                        return false;
                  break;

            case Qt::Key_Left:
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        mscore->textTools()->updateTools();
                        _score->update();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(true, true, true);      // go to previous lyrics
                  break;
            case Qt::Key_Right:
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        mscore->textTools()->updateTools();
                        _score->update();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(false, false, true);    // go to next lyrics
                  break;
            case Qt::Key_Up:
                  lyricsUpDown(true, true);
                  break;
            case Qt::Key_Down:
                  lyricsUpDown(false, true);
                  break;
            case Qt::Key_Return:
                  lyricsReturn();
                  break;
            default:
                  {
                  if(s == "-" && !(modifiers & CONTROL_MODIFIER))
                        lyricsMinus();
                  else if (s == "_" && !(modifiers & CONTROL_MODIFIER))
                        lyricsUnderscore();
                  else
                        return false;
                  }
            }
      return true;
      }
Exemplo n.º 3
0
void ScoreView::editCmd(const QString& cmd)
      {
      if (!editObject)
            return;

      if (editObject->type() == Element::LYRICS) {
            if (cmd == "next-lyric")
                  lyricsTab(false, true, false);
            else if (cmd == "prev-lyric")
                  lyricsTab(true, true, false);
            }
      }
Exemplo n.º 4
0
void ScoreView::editCmd(const QString& cmd)
      {
      if (!editData.element)
            return;

      if (editData.element->isLyrics()) {
            if (cmd == "next-lyric")
                  lyricsTab(false, true, false);
            else if (cmd == "prev-lyric")
                  lyricsTab(true, true, false);
            }
      }
Exemplo n.º 5
0
void ScoreView::editCmd(const QString& cmd)
      {
      if (!editObject)
            return;

      if (editObject->type() == LYRICS) {
            if (cmd == "next-lyric")
                  lyricsTab(false, true, false);
            else if (cmd == "prev-lyric")
                  lyricsTab(true, true, false);
            }
#if 0
      if (editObject->type() == LYRICS) {
            int found = false;
		if (key == Qt::Key_Space && !(modifiers & CONTROL_MODIFIER)) {
                  // TODO: shift+tab events are filtered by qt
                  lyricsTab(modifiers & Qt::ShiftModifier, true, false);
                  return;
                  }
            if (key == Qt::Key_Left) {
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        _score->end();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(true, true, true);      // go to previous lyrics
                  return;
                  }
            if (key == Qt::Key_Right) {
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        _score->end();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(false, false, true);    // go to next lyrics
                  found = true;
                  }
            else if (key == Qt::Key_Up) {
                  lyricsUpDown(true, true);
                  found = true;
                  }
            else if (key == Qt::Key_Down) {
                  lyricsUpDown(false, true);
                  found = true;
                  }
            else if (key == Qt::Key_Return) {
                  lyricsReturn();
                  found = true;
                  }
		else if (key == Qt::Key_Minus && !(modifiers & CONTROL_MODIFIER)) {
                  lyricsMinus();
                  found = true;
                  }
		else if (key == Qt::Key_Underscore) {
                  if (modifiers & CONTROL_MODIFIER) {
                        modifiers &= ~CONTROL_MODIFIER;
                        s = "_";
                        }
                  else {
                        lyricsUnderscore();
                        found = true;
                        }
                  }
            if (found) {
                  return;
                  }
            }
      if (editObject->type() == HARMONY) {
            if (key == Qt::Key_Space && !(modifiers & CONTROL_MODIFIER)) {
                  chordTab(modifiers & Qt::ShiftModifier);
                  ev->accept();
                  return;
                  }
            }
      if (editObject->type() == FIGURED_BASS) {
            int found = false;
            if (key == Qt::Key_Space && !(modifiers & CONTROL_MODIFIER)) {
                  figuredBassTab(false, modifiers & Qt::ShiftModifier);
                  found = true;
                  }
            if (key == Qt::Key_Tab || key == Qt::Key_Backtab) {
                  figuredBassTab(true, key == Qt::Key_Backtab ? true : (modifiers & Qt::ShiftModifier) );
                  found = true;
                  }
            if (key >= Qt::Key_1 && key <= Qt::Key_9 && (modifiers & CONTROL_MODIFIER)) {
                  int ticks = (MScore::division >> 4) << (key - Qt::Key_1);
                  figuredBassTicksTab(ticks);
                  found = true;
                  }
Exemplo n.º 6
0
void ScoreView::editKey(QKeyEvent* ev)
      {
      int key                         = ev->key();
      Qt::KeyboardModifiers modifiers = ev->modifiers();
      QString s                       = ev->text();
      bool ctrl                       = modifiers == Qt::ControlModifier;

      if (debugMode)
            printf("keyPressEvent key 0x%02x(%c) mod 0x%04x <%s>\n",
               key, key, int(modifiers), qPrintable(s));

      if (!editObject)
            return;

      if (editObject->type() == LYRICS) {
            int found = false;
		if (key == Qt::Key_Space && !(modifiers & CONTROL_MODIFIER)) {
                  // TODO: shift+tab events are filtered by qt
                  lyricsTab(modifiers & Qt::ShiftModifier, true, false);
                  found = true;
                  }
            else if (key == Qt::Key_Left) {
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        _score->end();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(true, true, true);      // go to previous lyrics
                  found = true;
                  }
            else if (key == Qt::Key_Right) {
                  if (!ctrl && editObject->edit(this, curGrip, key, modifiers, s)) {
                        _score->end();
                        mscore->endCmd();
                        }
                  else
                        lyricsTab(false, false, true);    // go to next lyrics
                  found = true;
                  }
            else if (key == Qt::Key_Up) {
                  lyricsUpDown(true, true);
                  found = true;
                  }
            else if (key == Qt::Key_Down) {
                  lyricsUpDown(false, true);
                  found = true;
                  }
            else if (key == Qt::Key_Return) {
                  lyricsReturn();
                  found = true;
                  }
		else if (key == Qt::Key_Minus && !(modifiers & CONTROL_MODIFIER)) {
                  lyricsMinus();
                  found = true;
                  }
		else if (key == Qt::Key_Underscore) {
                  if (modifiers & CONTROL_MODIFIER) {
                        modifiers &= ~CONTROL_MODIFIER;
                        s = "_";
                        }
                  else {
                        lyricsUnderscore();
                        found = true;
                        }
                  }
            if (found) {
                  ev->accept();
                  return;
                  }
            }
      if (editObject->type() == HARMONY) {
            if (key == Qt::Key_Space && !(modifiers & CONTROL_MODIFIER)) {
                  chordTab(modifiers & Qt::ShiftModifier);
                  ev->accept();
                  return;
                  }
            }
      if (!((modifiers & Qt::ShiftModifier) && (key == Qt::Key_Backtab))) {
            if (editObject->edit(this, curGrip, key, modifiers, s)) {
                  updateGrips();
                  ev->accept();
                  _score->end();
                  mscore->endCmd();
                  return;
                  }
            if (editObject->isText() && (key == Qt::Key_Left || key == Qt::Key_Right)) {
                  ev->accept();
                  _score->end();
                  mscore->endCmd();
                  //return;
                  }
            }
      QPointF delta;
      qreal _spatium = editObject->spatium();
      qreal xval     = MScore::nudgeStep * _spatium;

      if (modifiers & Qt::ControlModifier)
            xval = preferences.nudgeStep10 * _spatium;
      else if (modifiers & Qt::AltModifier)
            xval = preferences.nudgeStep50 * _spatium;
      qreal yval = xval;

      if (mscore->vRaster()) {
            qreal vRaster = _spatium / MScore::vRaster();
            if (yval < vRaster)
                  yval = vRaster;
            }
      if (mscore->hRaster()) {
            qreal hRaster = _spatium / MScore::hRaster();
            if (xval < hRaster)
                  xval = hRaster;
            }
      // TODO: if raster, then xval/yval should be multiple of raster

      switch (key) {
            case Qt::Key_Left:
                  delta = QPointF(-xval, 0);
                  break;
            case Qt::Key_Right:
                  delta = QPointF(xval, 0);
                  break;
            case Qt::Key_Up:
                  delta = QPointF(0, -yval);
                  break;
            case Qt::Key_Down:
                  delta = QPointF(0, yval);
                  break;
            default:
                  ev->ignore();
                  return;
            }
      EditData ed;
      ed.curGrip = curGrip;
      ed.delta   = delta;
      ed.view    = this;
      if (curGrip >= 0)
            ed.pos = grip[curGrip].center() + delta;
      editObject->editDrag(ed);
      updateGrips();
      _score->end();
      mscore->endCmd();
      ev->accept();
      }