/xbmc/pictures/GUIWindowPictures.cpp

http://github.com/xbmc/xbmc · C++ · 615 lines · 522 code · 75 blank · 18 comment · 153 complexity · fd5a316991d7dc95f19e9adbf90d71bc MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2020 Team Kodi
  3. * This file is part of Kodi - https://kodi.tv
  4. *
  5. * SPDX-License-Identifier: GPL-2.0-or-later
  6. * See LICENSES/README.md for more information.
  7. */
  8. #include "GUIWindowPictures.h"
  9. #include "Application.h"
  10. #include "Autorun.h"
  11. #include "GUIDialogPictureInfo.h"
  12. #include "GUIPassword.h"
  13. #include "GUIWindowSlideShow.h"
  14. #include "PictureInfoLoader.h"
  15. #include "PlayListPlayer.h"
  16. #include "ServiceBroker.h"
  17. #include "URL.h"
  18. #include "Util.h"
  19. #include "addons/GUIDialogAddonInfo.h"
  20. #include "dialogs/GUIDialogMediaSource.h"
  21. #include "dialogs/GUIDialogProgress.h"
  22. #include "guilib/GUIComponent.h"
  23. #include "guilib/GUIWindowManager.h"
  24. #include "interfaces/AnnouncementManager.h"
  25. #include "media/MediaLockState.h"
  26. #include "messaging/helpers/DialogOKHelper.h"
  27. #include "playlists/PlayList.h"
  28. #include "playlists/PlayListFactory.h"
  29. #include "settings/MediaSourceSettings.h"
  30. #include "settings/Settings.h"
  31. #include "settings/SettingsComponent.h"
  32. #include "threads/SystemClock.h"
  33. #include "utils/SortUtils.h"
  34. #include "utils/StringUtils.h"
  35. #include "utils/URIUtils.h"
  36. #include "utils/Variant.h"
  37. #include "utils/XTimeUtils.h"
  38. #include "utils/log.h"
  39. #include "view/GUIViewState.h"
  40. #define CONTROL_BTNVIEWASICONS 2
  41. #define CONTROL_BTNSORTBY 3
  42. #define CONTROL_BTNSORTASC 4
  43. #define CONTROL_LABELFILES 12
  44. using namespace XFILE;
  45. using namespace PLAYLIST;
  46. using namespace KODI::MESSAGING;
  47. #define CONTROL_BTNSLIDESHOW 6
  48. #define CONTROL_BTNSLIDESHOW_RECURSIVE 7
  49. #define CONTROL_SHUFFLE 9
  50. CGUIWindowPictures::CGUIWindowPictures(void)
  51. : CGUIMediaWindow(WINDOW_PICTURES, "MyPics.xml")
  52. {
  53. m_thumbLoader.SetObserver(this);
  54. m_slideShowStarted = false;
  55. m_dlgProgress = NULL;
  56. }
  57. void CGUIWindowPictures::OnInitWindow()
  58. {
  59. CGUIMediaWindow::OnInitWindow();
  60. if (m_slideShowStarted)
  61. {
  62. CGUIWindowSlideShow* wndw = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  63. std::string path;
  64. if (wndw && wndw->GetCurrentSlide())
  65. path = URIUtils::GetDirectory(wndw->GetCurrentSlide()->GetPath());
  66. if (m_vecItems->IsPath(path))
  67. {
  68. if (wndw && wndw->GetCurrentSlide())
  69. m_viewControl.SetSelectedItem(wndw->GetCurrentSlide()->GetPath());
  70. SaveSelectedItemInHistory();
  71. }
  72. m_slideShowStarted = false;
  73. }
  74. }
  75. CGUIWindowPictures::~CGUIWindowPictures(void) = default;
  76. bool CGUIWindowPictures::OnMessage(CGUIMessage& message)
  77. {
  78. switch ( message.GetMessage() )
  79. {
  80. case GUI_MSG_WINDOW_DEINIT:
  81. {
  82. if (m_thumbLoader.IsLoading())
  83. m_thumbLoader.StopThread();
  84. }
  85. break;
  86. case GUI_MSG_WINDOW_INIT:
  87. {
  88. // is this the first time accessing this window?
  89. if (m_vecItems->GetPath() == "?" && message.GetStringParam().empty())
  90. message.SetStringParam(CMediaSourceSettings::GetInstance().GetDefaultSource("pictures"));
  91. m_dlgProgress = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
  92. }
  93. break;
  94. case GUI_MSG_CLICKED:
  95. {
  96. int iControl = message.GetSenderId();
  97. if (iControl == CONTROL_BTNSLIDESHOW) // Slide Show
  98. {
  99. OnSlideShow();
  100. }
  101. else if (iControl == CONTROL_BTNSLIDESHOW_RECURSIVE) // Recursive Slide Show
  102. {
  103. OnSlideShowRecursive();
  104. }
  105. else if (iControl == CONTROL_SHUFFLE)
  106. {
  107. const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
  108. settings->ToggleBool(CSettings::SETTING_SLIDESHOW_SHUFFLE);
  109. settings->Save();
  110. }
  111. else if (m_viewControl.HasControl(iControl)) // list/thumb control
  112. {
  113. int iItem = m_viewControl.GetSelectedItem();
  114. int iAction = message.GetParam1();
  115. // iItem is checked for validity inside these routines
  116. if (iAction == ACTION_DELETE_ITEM)
  117. {
  118. // is delete allowed?
  119. if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION))
  120. OnDeleteItem(iItem);
  121. else
  122. return false;
  123. }
  124. else if (iAction == ACTION_PLAYER_PLAY)
  125. {
  126. ShowPicture(iItem, true);
  127. return true;
  128. }
  129. else if (iAction == ACTION_SHOW_INFO)
  130. {
  131. OnItemInfo(iItem);
  132. return true;
  133. }
  134. }
  135. }
  136. break;
  137. }
  138. return CGUIMediaWindow::OnMessage(message);
  139. }
  140. void CGUIWindowPictures::UpdateButtons()
  141. {
  142. CGUIMediaWindow::UpdateButtons();
  143. // Update the shuffle button
  144. SET_CONTROL_SELECTED(GetID(), CONTROL_SHUFFLE, CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SLIDESHOW_SHUFFLE));
  145. // check we can slideshow or recursive slideshow
  146. int nFolders = m_vecItems->GetFolderCount();
  147. if (nFolders == m_vecItems->Size() ||
  148. m_vecItems->GetPath() == "addons://sources/image/")
  149. {
  150. CONTROL_DISABLE(CONTROL_BTNSLIDESHOW);
  151. }
  152. else
  153. {
  154. CONTROL_ENABLE(CONTROL_BTNSLIDESHOW);
  155. }
  156. if (m_guiState.get() && !m_guiState->HideParentDirItems())
  157. nFolders--;
  158. if (m_vecItems->Size() == 0 || nFolders == 0 ||
  159. m_vecItems->GetPath() == "addons://sources/image/")
  160. {
  161. CONTROL_DISABLE(CONTROL_BTNSLIDESHOW_RECURSIVE);
  162. }
  163. else
  164. {
  165. CONTROL_ENABLE(CONTROL_BTNSLIDESHOW_RECURSIVE);
  166. }
  167. }
  168. void CGUIWindowPictures::OnPrepareFileItems(CFileItemList& items)
  169. {
  170. CGUIMediaWindow::OnPrepareFileItems(items);
  171. for (int i=0;i<items.Size();++i )
  172. if (StringUtils::EqualsNoCase(items[i]->GetLabel(), "folder.jpg"))
  173. items.Remove(i);
  174. if (items.GetFolderCount() == items.Size() || !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_USETAGS))
  175. return;
  176. // Start the music info loader thread
  177. CPictureInfoLoader loader;
  178. loader.SetProgressCallback(m_dlgProgress);
  179. loader.Load(items);
  180. bool bShowProgress = !CServiceBroker::GetGUI()->GetWindowManager().HasModalDialog(true);
  181. bool bProgressVisible = false;
  182. unsigned int tick=XbmcThreads::SystemClockMillis();
  183. while (loader.IsLoading() && m_dlgProgress && !m_dlgProgress->IsCanceled())
  184. {
  185. if (bShowProgress)
  186. { // Do we have to init a progress dialog?
  187. unsigned int elapsed=XbmcThreads::SystemClockMillis()-tick;
  188. if (!bProgressVisible && elapsed>1500 && m_dlgProgress)
  189. { // tag loading takes more then 1.5 secs, show a progress dialog
  190. CURL url(items.GetPath());
  191. m_dlgProgress->SetHeading(CVariant{189});
  192. m_dlgProgress->SetLine(0, CVariant{505});
  193. m_dlgProgress->SetLine(1, CVariant{""});
  194. m_dlgProgress->SetLine(2, CVariant{url.GetWithoutUserDetails()});
  195. m_dlgProgress->Open();
  196. m_dlgProgress->ShowProgressBar(true);
  197. bProgressVisible = true;
  198. }
  199. if (bProgressVisible && m_dlgProgress)
  200. { // keep GUI alive
  201. m_dlgProgress->Progress();
  202. }
  203. } // if (bShowProgress)
  204. KODI::TIME::Sleep(1);
  205. } // while (loader.IsLoading())
  206. if (bProgressVisible && m_dlgProgress)
  207. m_dlgProgress->Close();
  208. }
  209. bool CGUIWindowPictures::Update(const std::string &strDirectory, bool updateFilterPath /* = true */)
  210. {
  211. if (m_thumbLoader.IsLoading())
  212. m_thumbLoader.StopThread();
  213. if (!CGUIMediaWindow::Update(strDirectory, updateFilterPath))
  214. return false;
  215. m_vecItems->SetArt("thumb", "");
  216. if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_GENERATETHUMBS))
  217. m_thumbLoader.Load(*m_vecItems);
  218. CPictureThumbLoader thumbLoader;
  219. std::string thumb = thumbLoader.GetCachedImage(*m_vecItems, "thumb");
  220. m_vecItems->SetArt("thumb", thumb);
  221. return true;
  222. }
  223. bool CGUIWindowPictures::OnClick(int iItem, const std::string &player)
  224. {
  225. if ( iItem < 0 || iItem >= m_vecItems->Size() ) return true;
  226. CFileItemPtr pItem = m_vecItems->Get(iItem);
  227. if (pItem->IsCBZ() || pItem->IsCBR())
  228. {
  229. CURL pathToUrl;
  230. if (pItem->IsCBZ())
  231. pathToUrl = URIUtils::CreateArchivePath("zip", pItem->GetURL(), "");
  232. else
  233. pathToUrl = URIUtils::CreateArchivePath("rar", pItem->GetURL(), "");
  234. OnShowPictureRecursive(pathToUrl.Get());
  235. return true;
  236. }
  237. else if (CGUIMediaWindow::OnClick(iItem, player))
  238. return true;
  239. return false;
  240. }
  241. bool CGUIWindowPictures::GetDirectory(const std::string &strDirectory, CFileItemList& items)
  242. {
  243. if (!CGUIMediaWindow::GetDirectory(strDirectory, items))
  244. return false;
  245. std::string label;
  246. if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("pictures"), &label))
  247. items.SetLabel(label);
  248. if (items.GetContent().empty() && !items.IsVirtualDirectoryRoot() && !items.IsPlugin())
  249. items.SetContent("images");
  250. return true;
  251. }
  252. bool CGUIWindowPictures::OnPlayMedia(int iItem, const std::string &player)
  253. {
  254. if (m_vecItems->Get(iItem)->IsVideo())
  255. return CGUIMediaWindow::OnPlayMedia(iItem);
  256. return ShowPicture(iItem, false);
  257. }
  258. bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow)
  259. {
  260. if ( iItem < 0 || iItem >= m_vecItems->Size() ) return false;
  261. CFileItemPtr pItem = m_vecItems->Get(iItem);
  262. std::string strPicture = pItem->GetPath();
  263. #ifdef HAS_DVD_DRIVE
  264. if (pItem->IsDVD())
  265. return MEDIA_DETECT::CAutorun::PlayDiscAskResume(m_vecItems->Get(iItem)->GetPath());
  266. #endif
  267. if (pItem->m_bIsShareOrDrive)
  268. return false;
  269. CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  270. if (!pSlideShow)
  271. return false;
  272. if (g_application.GetAppPlayer().IsPlayingVideo())
  273. g_application.StopPlaying();
  274. pSlideShow->Reset();
  275. bool bShowVideos = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_SHOWVIDEOS);
  276. for (const auto pItem : *m_vecItems)
  277. {
  278. if (!pItem->m_bIsFolder &&
  279. !(URIUtils::IsRAR(pItem->GetPath()) || URIUtils::IsZIP(pItem->GetPath())) &&
  280. (pItem->IsPicture() || (bShowVideos && pItem->IsVideo())))
  281. {
  282. pSlideShow->Add(pItem.get());
  283. }
  284. }
  285. if (pSlideShow->NumSlides() == 0)
  286. return false;
  287. pSlideShow->Select(strPicture);
  288. if (startSlideShow)
  289. pSlideShow->StartSlideShow();
  290. else
  291. {
  292. CVariant param;
  293. param["player"]["speed"] = 1;
  294. param["player"]["playerid"] = PLAYLIST_PICTURE;
  295. CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", pSlideShow->GetCurrentSlide(), param);
  296. }
  297. m_slideShowStarted = true;
  298. CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
  299. return true;
  300. }
  301. void CGUIWindowPictures::OnShowPictureRecursive(const std::string& strPath)
  302. {
  303. CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  304. if (pSlideShow)
  305. {
  306. // stop any video
  307. if (g_application.GetAppPlayer().IsPlayingVideo())
  308. g_application.StopPlaying();
  309. SortDescription sorting = m_guiState->GetSortMethod();
  310. pSlideShow->AddFromPath(strPath, true,
  311. sorting.sortBy, sorting.sortOrder, sorting.sortAttributes);
  312. if (pSlideShow->NumSlides())
  313. {
  314. m_slideShowStarted = true;
  315. CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
  316. }
  317. }
  318. }
  319. void CGUIWindowPictures::OnSlideShowRecursive(const std::string &strPicture)
  320. {
  321. CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  322. if (pSlideShow)
  323. {
  324. std::string strExtensions;
  325. CFileItemList items;
  326. CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
  327. if (viewState)
  328. {
  329. strExtensions = viewState->GetExtensions();
  330. delete viewState;
  331. }
  332. m_slideShowStarted = true;
  333. SortDescription sorting = m_guiState->GetSortMethod();
  334. pSlideShow->RunSlideShow(strPicture, true,
  335. CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SLIDESHOW_SHUFFLE),false,
  336. "", true,
  337. sorting.sortBy, sorting.sortOrder, sorting.sortAttributes,
  338. strExtensions);
  339. }
  340. }
  341. void CGUIWindowPictures::OnSlideShowRecursive()
  342. {
  343. std::string strEmpty = "";
  344. OnSlideShowRecursive(m_vecItems->GetPath());
  345. }
  346. void CGUIWindowPictures::OnSlideShow()
  347. {
  348. OnSlideShow(m_vecItems->GetPath());
  349. }
  350. void CGUIWindowPictures::OnSlideShow(const std::string &strPicture)
  351. {
  352. CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  353. if (pSlideShow)
  354. {
  355. std::string strExtensions;
  356. CFileItemList items;
  357. CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
  358. if (viewState)
  359. {
  360. strExtensions = viewState->GetExtensions();
  361. delete viewState;
  362. }
  363. m_slideShowStarted = true;
  364. SortDescription sorting = m_guiState->GetSortMethod();
  365. pSlideShow->RunSlideShow(strPicture, false ,false, false,
  366. "", true,
  367. sorting.sortBy, sorting.sortOrder, sorting.sortAttributes,
  368. strExtensions);
  369. }
  370. }
  371. void CGUIWindowPictures::OnRegenerateThumbs()
  372. {
  373. if (m_thumbLoader.IsLoading()) return;
  374. m_thumbLoader.SetRegenerateThumbs(true);
  375. m_thumbLoader.Load(*m_vecItems);
  376. }
  377. void CGUIWindowPictures::GetContextButtons(int itemNumber, CContextButtons &buttons)
  378. {
  379. CFileItemPtr item;
  380. if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
  381. item = m_vecItems->Get(itemNumber);
  382. if (item)
  383. {
  384. if ( m_vecItems->IsVirtualDirectoryRoot() || m_vecItems->GetPath() == "sources://pictures/" )
  385. {
  386. CGUIDialogContextMenu::GetContextButtons("pictures", item, buttons);
  387. }
  388. else
  389. {
  390. if (item)
  391. {
  392. if (!(item->m_bIsFolder || item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR() || item->IsScript()))
  393. {
  394. if (item->IsPicture())
  395. buttons.Add(CONTEXT_BUTTON_INFO, 13406); // picture info
  396. buttons.Add(CONTEXT_BUTTON_VIEW_SLIDESHOW, item->m_bIsFolder ? 13317 : 13422); // View Slideshow
  397. }
  398. if (item->m_bIsFolder)
  399. buttons.Add(CONTEXT_BUTTON_RECURSIVE_SLIDESHOW, 13318); // Recursive Slideshow
  400. if (!m_thumbLoader.IsLoading())
  401. buttons.Add(CONTEXT_BUTTON_REFRESH_THUMBS, 13315); // Create Thumbnails
  402. if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && !item->IsReadOnly())
  403. {
  404. buttons.Add(CONTEXT_BUTTON_DELETE, 117);
  405. buttons.Add(CONTEXT_BUTTON_RENAME, 118);
  406. }
  407. }
  408. if (!item->IsPlugin() && !item->IsScript() && !m_vecItems->IsPlugin())
  409. buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523);
  410. }
  411. }
  412. CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
  413. }
  414. bool CGUIWindowPictures::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
  415. {
  416. CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr();
  417. if (CGUIDialogContextMenu::OnContextButton("pictures", item, button))
  418. {
  419. Update("");
  420. return true;
  421. }
  422. switch (button)
  423. {
  424. case CONTEXT_BUTTON_VIEW_SLIDESHOW:
  425. if (item && item->m_bIsFolder)
  426. OnSlideShow(item->GetPath());
  427. else
  428. ShowPicture(itemNumber, true);
  429. return true;
  430. case CONTEXT_BUTTON_RECURSIVE_SLIDESHOW:
  431. if (item)
  432. OnSlideShowRecursive(item->GetPath());
  433. return true;
  434. case CONTEXT_BUTTON_INFO:
  435. OnItemInfo(itemNumber);
  436. return true;
  437. case CONTEXT_BUTTON_REFRESH_THUMBS:
  438. OnRegenerateThumbs();
  439. return true;
  440. case CONTEXT_BUTTON_DELETE:
  441. OnDeleteItem(itemNumber);
  442. return true;
  443. case CONTEXT_BUTTON_RENAME:
  444. OnRenameItem(itemNumber);
  445. return true;
  446. case CONTEXT_BUTTON_SWITCH_MEDIA:
  447. CGUIDialogContextMenu::SwitchMedia("pictures", m_vecItems->GetPath());
  448. return true;
  449. default:
  450. break;
  451. }
  452. return CGUIMediaWindow::OnContextButton(itemNumber, button);
  453. }
  454. bool CGUIWindowPictures::OnAddMediaSource()
  455. {
  456. return CGUIDialogMediaSource::ShowAndAddMediaSource("pictures");
  457. }
  458. void CGUIWindowPictures::OnItemLoaded(CFileItem *pItem)
  459. {
  460. CPictureThumbLoader::ProcessFoldersAndArchives(pItem);
  461. }
  462. void CGUIWindowPictures::LoadPlayList(const std::string& strPlayList)
  463. {
  464. CLog::Log(LOGDEBUG,"CGUIWindowPictures::LoadPlayList()... converting playlist into slideshow: %s", strPlayList.c_str());
  465. std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(strPlayList));
  466. if (nullptr != pPlayList)
  467. {
  468. if (!pPlayList->Load(strPlayList))
  469. {
  470. HELPERS::ShowOKDialogText(CVariant{6}, CVariant{477});
  471. return ; //hmmm unable to load playlist?
  472. }
  473. }
  474. CPlayList playlist = *pPlayList;
  475. if (playlist.size() > 0)
  476. {
  477. // set up slideshow
  478. CGUIWindowSlideShow *pSlideShow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
  479. if (!pSlideShow)
  480. return;
  481. if (g_application.GetAppPlayer().IsPlayingVideo())
  482. g_application.StopPlaying();
  483. // convert playlist items into slideshow items
  484. pSlideShow->Reset();
  485. for (int i = 0; i < playlist.size(); ++i)
  486. {
  487. CFileItemPtr pItem = playlist[i];
  488. //CLog::Log(LOGDEBUG,"-- playlist item: %s", pItem->GetPath().c_str());
  489. if (pItem->IsPicture() && !(pItem->IsZIP() || pItem->IsRAR() || pItem->IsCBZ() || pItem->IsCBR()))
  490. pSlideShow->Add(pItem.get());
  491. }
  492. // start slideshow if there are items
  493. pSlideShow->StartSlideShow();
  494. if (pSlideShow->NumSlides())
  495. CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
  496. }
  497. }
  498. void CGUIWindowPictures::OnItemInfo(int itemNumber)
  499. {
  500. CFileItemPtr item = m_vecItems->Get(itemNumber);
  501. if (!item)
  502. return;
  503. if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
  504. {
  505. CGUIDialogAddonInfo::ShowForItem(item);
  506. return;
  507. }
  508. if (item->m_bIsFolder || item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR() || !item->IsPicture())
  509. return;
  510. CGUIDialogPictureInfo *pictureInfo = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogPictureInfo>(WINDOW_DIALOG_PICTURE_INFO);
  511. if (pictureInfo)
  512. {
  513. pictureInfo->SetPicture(item.get());
  514. pictureInfo->Open();
  515. }
  516. }
  517. std::string CGUIWindowPictures::GetStartFolder(const std::string &dir)
  518. {
  519. if (StringUtils::EqualsNoCase(dir, "plugins") ||
  520. StringUtils::EqualsNoCase(dir, "addons"))
  521. return "addons://sources/image/";
  522. SetupShares();
  523. VECSOURCES shares;
  524. m_rootDir.GetSources(shares);
  525. bool bIsSourceName = false;
  526. int iIndex = CUtil::GetMatchingSource(dir, shares, bIsSourceName);
  527. if (iIndex > -1)
  528. {
  529. if (iIndex < static_cast<int>(shares.size()) && shares[iIndex].m_iHasLock == LOCK_STATE_LOCKED)
  530. {
  531. CFileItem item(shares[iIndex]);
  532. if (!g_passwordManager.IsItemUnlocked(&item,"pictures"))
  533. return "";
  534. }
  535. if (bIsSourceName)
  536. return shares[iIndex].strPath;
  537. return dir;
  538. }
  539. return CGUIMediaWindow::GetStartFolder(dir);
  540. }