|
From: Tapio V. <aa...@us...> - 2011-01-31 14:38:06
|
Module: editor
Branch: master
Commit: 7bd441d5bfb48ee4415ef14e4705f40de2de7039
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 31 16:29:37 2011 +0200
Refactor song exporting.
---
editorapp.cc | 41 ++++++++++++++---------------------------
editorapp.hh | 1 +
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 12d189d..36a34ea 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -311,41 +311,28 @@ void EditorApp::saveProject(QString fileName)
updateMenuStates();
}
-void EditorApp::on_actionSingStarXML_triggered()
+void EditorApp::exportSong(QString format, QString dialogTitle)
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Export SingStar XML"), QDir::homePath());
+ QString path = QFileDialog::getExistingDirectory(this, dialogTitle, QDir::homePath());
if (!path.isNull()) {
- song->insertVocalTrack(TrackName::LEAD_VOCAL, noteGraph->getVocalTrack());
- try { SingStarXMLWriter(*song.data(), path); }
- catch (const std::exception& e) {
+ // Sync notes
+ if (noteGraph) song->insertVocalTrack(TrackName::LEAD_VOCAL, noteGraph->getVocalTrack());
+ // Pick exporter
+ try {
+ if (format == "XML") SingStarXMLWriter(*song.data(), path);
+ else if (format == "TXT") UltraStarTXTWriter(*song.data(), path);
+ else if (format == "INI") FoFMIDIWriter(*song.data(), path);
+ } catch (const std::exception& e) {
QMessageBox::critical(this, tr("Error exporting song!"), e.what());
}
}
}
-void EditorApp::on_actionUltraStarTXT_triggered()
-{
- QString path = QFileDialog::getExistingDirectory(this, tr("Export UltraStar TXT"), QDir::homePath());
- if (!path.isNull()) {
- song->insertVocalTrack(TrackName::LEAD_VOCAL, noteGraph->getVocalTrack());
- try { UltraStarTXTWriter(*song.data(), path); }
- catch (const std::exception& e) {
- QMessageBox::critical(this, tr("Error exporting song!"), e.what());
- }
- }
-}
+void EditorApp::on_actionSingStarXML_triggered() { exportSong("XML", tr("Export SingStar XML")); }
-void EditorApp::on_actionFoFMIDI_triggered()
-{
- QString path = QFileDialog::getExistingDirectory(this, tr("Export FoF MIDI"), QDir::homePath());
- if (!path.isNull()) {
- song->insertVocalTrack(TrackName::LEAD_VOCAL, noteGraph->getVocalTrack());
- try { FoFMIDIWriter(*song.data(), path); }
- catch (const std::exception& e) {
- QMessageBox::critical(this, tr("Error exporting song!"), e.what());
- }
- }
-}
+void EditorApp::on_actionUltraStarTXT_triggered() { exportSong("TXT", tr("Export UltraStar TXT")); }
+
+void EditorApp::on_actionFoFMIDI_triggered() { exportSong("INI", tr("Export Frets on Fire MIDI")); }
void EditorApp::on_actionLyricsToFile_triggered()
{
diff --git a/editorapp.hh b/editorapp.hh
index 81934b9..3a8b561 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -37,6 +37,7 @@ public:
private:
bool promptSaving();
void saveProject(QString fileName);
+ void exportSong(QString format, QString dialogTitle);
void doOpStack();
void playButton();
void readSettings();
|