Skip to content

Commit

Permalink
Merge pull request #3816 from amet/manualSearch
Browse files Browse the repository at this point in the history
[coreSubs] option to manually entering search string
  • Loading branch information
jmarshallnz committed Jan 5, 2014
2 parents f444d23 + 024aa3e commit a701a9e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
24 changes: 20 additions & 4 deletions addons/skin.confluence/720p/DialogSubtitles.xml
Expand Up @@ -8,7 +8,7 @@
<controls>
<control type="group" id="250">
<animation effect="slide" start="0,0" end="900,0" time="500" tween="quadratic" easing="out">WindowClose</animation>
<animation type="Conditional" condition="Control.HasFocus(150)" reversible="true">
<animation type="Conditional" condition="Control.HasFocus(150) | Control.HasFocus(160)" reversible="true">
<effect type="slide" end="-250,0" time="400"/>
</animation>
<control type="button" id="8999">
Expand Down Expand Up @@ -350,11 +350,11 @@
<left>900</left>
<top>206</top>
<width>250</width>
<height>434</height>
<height>399</height>
<onleft>120</onleft>
<onright>120</onright>
<onup>150</onup>
<ondown>150</ondown>
<onup>160</onup>
<ondown>160</ondown>
<viewtype label="535">list</viewtype>
<scrolltime>200</scrolltime>
<itemlayout width="400" height="36">
Expand Down Expand Up @@ -408,6 +408,22 @@
</control>
</focusedlayout>
</control>
<control type="button" id="160">
<description>Manual search button</description>
<left>925</left>
<top>640</top>
<width>200</width>
<height>40</height>
<onleft>120</onleft>
<onright>120</onright>
<onup>150</onup>
<ondown>150</ondown>
<label>$LOCALIZE[24120]</label>
<font>font12_title</font>
<textcolor>white</textcolor>
<focusedcolor>white</focusedcolor>
<align>center</align>
</control>
</control>
</control>
</controls>
Expand Down
12 changes: 11 additions & 1 deletion language/English/strings.po
Expand Up @@ -12101,7 +12101,17 @@ msgctxt "#24119"
msgid "Select service that will be used as default to search for Movie subtitles"
msgstr ""

#empty strings from id 24120 to 24999
#: xbmc/dialogs/GUIDialogSubtitles.cpp
msgctxt "#24120"
msgid "Manual search string"
msgstr ""

#: xbmc/dialogs/GUIDialogSubtitles.cpp
msgctxt "#24121"
msgid "Enter search string"
msgstr ""

#empty strings from id 24121 to 24999

msgctxt "#25000"
msgid "Notifications"
Expand Down
23 changes: 20 additions & 3 deletions xbmc/video/dialogs/GUIDialogSubtitles.cpp
Expand Up @@ -30,6 +30,7 @@
#include "filesystem/PluginDirectory.h"
#include "filesystem/SpecialProtocol.h"
#include "guilib/GUIImage.h"
#include "guilib/GUIKeyboardFactory.h"
#include "settings/MediaSettings.h"
#include "settings/Settings.h"
#include "settings/VideoSettings.h"
Expand All @@ -52,6 +53,7 @@ using namespace XFILE;
#define CONTROL_SUBSEXIST 130
#define CONTROL_SUBSTATUS 140
#define CONTROL_SERVICELIST 150
#define CONTROL_MANUALSEARCH 160

/*! \brief simple job to retrieve a directory and store a string (language)
*/
Expand Down Expand Up @@ -138,6 +140,15 @@ bool CGUIDialogSubtitles::OnMessage(CGUIMessage& message)

return true;
}
else if (iControl == CONTROL_MANUALSEARCH)
{
//manual search
if (CGUIKeyboardFactory::ShowAndGetInput(m_strManualSearch, g_localizeStrings.Get(24121), true))
{
Search(m_strManualSearch);
return true;
}
}
}
else if (message.GetMessage() == GUI_MSG_WINDOW_DEINIT)
{
Expand Down Expand Up @@ -290,7 +301,7 @@ const CFileItemPtr CGUIDialogSubtitles::GetService() const
return CFileItemPtr();
}

void CGUIDialogSubtitles::Search()
void CGUIDialogSubtitles::Search(const std::string &search/*=""*/)
{
if (m_currentService.empty())
return; // no services available
Expand All @@ -299,7 +310,13 @@ void CGUIDialogSubtitles::Search()
ClearSubtitles();

CURL url("plugin://" + m_currentService + "/");
url.SetOption("action", "search");
if (!search.empty())
{
url.SetOption("action", "manualsearch");
url.SetOption("searchstring", search);
}
else
url.SetOption("action", "search");

const CSetting *setting = CSettings::Get().GetSetting("subtitles.languages");
if (setting)
Expand All @@ -313,7 +330,7 @@ void CGUIDialogSubtitles::OnJobComplete(unsigned int jobID, bool success, CJob *
const CURL &url = ((CSubtitlesJob *)job)->GetURL();
const CFileItemList *items = ((CSubtitlesJob *)job)->GetItems();
const std::string &language = ((CSubtitlesJob *)job)->GetLanguage();
if (url.GetOption("action") == "search")
if (url.GetOption("action") == "search" || url.GetOption("action") == "manualsearch")
OnSearchComplete(items);
else
OnDownloadComplete(items, language);
Expand Down
3 changes: 2 additions & 1 deletion xbmc/video/dialogs/GUIDialogSubtitles.h
Expand Up @@ -49,7 +49,7 @@ class CGUIDialogSubtitles : public CGUIDialog, CJobQueue
enum STATUS { NO_SERVICES = 0, SEARCHING, SEARCH_COMPLETE, DOWNLOADING };
void UpdateStatus(STATUS status);

void Search();
void Search(const std::string &search="");
void OnSearchComplete(const CFileItemList *items);

void Download(const CFileItem &subtitle);
Expand All @@ -62,6 +62,7 @@ class CGUIDialogSubtitles : public CGUIDialog, CJobQueue
CFileItemList* m_serviceItems;
std::string m_currentService;
std::string m_status;
CStdString m_strManualSearch;
bool m_pausedOnRun;
bool m_updateSubsList; ///< true if we need to update our subs list
};

0 comments on commit a701a9e

Please sign in to comment.