|
From: Tapio V. <aa...@us...> - 2011-01-13 12:32:04
|
Module: editor
Branch: master
Commit: da9a210331238694c1c0bfcf7a7a99bf702c8b5d
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 13 14:30:16 2011 +0200
Song metadata stuff.
* New textboxes: genre & year
* Textboxes are populated when loading US TXT file
* Changes in the textboxes are updated to the Song class
---
editor.ui | 41 ++++++++++++++++++++++++++++++++++++++++-
editorapp.cc | 36 +++++++++++++++++++++++++++++++++++-
editorapp.hh | 6 ++++++
song.hh | 6 ++++--
4 files changed, 85 insertions(+), 4 deletions(-)
diff --git a/editor.ui b/editor.ui
index 8165720..f62336f 100644
--- a/editor.ui
+++ b/editor.ui
@@ -220,7 +220,7 @@
<attribute name="whatsThis">
<string>This tab lets you to configure the song metadata.</string>
</attribute>
- <layout class="QFormLayout" name="formLayout">
+ <layout class="QGridLayout" name="gridLayout_5" columnstretch="10,70,10,20">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -231,6 +231,19 @@
<item row="0" column="1">
<widget class="QLineEdit" name="txtTitle"/>
</item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Genre</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLineEdit" name="txtGenre"/>
+ </item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -241,6 +254,19 @@
<item row="1" column="1">
<widget class="QLineEdit" name="txtArtist"/>
</item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Year</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLineEdit" name="txtYear"/>
+ </item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
@@ -255,6 +281,19 @@
</property>
</widget>
</item>
+ <item row="3" column="1">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</widget>
diff --git a/editorapp.cc b/editorapp.cc
index 7eb9a07..e3fc389 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -35,6 +35,8 @@ EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
updateNoteInfo(NULL);
+ song.reset(new Song);
+
// Some icons to menus to make them prettier
ui.actionNew->setIcon(QIcon::fromTheme("document-new"));
ui.actionOpen->setIcon(QIcon::fromTheme("document-open"));
@@ -116,6 +118,9 @@ void EditorApp::on_actionOpen_triggered()
try {
song.reset(new Song(QString(finfo.path()+"/").toStdString(), finfo.fileName().toStdString()));
noteGraph->setLyrics(song->getVocalTrack().notes);
+ updateSongMeta(true);
+ noteGraph->doOperation(Operation("BLOCK")); // Lock the undo stack
+ ui.tabWidget->setCurrentIndex(1); // Swicth to song properties tab
} catch (const std::exception& e) {
QMessageBox::critical(this, tr("Error loading file!"), e.what());
}
@@ -174,7 +179,7 @@ void EditorApp::on_actionMusicFile_triggered()
if (!fileName.isNull()) {
ui.valMusicFile->setText(fileName);
- ui.tabWidget->setCurrentIndex(1);
+ ui.tabWidget->setCurrentIndex(1); // Swicth to song properties tab
// TODO: Do something with the file
}
}
@@ -232,6 +237,35 @@ void EditorApp::on_actionAbout_triggered()
);
}
+void EditorApp::updateSongMeta(bool readFromSongToUI)
+{
+ if (!song) return;
+ // TODO: Undo
+ if (!readFromSongToUI) {
+ if (ui.txtTitle->text().toStdString() != song->title) {
+ song->title = ui.txtTitle->text().toStdString();
+ }
+ if (ui.txtArtist->text().toStdString() != song->artist) {
+ song->artist = ui.txtArtist->text().toStdString();
+ }
+ if (ui.txtGenre->text().toStdString() != song->genre) {
+ song->genre = ui.txtGenre->text().toStdString();
+ }
+ if (ui.txtYear->text().toStdString() != song->year) {
+ song->year = ui.txtYear->text().toStdString();
+ }
+ } else {
+ if (!song->title.empty()) ui.txtTitle->setText(QString::fromStdString(song->title));
+ if (!song->artist.empty()) ui.txtArtist->setText(QString::fromStdString(song->artist));
+ if (!song->genre.empty()) ui.txtGenre->setText(QString::fromStdString(song->genre));
+ if (!song->year.empty()) ui.txtYear->setText(QString::fromStdString(song->year));
+ }
+}
+
+void EditorApp::on_txtTitle_editingFinished() { updateSongMeta(); }
+void EditorApp::on_txtArtist_editingFinished() { updateSongMeta(); }
+void EditorApp::on_txtGenre_editingFinished() { updateSongMeta(); }
+void EditorApp::on_txtYear_editingFinished() { updateSongMeta(); }
void EditorApp::on_cmbNoteType_currentIndexChanged(int index)
{
diff --git a/editorapp.hh b/editorapp.hh
index 3865b25..4a66eed 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -14,6 +14,8 @@ class EditorApp: public QMainWindow
public:
EditorApp(QWidget *parent = 0);
+ void updateSongMeta(bool readFromSongToUI = false);
+
public slots:
void operationDone(const Operation &op);
void updateNoteInfo(NoteLabel *note);
@@ -38,6 +40,10 @@ public slots:
void on_actionAbout_triggered();
// Note properties tab
+ void on_txtTitle_editingFinished();
+ void on_txtArtist_editingFinished();
+ void on_txtGenre_editingFinished();
+ void on_txtYear_editingFinished();
void on_cmbNoteType_currentIndexChanged(int);
void on_chkFloating_stateChanged(int);
diff --git a/song.hh b/song.hh
index 942161b..43903fb 100644
--- a/song.hh
+++ b/song.hh
@@ -38,7 +38,8 @@ class Song {
VocalTracks vocalTracks; ///< notes for the sing part
VocalTrack dummyVocal; ///< notes for the sing part
public:
- /// constructor
+ /// constructors
+ Song(): dummyVocal(TrackName::LEAD_VOCAL) { reload(true); }
Song(std::string const& path_, std::string const& filename_): dummyVocal(TrackName::LEAD_VOCAL), path(path_), filename(filename_) { reload(false); }
/// reload song
void reload(bool errorIgnore = true);
@@ -60,7 +61,7 @@ class Song {
void insertVocalTrack(std::string vocalTrack, VocalTrack track) {
vocalTracks.erase(vocalTrack);
vocalTracks.insert(std::make_pair<std::string, VocalTrack>(vocalTrack, track));
- };
+ }
// Get a selected track, or LEAD_VOCAL if not found or the first one if not found
VocalTrack& getVocalTrack(std::string vocalTrack = TrackName::LEAD_VOCAL) {
if(vocalTracks.find(vocalTrack) != vocalTracks.end()) {
@@ -101,6 +102,7 @@ class Song {
std::string text; ///< songtext
std::string creator; ///< creator
std::string language; ///< language
+ std::string year; ///< year
std::map<std::string,std::string> music; ///< music files (background, guitar, rhythm/bass, drums, vocals)
std::string cover; ///< cd cover
std::string background; ///< background image
|