From 322bd18c0e4344760924d916cf4cf664be33fb85 Mon Sep 17 00:00:00 2001 From: arnova Date: Tue, 15 Oct 2013 13:24:35 +0200 Subject: changed: Add logic to properly handle subtitles for stacked files --- xbmc/Application.cpp | 8 ++++++++ xbmc/Application.h | 1 + xbmc/video/dialogs/GUIDialogSubtitles.cpp | 15 +++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 08bfba0deb..c3797f7e8e 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -5214,6 +5214,14 @@ CFileItem& CApplication::CurrentFileItem() return *m_itemCurrentFile; } +CFileItem& CApplication::CurrentUnstackedItem() +{ + if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0) + return *(*m_currentStack)[m_currentStackPosition]; + else + return *m_itemCurrentFile; +} + void CApplication::ShowVolumeBar(const CAction *action) { CGUIDialog *volumeBar = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VOLUME_BAR); diff --git a/xbmc/Application.h b/xbmc/Application.h index a0e20b4253..e3a26c5e7c 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -156,6 +156,7 @@ public: void ReloadSkin(bool confirm = false); const CStdString& CurrentFile(); CFileItem& CurrentFileItem(); + CFileItem& CurrentUnstackedItem(); virtual bool OnMessage(CGUIMessage& message); PLAYERCOREID GetCurrentPlayer(); virtual void OnPlayBackEnded(); diff --git a/xbmc/video/dialogs/GUIDialogSubtitles.cpp b/xbmc/video/dialogs/GUIDialogSubtitles.cpp index 7d6f7aa215..d4748b3d9e 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitles.cpp +++ b/xbmc/video/dialogs/GUIDialogSubtitles.cpp @@ -222,7 +222,7 @@ void CGUIDialogSubtitles::FillServices() } std::string defaultService; - const CFileItem &item = g_application.CurrentFileItem(); + const CFileItem &item = g_application.CurrentUnstackedItem(); if (item.GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS || item.GetVideoContentType() == VIDEODB_CONTENT_EPISODES) // Set default service for tv shows @@ -386,6 +386,8 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s CStdString strFileName; CStdString strDestPath; +#if 0 + // TODO: Code to download all subtitles for all stack items in one run if (g_application.CurrentFileItem().IsStack()) { for (int i = 0; i < items->Size(); i++) @@ -394,17 +396,22 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s // CLog::Log(LOGDEBUG, "Stack Subs [%s} Found", vecItems[i]->GetLabel().c_str()); } } - else if (StringUtils::StartsWith(g_application.CurrentFile(), "http://")) +#endif + + // Get (unstacked) path + const CStdString &strCurrentFile = g_application.CurrentUnstackedItem().GetPath(); + + if (StringUtils::StartsWith(strCurrentFile, "http://")) { strFileName = "TemporarySubs"; strDestPath = "special://temp/"; } else { - strFileName = URIUtils::GetFileName(g_application.CurrentFile()); + strFileName = URIUtils::GetFileName(strCurrentFile); if (CSettings::Get().GetBool("subtitles.savetomoviefolder")) { - strDestPath = URIUtils::GetDirectory(g_application.CurrentFile()); + strDestPath = URIUtils::GetDirectory(strCurrentFile); if (!CUtil::SupportsWriteFileOperations(strDestPath)) strDestPath.clear(); } -- cgit v1.2.3