changed: Add logic to properly handle subtitles for stacked files
authorarnova <arnova@void.org>
Tue, 15 Oct 2013 11:24:35 +0000 (13:24 +0200)
committerarnova <arnova@void.org>
Tue, 4 Feb 2014 19:00:07 +0000 (20:00 +0100)
xbmc/Application.cpp
xbmc/Application.h
xbmc/video/dialogs/GUIDialogSubtitles.cpp

index 08bfba0..c3797f7 100644 (file)
@@ -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);
index a0e20b4..e3a26c5 100644 (file)
@@ -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();
index 7d6f7aa..d4748b3 100644 (file)
@@ -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();
     }