Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable editing of userrating from the frontend #8049

Merged
merged 3 commits into from Oct 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -2474,6 +2474,7 @@ msgstr ""

#: xbmc/dialogs/GUIDialogMediaFilter.cpp
#: xbmc/playlists/SmartPlaylist.cpp
#: xbmc/video/dialogs/GUIDialogVideoInfo.cpp
msgctxt "#563"
msgid "Rating"
msgstr ""
Expand Down Expand Up @@ -18102,7 +18103,7 @@ msgstr ""
#. Used for the viewstate selection
#: xbmc/video/GUIViewStateVideo.xml
msgctxt "#38018"
msgid "User rating"
msgid "My rating"
msgstr ""

#. Setting #38019 "Settings -> System -> Audio output -> Support 8 channel DTS-HD audio decoding"
Expand All @@ -18116,3 +18117,14 @@ msgstr ""
msgctxt "#38020"
msgid "Enables decoding of high quality DTS-HD audio streams. Note: This increases CPU load and is only available when DTS and DTS-HD audio passthrough are disabled."
msgstr ""

#. Used for the viewstate selection
#: xbmc/video/dialogs/GUIDialogVideoInfo.cpp
msgctxt "#38022"
msgid "No rating"
msgstr ""

#. Used in Confluence
msgctxt "#38023"
msgid "Set my rating"
msgstr ""
82 changes: 17 additions & 65 deletions addons/skin.confluence/720p/DialogSongInfo.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<window>
<defaultcontrol always="true">10</defaultcontrol>
<defaultcontrol always="true">12</defaultcontrol>
<coordinates>
<left>185</left>
<top>105</top>
Expand Down Expand Up @@ -201,34 +201,6 @@
<aspectratio align="left">keep</aspectratio>
<texture>LeftRating/$INFO[ListItem.StarRating]</texture>
</control>
<control type="button" id="14">
<description>Decrease Rating</description>
<left>160</left>
<top>5</top>
<width>33</width>
<height>22</height>
<onclick>DecreaseRating</onclick>
<texturenofocus>scroll-down-2.png</texturenofocus>
<texturefocus>scroll-down-focus-2.png</texturefocus>
<onleft>15</onleft>
<onright>15</onright>
<ondown>9000</ondown>
<onup>9000</onup>
</control>
<control type="button" id="15">
<description>Increase Rating</description>
<left>193</left>
<top>5</top>
<width>33</width>
<height>22</height>
<onclick>IncreaseRating</onclick>
<texturenofocus>scroll-up-2.png</texturenofocus>
<texturefocus>scroll-up-focus-2.png</texturefocus>
<onleft>14</onleft>
<onright>14</onright>
<ondown>9000</ondown>
<onup>9000</onup>
</control>
</control>
<control type="label">
<description>Comment Title</description>
Expand All @@ -254,63 +226,43 @@
</control>
</control>
<control type="group" id="9000">
<left>40</left>
<left>140</left>
<top>445</top>
<control type="button" id="10">
<description>Ok button</description>
<control type="button" id="12">
<description>Album Info button</description>
<left>0</left>
<top>0</top>
<width>200</width>
<height>40</height>
<label>186</label>
<label>10523</label>
<font>font12_title</font>
<align>center</align>
<onleft>13</onleft>
<onright>11</onright>
<onup>14</onup>
<ondown>14</ondown>
<onleft>7</onleft>
<onright>13</onright>
</control>
<control type="button" id="11">
<description>Cancel button</description>
<control type="button" id="13">
<description>Get Thumb button</description>
<left>210</left>
<top>0</top>
<width>200</width>
<height>40</height>
<label>222</label>
<label>13405</label>
<font>font12_title</font>
<align>center</align>
<onleft>10</onleft>
<onright>12</onright>
<onup>14</onup>
<ondown>14</ondown>
<onleft>12</onleft>
<onright>7</onright>
</control>
<control type="button" id="12">
<description>Album Info button</description>
<control type="button" id="7">
<description>Set my rating</description>
<left>420</left>
<top>0</top>
<width>200</width>
<height>40</height>
<label>10523</label>
<font>font12_title</font>
<align>center</align>
<onleft>11</onleft>
<onright>13</onright>
<onup>14</onup>
<ondown>14</ondown>
</control>
<control type="button" id="13">
<description>Get Thumb button</description>
<left>630</left>
<top>0</top>
<width>200</width>
<height>40</height>
<label>13405</label>
<label>38023</label>
<font>font12_title</font>
<align>center</align>
<onleft>12</onleft>
<onright>10</onright>
<onup>14</onup>
<ondown>14</ondown>
<onleft>13</onleft>
<onright>12</onright>
</control>
</control>
</control>
Expand Down
39 changes: 34 additions & 5 deletions addons/skin.confluence/720p/DialogVideoInfo.xml
Expand Up @@ -178,9 +178,9 @@
</control>
<control type="list" id="49">
<left>290</left>
<top>20</top>
<top>-4</top>
<width>740</width>
<height>330</height>
<height>390</height>
<onleft>49</onleft>
<onright>49</onright>
<onup>9000</onup>
Expand Down Expand Up @@ -291,6 +291,12 @@
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Duration)</visible>
</item>
<item>
<label>$LOCALIZE[38018]:</label>
<label2>$INFO[ListItem.Userrating]</label2>
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</item>
<item>
<label>$LOCALIZE[563]:</label>
<label2>$INFO[ListItem.RatingAndVotes]</label2>
Expand Down Expand Up @@ -325,7 +331,7 @@
</control>
<control type="image">
<left>290</left>
<top>370</top>
<top>382</top>
<width>740</width>
<height>4</height>
<aspectratio>stretch</aspectratio>
Expand Down Expand Up @@ -453,6 +459,12 @@
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Year)</visible>
</item>
<item>
<label>$LOCALIZE[38018]:</label>
<label2>$INFO[ListItem.Userrating]</label2>
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</item>
<item>
<label>$LOCALIZE[563]:</label>
<label2>$INFO[ListItem.RatingAndVotes]</label2>
Expand Down Expand Up @@ -503,9 +515,9 @@
</control>
<control type="list" id="49">
<left>390</left>
<top>20</top>
<top>0</top>
<width>640</width>
<height>330</height>
<height>360</height>
<onleft>49</onleft>
<onright>49</onright>
<onup>9000</onup>
Expand Down Expand Up @@ -628,6 +640,12 @@
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Duration)</visible>
</item>
<item>
<label>$LOCALIZE[38018]:</label>
<label2>$INFO[ListItem.Userrating]</label2>
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</item>
<item>
<label>$LOCALIZE[563]:</label>
<label2>$INFO[ListItem.RatingAndVotes]</label2>
Expand Down Expand Up @@ -787,6 +805,12 @@
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Duration)</visible>
</item>
<item>
<label>$LOCALIZE[38018]:</label>
<label2>$INFO[ListItem.Userrating]</label2>
<onclick>noop</onclick>
<visible>!IsEmpty(ListItem.Userrating)</visible>
</item>
<item>
<label>$LOCALIZE[15311]</label>
<label2>$INFO[ListItem.FilenameAndPath]</label2>
Expand Down Expand Up @@ -983,6 +1007,11 @@
<onclick>PlayMedia($INFO[ListItem.Trailer],1)</onclick>
<visible>!IsEmpty(ListItem.Trailer) + Skin.HasSetting(WindowedTrailer)</visible>
</control>
<control type="button" id="7">
<description>Set my rating</description>
<include>ButtonInfoDialogsCommonValues</include>
<label>38023</label>
</control>
<control type="button" id="100">
<description>Fetch TvTunes stuff</description>
<include>ButtonInfoDialogsCommonValues</include>
Expand Down
8 changes: 4 additions & 4 deletions xbmc/Application.cpp
Expand Up @@ -2217,24 +2217,24 @@ bool CApplication::OnAction(const CAction &action)
if (tag)
{
*m_itemCurrentFile->GetMusicInfoTag() = *tag;
char rating = tag->GetRating();
char rating = tag->GetUserrating();
bool needsUpdate(false);
if (rating > '0' && action.GetID() == ACTION_DECREASE_RATING)
{
m_itemCurrentFile->GetMusicInfoTag()->SetRating(rating - 1);
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(rating - 1);
needsUpdate = true;
}
else if (rating < '5' && action.GetID() == ACTION_INCREASE_RATING)
{
m_itemCurrentFile->GetMusicInfoTag()->SetRating(rating + 1);
m_itemCurrentFile->GetMusicInfoTag()->SetUserrating(rating + 1);
needsUpdate = true;
}
if (needsUpdate)
{
CMusicDatabase db;
if (db.Open()) // OpenForWrite() ?
{
db.SetSongRating(m_itemCurrentFile->GetPath(), m_itemCurrentFile->GetMusicInfoTag()->GetRating());
db.SetSongUserrating(m_itemCurrentFile->GetPath(), m_itemCurrentFile->GetMusicInfoTag()->GetUserrating());
db.Close();
}
// send a message to all windows to tell them to update the fileitem (eg playlistplayer, media windows)
Expand Down
8 changes: 4 additions & 4 deletions xbmc/GUIInfoManager.cpp
Expand Up @@ -5198,9 +5198,9 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::
std::string rating;
if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
rating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetUserrating() > '0')
{ // song rating. Images will probably be better than numbers for this in the long run
rating.assign(1, item->GetMusicInfoTag()->GetRating());
rating.assign(1, item->GetMusicInfoTag()->GetUserrating());
}
return rating;
}
Expand Down Expand Up @@ -5813,7 +5813,7 @@ std::string CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::
{
if (item->HasMusicInfoTag())
{
return StringUtils::Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
return StringUtils::Format("songrating%c.png", item->GetMusicInfoTag()->GetUserrating());
}
}
break;
Expand All @@ -5826,7 +5826,7 @@ std::string CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::
}
else if (item->HasMusicInfoTag())
{ // song rating.
rating = StringUtils::Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
rating = StringUtils::Format("rating%c.png", item->GetMusicInfoTag()->GetUserrating());
}
return rating;
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/Visualisation.cpp
Expand Up @@ -225,7 +225,7 @@ bool CVisualisation::OnAction(VIS_ACTION action, void *param)
track.discNumber = tag->GetDiscNumber();
track.duration = tag->GetDuration();
track.year = tag->GetYear();
track.rating = tag->GetRating();
track.rating = tag->GetUserrating();

