|
From: Tapio V. <aa...@us...> - 2011-01-25 14:55:01
|
Module: editor
Branch: master
Commit: db88438d3f6b8d8143c393d4400b528cbd3c7e6d
Author: Tapio Vierros <tap...@gm...>
Date: Tue Jan 25 16:35:22 2011 +0200
Implemented lyrics dumping to file and clipboard.
---
editor.ui | 3 ---
editorapp.cc | 20 +++++++++++++++++++-
editorapp.hh | 2 ++
notegraphwidget.cc | 15 +++++++++++++++
notegraphwidget.hh | 2 ++
5 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/editor.ui b/editor.ui
index 513440e..1dd2b95 100644
--- a/editor.ui
+++ b/editor.ui
@@ -216,9 +216,6 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
diff --git a/editorapp.cc b/editorapp.cc
index d51f23c..9e1d822 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -327,7 +327,7 @@ void EditorApp::on_actionUltraStarTXT_triggered()
void EditorApp::on_actionFoFMIDI_triggered()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Export FoF MIDI"), QDir::homePath());
+ QString path = QFileDialog::getExistingDirectory(this, tr("Export FoF MIDI"), QDir::homePath());
if (!path.isNull()) {
try { FoFMIDIWriter(*song.data(), path); }
catch (const std::exception& e) {
@@ -336,6 +336,24 @@ void EditorApp::on_actionFoFMIDI_triggered()
}
}
+void EditorApp::on_actionLyricsToFile_triggered()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Export to plain text lyrics"), QDir::homePath());
+ if (!fileName.isNull()) {
+ QFile f(fileName);
+ if (f.open(QFile::WriteOnly | QFile::Truncate)) {
+ QTextStream out(&f);
+ out << noteGraph->dumpLyrics();
+ } else
+ QMessageBox::critical(this, tr("Error saving file!"), tr("Couldn't open file %1 for writing.").arg(fileName));
+ }
+}
+
+void EditorApp::on_actionLyricsToClipboard_triggered()
+{
+ QApplication::clipboard()->setText(noteGraph->dumpLyrics());
+}
+
void EditorApp::on_actionExit_triggered()
{
close();
diff --git a/editorapp.hh b/editorapp.hh
index bbbff64..ee26dd4 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -51,6 +51,8 @@ public slots:
void on_actionSingStarXML_triggered();
void on_actionUltraStarTXT_triggered();
void on_actionFoFMIDI_triggered();
+ void on_actionLyricsToFile_triggered();
+ void on_actionLyricsToClipboard_triggered();
void on_actionExit_triggered();
// Edit menu
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 6950fd1..4da17ec 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -531,6 +531,21 @@ int NoteGraphWidget::n2px(int note) const { return m_pitch->note2px(note) - m_no
int NoteGraphWidget::px2n(int px) const { return m_pitch->px2note(px + m_noteHalfHeight); }
+QString NoteGraphWidget::dumpLyrics() const
+{
+ QString lyrics;
+ if (!m_notes.isEmpty()) {
+ for (int i = 0; i < m_notes.size(); ++i) {
+ lyrics += m_notes[i]->lyric() + " ";
+ if (m_notes[i]->note().lineBreak)
+ lyrics.replace(lyrics.size()-1, 1, QString("\n"));
+ }
+ lyrics.replace(lyrics.size()-1, 1, QString("\n"));
+ }
+ return lyrics;
+}
+
+
SeekHandle::SeekHandle(QWidget *parent)
: QLabel(parent)
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index e2c7e9f..f022495 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -56,6 +56,8 @@ public:
int px2n(int px) const;
int h() const { return m_pitch->height; }
+ QString dumpLyrics() const;
+
public slots:
void timeSyllable();
void timeSentence();
|