Skip to content

Commit

Permalink
This makes the SubtitleDialog remember the last service used, and als…
Browse files Browse the repository at this point in the history
…o the last search instead of always using, and searching, the first service in the list.
  • Loading branch information
raptorjr committed Jun 21, 2016
1 parent 7b8e691 commit 17525c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@

// Dialog includes
#include "video/dialogs/GUIDialogVideoBookmarks.h"
#include "video/dialogs/GUIDialogSubtitles.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogSubMenu.h"
Expand Down Expand Up @@ -3795,6 +3796,12 @@ void CApplication::StopPlaying()
{
m_pPlayer->CloseFile();

// When playback stops we must clear the saved subtitle search from the SubtitleDialog since the dialog is preserved in memory
// Otherwise the next time the dialogs open any previous search from a previous movie will be shown
CGUIDialogSubtitles *dialog = (CGUIDialogSubtitles*)g_windowManager.GetWindow(WINDOW_DIALOG_SUBTITLES);
CGUIMessage msg(GUI_MSG_WINDOW_RESET, dialog->GetID(), 0);
dialog->OnMessage(msg);

// turn off visualisation window when stopping
if ((iWin == WINDOW_VISUALISATION
|| iWin == WINDOW_FULLSCREEN_VIDEO)
Expand Down
17 changes: 14 additions & 3 deletions xbmc/video/dialogs/GUIDialogSubtitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,14 @@ bool CGUIDialogSubtitles::OnMessage(CGUIMessage& message)

CGUIDialog::OnMessage(message);

return true;
}
else if (message.GetMessage() == GUI_MSG_WINDOW_RESET)
{
CGUIDialog::OnMessage(message);

// Clear saved subtitles from any previous subtitle search
ClearSubtitles();
ClearServices();
return true;
}
return CGUIDialog::OnMessage(message);
Expand All @@ -181,7 +187,10 @@ void CGUIDialogSubtitles::OnInitWindow()

FillServices();
CGUIWindow::OnInitWindow();
Search();

// Only do a inital search for subtitles if there isn't a saved search
if (m_subtitles->IsEmpty())
Search();
}

void CGUIDialogSubtitles::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
Expand Down Expand Up @@ -231,6 +240,7 @@ void CGUIDialogSubtitles::Process(unsigned int currentTime, CDirtyRegionList &di

void CGUIDialogSubtitles::FillServices()
{
std::string previousService = m_currentService;
ClearServices();

VECADDONS addons;
Expand All @@ -257,7 +267,8 @@ void CGUIDialogSubtitles::FillServices()
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addonIt, "plugin://" + (*addonIt)->ID(), false));
m_serviceItems->Add(item);
if ((*addonIt)->ID() == defaultService)
// If we don't have used a previous service use the default service, otherwise use the previous service
if ((previousService.empty() && (*addonIt)->ID() == defaultService) || (*addonIt)->ID() == previousService)
service = (*addonIt)->ID();
}

Expand Down

0 comments on commit 17525c5

Please sign in to comment.