Skip to content

Commit

Permalink
Add a subtitle to the song info metadata.
Browse files Browse the repository at this point in the history
This is now rendered in the score (similar to the existing subtitile metadata for lessons) and imported from Guitar Pro 6/7 files.

Fixes: #297
  • Loading branch information
cameronwhite committed Jun 17, 2020
1 parent ec60472 commit 0152c33
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- Left hand fingerings now support thumbs. This is also now supported by the Guitar Pro 6/7 importers (#292).
- The song information can now store a subtitle. This is also now supported by the Guitar Pro 6/7 importers (#297).

### Changed

Expand Down
1 change: 1 addition & 0 deletions source/dialogs/fileinformationdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ ScoreInfo FileInformationDialog::getScoreInfo() const
SongData song;

song.setTitle(ui->songTitleValue->text().toStdString());
song.setSubtitle(ui->songSubtitleValue->text().toStdString());
song.setArtist(ui->songArtistValue->text().toStdString());

switch (ui->releaseInfoStack->currentIndex())
Expand Down
29 changes: 20 additions & 9 deletions source/dialogs/fileinformationdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,50 @@
<x>0</x>
<y>10</y>
<width>481</width>
<height>71</height>
<height>85</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="songTitleLabel">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="songTitleValue"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="songArtistLabel">
<widget class="QLabel" name="songSubtitleLabel">
<property name="text">
<string>Artist:</string>
<string>Subtitle:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="songArtistValue"/>
<widget class="QLineEdit" name="songSubtitleValue"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="songTitleLabel">
<item row="2" column="0">
<widget class="QLabel" name="songArtistLabel">
<property name="text">
<string>Title:</string>
<string>Artist:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="songArtistValue"/>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>80</y>
<y>100</y>
<width>491</width>
<height>161</height>
</rect>
Expand Down Expand Up @@ -363,7 +373,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>250</y>
<y>270</y>
<width>491</width>
<height>251</height>
</rect>
Expand Down Expand Up @@ -884,6 +894,7 @@
</layout>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="lessonLevelButtonGroup"/>
<buttongroup name="songTypeButtonGroup"/>
Expand Down
3 changes: 1 addition & 2 deletions source/formats/gp7/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ convertScoreInfo(const Gp7::ScoreInfo &gp_info, Score &score)
ScoreInfo info;
SongData data;

// No support for subtitle.
// TODO - consider adding this to SongData.
data.setTitle(gp_info.myTitle);
data.setSubtitle(gp_info.mySubtitle);
data.setArtist(gp_info.myArtist);

data.setAudioReleaseInfo(SongData::AudioReleaseInfo(
Expand Down
14 changes: 10 additions & 4 deletions source/painters/scoreinforenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include <score/scoreinfo.h>
#include <QDate>

static const double VERTICAL_SPACING = 10.0;
static constexpr double VERTICAL_SPACING = 10.0;
static const double AUTHOR_INFO_WIDTH = LayoutInfo::STAFF_WIDTH * 0.4;
static const int TITLE_SIZE = 36;
static const int SUBTITLE_SIZE = 20;
static const int AUTHOR_SIZE = 14;
static constexpr int TITLE_SIZE = 36;
static constexpr int SUBTITLE_SIZE = 20;
static constexpr int AUTHOR_SIZE = 14;

static const QString theAudioReleaseTypes[] = {
"Single", "EP", "Album", "Double Album", "Triple Album", "Boxset"
Expand Down Expand Up @@ -201,6 +201,12 @@ static void renderSongInfo(QGraphicsItemGroup &group, const QFont &font,
QString::fromStdString(song_data.getTitle()));
}

if (!song_data.getSubtitle().empty())
{
addCenteredText(group, font, SUBTITLE_SIZE,
QString::fromStdString(song_data.getSubtitle()));
}

if (!song_data.getArtist().empty())
{
QString artist_info =
Expand Down
4 changes: 3 additions & 1 deletion source/score/fileversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ enum class FileVersion : int
LEFT_HAND_FINGERING = 4,
/// Added a thumb option to left hand fingerings.
LEFT_HAND_FINGERING_THUMB = 5,
LATEST_VERSION = LEFT_HAND_FINGERING_THUMB
/// Added a subtitle to the score info.
SONG_SUBTITLE = 6,
LATEST_VERSION = SONG_SUBTITLE
};

#endif
10 changes: 10 additions & 0 deletions source/score/scoreinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ const std::string &SongData::getTitle() const
return myTitle;
}

void SongData::setSubtitle(const std::string &subtitle)
{
mySubtitle = subtitle;
}

const std::string &SongData::getSubtitle() const
{
return mySubtitle;
}

void SongData::setArtist(const std::string &artist)
{
myArtist = artist;
Expand Down
10 changes: 9 additions & 1 deletion source/score/scoreinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class SongData
void setTitle(const std::string &title);
const std::string &getTitle() const;

void setSubtitle(const std::string &subtitle);
const std::string &getSubtitle() const;

void setArtist(const std::string &artist);
const std::string &getArtist() const;

Expand Down Expand Up @@ -181,6 +184,7 @@ class SongData

private:
std::string myTitle;
std::string mySubtitle;
std::string myArtist;
std::optional<AudioReleaseInfo> myAudioReleaseInfo;
std::optional<VideoReleaseInfo> myVideoReleaseInfo;
Expand All @@ -195,9 +199,13 @@ class SongData
};

template <class Archive>
void SongData::serialize(Archive &ar, const FileVersion /*version*/)
void SongData::serialize(Archive &ar, const FileVersion version)
{
ar("title", myTitle);

if (version >= FileVersion::SONG_SUBTITLE)
ar("subtitle", mySubtitle);

ar("artist", myArtist);
ar("audio_release_info", myAudioReleaseInfo);
ar("video_release_info", myVideoReleaseInfo);
Expand Down
1 change: 1 addition & 0 deletions test/formats/gp7/test_gp7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TEST_CASE("Formats/Gp7Import/ScoreInfo/Basic", "")
REQUIRE(info.getScoreType() == ScoreInfo::ScoreType::Song);
const SongData &data = info.getSongData();
REQUIRE(data.getTitle() == "The title");
REQUIRE(data.getSubtitle() == "The subtitle");
REQUIRE(data.getArtist() == "The artist");
REQUIRE(data.isAudioRelease());
REQUIRE(data.getAudioReleaseInfo().getTitle() == "The album");
Expand Down

0 comments on commit 0152c33

Please sign in to comment.