Skip to content

Commit

Permalink
Merge pull request #9094 from Razzeee/userrating-osd
Browse files Browse the repository at this point in the history
Userrating in MusicOSD
  • Loading branch information
razzeee committed Feb 10, 2016
2 parents 01d4e3f + ca27828 commit 036a59f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 12 deletions.
13 changes: 9 additions & 4 deletions addons/skin.confluence/720p/MusicOSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@
<visible>!MusicPlayer.Content(LiveTV)</visible>
<onclick>PlayerControl(Random)</onclick>
</control>
<control type="image" id="2300">
<width>160</width>
<texture>-</texture>
</control>
<control type="image" id="2400">
<width>55</width>
<texture>-</texture>
Expand All @@ -277,6 +273,15 @@
<texture>-</texture>
<visible>!Player.CanRecord</visible>
</control>
<control type="button" id="705">
<width>55</width>
<height>55</height>
<label>15047</label>
<font>-</font>
<texturefocus>OSDRateFO.png</texturefocus>
<texturenofocus>OSDRateNF.png</texturenofocus>
<onclick>setrating</onclick>
</control>
<control type="button" id="700">
<width>55</width>
<height>55</height>
Expand Down
Binary file added addons/skin.confluence/media/OSDRateFO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addons/skin.confluence/media/OSDRateNF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions xbmc/input/ButtonTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static const ActionMapping actions[] =
{ "enter" , ACTION_ENTER },
{ "increaserating" , ACTION_INCREASE_RATING },
{ "decreaserating" , ACTION_DECREASE_RATING },
{ "setrating" , ACTION_SET_RATING },
{ "togglefullscreen" , ACTION_TOGGLE_FULLSCREEN },
{ "nextscene" , ACTION_NEXT_SCENE },
{ "previousscene" , ACTION_PREV_SCENE },
Expand Down
2 changes: 2 additions & 0 deletions xbmc/input/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@
#define ACTION_SUBTITLE_DELAY 162
#define ACTION_MENU 163

#define ACTION_SET_RATING 164

#define ACTION_RECORD 170

#define ACTION_PASTE 180
Expand Down
53 changes: 48 additions & 5 deletions xbmc/music/dialogs/GUIDialogMusicOSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "GUIUserMessages.h"
#include "settings/Settings.h"
#include "addons/GUIWindowAddonBrowser.h"
#include "xbmc/dialogs/GUIDialogSelect.h"
#include "xbmc/Application.h"
#include "xbmc/FileItem.h"
#include "xbmc/music/tags/MusicInfoTag.h"
#include "xbmc/music/MusicDatabase.h"

#define CONTROL_VIS_BUTTON 500
#define CONTROL_LOCK_BUTTON 501
Expand Down Expand Up @@ -72,12 +77,50 @@ bool CGUIDialogMusicOSD::OnAction(const CAction &action)
{
switch (action.GetID())
{
case ACTION_SHOW_OSD:
Close();
return true;
case ACTION_SHOW_OSD:
Close();
return true;

case ACTION_SET_RATING:
{
CGUIDialogSelect *dialog = static_cast<CGUIDialogSelect *>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT));
if (dialog)
{
dialog->SetHeading(CVariant{ 38023 });
dialog->Add(g_localizeStrings.Get(38022));
for (int i = 1; i <= 10; i++)
dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i));

default:
break;
auto track = std::make_shared<CFileItem>(g_application.CurrentFileItem());
dialog->SetSelected(track->GetMusicInfoTag()->GetUserrating());

dialog->Open();

int userrating = dialog->GetSelectedItem();

if (userrating < 0) userrating = 0;
if (userrating > 10) userrating = 10;
if (userrating != track->GetMusicInfoTag()->GetUserrating())
{
track->GetMusicInfoTag()->SetUserrating(userrating);
// send a message to all windows to tell them to update the fileitem (eg playlistplayer, media windows)
CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_ITEM, 0, track);
g_windowManager.SendMessage(msg);

CMusicDatabase db;
if (db.Open())
{
db.SetSongUserrating(track->GetMusicInfoTag()->GetURL(), userrating);
db.Close();
}
}

}
return true;
}

default:
break;
}

return CGUIDialog::OnAction(action);
Expand Down
6 changes: 3 additions & 3 deletions xbmc/music/dialogs/GUIDialogMusicOSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CGUIDialogMusicOSD :
public:
CGUIDialogMusicOSD(void);
virtual ~CGUIDialogMusicOSD(void);
virtual bool OnMessage(CGUIMessage &message);
virtual bool OnAction(const CAction &action);
virtual void FrameMove();
bool OnMessage(CGUIMessage &message) override;
bool OnAction(const CAction &action) override;
void FrameMove() override;
};

0 comments on commit 036a59f

Please sign in to comment.