[coreSubs] set default services for Tv Shows and Movies
authoramet <amet.nospam@gmail.com>
Mon, 2 Dec 2013 21:49:40 +0000 (01:49 +0400)
committeramet <amet.nospam@gmail.com>
Mon, 2 Dec 2013 21:49:40 +0000 (01:49 +0400)
language/English/strings.po
system/settings/settings.xml
xbmc/video/dialogs/GUIDialogSubtitles.cpp

index 93d0c3c..1f666ba 100755 (executable)
@@ -12046,7 +12046,27 @@ msgctxt "#24115"
 msgid "Save subtitles to movie folder"
 msgstr ""
 
-#empty strings from id 24116 to 24999
+#: system/settings/settings.xml
+msgctxt "#24116"
+msgid "Default TV Service"
+msgstr ""
+
+#: system/settings/settings.xml
+msgctxt "#24117"
+msgid "Select service that will be used as default to search for TV Show subtitles"
+msgstr ""
+
+#: system/settings/settings.xml
+msgctxt "#24118"
+msgid "Default Movie Service"
+msgstr ""
+
+#: system/settings/settings.xml
+msgctxt "#24119"
+msgid "Select service that will be used as default to search for Movie subtitles"
+msgstr ""
+
+#empty strings from id 24120 to 24999
 
 msgctxt "#25000"
 msgid "Notifications"
index aa1cdd7..f224c70 100644 (file)
             <multiselect>true</multiselect>
           </control>
         </setting>
+        <setting id="subtitles.tv" type="addon" label="24116" help="24117">
+          <level>1</level>
+          <default>-</default>
+          <constraints>
+            <addontype>xbmc.subtitle.module</addontype>
+          </constraints>
+          <control type="button" format="addon" />
+        </setting>
+        <setting id="subtitles.movie" type="addon" label="24118" help="24119">
+          <level>1</level>
+          <default>-</default>
+          <constraints>
+            <addontype>xbmc.subtitle.module</addontype>
+          </constraints>
+          <control type="button" format="addon" />
+        </setting>
         <setting id="subtitles.custompath" type="path" label="21366" help="36191">
           <level>1</level>
           <default></default>
index 81f52b1..d57a91b 100644 (file)
@@ -41,6 +41,7 @@
 #include "utils/URIUtils.h"
 #include "URL.h"
 #include "Util.h"
+#include "video/VideoDatabase.h"
 
 using namespace ADDON;
 using namespace XFILE;
@@ -211,18 +212,30 @@ void CGUIDialogSubtitles::FillServices()
     return;
   }
 
+  std::string defaultService;
+  const CFileItem &item = g_application.CurrentFileItem();
+  if (item.GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS ||
+      item.GetVideoContentType() == VIDEODB_CONTENT_EPISODES)
+    // Set default service for tv shows
+    defaultService = CSettings::Get().GetString("subtitles.tv");
+  else
+    // Set default service for filemode and movies
+    defaultService = CSettings::Get().GetString("subtitles.movie");
+  
+  std::string service = addons.front()->ID();
   for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); addonIt++)
   {
     CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addonIt, "plugin://", false));
     m_serviceItems->Add(item);
+    if ((*addonIt)->ID() == defaultService)
+      service = (*addonIt)->ID();
   }
 
   // Bind our services to the UI
   CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_SERVICELIST, 0, 0, m_serviceItems);
   OnMessage(msg);
 
-  // TODO: Default service support will need to check through the items to find the CFileItem in the loop above.
-  SetService(m_serviceItems->Get(0)->GetProperty("Addon.ID").asString());
+  SetService(service);
 }
 
 bool CGUIDialogSubtitles::SetService(const std::string &service)