|
From: Tapio V. <aa...@us...> - 2011-01-21 10:12:25
|
Module: editor
Branch: master
Commit: 2aba089093166d1b21436643411240c2ba995dee
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 21 12:11:41 2011 +0200
Simplify lyric editing handling and allow editing with Enter-key.
---
notegraphwidget.cc | 16 +++++++++++++---
notegraphwidget.hh | 1 +
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 7c9dfea..7a41ff3 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -310,15 +310,22 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
return;
}
+ editLyric(child);
+}
+
+void NoteGraphWidget::editLyric(NoteLabel *note) {
+ if (!note) return;
+
// Spawn an input dialog
bool ok;
QString text = QInputDialog::getText(this, tr("Edit lyric"),
tr("Lyric:"), QLineEdit::Normal,
- child->lyric(), &ok);
+ note->lyric(), &ok);
if (ok && !text.isEmpty()) {
- child->setLyric(text);
+ note->setLyric(text);
+ // Create undo operation
Operation op("LYRIC");
- op << getNoteLabelId(child) << text;
+ op << getNoteLabelId(note) << text;
doOperation(op, Operation::NO_EXEC);
}
}
@@ -361,6 +368,9 @@ void NoteGraphWidget::mouseMoveEvent(QMouseEvent *event)
void NoteGraphWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
+ case Qt::Key_Return: // Edit lyric
+ editLyric(m_selectedNote);
+ break;
case Qt::Key_Left: // Select note on the left
if (m_selectedNote && m_notes.size() > 1 && m_selectedNote != m_notes.front()) {
for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index ab77485..3db1520 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -47,6 +47,7 @@ public:
int getNoteLabelId(NoteLabel* note) const;
NoteLabels& noteLabels() { return m_notes; }
void doOperation(const Operation& op, Operation::OperationFlags flags = Operation::NORMAL);
+ void editLyric(NoteLabel *note);
int s2px(double sec) const;
double px2s(int px) const;
|