Esempio n. 1
0
bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      if (m_startUserrating != m_song->GetMusicInfoTag()->GetUserrating())
      {
        CMusicDatabase db;
        if (db.Open())      // OpenForWrite() ?
        {
          m_needsUpdate = true;
          db.SetSongUserrating(m_song->GetPath(), m_song->GetMusicInfoTag()->GetUserrating());
          db.Close();
        }
      }
      break;
    }
  case GUI_MSG_WINDOW_INIT:
    m_cancelled = false;
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_USERRATING)
      {
        OnSetUserrating();
      }
      else if (iControl == CONTROL_ALBUMINFO)
      {
        CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV);
        if (window)
        {
          CFileItem item(*m_song);
          std::string path = StringUtils::Format("musicdb://albums/%li",m_albumId);
          item.SetPath(path);
          item.m_bIsFolder = true;
          window->OnItemInfo(&item, true);
        }
        return true;
      }
      else if (iControl == CONTROL_GETTHUMB)
      {
        OnGetThumb();
        return true;
      }
    }
    break;
  }

  return CGUIDialog::OnMessage(message);
}
Esempio n. 2
0
bool CGUIDialogMusicOSD::OnAction(const CAction &action)
{
  switch (action.GetID())
  {
    case ACTION_SHOW_OSD:
      Close();
      return true;
  
    case ACTION_SET_RATING:
    {
      CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(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));

        auto track = g_application.CurrentFileItemPtr();
        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);
}
Esempio n. 3
0
bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      if (m_startUserrating != m_song->GetMusicInfoTag()->GetUserrating())
      {
        CMusicDatabase db;
        if (db.Open())
        {
          m_needsUpdate = true;
          db.SetSongUserrating(m_song->GetPath(), m_song->GetMusicInfoTag()->GetUserrating());
          db.Close();
        }
      }
      CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST);
      OnMessage(msg);
      break;
    }
  case GUI_MSG_WINDOW_INIT:
    CGUIDialog::OnMessage(message);    
    Update();
    m_cancelled = false;
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_USERRATING)
      {
        OnSetUserrating();
      }
      else if (iControl == CONTROL_ALBUMINFO)
      {
        CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV);
        if (window)
        {
          CFileItem item(*m_song);
          std::string path = StringUtils::Format("musicdb://albums/%li",m_albumId);
          item.SetPath(path);
          item.m_bIsFolder = true;
          window->OnItemInfo(&item, true);
        }
        return true;
      }
      else if (iControl == CONTROL_BTN_GET_THUMB)
      {
        OnGetThumb();
        return true;
      }
      else if (iControl == CONTROL_LIST)
      {
        int iAction = message.GetParam1();
        if ((ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction))
        {
          CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl);
          g_windowManager.SendMessage(msg);
          int iItem = msg.GetParam1();
          if (iItem < 0 || iItem >= static_cast<int>(m_song->GetMusicInfoTag()->GetContributors().size()))
            break;
          int idArtist = m_song->GetMusicInfoTag()->GetContributors()[iItem].GetArtistId();
          if (idArtist > 0)
          {
              CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV);
              if (window)
              {
                CFileItem item(*m_song);
                std::string path = StringUtils::Format("musicdb://artists/%i", idArtist);
                item.SetPath(path);
                item.m_bIsFolder = true;
                window->OnItemInfo(&item, true);
              }
          }
          return true;
        }
      }
    }
    break;
  }

  return CGUIDialog::OnMessage(message);
}