Skip to content

Commit

Permalink
Merge pull request #2543 from ulion/enhanced_builtin_slideshow
Browse files Browse the repository at this point in the history
Enhanced builtin func SlideShow() support pause and set beginslide path
  • Loading branch information
jmarshallnz committed Apr 7, 2013
2 parents 5de5933 + cc67a07 commit 425fd3e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 19 deletions.
30 changes: 25 additions & 5 deletions xbmc/Util.cpp
Expand Up @@ -1095,14 +1095,14 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
lastEscaped = escaped;
if (inQuotes)
{ // if we're in a quote, we accept everything until the closing quote
if (ch == '\"' && !escaped)
if (ch == '"' && !escaped)
{ // finished a quote - no need to add the end quote to our string
inQuotes = false;
}
}
else
{ // not in a quote, so check if we should be starting one
if (ch == '\"' && !escaped)
if (ch == '"' && !escaped)
{ // start of quote - no need to add the quote to our string
inQuotes = true;
}
Expand All @@ -1119,15 +1119,25 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
if (whiteSpacePos)
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
parameter = parameter.Mid(1,parameter.GetLength() - 2);
else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
{
// check name="value" style param.
int quotaPos = parameter.Find('"');
if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
{
parameter.Delete(parameter.GetLength() - 1);
parameter.Delete(quotaPos);
}
}
parameters.push_back(parameter);
parameter.Empty();
whiteSpacePos = 0;
continue;
}
}
if ((ch == '\"' || ch == '\\') && escaped)
if ((ch == '"' || ch == '\\') && escaped)
{ // escaped quote or backslash
parameter[parameter.size()-1] = ch;
continue;
Expand All @@ -1149,8 +1159,18 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
if (whiteSpacePos)
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
parameter = parameter.Mid(1,parameter.GetLength() - 2);
else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
{
// check name="value" style param.
int quotaPos = parameter.Find('"');
if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
{
parameter.Delete(parameter.GetLength() - 1);
parameter.Delete(quotaPos);
}
}
if (!parameter.IsEmpty() || parameters.size())
parameters.push_back(parameter);
}
Expand Down
29 changes: 21 additions & 8 deletions xbmc/interfaces/Builtins.cpp
Expand Up @@ -642,24 +642,37 @@ int CBuiltins::Execute(const CStdString& execString)
CLog::Log(LOGERROR, "XBMC.SlideShow called with empty parameter");
return -2;
}
std::string beginSlidePath;
// leave RecursiveSlideShow command as-is
unsigned int flags = 0;
if (execute.Equals("RecursiveSlideShow"))
flags |= 1;

// SlideShow(dir[,recursive][,[not]random])
// SlideShow(dir[,recursive][,[not]random][,pause][,beginslide="/path/to/start/slide.jpg"])
// the beginslide value need be escaped (for '"' or '\' in it, by backslash)
// and then quoted, or not. See CUtil::SplitParams()
else
{
if ((params.size() > 1 && params[1] == "recursive") || (params.size() > 2 && params[2] == "recursive"))
flags |= 1;
if ((params.size() > 1 && params[1] == "random") || (params.size() > 2 && params[2] == "random"))
flags |= 2;
if ((params.size() > 1 && params[1] == "notrandom") || (params.size() > 2 && params[2] == "notrandom"))
flags |= 4;
for (unsigned int i = 1 ; i < params.size() ; i++)
{
if (params[i].Equals("recursive"))
flags |= 1;
else if (params[i].Equals("random")) // set fullscreen or windowed
flags |= 2;
else if (params[i].Equals("notrandom"))
flags |= 4;
else if (params[i].Equals("pause"))
flags |= 8;
else if (params[i].Left(11).Equals("beginslide="))
beginSlidePath = params[i].Mid(11);
}
}

CGUIMessage msg(GUI_MSG_START_SLIDESHOW, 0, 0, flags);
msg.SetStringParam(params[0]);
vector<CStdString> strParams;
strParams.push_back(params[0]);
strParams.push_back(beginSlidePath);
msg.SetStringParams(strParams);
CGUIWindow *pWindow = g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (pWindow) pWindow->OnMessage(msg);
}
Expand Down
29 changes: 24 additions & 5 deletions xbmc/pictures/GUIWindowSlideShow.cpp
Expand Up @@ -864,10 +864,12 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
{
CStdString strFolder = message.GetStringParam();
unsigned int iParams = message.GetParam1();
std::string beginSlidePath = message.GetStringParam(1);
//decode params
bool bRecursive = false;
bool bRandom = false;
bool bNotRandom = false;
bool bPause = false;
if (iParams > 0)
{
if ((iParams & 1) == 1)
Expand All @@ -876,8 +878,10 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
bRandom = true;
if ((iParams & 4) == 4)
bNotRandom = true;
if ((iParams & 8) == 8)
bPause = true;
}
RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom);
RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom, SORT_METHOD_LABEL, SortOrderAscending, "", beginSlidePath, !bPause);
}
break;

Expand Down Expand Up @@ -1091,14 +1095,18 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
bool bRecursive /* = false */, bool bRandom /* = false */,
bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */,
SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions)
SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions /* = "" */,
const CStdString &beginSlidePath /* = "" */, bool startSlideShow /* = true */)
{
// stop any video
if (g_application.IsPlayingVideo())
g_application.StopPlaying();

AddFromPath(strPath, bRecursive, method, order, strExtensions);

if (!NumSlides())
return;

// mutually exclusive options
// if both are set, clear both and use the gui setting
if (bRandom && bNotRandom)
Expand All @@ -1108,9 +1116,20 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
if ((!bNotRandom && g_guiSettings.GetBool("slideshow.shuffle")) || bRandom)
Shuffle();

StartSlideShow();
if (NumSlides())
g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
if (!beginSlidePath.IsEmpty())
Select(beginSlidePath);

if (startSlideShow)
StartSlideShow();
else
{
CVariant param;
param["player"]["speed"] = 0;
param["player"]["playerid"] = PLAYLIST_PICTURE;
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", GetCurrentSlide(), param);
}

g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
}

void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SortOrder order)
Expand Down
3 changes: 2 additions & 1 deletion xbmc/pictures/GUIWindowSlideShow.h
Expand Up @@ -76,7 +76,8 @@ class CGUIWindowSlideShow : public CGUIWindow
void RunSlideShow(const CStdString &strPath, bool bRecursive = false,
bool bRandom = false, bool bNotRandom = false,
SORT_METHOD method = SORT_METHOD_LABEL,
SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
SortOrder order = SortOrderAscending, const CStdString &strExtensions="",
const CStdString &beginSlidePath="", bool startSlideShow = true);
void AddFromPath(const CStdString &strPath, bool bRecursive,
SORT_METHOD method=SORT_METHOD_LABEL,
SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
Expand Down

0 comments on commit 425fd3e

Please sign in to comment.