return m_pStruct->OnAction(action, &track);
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/legacy/ListItem.cpp
Expand Up @@ -451,7 +451,7 @@ namespace XBMCAddon
else if (key == "title")
item->GetMusicInfoTag()->SetTitle(value);
else if (key == "rating")
item->GetMusicInfoTag()->SetRating(value[0]);
item->GetMusicInfoTag()->SetUserrating(value[0]);
else if (key == "lyrics")
item->GetMusicInfoTag()->SetLyrics(value);
else if (key == "lastplayed")
Expand Down
6 changes: 3 additions & 3 deletions xbmc/music/MusicDatabase.cpp
Expand Up @@ -1689,7 +1689,7 @@ CSong CMusicDatabase::GetSongFromDataset(const dbiplus::sql_record* const record
song.iStartOffset = record->at(offset + song_iStartOffset).get_asInt();
song.iEndOffset = record->at(offset + song_iEndOffset).get_asInt();
song.strMusicBrainzTrackID = record->at(offset + song_strMusicBrainzTrackID).get_asString();
song.rating = record->at(offset + song_rating).get_asChar();
song.rating = record->at(offset + song_userrating).get_asChar();
song.strComment = record->at(offset + song_comment).get_asString();
song.strMood = record->at(offset + song_mood).get_asString();
song.iKaraokeNumber = record->at(offset + song_iKarNumber).get_asInt();
Expand Down Expand Up @@ -1728,7 +1728,7 @@ void CMusicDatabase::GetFileItemFromDataset(const dbiplus::sql_record* const rec
item->SetProperty("item_start", item->m_lStartOffset);
item->m_lEndOffset = record->at(song_iEndOffset).get_asInt();
item->GetMusicInfoTag()->SetMusicBrainzTrackID(record->at(song_strMusicBrainzTrackID).get_asString());
item->GetMusicInfoTag()->SetRating(record->at(song_rating).get_asChar());
item->GetMusicInfoTag()->SetUserrating(record->at(song_userrating).get_asChar());
item->GetMusicInfoTag()->SetComment(record->at(song_comment).get_asString());
item->GetMusicInfoTag()->SetMood(record->at(song_mood).get_asString());
item->GetMusicInfoTag()->SetPlayCount(record->at(song_iTimesPlayed).get_asInt());
Expand Down Expand Up @@ -4450,7 +4450,7 @@ bool CMusicDatabase::GetPaths(std::set<std::string> &paths)
return false;
}

bool CMusicDatabase::SetSongRating(const std::string &filePath, char rating)
bool CMusicDatabase::SetSongUserrating(const std::string &filePath, char rating)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions xbmc/music/MusicDatabase.h
Expand Up @@ -191,7 +191,7 @@ class CMusicDatabase : public CDatabase
bool GetSongsByPath(const std::string& strPath, MAPSONGS& songs, bool bAppendToMap = false);
bool Search(const std::string& search, CFileItemList &items);
bool RemoveSongsFromPath(const std::string &path, MAPSONGS& songs, bool exact=true);
bool SetSongRating(const std::string &filePath, char rating);
bool SetSongUserrating(const std::string &filePath, char rating);
int GetSongByArtistAndAlbumAndTitle(const std::string& strArtist, const std::string& strAlbum, const std::string& strTitle);

/////////////////////////////////////////////////
Expand Down Expand Up @@ -537,7 +537,7 @@ class CMusicDatabase : public CDatabase
song_iStartOffset,
song_iEndOffset,
song_lastplayed,
song_rating,
song_userrating,
song_comment,
song_idAlbum,
song_strAlbum,
Expand Down
2 changes: 1 addition & 1 deletion xbmc/music/Song.cpp
Expand Up @@ -73,7 +73,7 @@ CSong::CSong(CFileItem& item)
strComment = tag.GetComment();
strCueSheet = tag.GetCueSheet();
strMood = tag.GetMood();
rating = tag.GetRating();
rating = tag.GetUserrating();
iYear = stTime.wYear;
iTrack = tag.GetTrackAndDiscNumber();
iDuration = tag.GetDuration();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/music/dialogs/GUIDialogMusicInfo.cpp
Expand Up @@ -152,7 +152,7 @@ void CGUIDialogMusicInfo::SetAlbum(const CAlbum& album, const std::string &path)
m_albumItem->GetMusicInfoTag()->SetArtist(m_album.GetAlbumArtist());
m_albumItem->GetMusicInfoTag()->SetYear(m_album.iYear);
m_albumItem->GetMusicInfoTag()->SetLoaded(true);
m_albumItem->GetMusicInfoTag()->SetRating('0' + m_album.iRating);
m_albumItem->GetMusicInfoTag()->SetUserrating('0' + m_album.iRating);
m_albumItem->GetMusicInfoTag()->SetGenre(m_album.genre);
m_albumItem->GetMusicInfoTag()->SetDatabaseId(m_album.idAlbum, MediaTypeAlbum);
CMusicDatabase::SetPropertiesFromAlbum(*m_albumItem,m_album);
Expand Down