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); }
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); }