MythTV  master
gallerythumbview.cpp
Go to the documentation of this file.
1 #include "gallerythumbview.h"
2 
3 #include <chrono> // for milliseconds
4 #include <thread> // for sleep_for
5 
6 #include <QApplication>
7 #include <utility>
8 
9 #include "compat.h"
10 
11 #include "mythuitext.h"
12 #include "mythprogressdialog.h"
13 #include "mythuiprogressbar.h"
14 #include "remotefile.h"
15 #include "mythsystemlegacy.h"
16 #include "mythdialogbox.h"
17 
18 #include "galleryconfig.h"
19 
20 #define LOC QString("Thumbview: ")
21 
22 
24 class ShellThread: public MThread
25 {
26 public:
27  ShellThread(QString cmd, QString path)
28  : MThread("Import"), m_command(std::move(cmd)), m_path(std::move(path)) {}
29 
30  int GetResult(void) const { return m_result; }
31 
32  void run() override // MThread
33  {
34  RunProlog();
35 
36  QString cmd = QString("cd %1 && %2").arg(m_path, m_command);
37  LOG(VB_GENERAL, LOG_INFO, QString("Executing \"%1\"").arg(cmd));
38 
39  m_result = myth_system(cmd);
40 
41  LOG(VB_GENERAL, LOG_INFO, QString(" ...with result %1").arg(m_result));
42 
43  RunEpilog();
44  }
45 
46 private:
47  int m_result {0};
48  QString m_command;
49  QString m_path;
50 };
51 
52 
54 class TransferThread : public MThread
55 {
56  Q_DECLARE_TR_FUNCTIONS(FileTransferWorker);
57 public:
58  using TransferMap = QMap<ImagePtrK, QString>;
59  using ImageSet = QSet<ImagePtrK>;
60 
61  TransferThread(TransferMap files, bool move, MythUIProgressDialog *dialog)
62  : MThread("FileTransfer"),
63  m_move(move), m_files(std::move(files)), m_dialog(dialog) {}
64 
65  ImageSet GetResult(void) { return m_failed; }
66 
67  void run() override // MThread
68  {
69  RunProlog();
70 
71  QString action = m_move ? tr("Moving") : tr("Copying");
72 
73  // Sum file sizes
74  auto keys = m_files.keys();
75  auto add_size = [](int t, const ImagePtrK & im){ return t + im->m_size; };
76  int total = std::accumulate(keys.cbegin(), keys.cend(), 0, add_size);
77 
78  int progressSize = 0;
79  for (const ImagePtrK & im : m_files.keys())
80  {
81  // Update progress dialog
82  if (m_dialog)
83  {
84  QString message = QString("%1 %2\n%3")
85  .arg(action, QFileInfo(im->m_url).fileName(),
86  ImageAdapterBase::FormatSize(im->m_size / 1024));
87 
88  auto *pue = new ProgressUpdateEvent(progressSize, total, message);
89  QApplication::postEvent(m_dialog, pue);
90  }
91 
92  QString newPath = m_files.value(im);
93  LOG(VB_FILE, LOG_INFO, QString("%2 %3 -> %4")
94  .arg(action, im->m_url, newPath));
95 
96  bool success = m_move ? RemoteFile::MoveFile(im->m_url, newPath)
97  : RemoteFile::CopyFile(im->m_url, newPath,
98  false, true);
99  if (!success)
100  {
101  // Flag failures
102  m_failed.insert(im);
103 
104  LOG(VB_GENERAL, LOG_ERR,
105  QString("%1: Failed to copy/move %2 -> %3")
106  .arg(objectName(), im->m_url, m_files[im]));
107  }
108 
109  progressSize += im->m_size;
110  }
111 
112  // Update progress dialog
113  if (m_dialog)
114  {
115  auto *pue =
116  new ProgressUpdateEvent(progressSize, total, tr("Complete"));
117  QApplication::postEvent(m_dialog, pue);
118  }
119 
120  RunEpilog();
121  }
122 
123 private:
124  bool m_move;
128 };
129 
130 
135 static void WaitUntilDone(MThread &worker)
136 {
137  worker.start();
138  while (!worker.isFinished())
139  {
140  std::this_thread::sleep_for(std::chrono::milliseconds(1));
141  QCoreApplication::processEvents();
142  }
143 }
144 
145 
152  : MythScreenType(parent, name),
153  m_popupStack(*GetMythMainWindow()->GetStack("popup stack")),
154  m_mgr(ImageManagerFe::getInstance()),
155  // This screen uses a single fixed view (Parent dir, ordered dirs, ordered images)
156  m_view(new DirectoryView(kOrdered)),
157  m_infoList(*this),
158  // Start in edit mode unless a password exists
159  m_editsAllowed(gCoreContext->GetSetting("GalleryPassword").isEmpty())
160 {
161  // Hide hidden when edits disallowed
162  if (!m_editsAllowed)
163  m_mgr.SetVisibility(false);
164 }
165 
166 
171 {
172  LOG(VB_GUI, LOG_DEBUG, LOC + "Exiting Gallery");
173  delete m_view;
174 }
175 
176 
181 {
182  LOG(VB_GUI, LOG_DEBUG, LOC + "Closing Gallery");
183 
185 
186  // Cleanup local devices
188 
189  // Cleanup view
190  m_view->Clear();
191 
193 }
194 
195 
200 {
201  if (!LoadWindowFromXML("image-ui.xml", "gallery", this))
202  return false;
203 
204  // Determine zoom levels supported by theme
205  // images0 must exist; images1, images2 etc. are optional and enable zoom
206  int zoom = 0;
207  MythUIButtonList *widget = nullptr;
208  do
209  {
210  QString name = QString("images%1").arg(zoom++);
211  widget = dynamic_cast<MythUIButtonList *>(this->GetChild(name));
212  if (widget)
213  {
214  m_zoomWidgets.append(widget);
215  widget->SetVisible(false);
216  }
217  }
218  while (widget);
219 
220  if (m_zoomWidgets.isEmpty())
221  {
222  LOG(VB_GENERAL, LOG_ERR, LOC + "Screen 'Gallery' is missing 'images0'");
223  return false;
224  }
225  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Screen 'Gallery' found %1 zoom levels")
226  .arg(m_zoomWidgets.size()));
227 
228  // File details list is managed elsewhere
229  if (!m_infoList.Create(false))
230  {
231  LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot load 'Info buttonlist'");
232  return false;
233  }
234 
235  UIUtilW::Assign(this, m_captionText, "caption");
236  UIUtilW::Assign(this, m_emptyText, "noimages");
237  UIUtilW::Assign(this, m_positionText, "position");
238  UIUtilW::Assign(this, m_crumbsText, "breadcrumbs");
239  UIUtilW::Assign(this, m_hideFilterText, "hidefilter");
240  UIUtilW::Assign(this, m_typeFilterText, "typefilter");
241  UIUtilW::Assign(this, m_scanProgressText, "scanprogresstext");
242  UIUtilW::Assign(this, m_scanProgressBar, "scanprogressbar");
243 
244  if (m_scanProgressText)
246  if (m_scanProgressBar)
248 
249  BuildFocusList();
250 
251  // Initialise list widget with appropriate zoom level for this theme.
252  m_zoomLevel = gCoreContext->GetNumSetting("GalleryZoomLevel", 0);
253  SelectZoomWidget(0);
254 
255  return true;
256 }
257 
258 
263 bool GalleryThumbView::keyPressEvent(QKeyEvent *event)
264 {
265  if (GetFocusWidget()->keyPressEvent(event))
266  return true;
267 
268  QStringList actions;
269  bool handled = GetMythMainWindow()->TranslateKeyPress("Images", event, actions);
270 
271  for (int i = 0; i < actions.size() && !handled; i++)
272  {
273  QString action = actions[i];
274  handled = true;
275 
276  if (action == "MENU")
277  MenuMain();
278  else if (action == "INFO")
279  ShowDetails();
280  else if (action == "ZOOMIN")
281  ZoomIn();
282  else if (action == "ZOOMOUT")
283  ZoomOut();
284  else if (action == "ROTRIGHT")
285  RotateCW();
286  else if (action == "ROTLEFT")
287  RotateCCW();
288  else if (action == "FLIPHORIZONTAL")
289  FlipHorizontal();
290  else if (action == "FLIPVERTICAL")
291  FlipVertical();
292  else if (action == "COVER")
293  {
294  ImagePtrK im = m_view->GetSelected();
295  if (m_editsAllowed && im)
296  {
297  if (im == m_view->GetParent())
298  {
299  // Reset dir
300  m_mgr.SetCover(im->m_id, 0);
301  }
302  else
303  {
304  // Set parent cover
305  m_mgr.SetCover(im->m_parentId, im->m_id);
306  }
307  }
308  }
309  else if (action == "PLAY")
310  Slideshow();
311  else if (action == "RECURSIVESHOW")
312  {
313  ImagePtrK im = m_view->GetSelected();
314  if (im && im->IsDirectory())
316  }
317  else if (action == "MARK")
318  {
319  ImagePtrK im = m_view->GetSelected();
320  if (m_editsAllowed && im && im != m_view->GetParent())
321  MarkItem(!m_view->IsMarked(im->m_id));
322  }
323  else if (action == "ESCAPE" && !GetMythMainWindow()->IsExitingToMain())
324  {
325  // Exit info list, if shown
326  handled = m_infoList.Hide();
327 
328  // Ascend the tree unless parent is root,
329  // or a device and multiple devices/imports exist
330  if (!handled)
331  {
332  ImagePtrK node = m_view->GetParent();
333  if (node && node->m_id != GALLERY_DB_ID
334  && (!node->IsDevice() || m_mgr.DeviceCount() > 0))
335  handled = DirSelectUp();
336  }
337  }
338  else
339  handled = false;
340  }
341 
342  if (!handled)
343  handled = MythScreenType::keyPressEvent(event);
344 
345  return handled;
346 }
347 
348 
353 void GalleryThumbView::customEvent(QEvent *event)
354 {
355 
356  if (event->type() == MythEvent::MythEventMessage)
357  {
358  auto *me = dynamic_cast<MythEvent *>(event);
359  if (me == nullptr)
360  return;
361 
362  const QString& mesg = me->Message();
363  QStringList extra = me->ExtraDataList();
364 
365  // Internal messages contain a hostname. Ignore other FE messages
366  QStringList token = mesg.split(' ');
367  if (token.size() >= 2 && token[1] != gCoreContext->GetHostName())
368  return;
369 
370  if (token[0] == "IMAGE_METADATA")
371  {
372  int id = extra[0].toInt();
373  ImagePtrK selected = m_view->GetSelected();
374 
375  if (selected && selected->m_id == id)
376  m_infoList.Display(*selected, extra.mid(1));
377  }
378  else if (token[0] == "THUMB_AVAILABLE")
379  {
380  int id = extra[0].toInt();
381 
382  // Note existance of all thumbs
383  m_thumbExists.insert(id);
384 
385  // Get all buttons waiting for this thumbnail
386  QList<ThumbLocation> affected = m_pendingMap.values(id);
387 
388  // Only concerned with thumbnails we've requested
389  if (affected.isEmpty())
390  return;
391 
392  LOG(VB_GENERAL, LOG_DEBUG, LOC +
393  QString("Rx %1 : %2").arg(token[0], extra.join(",")));
394 
395  // Thumb url was cached when request was sent
396  QString url = m_view->GetCachedThumbUrl(id);
397 
398  // Set thumbnail for each button now it exists
399  for (const ThumbLocation & location : qAsConst(affected))
400  {
401  MythUIButtonListItem *button = location.first;
402  int index = location.second;
403 
404  auto im = button->GetData().value<ImagePtrK>();
405  if (im)
406  UpdateThumbnail(button, im, url, index);
407  }
408 
409  // Cancel pending request
410  m_pendingMap.remove(id);
411  }
412  else if (token[0] == "IMAGE_DB_CHANGED")
413  {
414  // Expects csv list of deleted ids, csv list of changed ids
415  LOG(VB_GENERAL, LOG_DEBUG, LOC +
416  QString("Rx %1 : %2").arg(token[0], extra.join(",")));
417 
418  if (!extra.isEmpty())
419  {
420 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
421  QStringList idDeleted =
422  extra[0].split(",", QString::SkipEmptyParts);
423 #else
424  QStringList idDeleted =
425  extra[0].split(",", Qt::SkipEmptyParts);
426 #endif
427 
428  RemoveImages(idDeleted);
429  }
430  if (extra.size() >= 2)
431  {
432 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
433  QStringList idChanged =
434  extra[1].split(",", QString::SkipEmptyParts);
435 #else
436  QStringList idChanged =
437  extra[1].split(",", Qt::SkipEmptyParts);
438 #endif
439  RemoveImages(idChanged, false);
440  }
441 
442  // Refresh display
444  }
445  else if (token[0] == "IMAGE_DEVICE_CHANGED")
446  {
447  // Expects list of url prefixes
448  LOG(VB_GENERAL, LOG_DEBUG, LOC +
449  QString("Rx %1 : %2").arg(token[0], extra.join(",")));
450 
451  // Clear everything. Local devices will be rebuilt
452  m_view->Clear();
453  m_thumbExists.clear();
454 
455  // Remove thumbs & images from image cache using supplied prefixes
456  for (const QString & url : qAsConst(extra))
458 
459  // Refresh display
461  }
462  else if (token[0] == "IMAGE_SCAN_STATUS" && extra.size() == 3)
463  {
464  // Expects scanner id, scanned#, total#
465  UpdateScanProgress(extra[0], extra[1].toInt(), extra[2].toInt());
466  }
467  }
468  else if (event->type() == DialogCompletionEvent::kEventType)
469  {
470  auto *dce = (DialogCompletionEvent *)(event);
471 
472  QString resultid = dce->GetId();
473  int buttonnum = dce->GetResult();
474 
475  if (resultid == "FileRename")
476  {
477  QString newName = dce->GetResultText();
479  {
480  QString err = m_mgr.RenameFile(m_menuState.m_selected,
481  newName);
482  if (!err.isEmpty())
483  ShowOkPopup(err);
484  }
485  }
486  else if (resultid == "MakeDir")
487  {
489  {
490  // Prohibit subtrees
491  QString name = dce->GetResultText();
492  QString err = name.contains("/")
493  ? tr("Invalid Name")
495  QStringList(name));
496  if (!err.isEmpty())
497  ShowOkPopup(err);
498  }
499  }
500  else if (resultid == "SlideOrderMenu")
501  {
502  SlideOrderType slideOrder = kOrdered;
503 
504  switch (buttonnum)
505  {
506  case 0: slideOrder = kOrdered; break;
507  case 1: slideOrder = kShuffle; break;
508  case 2: slideOrder = kRandom; break;
509  case 3: slideOrder = kSeasonal; break;
510  }
511  gCoreContext->SaveSetting("GallerySlideOrder", slideOrder);
512  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Order %1").arg(slideOrder));
513  }
514  else if (resultid == "ImageCaptionMenu")
515  {
516  ImageCaptionType captions = kNoCaption;
517 
518  switch (buttonnum)
519  {
520  case 0: captions = kNameCaption; break;
521  case 1: captions = kDateCaption; break;
522  case 2: captions = kUserCaption; break;
523  case 3: captions = kNoCaption; break;
524  }
525  gCoreContext->SaveSetting("GalleryImageCaption", captions);
526  BuildImageList();
527  }
528  else if (resultid == "DirCaptionMenu")
529  {
530  ImageCaptionType captions = kNoCaption;
531 
532  switch (buttonnum)
533  {
534  case 0: captions = kNameCaption; break;
535  case 1: captions = kDateCaption; break;
536  case 2: captions = kNoCaption; break;
537  }
538  gCoreContext->SaveSetting("GalleryDirCaption", captions);
539  BuildImageList();
540  }
541  else if (resultid == "Password")
542  {
543  QString password = dce->GetResultText();
544  m_editsAllowed = (password == gCoreContext->GetSetting("GalleryPassword"));
545  }
546  else if (buttonnum == 1)
547  {
548  // Confirm current file deletion
549  QString err;
550  if (resultid == "ConfirmDelete" && m_menuState.m_selected)
551  {
553  err = m_mgr.DeleteFiles(ids);
554  }
555  // Confirm marked file deletion
556  else if (resultid == "ConfirmDeleteMarked")
557  {
559  }
560  else
561  return;
562 
563  if (!err.isEmpty())
564  ShowOkPopup(err);
565  }
566  }
567 }
568 
569 
575 void GalleryThumbView::RemoveImages(const QStringList &ids, bool deleted)
576 {
577  for (const QString & id : qAsConst(ids))
578  {
579  // Remove image from view
580  QStringList urls = m_view->RemoveImage(id.toInt(), deleted);
581  // Cleanup url lookup
582  m_thumbExists.remove(id.toInt());
583 
584  // Remove thumbs & images from image cache
585  for (const QString & url : qAsConst(urls))
586  {
587  LOG(VB_FILE, LOG_DEBUG, LOC +
588  QString("Clearing image cache of '%1'").arg(url));
589 
591  }
592  }
593 }
594 
595 
600 {
601  // Detect any running BE scans
602  // Expects OK, scanner id, current#, total#
603  QStringList message = ImageManagerFe::ScanQuery();
604  if (message.size() == 4 && message[0] == "OK")
605  {
606  UpdateScanProgress(message[1], message[2].toInt(), message[3].toInt());
607  }
608 
609  // Only receive events after device/scan status has been established
610  gCoreContext->addListener(this);
611 
612  // Start at Root if devices exist. Otherwise go straight to SG node
614 
615  LoadData(start);
616 }
617 
618 
624 {
626 
627  // Load view for parent directory
628  if (m_view->LoadFromDb(parent))
629  {
630  m_imageList->SetVisible(true);
631  if (m_emptyText)
632  {
633  m_emptyText->SetVisible(false);
634  m_emptyText->Reset();
635  }
636 
637  // Construct the buttonlist
638  BuildImageList();
639  }
640  else
641  {
642  m_infoList.Hide();
643  m_imageList->SetVisible(false);
644  if (m_emptyText)
645  {
646  m_emptyText->SetVisible(true);
647  m_emptyText->SetText(tr("No images found.\n"
648  "Scan storage group using menu,\n"
649  "or insert/mount local media.\n"));
650  }
651  }
652 }
653 
654 
659 {
660  m_imageList->Reset();
661  m_pendingMap.clear();
662 
663  // Get parent & all children
664  ImageListK nodes = m_view->GetAllNodes();
665  ImagePtrK selected = m_view->GetSelected();
666 
667  // go through the entire list and update
668  for (const ImagePtrK & im : qAsConst(nodes))
669  {
670  if (im)
671  {
672  // Data must be set by constructor: First item is automatically
673  // selected and must have data available for selection event, as
674  // subsequent reselection of same item will always fail.
675  auto *item = new MythUIButtonListItem(m_imageList, "",
676  QVariant::fromValue(im));
677 
678  item->setCheckable(true);
679  item->setChecked(MythUIButtonListItem::NotChecked);
680 
681  // assign and display all information about
682  // the current item, like title and subdirectory count
683  UpdateImageItem(item);
684 
685  // Treat parent differently
686  if (im == nodes[0])
687  {
688  // Only non-root parents can ascend
689  if (im->m_id != GALLERY_DB_ID)
690  item->DisplayState("upfolder", "parenttype");
691  }
692  else if (im == selected)
693  // Reinstate the active button item. Note this would fail for parent
695  }
696  }
697 }
698 
699 
705 {
706  auto im = item->GetData().value<ImagePtrK >();
707  if (!im)
708  return;
709 
710  // Allow themes to distinguish between roots, folders, pics, videos
711  switch (im->m_type)
712  {
713  case kDevice:
714  case kCloneDir:
715  case kDirectory:
716  if (im->m_dirCount > 0)
717  {
718  item->SetText(QString("%1/%2")
719  .arg(im->m_fileCount).arg(im->m_dirCount),
720  "childcount");
721  }
722  else
723  {
724  item->SetText(QString::number(im->m_fileCount), "childcount");
725  }
726 
727  item->DisplayState(im->IsDevice() ? "device" : "subfolder", "buttontype");
728  break;
729 
730  case kImageFile:
731  item->DisplayState("image", "buttontype");
732  break;
733 
734  case kVideoFile:
735  item->DisplayState("video", "buttontype");
736  break;
737 
738  default:
739  break;
740  }
741 
742  // Allow theme to distinguish visible/hidden nodes
743  QString hideState = (im->m_isHidden) ? "hidden" : "visible";
744  item->DisplayState(hideState, "buttonstate");
745 
746  // Caption
747  QString text;
749  im->IsFile() ? "GalleryImageCaption"
750  : "GalleryDirCaption");
751  switch (show)
752  {
753  case kNameCaption: text = m_mgr.CrumbName(*im); break;
754  case kDateCaption: text = m_mgr.ShortDateOf(im); break;
755  case kUserCaption: text = im->m_comment; break;
756  default:
757  case kNoCaption: text = ""; break;
758  }
759  item->SetText(text);
760 
761  // Set marked state
763  = m_view->IsMarked(im->m_id)
766 
767  item->setChecked(state);
768 
769  // Thumbnails required
770  ImageIdList request;
771 
772  if (im->m_thumbNails.size() == 1)
773  {
774  // Single thumbnail
775  QString url = CheckThumbnail(item, im, request, 0);
776 
777  if (!url.isEmpty())
778  UpdateThumbnail(item, im, url, 0);
779  }
780  else
781  {
782  // Dir showing up to 4 thumbs. Set them all at same time
783  InfoMap thumbMap;
784  for (int index = 0; index < im->m_thumbNails.size(); ++index)
785  {
786  QString url = CheckThumbnail(item, im, request, index);
787  if (!url.isEmpty())
788  thumbMap.insert(QString("thumbimage%1").arg(index), url);
789  }
790  if (!thumbMap.isEmpty())
791  item->SetImageFromMap(thumbMap);
792  }
793 
794  // Request creation/verification of unknown thumbnails.
795  if (!request.isEmpty())
796  m_mgr.CreateThumbnails(request, im->IsDirectory());
797 }
798 
799 
812  ImageIdList &request, int index)
813 {
814  ThumbPair thumb(im->m_thumbNails.at(index));
815  int id = thumb.first;
816 
817  if (m_thumbExists.contains(id))
818  return thumb.second;
819 
820  // Request BE thumbnail check if it is not already pending
821  if (!m_pendingMap.contains(id))
822  request << id;
823 
824  // Note this button is awaiting an update
825  m_pendingMap.insert(id, qMakePair(item, index));
826 
827  return "";
828 }
829 
830 
839  const ImagePtrK& im, const QString &url,
840  int index)
841 {
842  if (im->m_thumbNails.size() == 1)
843  {
844  // Pics, dirs & videos use separate widgets
845  switch (im->m_type)
846  {
847  case kImageFile: button->SetImage(url); break;
848  case kVideoFile: button->SetImage(url, "videoimage"); break;
849  default: button->SetImage(url, "folderimage"); break;
850  }
851  }
852  else
853  // Dir with 4 thumbnails
854  button->SetImage(url, QString("thumbimage%1").arg(index));
855 }
856 
857 
865 void GalleryThumbView::UpdateScanProgress(const QString &scanner,
866  int current, int total)
867 {
868  // Scan update
869  m_scanProgress.insert(scanner, qMakePair(current, total));
870 
871  // Detect end of this scan
872  if (current >= total)
873  {
874  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Scan Finished %1 %2/%3")
875  .arg(scanner).arg(current).arg(total));
876 
877  // Mark inactive scanner
878  m_scanActive.remove(scanner);
879 
880  // Detect end of last scan
881  if (m_scanActive.isEmpty())
882  {
883  if (m_scanProgressText)
884  {
887  }
888  if (m_scanProgressBar)
889  {
892  }
893 
894  m_scanProgress.clear();
895 
896  return;
897  }
898  }
899  else
900  {
901  // Detect first scan update
902  if (m_scanActive.isEmpty())
903  {
904  // Show progressbar when first scan starts
905  if (m_scanProgressBar)
906  {
909  }
910  if (m_scanProgressText)
912  }
913 
914  if (!m_scanActive.contains(scanner))
915  {
916  LOG(VB_GUI, LOG_DEBUG, LOC + QString("Scan Started %1 %2/%3")
917  .arg(scanner).arg(current).arg(total));
918 
919  // Mark active scanner
920  m_scanActive.insert(scanner);
921  }
922  }
923 
924  // Aggregate all running scans
925  int currentAgg = 0;
926  int totalAgg = 0;
927  for (IntPair scan : m_scanProgress.values())
928  {
929  currentAgg += scan.first;
930  totalAgg += scan.second;
931  }
932 
933  if (m_scanProgressBar)
934  {
935  m_scanProgressBar->SetUsed(currentAgg);
936  m_scanProgressBar->SetTotal(totalAgg);
937  }
938  if (m_scanProgressText)
939  m_scanProgressText->SetText(tr("%L1 of %L3").arg(currentAgg).arg(totalAgg));
940 }
941 
942 
947 {
948  if (m_positionText)
950 
951  if (m_captionText)
952  m_captionText->Reset();
953 
954  if (m_crumbsText)
955  m_crumbsText->Reset();
956 
957  if (m_hideFilterText)
959 
960  if (m_typeFilterText)
962 }
963 
964 
970 {
971  auto im = item->GetData().value<ImagePtrK >();
972  if (im)
973  {
974  // update the position in the node list
975  m_view->Select(im->m_id);
976 
977  // show the name/path of the image
978  if (m_crumbsText)
979  m_crumbsText->SetText(m_mgr.CrumbName(*im, true));
980 
981  if (m_captionText)
982  {
983  // show the date & comment of non-root nodes
984  QStringList text;
985  if (im->m_id != GALLERY_DB_ID)
986  {
987  if (im->IsFile() || im->IsDevice())
988  text << ImageManagerFe::LongDateOf(im);
989 
990  if (!im->m_comment.isEmpty())
991  text << im->m_comment;
992  }
993  m_captionText->SetText(text.join(" - "));
994  }
995 
996  if (m_hideFilterText)
997  {
998  m_hideFilterText->SetText(m_mgr.GetVisibility() ? tr("Hidden") : "");
999  }
1000 
1001  if (m_typeFilterText)
1002  {
1003  QString text = "";
1004  switch (m_mgr.GetType())
1005  {
1006  case kPicAndVideo : text = ""; break;
1007  case kPicOnly : text = tr("Pictures"); break;
1008  case kVideoOnly : text = tr("Videos"); break;
1009  }
1010  m_typeFilterText->SetText(text);
1011  }
1012 
1013  // show the position of the image
1014  if (m_positionText)
1016 
1017  // Update any file details information
1018  m_infoList.Update(im);
1019  }
1020 }
1021 
1022 
1027 {
1028  // Create the main menu
1029  auto *menu = new MythMenu(tr("Gallery Options"), this, "mainmenu");
1030 
1031  // Menu options depend on the marked files and the current node
1033 
1034  if (m_menuState.m_selected)
1035  {
1036  if (m_editsAllowed)
1037  {
1038  MenuMarked(menu);
1039  MenuPaste(menu);
1041  MenuAction(menu);
1042  }
1044  MenuShow(menu);
1045  if (!m_editsAllowed)
1046  menu->AddItem(tr("Enable Edits"), SLOT(ShowPassword()));
1047  }
1048 
1049  // Depends on current status of backend scanner - string(number(isBackend()))
1050  if (m_scanActive.contains("1"))
1051  menu->AddItem(tr("Stop Scan"), SLOT(StopScan()));
1052  else
1053  menu->AddItem(tr("Scan Storage Group"), SLOT(StartScan()));
1054 
1055  menu->AddItem(tr("Settings"), SLOT(ShowSettings()));
1056 
1057  auto *popup = new MythDialogBox(menu, &m_popupStack, "menuPopup");
1058  if (popup->Create())
1059  m_popupStack.AddScreen(popup);
1060  else
1061  delete popup;
1062 }
1063 
1064 
1070 {
1071  ImagePtrK parent = m_view->GetParent();
1072 
1073  if (m_menuState.m_childCount == 0 || parent.isNull())
1074  return;
1075 
1076  QString title = tr("%L1 marked").arg(m_menuState.m_markedId.size());
1077  auto *menu = new MythMenu(title, this, "markmenu");
1078 
1079  // Mark/unmark selected
1080  if (m_menuState.m_selected->IsFile())
1081  {
1083  menu->AddItem(tr("Unmark File"), SLOT(UnmarkItem()));
1084  else
1085  menu->AddItem(tr("Mark File"), SLOT(MarkItem()));
1086  }
1087  // Cannot mark/unmark parent dir from this level
1088  else if (!m_menuState.m_selected->IsDevice()
1089  && m_menuState.m_selected != parent)
1090  {
1092  menu->AddItem(tr("Unmark Directory"), SLOT(UnmarkItem()));
1093  else
1094  menu->AddItem(tr("Mark Directory"), SLOT(MarkItem()));
1095  }
1096 
1097  if (parent->m_id != GALLERY_DB_ID)
1098  {
1099  // Mark All if unmarked files exist
1101  menu->AddItem(tr("Mark All"), SLOT(MarkAll()));
1102 
1103  // Unmark All if marked files exist
1104  if (!m_menuState.m_markedId.isEmpty())
1105  {
1106  menu->AddItem(tr("Unmark All"), SLOT(UnmarkAll()));
1107  menu->AddItem(tr("Invert Marked"), SLOT(MarkInvertAll()));
1108  }
1109  }
1110 
1111  if (menu->IsEmpty())
1112  delete menu;
1113  else
1114  mainMenu->AddItem(tr("Mark"), nullptr, menu);
1115 }
1116 
1117 
1123 {
1124  // Can only copy/move into non-root dirs
1125  if (m_menuState.m_selected->IsDirectory()
1126  && m_menuState.m_selected->m_id != GALLERY_DB_ID)
1127  {
1128  // Operate on current marked files, if any
1130  if (files.isEmpty())
1131  files = m_menuState.m_prevMarkedId;
1132  if (files.isEmpty())
1133  return;
1134 
1135  QString title = tr("%L1 marked").arg(files.size());
1136 
1137  auto *menu = new MythMenu(title, this, "pastemenu");
1138 
1139  menu->AddItem(tr("Move Marked Into"), SLOT(Move()));
1140  menu->AddItem(tr("Copy Marked Into"), SLOT(Copy()));
1141 
1142  mainMenu->AddItem(tr("Paste"), nullptr, menu);
1143  }
1144 }
1145 
1146 
1152 {
1153  // Operate on marked files, if any, otherwise selected node
1154  if (!m_menuState.m_markedId.isEmpty())
1155  {
1156  QString title = tr("%L1 marked").arg(m_menuState.m_markedId.size());
1157 
1158  auto *menu = new MythMenu(title, this, "");
1159 
1160  menu->AddItem(tr("Rotate Marked CW"), SLOT(RotateCWMarked()));
1161  menu->AddItem(tr("Rotate Marked CCW"), SLOT(RotateCCWMarked()));
1162  menu->AddItem(tr("Flip Marked Horizontal"), SLOT(FlipHorizontalMarked()));
1163  menu->AddItem(tr("Flip Marked Vertical"), SLOT(FlipVerticalMarked()));
1164  menu->AddItem(tr("Reset Marked to Exif"), SLOT(ResetExifMarked()));
1165 
1166  mainMenu->AddItem(tr("Transforms"), nullptr, menu);
1167  }
1168  else if (m_menuState.m_selected->IsFile())
1169  {
1170  auto *menu = new MythMenu(m_menuState.m_selected->m_baseName, this, "");
1171 
1172  menu->AddItem(tr("Rotate CW"), SLOT(RotateCW()));
1173  menu->AddItem(tr("Rotate CCW"), SLOT(RotateCCW()));
1174  menu->AddItem(tr("Flip Horizontal"), SLOT(FlipHorizontal()));
1175  menu->AddItem(tr("Flip Vertical"), SLOT(FlipVertical()));
1176  menu->AddItem(tr("Reset to Exif"), SLOT(ResetExif()));
1177 
1178  mainMenu->AddItem(tr("Transforms"), nullptr, menu);
1179  }
1180 }
1181 
1182 
1188 {
1189  MythMenu *menu = nullptr;
1190  ImagePtrK selected = m_menuState.m_selected;
1191 
1192  // Operate on current marked files, if any
1193  if (!m_menuState.m_markedId.empty())
1194  {
1195  QString title = tr("%L1 marked").arg(m_menuState.m_markedId.size());
1196 
1197  menu = new MythMenu(title, this, "actionmenu");
1198 
1199  // Only offer Hide/Unhide if relevant
1201  menu->AddItem(tr("Hide Marked"), SLOT(HideMarked()));
1203  menu->AddItem(tr("Unhide Marked"), SLOT(UnhideMarked()));
1204 
1205  menu->AddItem(tr("Delete Marked"), SLOT(DeleteMarked()));
1206  }
1207  else
1208  {
1209  // Operate on selected file/dir
1210  menu = new MythMenu(selected->m_baseName, this, "actionmenu");
1211 
1212  // Prohibit actions on devices and parent dirs
1213  if (!selected->IsDevice() && selected != m_view->GetParent())
1214  {
1215  if (selected->m_isHidden)
1216  menu->AddItem(tr("Unhide"), SLOT(Unhide()));
1217  else
1218  menu->AddItem(tr("Hide"), SLOT(HideItem()));
1219 
1220  menu->AddItem(tr("Use as Cover"), SLOT(SetCover()));
1221  menu->AddItem(tr("Delete"), SLOT(DeleteItem()));
1222  menu->AddItem(tr("Rename"), SLOT(ShowRenameInput()));
1223  }
1224  else if (selected->m_userThumbnail)
1225  menu->AddItem(tr("Reset Cover"), SLOT(ResetCover()));
1226  }
1227 
1228  // Can only mkdir in a non-root dir
1229  if (selected->IsDirectory()
1230  && selected->m_id != GALLERY_DB_ID)
1231  menu->AddItem(tr("Create Directory"), SLOT(MakeDir()));
1232 
1233  // Only show import command on root, when defined
1234  if (selected->m_id == GALLERY_DB_ID
1235  && !gCoreContext->GetSetting("GalleryImportCmd").isEmpty())
1236  menu->AddItem(tr("Import"), SLOT(Import()));
1237 
1238  // Only show eject when devices (excluding import) exist
1239  if (selected->IsDevice() && selected->IsLocal())
1240  menu->AddItem(tr("Eject media"), SLOT(Eject()));
1241 
1242  if (menu->IsEmpty())
1243  delete menu;
1244  else
1245  mainMenu->AddItem(tr("Actions"), nullptr, menu);
1246 }
1247 
1248 
1254 {
1255  int order = gCoreContext->GetNumSetting("GallerySlideOrder", kOrdered);
1256 
1257  QString ordering;
1258  switch (order)
1259  {
1260  case kShuffle : ordering = tr("Shuffled"); break;
1261  case kRandom : ordering = tr("Random"); break;
1262  case kSeasonal : ordering = tr("Seasonal"); break;
1263  default:
1264  case kOrdered : ordering = tr("Ordered"); break;
1265  }
1266 
1267  auto *menu = new MythMenu(tr("Slideshow") + " (" + ordering + ")",
1268  this, "SlideshowMenu");
1269 
1270  // Use selected dir or parent, if image selected
1271  if (m_menuState.m_selected->IsDirectory())
1272  {
1273  if (m_menuState.m_selected->m_fileCount > 0)
1274  menu->AddItem(tr("Directory"), SLOT(Slideshow()));
1275 
1276  if (m_menuState.m_selected->m_dirCount > 0)
1277  menu->AddItem(tr("Recursive"), SLOT(RecursiveSlideshow()));
1278  }
1279  else
1280  menu->AddItem(tr("Current Directory"), SLOT(Slideshow()));
1281 
1282  auto *orderMenu = new MythMenu(tr("Slideshow Order"), this, "SlideOrderMenu");
1283 
1284  orderMenu->AddItem(tr("Ordered"), nullptr, nullptr, order == kOrdered);
1285  orderMenu->AddItem(tr("Shuffled"), nullptr, nullptr, order == kShuffle);
1286  orderMenu->AddItem(tr("Random"), nullptr, nullptr, order == kRandom);
1287  orderMenu->AddItem(tr("Seasonal"), nullptr, nullptr, order == kSeasonal);
1288 
1289  menu->AddItem(tr("Change Order"), nullptr, orderMenu);
1290 
1291  if (gCoreContext->GetBoolSetting("GalleryRepeat", false))
1292  menu->AddItem(tr("Turn Repeat Off"), SLOT(RepeatOff()));
1293  else
1294  menu->AddItem(tr("Turn Repeat On"), SLOT(RepeatOn()));
1295 
1296  mainMenu->AddItem(tr("Slideshow"), nullptr, menu);
1297 }
1298 
1299 
1305 {
1306  auto *menu = new MythMenu(tr("Show Options"), this, "showmenu");
1307 
1308  int type = m_mgr.GetType();
1309  if (type == kPicAndVideo)
1310  {
1311  menu->AddItem(tr("Hide Pictures"), SLOT(HidePictures()));
1312  menu->AddItem(tr("Hide Videos"), SLOT(HideVideos()));
1313  }
1314  else
1315  menu->AddItem(type == kPicOnly ? tr("Show Videos") : tr("Show Pictures"),
1316  SLOT(ShowType()));
1317 
1318  int show = gCoreContext->GetNumSetting("GalleryImageCaption");
1319  auto *captionMenu = new MythMenu(tr("Image Captions"), this,
1320  "ImageCaptionMenu");
1321 
1322  captionMenu->AddItem(tr("Name"), nullptr, nullptr, show == kNameCaption);
1323  captionMenu->AddItem(tr("Date"), nullptr, nullptr, show == kDateCaption);
1324  captionMenu->AddItem(tr("Comment"), nullptr, nullptr, show == kUserCaption);
1325  captionMenu->AddItem(tr("None"), nullptr, nullptr, show == kNoCaption);
1326 
1327  menu->AddItem(tr("Image Captions"), nullptr, captionMenu);
1328 
1329  show = gCoreContext->GetNumSetting("GalleryDirCaption");
1330  captionMenu = new MythMenu(tr("Directory Captions"), this, "DirCaptionMenu");
1331 
1332  captionMenu->AddItem(tr("Name"), nullptr, nullptr, show == kNameCaption);
1333  captionMenu->AddItem(tr("Date"), nullptr, nullptr, show == kDateCaption);
1334  captionMenu->AddItem(tr("None"), nullptr, nullptr, show == kNoCaption);
1335 
1336  menu->AddItem(tr("Directory Captions"), nullptr, captionMenu);
1337 
1338  if (m_editsAllowed)
1339  {
1340  if (m_mgr.GetVisibility())
1341  menu->AddItem(tr("Hide Hidden Items"), SLOT(HideHidden()));
1342  else
1343  menu->AddItem(tr("Show Hidden Items"), SLOT(ShowHidden()));
1344  }
1345 
1346  if (m_zoomLevel > 0)
1347  menu->AddItem(tr("Zoom Out"), SLOT(ZoomOut()));
1348  if (m_zoomLevel < m_zoomWidgets.size() - 1)
1349  menu->AddItem(tr("Zoom In"), SLOT(ZoomIn()));
1350 
1351  QString details = m_infoList.GetState() == kNoInfo
1352  ? tr("Show Details") : tr("Hide Details");
1353 
1354  menu->AddItem(details, SLOT(ShowDetails()));
1355 
1356  mainMenu->AddItem(tr("Show"), nullptr, menu);
1357 }
1358 
1359 
1365 {
1366  // Only update selection if image is currently displayed
1367  if (m_view->Select(id, -1))
1368  BuildImageList();
1369 }
1370 
1371 
1377 {
1378  if (!item)
1379  return;
1380 
1381  auto im = item->GetData().value<ImagePtrK>();
1382  if (!im)
1383  return;
1384 
1385  switch (im->m_type)
1386  {
1387  case kDevice:
1388  case kCloneDir:
1389  case kDirectory:
1390  if (im == m_view->GetParent())
1391  DirSelectUp();
1392  else
1393  DirSelectDown();
1394  break;
1395 
1396  case kImageFile:
1397  case kVideoFile:
1398  StartSlideshow(kBrowseSlides); break;
1399  };
1400 }
1401 
1402 
1408 {
1409  QString err = m_mgr.ScanImagesAction(start);
1410  if (!err.isEmpty())
1411  ShowOkPopup(err);
1412 }
1413 
1414 
1420 {
1421  ImagePtrK selected = m_view->GetSelected();
1422  if (!selected)
1423  return;
1424 
1426  auto *slide = new GallerySlideView(mainStack, "galleryslideview",
1427  m_editsAllowed);
1428  if (slide->Create())
1429  {
1430  mainStack->AddScreen(slide);
1431 
1432  // Update selected item when slideshow exits
1433  connect(slide, &GallerySlideView::ImageSelected,
1435 
1436  if (selected->IsDirectory())
1437  {
1438  // Show selected dir
1439  slide->Start(mode, selected->m_id);
1440  }
1441  else
1442  {
1443  // Show current dir starting at selection
1444  slide->Start(mode, selected->m_parentId, selected->m_id);
1445  }
1446  }
1447  else
1448  delete slide;
1449 }
1450 
1451 
1456 {
1457  ImagePtrK im = m_view->GetParent();
1458  if (im)
1459  {
1460  LOG(VB_GUI, LOG_DEBUG, LOC +
1461  QString("Going up from %1").arg(im->m_filePath));
1462 
1463  // Select the upfolder in the higher dir
1464  m_view->Select(im->m_id);
1465 
1466  // Create tree rooted at parent of the kUpFolder directory node
1467  LoadData(im->m_parentId);
1468  }
1469  return true;
1470 }
1471 
1472 
1477 {
1478  ImagePtrK im = m_view->GetSelected();
1479  if (im)
1480  {
1481  LOG(VB_GUI, LOG_DEBUG, LOC +
1482  QString("Going down to %1").arg(im->m_filePath));
1483 
1484  // Create tree rooted at selected item
1485  LoadData(im->m_id);
1486  }
1487 }
1488 
1489 
1495 {
1496  ImagePtrK im = m_view->GetSelected();
1497  if (im)
1498  {
1499  // Mark/unmark selected item
1500  m_view->Mark(im->m_id, mark);
1501 
1502  // Redisplay buttonlist as a parent dir may have been unmarked
1503  BuildImageList();
1504  }
1505 }
1506 
1507 
1513 {
1514  if (mark)
1515  m_view->MarkAll();
1516  else
1517  m_view->ClearMarked();
1518 
1519  // Redisplay buttonlist
1520  BuildImageList();
1521 }
1522 
1523 
1528 {
1529  m_view->InvertMarked();
1530 
1531  // Redisplay buttonlist
1532  BuildImageList();
1533 }
1534 
1535 
1541 {
1542  ImagePtrK im = m_view->GetSelected();
1543  if (im && m_editsAllowed)
1544  {
1545  ImageIdList ids;
1546  ids.append(im->m_id);
1547  QString err = m_mgr.ChangeOrientation(transform, ids);
1548  if (!err.isEmpty())
1549  ShowOkPopup(err);
1550  }
1551 }
1552 
1553 
1559 {
1560  QString err = m_mgr.ChangeOrientation(transform, m_menuState.m_markedId);
1561  if (!err.isEmpty())
1562  ShowOkPopup(err);
1563 }
1564 
1565 
1571 {
1572  if (m_menuState.m_selected)
1573  {
1574  ImageIdList ids;
1575  ids.append(m_menuState.m_selected->m_id);
1576 
1577  QString err = m_mgr.HideFiles(hide, ids);
1578  if (!err.isEmpty())
1579  {
1580  ShowOkPopup(err);
1581  }
1582  else if (hide && !m_mgr.GetVisibility())
1583  {
1584  // Unmark invisible file
1585  m_view->Mark(m_menuState.m_selected->m_id, false);
1586  }
1587  }
1588 }
1589 
1590 
1596 {
1597  QString err = m_mgr.HideFiles(hide, m_menuState.m_markedId);
1598  if (!err.isEmpty())
1599  {
1600  ShowOkPopup(err);
1601  }
1602  else if (hide && !m_mgr.GetVisibility())
1603  {
1604  // Unmark invisible files
1605  for (int id : qAsConst(m_menuState.m_markedId))
1606  m_view->Mark(id, false);
1607  }
1608 }
1609 
1610 
1615 {
1616  if (m_menuState.m_selected)
1617  ShowDialog(tr("Do you want to delete\n%1 ?")
1618  .arg(m_menuState.m_selected->m_baseName), "ConfirmDelete");
1619 }
1620 
1621 
1626 {
1627  ShowDialog(tr("Do you want to delete all marked files ?"),
1628  "ConfirmDeleteMarked");
1629 }
1630 
1631 
1636 {
1637  // Show settings dialog
1638  auto *config = new GallerySettings(m_editsAllowed);
1640  auto *ssd = new StandardSettingDialog(mainStack, "gallerysettings", config);
1641  if (!ssd->Create())
1642  {
1643  delete ssd;
1644  return;
1645  }
1646 
1647  mainStack->AddScreen(ssd);
1648 
1649  // Effect setting changes when dialog saves on exit
1650 
1651  connect(config, &GallerySettings::ClearDbPressed,
1653 
1654  connect(config, &GallerySettings::OrderChanged,
1655  this, [this]()
1656  {
1657  // Update db view, reset cover cache & reload
1658  int sortIm = gCoreContext->GetNumSetting("GalleryImageOrder");
1659  int sortDir = gCoreContext->GetNumSetting("GalleryDirOrder");
1660  m_mgr.SetSortOrder(sortIm, sortDir);
1661  m_view->ClearCache();
1663  });
1664 
1665  connect(config, &GallerySettings::DateChanged,
1666  this, [this]()
1667  {
1668  QString date = gCoreContext->GetSetting("GalleryDateFormat");
1669  m_mgr.SetDateFormat(date);
1670  BuildImageList();
1671  });
1672 
1673  connect(config, &GallerySettings::ExclusionsChanged,
1674  this, [this]()
1675  {
1676  // Request rescan
1677  QString exclusions = gCoreContext->GetSetting("GalleryIgnoreFilter");
1678  m_view->ClearCache();
1679  ImageManagerFe::IgnoreDirs(exclusions);
1680  });
1681 }
1682 
1683 
1689 {
1690  gCoreContext->SaveBoolSetting("GalleryShowHidden", show);
1691 
1692  // Update Db(s)
1694 
1695  // Reset dir thumbnail cache
1696  m_view->ClearCache();;
1697 
1699 }
1700 
1701 
1707 void GalleryThumbView::ShowDialog(const QString& msg, const QString& event)
1708 {
1709  auto *popup = new MythConfirmationDialog(&m_popupStack, msg, true);
1710 
1711  if (popup->Create())
1712  {
1713  popup->SetReturnEvent(this, event);
1714  m_popupStack.AddScreen(popup);
1715  }
1716  else
1717  delete popup;
1718 }
1719 
1720 
1725 {
1726  if (m_menuState.m_selected)
1727  {
1728  QString base = QFileInfo(m_menuState.m_selected->m_baseName).completeBaseName();
1729  QString msg = tr("Enter a new name:");
1730  auto *popup = new MythTextInputDialog(&m_popupStack, msg, FilterNone,
1731  false, base);
1732  if (popup->Create())
1733  {
1734  popup->SetReturnEvent(this, "FileRename");
1735  m_popupStack.AddScreen(popup);
1736  }
1737  else
1738  delete popup;
1739  }
1740 }
1741 
1742 
1747 {
1749 }
1750 
1751 
1756 {
1757  QString msg = tr("Enter password:");
1758  auto *popup = new MythTextInputDialog(&m_popupStack, msg, FilterNone, true);
1759  if (popup->Create())
1760  {
1761  popup->SetReturnEvent(this, "Password");
1762  m_popupStack.AddScreen(popup);
1763  }
1764  else
1765  delete popup;
1766 }
1767 
1768 
1773 {
1774  gCoreContext->SaveSetting("GalleryShowType", type);
1775 
1776  // Update Db(s)
1777  m_mgr.SetType(type);
1778 
1779  // Reset dir thumbnail cache
1780  m_view->ClearCache();
1781 
1783 }
1784 
1785 
1791 {
1792  if (m_menuState.m_selected)
1793  {
1794  QString err = reset ? m_mgr.SetCover(m_menuState.m_selected->m_id, 0)
1795  : m_mgr.SetCover(m_menuState.m_selected->m_parentId,
1796  m_menuState.m_selected->m_id);
1797  if (!err.isEmpty())
1798  ShowOkPopup(err);
1799  }
1800 }
1801 
1802 
1807 {
1808  SelectZoomWidget(-1);
1809  BuildImageList();
1810 }
1811 
1812 
1817 {
1818  SelectZoomWidget(1);
1819  BuildImageList();
1820 }
1821 
1822 
1828 {
1829  m_zoomLevel += change;
1830 
1831  // constrain to zoom levels supported by theme
1832  if (m_zoomLevel < 0)
1833  m_zoomLevel = 0;
1834  if (m_zoomLevel >= m_zoomWidgets.size())
1835  m_zoomLevel = m_zoomWidgets.size() - 1;
1836 
1837  // Store any requested change, but not constraining adjustments
1838  // Thus, changing to a theme with fewer zoom levels will not overwrite the
1839  // setting
1840  if (change != 0)
1841  gCoreContext->SaveSetting("GalleryZoomLevel", m_zoomLevel);
1842 
1843  // dump the current list widget
1844  if (m_imageList)
1845  {
1846  m_imageList->SetVisible(false);
1847  disconnect(m_imageList, nullptr, this, nullptr);
1848  }
1849 
1850  // initialise new list widget
1852 
1853  m_imageList->SetVisible(true);
1855 
1856  // Monitor list actions (after focus events have been ignored)
1861 }
1862 
1863 
1868 {
1869  auto *popup = new MythTextInputDialog(&m_popupStack,
1870  tr("Enter name of new directory"),
1871  FilterNone, false);
1872  if (popup->Create())
1873  {
1874  popup->SetReturnEvent(this, "MakeDir");
1875  m_popupStack.AddScreen(popup);
1876  }
1877  else
1878  delete popup;
1879 }
1880 
1881 
1886 {
1888  if (dir)
1889  m_mgr.CloseDevices(dir->m_device, true);
1890 }
1891 
1892 
1902 void GalleryThumbView::Copy(bool deleteAfter)
1903 {
1904  // Destination must be a dir
1905  ImagePtrK destDir = m_menuState.m_selected;
1906  if (!destDir || destDir->IsFile())
1907  return;
1908 
1909  // Use current markings, if any. Otherwise use previous markings
1910  ImageIdList markedIds = m_menuState.m_markedId;
1911  if (markedIds.isEmpty())
1912  {
1913  markedIds = m_menuState.m_prevMarkedId;
1914  if (markedIds.isEmpty())
1915  {
1916  ShowOkPopup(tr("No files specified"));
1917  return;
1918  }
1919  }
1920 
1921  // Get all files/dirs in subtree(s). Only files are copied
1922  ImageList files;
1923  ImageList dirs;
1924  m_mgr.GetDescendants(markedIds, files, dirs);
1925 
1926  if (dirs.isEmpty() && files.isEmpty())
1927  {
1928  ShowOkPopup(tr("No images"));
1929  // Nothing to clean up
1930  return;
1931  }
1932 
1933  // Child dirs appear before their subdirs. If no dirs, images are all direct children
1934  ImagePtrK aChild = dirs.isEmpty() ? files[0] : dirs[0];
1935 
1936  // Determine parent path including trailing /
1937  int basePathSize = aChild->m_filePath.size() - aChild->m_baseName.size();
1938 
1939  // Update filepaths for Db & generate URLs for filesystem copy
1940  // Only copy files, destination dirs will be created automatically
1941  TransferThread::TransferMap transfers;
1942  for (const ImagePtr & im : qAsConst(files))
1943  {
1944  // Replace base path with destination path
1945  im->m_filePath = ImageManagerFe::ConstructPath(destDir->m_filePath,
1946  im->m_filePath.mid(basePathSize));
1947 
1948  transfers.insert(im, m_mgr.BuildTransferUrl(im->m_filePath,
1949  destDir->IsLocal()));
1950  }
1951 
1952  // Create progress dialog
1953  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1954  auto *progress = new MythUIProgressDialog(tr("Copying files"), popupStack,
1955  "copydialog");
1956  if (progress->Create())
1957  popupStack->AddScreen(progress, false);
1958  else
1959  {
1960  delete progress;
1961  progress = nullptr;
1962  }
1963 
1964  // Copy files in a servant thread
1965  TransferThread copy(transfers, false, progress);
1967  TransferThread::ImageSet failed = copy.GetResult();
1968 
1969  if (progress)
1970  progress->Close();
1971 
1972  if (!failed.isEmpty())
1973  ShowOkPopup(tr("Failed to copy %L1/%Ln file(s)", nullptr, transfers.size())
1974  .arg(failed.size()));
1975 
1976  // Don't update Db for files that failed
1977  for (const ImagePtrK & im : qAsConst(failed))
1978  transfers.remove(im);
1979 
1980  ImageListK newImages = transfers.keys();
1981 
1982  // Include dirs
1983  QStringList dirPaths;
1984  for (const ImagePtr & im : qAsConst(dirs))
1985  {
1986  QString relPath = im->m_filePath.mid(basePathSize);
1987 
1988  dirPaths << relPath;
1989 
1990  // Replace base path with destination path
1991  im->m_filePath = ImageManagerFe::ConstructPath(destDir->m_filePath, relPath);
1992 
1993  // Append dirs so that hidden state & cover is preserved for new dirs
1994  // Pre-existing dirs will take precedance over these.
1995  newImages.append(im);
1996  }
1997 
1998  // Copy empty dirs as well (will fail for non-empty dirs)
1999  if (!dirPaths.isEmpty())
2000  m_mgr.MakeDir(destDir->m_id, dirPaths, false);
2001 
2002  if (!newImages.isEmpty())
2003  {
2004  // Update Db
2005  m_mgr.CreateImages(destDir->m_id, newImages);
2006 
2007  if (deleteAfter)
2008  {
2009  // Delete files/dirs that have been successfully copied
2010  // Will fail for dirs containing images that failed to copy
2011  ImageIdList ids;
2012  for (const ImagePtrK & im : qAsConst(newImages))
2013  ids << im->m_id;
2014 
2015  m_mgr.DeleteFiles(ids);
2016  }
2017  }
2018 }
2019 
2020 
2031 {
2032  // Destination must be a dir
2033  ImagePtrK destDir = m_menuState.m_selected;
2034  if (!destDir || destDir->IsFile())
2035  return;
2036 
2037  // Use current markings, if any. Otherwise use previous markings
2038  ImageIdList markedIds = m_menuState.m_markedId;
2039  if (markedIds.isEmpty())
2040  {
2041  markedIds = m_menuState.m_prevMarkedId;
2042  if (markedIds.isEmpty())
2043  {
2044  ShowOkPopup(tr("No files specified"));
2045  return;
2046  }
2047  }
2048 
2049  // Note UI mandates that transferees are either all local or all remote
2050  if (destDir->IsLocal() != ImageItem::IsLocalId(markedIds[0]))
2051  {
2052  // Moves between hosts require copy/delete
2053  Copy(true);
2054  return;
2055  }
2056 
2057  // Get marked images. Each file and dir will be renamed
2058  ImageList files;
2059  ImageList dirs;
2060  if (m_mgr.GetImages(markedIds, files, dirs) <= 0)
2061  {
2062  ShowOkPopup(tr("No images specified"));
2063  // Nothing to clean up
2064  return;
2065  }
2066  ImageList images = dirs + files;
2067 
2068  // Determine parent from first dir or pic
2069  ImagePtr aChild = images[0];
2070 
2071  // Determine parent path including trailing /
2072  // Note UI mandates that transferees all have same parent.
2073  int basePathSize = aChild->m_filePath.size() - aChild->m_baseName.size();
2074  QString parentPath = aChild->m_filePath.left(basePathSize);
2075 
2076  // Determine destination URLs
2077  TransferThread::TransferMap transfers;
2078  for (const QSharedPointer<ImageItem> & im : qAsConst(images))
2079  {
2080  // Replace base path with destination path
2081  QString newPath = ImageManagerFe::ConstructPath(destDir->m_filePath,
2082  im->m_filePath.mid(basePathSize));
2083 
2084  transfers.insert(im, m_mgr.BuildTransferUrl(newPath, aChild->IsLocal()));
2085  }
2086 
2087  // Create progress dialog
2088  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
2089  auto *progress = new MythUIProgressDialog(tr("Moving files"), popupStack,
2090  "movedialog");
2091 
2092  if (progress->Create())
2093  popupStack->AddScreen(progress, false);
2094  else
2095  {
2096  delete progress;
2097  progress = nullptr;
2098  }
2099 
2100  // Move files in a servant thread
2101  TransferThread move(transfers, true, progress);
2102  WaitUntilDone(move);
2103  TransferThread::ImageSet failed = move.GetResult();
2104 
2105  if (progress)
2106  progress->Close();
2107 
2108  if (!failed.isEmpty())
2109  ShowOkPopup(tr("Failed to move %L1/%Ln file(s)", nullptr, transfers.size())
2110  .arg(failed.size()));
2111 
2112  // Don't update Db for files that failed
2113  for (const ImagePtrK & im : qAsConst(failed))
2114  transfers.remove(im);
2115 
2116  if (!transfers.isEmpty())
2117  {
2118  ImageListK moved = transfers.keys();
2119 
2120  // Unmark moved files
2121  for (const ImagePtrK & im : qAsConst(moved))
2122  m_view->Mark(im->m_id, false);
2123 
2124  // Update Db
2125  m_mgr.MoveDbImages(destDir, moved, parentPath);
2126  }
2127 }
2128 
2129 
2134 {
2135  QString path = m_mgr.CreateImport();
2136  if (path.isEmpty())
2137  {
2138  ShowOkPopup(tr("Failed to create temporary directory."));
2139  return;
2140  }
2141 
2142  // Replace placeholder in command
2143  QString cmd = gCoreContext->GetSetting("GalleryImportCmd");
2144  cmd.replace("%TMPDIR%", path);
2145 
2146  // Run command in a separate thread
2147  MythUIBusyDialog *busy =
2148  ShowBusyPopup(tr("Running Import command.\nPlease wait..."));
2149 
2150  ShellThread thread(cmd, path);
2151  WaitUntilDone(thread);
2152 
2153  if (busy)
2154  busy->Close();
2155 
2156  int error = thread.GetResult();
2157  if (error != 0)
2158  ShowOkPopup(tr("Import command failed.\nError: %1").arg(error));
2159 
2160  // Rescan local devices
2161  QString err = m_mgr.ScanImagesAction(true, true);
2162  if (!err.isEmpty())
2163  LOG(VB_GENERAL, LOG_ERR, LOC + err);
2164 }
GalleryThumbView::FlipVerticalMarked
void FlipVerticalMarked()
Definition: gallerythumbview.h:81
GalleryThumbView::UpdateThumbnail
static void UpdateThumbnail(MythUIButtonListItem *button, const ImagePtrK &im, const QString &url, int index)
Update the buttonlist item with a thumbnail.
Definition: gallerythumbview.cpp:838
kPicAndVideo
@ kPicAndVideo
Show Pictures & Videos.
Definition: imagemanager.h:78
ImagePtrK
QSharedPointer< ImageItemK > ImagePtrK
Definition: imagetypes.h:164
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:321
MenuSubjects::m_prevMarkedId
ImageIdList m_prevMarkedId
Ids of marked items in previous dir.
Definition: galleryviews.h:69
InfoList::Display
void Display(ImageItemK &im, const QStringList &tagStrings)
Build list of metadata tags.
Definition: galleryinfo.cpp:217
PHOTO_DB_ID
#define PHOTO_DB_ID
Definition: imagetypes.h:28
ImageDbReader::GetImages
int GetImages(const ImageIdList &ids, ImageList &files, ImageList &dirs) const
Returns images (local or remote but not a combination)
Definition: imagemanager.cpp:1818
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:73
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:288
myth_system
uint myth_system(const QString &command, uint flags, uint timeout)
Definition: mythsystemlegacy.cpp:501
ShowBusyPopup
MythUIBusyDialog * ShowBusyPopup(const QString &message)
Definition: mythprogressdialog.cpp:95
GalleryThumbView::m_scanProgressBar
MythUIProgressBar * m_scanProgressBar
Definition: gallerythumbview.h:128
GalleryThumbView::SetCover
void SetCover(bool reset=false)
Set or reset thumbnails to use for a directory cover.
Definition: gallerythumbview.cpp:1790
GalleryThumbView::m_thumbExists
QSet< int > m_thumbExists
Images where thumbnails are known to exist.
Definition: gallerythumbview.h:151
GalleryThumbView::IntPair
QPair< int, int > IntPair
Definition: gallerythumbview.h:117
mythuitext.h
mythuiprogressbar.h
copy
long long copy(QFile &dst, QFile &src, uint block_size)
Copies src file to dst file.
Definition: mythmiscutil.cpp:305
FilterNone
@ FilterNone
Definition: mythuitextedit.h:19
ImageManagerFe::CreateThumbnails
void CreateThumbnails(const ImageIdList &ids, bool forFolder)
Create thumbnails or verify that they already exist.
Definition: imagemanager.cpp:1964
TransferThread::m_failed
ImageSet m_failed
Definition: gallerythumbview.cpp:126
GalleryThumbView::m_positionText
MythUIText * m_positionText
Definition: gallerythumbview.h:126
DirectoryView::GetPosition
QString GetPosition() const
Get positional status.
Definition: galleryviews.cpp:489
GallerySettings::DateChanged
void DateChanged()
MythUIText::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitext.cpp:84
error
static void error(const char *str,...)
Definition: vbi.cpp:42
kVideoFile
@ kVideoFile
A video.
Definition: imagetypes.h:39
GalleryThumbView::HideMarked
void HideMarked(bool hide=true)
Hide or unhide marked items.
Definition: gallerythumbview.cpp:1595
GallerySettings::ExclusionsChanged
void ExclusionsChanged()
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:551
TransferThread::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(FileTransferWorker)
ImageSlideShowType
ImageSlideShowType
Type of slide show.
Definition: galleryslideview.h:15
GalleryThumbView::MenuPaste
void MenuPaste(MythMenu *mainMenu)
Add a Paste submenu.
Definition: gallerythumbview.cpp:1122
GalleryThumbView::m_imageList
MythUIButtonList * m_imageList
Definition: gallerythumbview.h:120
MythUIButtonListItem::DisplayState
void DisplayState(const QString &state, const QString &name)
Definition: mythuibuttonlist.cpp:3499
ImageManagerFe::CreateImages
QString CreateImages(int destId, const ImageListK &images)
Copies database images (but not the files themselves).
Definition: imagemanager.cpp:2210
GalleryThumbView::MakeDir
void MakeDir()
Show dialog to input new directory name.
Definition: gallerythumbview.cpp:1867
GalleryThumbView::SelectZoomWidget
void SelectZoomWidget(int change)
Change buttonlist to use a different size.
Definition: gallerythumbview.cpp:1827
ImageManagerFe::ScanImagesAction
QString ScanImagesAction(bool start, bool local=false)
Handle scanner start/stop commands.
Definition: imagemanager.cpp:1999
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
MythUIButtonListItem::SetImageFromMap
void SetImageFromMap(const InfoMap &imageMap)
Definition: mythuibuttonlist.cpp:3430
ImageManagerFe::BuildTransferUrl
QString BuildTransferUrl(const QString &path, bool local) const
Generate Myth URL for a local or remote path.
Definition: imagemanager.h:496
GalleryThumbView::m_scanProgress
QHash< QString, IntPair > m_scanProgress
Last scan updates received from scanners.
Definition: gallerythumbview.h:140
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:636
GalleryThumbView::customEvent
void customEvent(QEvent *event) override
Handle custom events.
Definition: gallerythumbview.cpp:353
MythUIProgressBar::SetStart
void SetStart(int value)
Definition: mythuiprogressbar.cpp:53
GalleryThumbView::DirSelectDown
void DirSelectDown()
Goes one directory level down.
Definition: gallerythumbview.cpp:1476
GallerySettings
Definition: galleryconfig.h:10
MenuSubjects::m_unhiddenMarked
bool m_unhiddenMarked
Is any marked item unhidden ?
Definition: galleryviews.h:72
GalleryThumbView::UnmarkAll
void UnmarkAll()
Definition: gallerythumbview.h:86
GalleryThumbView::ShowType
void ShowType(int type=kPicAndVideo)
Show/hide pictures or videos.
Definition: gallerythumbview.cpp:1772
DirectoryView::Mark
void Mark(int id, bool mark)
Mark/unmark an image/dir.
Definition: galleryviews.cpp:741
GalleryThumbView::m_infoList
InfoList m_infoList
Image details overlay.
Definition: gallerythumbview.h:137
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1139
ImageManagerFe::MakeDir
QString MakeDir(int parent, const QStringList &names, bool rescan=true)
Create directories.
Definition: imagemanager.cpp:2168
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:131
MenuSubjects::m_markedId
ImageIdList m_markedId
Ids of all marked items.
Definition: galleryviews.h:68
MenuSubjects::m_childCount
int m_childCount
Number of images & dirs excl parent.
Definition: galleryviews.h:70
kDirectory
@ kDirectory
A device sub directory.
Definition: imagetypes.h:37
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
GalleryThumbView::ShowPassword
void ShowPassword()
Displays dialog to accept password.
Definition: gallerythumbview.cpp:1755
kBrowseSlides
@ kBrowseSlides
Definition: galleryslideview.h:16
ImageManagerFe::DeviceCount
int DeviceCount() const
Definition: imagemanager.h:100
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:73
MythUIButtonList::itemSelected
void itemSelected(MythUIButtonListItem *item)
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
GalleryThumbView::FlipHorizontalMarked
void FlipHorizontalMarked()
Definition: gallerythumbview.h:80
ImageManagerFe::IgnoreDirs
static QString IgnoreDirs(const QString &excludes)
Set directories to ignore during scans of the storage group.
Definition: imagemanager.cpp:2152
MythUIProgressBar::SetUsed
void SetUsed(int value)
Definition: mythuiprogressbar.cpp:59
GalleryThumbView::GalleryThumbView
GalleryThumbView(MythScreenStack *parent, const char *name)
Constructor.
Definition: gallerythumbview.cpp:151
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
arg
arg(title).arg(filename).arg(doDelete))
GalleryThumbView::FlipVertical
void FlipVertical()
Definition: gallerythumbview.h:76
MythUIButtonListItem::FullChecked
@ FullChecked
Definition: mythuibuttonlist.h:34
GalleryThumbView::LoadData
void LoadData(int parent)
Loads & displays images from database.
Definition: gallerythumbview.cpp:623
TransferThread::m_files
TransferMap m_files
Maps source filepath to destination filepath.
Definition: gallerythumbview.cpp:125
TransferThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: gallerythumbview.cpp:67
kNoInfo
@ kNoInfo
Details not displayed.
Definition: galleryinfo.h:16
kDateCaption
@ kDateCaption
Dates.
Definition: gallerythumbview.h:17
GalleryThumbView::m_crumbsText
MythUIText * m_crumbsText
Definition: gallerythumbview.h:122
InfoList::Update
void Update(const ImagePtrK &im)
Populates available exif details for the current image/dir.
Definition: galleryinfo.cpp:191
kNoCaption
@ kNoCaption
None.
Definition: gallerythumbview.h:15
GalleryThumbView::m_typeFilterText
MythUIText * m_typeFilterText
Definition: gallerythumbview.h:125
ImageManagerFe::HideFiles
QString HideFiles(bool hidden, const ImageIdList &ids)
Hide/unhide images.
Definition: imagemanager.cpp:2045
GalleryThumbView::MenuAction
void MenuAction(MythMenu *mainMenu)
Add a Action submenu.
Definition: gallerythumbview.cpp:1187
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MThread::RunProlog
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Definition: mthread.cpp:198
ImageManagerFe::SetDateFormat
void SetDateFormat(const QString &format)
Definition: imagemanager.h:489
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:339
kSeasonal
@ kSeasonal
Biased random selection so that images are more likely to appear on anniversaries.
Definition: galleryviews.h:25
GalleryThumbView::m_hideFilterText
MythUIText * m_hideFilterText
Definition: gallerythumbview.h:124
GalleryThumbView::Import
void Import()
Executes user 'Import command'.
Definition: gallerythumbview.cpp:2133
DirectoryView::GetParent
ImagePtrK GetParent() const
Definition: galleryviews.h:175
ImageDbReader::SetVisibility
void SetVisibility(bool showHidden)
Definition: imagemanager.h:414
GalleryThumbView::ZoomIn
void ZoomIn()
Use smaller buttonlist widgets.
Definition: gallerythumbview.cpp:1816
GalleryThumbView::HideHidden
void HideHidden()
Definition: gallerythumbview.h:94
TransferThread::TransferThread
TransferThread(TransferMap files, bool move, MythUIProgressDialog *dialog)
Definition: gallerythumbview.cpp:61
GalleryThumbView::m_menuState
MenuSubjects m_menuState
Current selection/marked files when menu is invoked.
Definition: gallerythumbview.h:145
menu
static MythThemedMenu * menu
Definition: mythtv/programs/mythtv-setup/main.cpp:53
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:326
TransferThread::TransferMap
QMap< ImagePtrK, QString > TransferMap
Definition: gallerythumbview.cpp:58
ImageManagerFe::CloseDevices
void CloseDevices(int devId=DEVICE_INVALID, bool eject=false)
Definition: imagemanager.cpp:2391
FlatView::Select
bool Select(int id, int fallback=0)
Selects first occurrence of an image.
Definition: galleryviews.cpp:116
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:57
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
mythprogressdialog.h
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
MenuSubjects::m_selectedMarked
bool m_selectedMarked
Is selected item marked ?
Definition: galleryviews.h:67
GalleryThumbView::MarkItem
void MarkItem(bool mark=true)
Mark or unmark a single item.
Definition: gallerythumbview.cpp:1494
MythUIButtonListItem::CheckState
CheckState
Definition: mythuibuttonlist.h:30
GalleryThumbView::Create
bool Create() override
Initialises and shows the graphical elements.
Definition: gallerythumbview.cpp:199
ImageManagerFe::ChangeOrientation
QString ChangeOrientation(ImageFileTransform transform, const ImageIdList &ids)
Apply an orientation transform to images.
Definition: imagemanager.cpp:2076
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
GalleryThumbView::MenuMain
void MenuMain()
Shows the main menu when the MENU button was pressed.
Definition: gallerythumbview.cpp:1026
mythsystemlegacy.h
DirectoryView::MarkAll
void MarkAll()
Mark all images/dirs.
Definition: galleryviews.cpp:728
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythUIButtonListItem::SetText
void SetText(const QString &text, const QString &name="", const QString &state="")
Definition: mythuibuttonlist.cpp:3264
MythMenu::AddItem
void AddItem(const QString &title, QVariant data=0, MythMenu *subMenu=nullptr, bool selected=false, bool checked=false)
Definition: mythdialogbox.cpp:66
GalleryThumbView::RepeatOff
static void RepeatOff()
Definition: gallerythumbview.h:114
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
GalleryThumbView::SetUiSelection
void SetUiSelection(MythUIButtonListItem *item)
Updates text widgets for selected item.
Definition: gallerythumbview.cpp:969
GalleryThumbView::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Handle keypresses.
Definition: gallerythumbview.cpp:263
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
TransferThread
Worker thread for copying/moving files.
Definition: gallerythumbview.cpp:55
ImageFileTransform
ImageFileTransform
Image transformations.
Definition: imagemetadata.h:46
TransferThread::m_move
bool m_move
Copy if false, Move if true.
Definition: gallerythumbview.cpp:124
ProgressUpdateEvent
Definition: mythprogressdialog.h:17
StandardSettingDialog
Definition: standardsettings.h:466
MythUIProgressBar::SetTotal
void SetTotal(int value)
Definition: mythuiprogressbar.cpp:71
ShellThread
Worker thread for running import.
Definition: gallerythumbview.cpp:25
GalleryThumbView::ResetUiSelection
void ResetUiSelection()
Clears all text widgets for selected item.
Definition: gallerythumbview.cpp:946
GallerySlideView
Slideshow screen.
Definition: galleryslideview.h:24
InfoList::Toggle
void Toggle(const ImagePtrK &im)
Toggle infolist state for an image. Focusable widgets toggle between Basic & Full info....
Definition: galleryinfo.cpp:80
GalleryThumbView::RotateCCWMarked
void RotateCCWMarked()
Definition: gallerythumbview.h:79
GalleryThumbView::MenuShow
void MenuShow(MythMenu *mainMenu)
Add a Show submenu.
Definition: gallerythumbview.cpp:1304
kPicOnly
@ kPicOnly
Hide videos.
Definition: imagemanager.h:79
GalleryThumbView::ShowSettings
void ShowSettings()
Show configuration screen.
Definition: gallerythumbview.cpp:1635
MythUIButtonList::itemClicked
void itemClicked(MythUIButtonListItem *item)
ImageDbReader::SetSortOrder
void SetSortOrder(int order, int dirOrder)
Definition: imagemanager.h:411
GalleryThumbView::UpdateScanProgress
void UpdateScanProgress(const QString &scanner, int current, int total)
Update progressbar with scan status.
Definition: gallerythumbview.cpp:865
GalleryThumbView::StartScan
void StartScan(bool start=true)
Action scan request.
Definition: gallerythumbview.cpp:1407
remotefile.h
MythUIProgressBar::Reset
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuiprogressbar.cpp:16
MythUIProgressDialog
Definition: mythprogressdialog.h:60
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
hardwareprofile.i18n.t
t
Definition: i18n.py:36
GalleryThumbView::TransformMarked
void TransformMarked(ImageFileTransform tran=kRotateCW)
Apply transform to marked images.
Definition: gallerythumbview.cpp:1558
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:138
GalleryThumbView::SelectImage
void SelectImage(int id)
Select item if it is displayed.
Definition: gallerythumbview.cpp:1364
compat.h
GalleryThumbView::ResetCover
void ResetCover()
Definition: gallerythumbview.h:96
mark
Definition: lang.cpp:21
ImageDbReader::GetType
int GetType() const
Definition: imagemanager.h:405
ImageAdapterBase::FormatSize
static QString FormatSize(int sizeKib)
Definition: imagemanager.h:143
GalleryThumbView::m_view
DirectoryView * m_view
List of images comprising the view.
Definition: gallerythumbview.h:136
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
gallerythumbview.h
Implements Gallery Thumbnail screen.
GalleryThumbView::MenuSlideshow
void MenuSlideshow(MythMenu *mainMenu)
Add a Slideshow submenu.
Definition: gallerythumbview.cpp:1253
kShuffle
@ kShuffle
Each image appears exactly once, but in random order.
Definition: galleryviews.h:23
GalleryThumbView::ClearSgDb
static void ClearSgDb()
Definition: gallerythumbview.h:34
GalleryThumbView::BuildImageList
void BuildImageList()
Displays all images in current view.
Definition: gallerythumbview.cpp:658
ImageDbReader::GetDescendants
void GetDescendants(const ImageIdList &ids, ImageList &files, ImageList &dirs) const
Return all (local or remote) images that are direct children of a dir.
Definition: imagemanager.cpp:1858
GalleryThumbView::StartSlideshow
void StartSlideshow(ImageSlideShowType mode)
Start slideshow screen.
Definition: gallerythumbview.cpp:1419
GalleryThumbView::ShowRenameInput
void ShowRenameInput()
Show dialog to allow input.
Definition: gallerythumbview.cpp:1724
GalleryThumbView::ShowDialog
void ShowDialog(const QString &msg, const QString &event="")
Show a confirmation dialog.
Definition: gallerythumbview.cpp:1707
FlatView::GetAllNodes
ImageListK GetAllNodes() const
Get all images/dirs in view.
Definition: galleryviews.cpp:50
DirectoryView::InvertMarked
void InvertMarked()
Mark all unmarked items, unmark all marked items.
Definition: galleryviews.cpp:760
MythUIThemeCache::RemoveFromCacheByFile
void RemoveFromCacheByFile(const QString &File)
Definition: mythuithemecache.cpp:525
GalleryThumbView::DeleteMarked
void DeleteMarked()
Confirm user deletion of marked files.
Definition: gallerythumbview.cpp:1625
GalleryThumbView::Unhide
void Unhide()
Definition: gallerythumbview.h:89
ImageListK
QList< ImagePtrK > ImageListK
Definition: imagetypes.h:165
MThread::RunEpilog
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
Definition: mthread.cpp:211
ImageCaptionType
ImageCaptionType
Type of captions to display.
Definition: gallerythumbview.h:14
GalleryThumbView::m_scanActive
QSet< QString > m_scanActive
Scanners currently scanning.
Definition: gallerythumbview.h:142
FlatView::GetCachedThumbUrl
QString GetCachedThumbUrl(int id) const
Definition: galleryviews.h:121
GalleryThumbView::RotateCCW
void RotateCCW()
Definition: gallerythumbview.h:74
ImageManagerFe::LongDateOf
static QString LongDateOf(const ImagePtrK &im)
Return a timestamp/datestamp for an image or dir.
Definition: imagemanager.cpp:2311
ShellThread::m_command
QString m_command
Definition: gallerythumbview.cpp:48
MythUIBusyDialog
Definition: mythprogressdialog.h:37
ImageDbReader::GetVisibility
bool GetVisibility() const
Definition: imagemanager.h:406
GetSetting
t<< doc.toString(4);f.close();LOG(VB_JOBQUEUE, LOG_INFO, "Copying video file");bool res=copyFile(filename, saveDirectory+title+"/"+baseName);if(!res) return 0;if(QFile::exists(filename+".png")) { LOG(VB_JOBQUEUE, LOG_INFO, "Copying preview image");res=copyFile(filename+".png", saveDirectory+title+"/"+baseName+".png");if(!res) return 0;} LOG(VB_JOBQUEUE, LOG_INFO, "Item Archived OK");return 1;}int NativeArchive::exportVideo(QDomElement &itemNode, const QString &saveDirectory){ QString dbVersion=gCoreContext-> GetSetting("DBSchemaVer", "")
GalleryThumbView::ZoomOut
void ZoomOut()
Use larger buttonlist widgets.
Definition: gallerythumbview.cpp:1806
MThread::isFinished
bool isFinished(void) const
Definition: mthread.cpp:263
GalleryThumbView::ResetExif
void ResetExif()
Definition: gallerythumbview.h:77
FlatView::GetSelected
ImagePtrK GetSelected() const
Get current selection.
Definition: galleryviews.cpp:63
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3580
ImageManagerFe::SetCover
QString SetCover(int parent, int cover)
Set image to use as a cover thumbnail(s)
Definition: imagemanager.cpp:2108
GallerySettings::ClearDbPressed
void ClearDbPressed()
GalleryThumbView::ItemClicked
void ItemClicked(MythUIButtonListItem *item)
Action item click.
Definition: gallerythumbview.cpp:1376
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:56
InfoList::GetState
InfoVisibleState GetState() const
Definition: galleryinfo.h:33
ImageItem::IsLocalId
static bool IsLocalId(int id)
Determine image type (local/remote) from its id. Root/Gallery is remote.
Definition: imagetypes.h:121
LOC
#define LOC
Definition: gallerythumbview.cpp:20
token
return token
Definition: musicutils.cpp:74
GallerySettings::OrderChanged
void OrderChanged()
GalleryThumbView::DirSelectUp
bool DirSelectUp()
Goes up one directory level.
Definition: gallerythumbview.cpp:1455
GalleryThumbView::UpdateImageItem
void UpdateImageItem(MythUIButtonListItem *item)
Initialises a single buttonlist item.
Definition: gallerythumbview.cpp:704
TransferThread::GetResult
ImageSet GetResult(void)
Definition: gallerythumbview.cpp:65
GalleryThumbView::ShowDetails
void ShowDetails()
Shows exif info/details about an item.
Definition: gallerythumbview.cpp:1746
GalleryThumbView::CheckThumbnail
QString CheckThumbnail(MythUIButtonListItem *item, const ImagePtrK &im, ImageIdList &request, int index)
Verify thumbnail is known to exist.
Definition: gallerythumbview.cpp:811
RemoteFile::CopyFile
static bool CopyFile(const QString &src, const QString &dst, bool overwrite=false, bool verify=false)
Definition: remotefile.cpp:587
GalleryThumbView::FlipHorizontal
void FlipHorizontal()
Definition: gallerythumbview.h:75
GalleryThumbView::m_popupStack
MythScreenStack & m_popupStack
Definition: gallerythumbview.h:134
GalleryThumbView::m_pendingMap
QMultiHash< int, ThumbLocation > m_pendingMap
Buttons waiting for thumbnails to be created.
Definition: gallerythumbview.h:149
ImageList
QVector< ImagePtr > ImageList
Definition: imagetypes.h:159
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:929
GalleryThumbView::TransformItem
void TransformItem(ImageFileTransform tran=kRotateCW)
Apply transform to an image.
Definition: gallerythumbview.cpp:1540
ImageManagerFe::CreateImport
QString CreateImport()
Definition: imagemanager.cpp:2488
GalleryThumbView::RotateCW
void RotateCW()
Definition: gallerythumbview.h:73
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
GalleryThumbView::m_scanProgressText
MythUIText * m_scanProgressText
Definition: gallerythumbview.h:127
GalleryThumbView::MarkInvertAll
void MarkInvertAll()
Invert all marked items.
Definition: gallerythumbview.cpp:1527
DirectoryView::LoadFromDb
bool LoadFromDb(int parentId) override
Populate view from database as images/subdirs of a directory. View is ordered: Parent dir,...
Definition: galleryviews.cpp:503
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:923
GalleryThumbView::RecursiveSlideshow
void RecursiveSlideshow()
Definition: gallerythumbview.h:71
InfoList::Hide
bool Hide()
Remove infolist from display.
Definition: galleryinfo.cpp:114
GalleryThumbView::MarkAll
void MarkAll(bool mark=true)
Mark or unmark all items.
Definition: gallerythumbview.cpp:1512
TransferThread::ImageSet
QSet< ImagePtrK > ImageSet
Definition: gallerythumbview.cpp:59
GalleryThumbView::m_emptyText
MythUIText * m_emptyText
Definition: gallerythumbview.h:123
GalleryThumbView::Move
void Move()
Move marked images to selected dir. If no marked files, use previously marked files....
Definition: gallerythumbview.cpp:2030
kImageFile
@ kImageFile
A picture.
Definition: imagetypes.h:38
MythMenu
Definition: mythdialogbox.h:93
ImageManagerFe::MoveDbImages
QString MoveDbImages(const ImagePtrK &destDir, ImageListK &images, const QString &srcPath)
Moves database images (but not the files themselves).
Definition: imagemanager.cpp:2254
GalleryThumbView::m_mgr
ImageManagerFe & m_mgr
Manages the images.
Definition: gallerythumbview.h:135
kUserCaption
@ kUserCaption
Exif comments.
Definition: gallerythumbview.h:18
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
GallerySlideView::ImageSelected
void ImageSelected(int)
GalleryThumbView::Copy
void Copy(bool deleteAfter=false)
Copy marked images to selected dir. If no marked files, use previously marked files....
Definition: gallerythumbview.cpp:1902
ImagePtr
QSharedPointer< ImageItem > ImagePtr
Definition: imagetypes.h:158
GalleryThumbView::m_editsAllowed
bool m_editsAllowed
Edit privileges.
Definition: gallerythumbview.h:152
MythConfirmationDialog
Dialog asking for user confirmation.
Definition: mythdialogbox.h:222
ImageDbReader::SetType
void SetType(int showType)
Definition: imagemanager.h:408
GalleryThumbView::HidePictures
void HidePictures()
Definition: gallerythumbview.h:98
ImageManagerFe
The image manager for use by Frontends.
Definition: imagemanager.h:457
ImageManagerFe::ConstructPath
static QString ConstructPath(const QString &path, const QString &name)
Assembles a canonical file path without corrupting its absolute/relative nature.
Definition: imagemanager.h:132
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
MythUIButtonListItem::SetImage
void SetImage(MythImage *image, const QString &name="")
Sets an image directly, should only be used in special circumstances since it bypasses the cache.
Definition: mythuibuttonlist.cpp:3398
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
FlatView::GetParentId
int GetParentId() const
Definition: galleryviews.h:105
GalleryThumbView::HideItem
void HideItem(bool hide=true)
Hide or unhide item.
Definition: gallerythumbview.cpp:1570
WaitUntilDone
static void WaitUntilDone(MThread &worker)
Runs a worker thread and waits for it to finish.
Definition: gallerythumbview.cpp:135
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:42
ImageIdList
QList< int > ImageIdList
Definition: imagetypes.h:59
ShellThread::GetResult
int GetResult(void) const
Definition: gallerythumbview.cpp:30
ImageManagerFe::CrumbName
QString CrumbName(ImageItemK &im, bool getPath=false) const
Return a displayable name (with optional path) for an image.
Definition: imagemanager.cpp:2370
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:134
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1086
RemoteFile::MoveFile
static bool MoveFile(const QString &src, const QString &dst, bool overwrite=false)
Definition: remotefile.cpp:677
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
GalleryThumbView::DeleteItem
void DeleteItem()
Confirm user deletion of an item.
Definition: gallerythumbview.cpp:1614
DirectoryView::GetMenuSubjects
MenuSubjects GetMenuSubjects()
Determine current selection, markings & various info to support menu display.
Definition: galleryviews.cpp:812
GalleryThumbView::m_zoomWidgets
QList< MythUIButtonList * > m_zoomWidgets
Theme buttonlist widgets implementing zoom levels.
Definition: gallerythumbview.h:131
MythUIButtonList::Reset
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuibuttonlist.cpp:114
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:105
SlideOrderType
SlideOrderType
Order of images in slideshow.
Definition: galleryviews.h:21
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
GalleryThumbView::UnhideMarked
void UnhideMarked()
Definition: gallerythumbview.h:91
GalleryThumbView::~GalleryThumbView
~GalleryThumbView() override
Destructor.
Definition: gallerythumbview.cpp:170
build_compdb.action
action
Definition: build_compdb.py:9
DirectoryView::ClearCache
void ClearCache()
Clears UI cache.
Definition: galleryviews.cpp:892
GalleryThumbView::m_zoomLevel
int m_zoomLevel
Definition: gallerythumbview.h:132
GalleryThumbView::RemoveImages
void RemoveImages(const QStringList &ids, bool deleted=true)
Cleanup UI & image caches when a device is removed.
Definition: gallerythumbview.cpp:575
DirectoryView::Clear
void Clear(bool resetParent=true)
Resets view.
Definition: galleryviews.cpp:717
ShellThread::ShellThread
ShellThread(QString cmd, QString path)
Definition: gallerythumbview.cpp:27
GalleryThumbView::UnmarkItem
void UnmarkItem()
Definition: gallerythumbview.h:84
MThread::objectName
QString objectName(void) const
Definition: mthread.cpp:248
GalleryThumbView::Slideshow
void Slideshow()
Definition: gallerythumbview.h:70
DirectoryView::RemoveImage
QStringList RemoveImage(int id, bool deleted=false)
Clear file/dir and all its ancestors from UI cache so that ancestor thumbnails are recalculated....
Definition: galleryviews.cpp:907
GalleryThumbView::MenuTransform
void MenuTransform(MythMenu *mainMenu)
Add a Transform submenu.
Definition: gallerythumbview.cpp:1151
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:855
ThumbPair
QPair< int, QString > ThumbPair
Definition: imagetypes.h:63
MenuSubjects::m_selected
ImagePtrK m_selected
Selected item.
Definition: galleryviews.h:66
kOrdered
@ kOrdered
Ordered as per user setting GallerySortOrder.
Definition: galleryviews.h:22
GalleryThumbView::ThumbLocation
QPair< MythUIButtonListItem *, int > ThumbLocation
Definition: gallerythumbview.h:147
ImageManagerFe::DeleteFiles
QString DeleteFiles(const ImageIdList &ids)
Delete images.
Definition: imagemanager.cpp:2281
GalleryThumbView::m_captionText
MythUIText * m_captionText
Definition: gallerythumbview.h:121
ShellThread::m_path
QString m_path
Definition: gallerythumbview.cpp:49
GalleryThumbView::ResetExifMarked
void ResetExifMarked()
Definition: gallerythumbview.h:82
InfoList::Create
bool Create(bool focusable)
Initialise buttonlist from XML.
Definition: galleryinfo.cpp:62
galleryconfig.h
Provides Gallery configuration screens.
MythTextInputDialog
Dialog prompting the user to enter a text string.
Definition: mythdialogbox.h:264
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:898
GalleryThumbView::HideVideos
void HideVideos()
Definition: gallerythumbview.h:99
DirectoryView
A datastore of images for display by a screen. Provides an ordered list of dirs & images from a singl...
Definition: galleryviews.h:171
kDevice
@ kDevice
Storage Group and local mounted media.
Definition: imagetypes.h:35
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:144
DirectoryView::IsMarked
bool IsMarked(int id) const
Definition: galleryviews.h:188
MythUIProgressBar::SetVisible
void SetVisible(bool visible) override
Definition: mythuiprogressbar.cpp:186
DirectoryView::ClearMarked
void ClearMarked()
Unmark all items.
Definition: galleryviews.cpp:771
GalleryThumbView::MenuMarked
void MenuMarked(MythMenu *mainMenu)
Adds a Marking submenu.
Definition: gallerythumbview.cpp:1069
GalleryThumbView::ShowHidden
void ShowHidden(bool show=true)
Show or hide hidden files.
Definition: gallerythumbview.cpp:1688
MythUIButtonListItem::setChecked
void setChecked(CheckState state)
Definition: mythuibuttonlist.cpp:3544
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
kNameCaption
@ kNameCaption
Filenames.
Definition: gallerythumbview.h:16
kRandom
@ kRandom
Random selection from view. An image may be absent or appear multiple times.
Definition: galleryviews.h:24
GalleryThumbView::Close
void Close() override
Exit Gallery.
Definition: gallerythumbview.cpp:180
ImageManagerFe::ScanQuery
static QStringList ScanQuery()
Returns storage group scanner status.
Definition: imagemanager.cpp:2025
ImageManagerFe::RenameFile
QString RenameFile(const ImagePtrK &im, const QString &name)
Rename an image.
Definition: imagemanager.cpp:2190
ImageManagerFe::ShortDateOf
QString ShortDateOf(const ImagePtrK &im) const
Return a short datestamp for thumbnail captions.
Definition: imagemanager.cpp:2337
GalleryThumbView::Eject
void Eject()
Remove local device (or Import) from Gallery.
Definition: gallerythumbview.cpp:1885
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
GalleryThumbView::RotateCWMarked
void RotateCWMarked()
Definition: gallerythumbview.h:78
ShellThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: gallerythumbview.cpp:32
MythCoreContext::SaveBoolSetting
void SaveBoolSetting(const QString &key, bool newValue)
Definition: mythcorecontext.h:148
TransferThread::m_dialog
MythUIProgressDialog * m_dialog
Images for which copy/move failed.
Definition: gallerythumbview.cpp:127
ShellThread::m_result
int m_result
Definition: gallerythumbview.cpp:47
kCloneDir
@ kCloneDir
A device sub dir comprised from multiple SG dirs.
Definition: imagetypes.h:36
GALLERY_DB_ID
#define GALLERY_DB_ID
Definition: imagetypes.h:26
kVideoOnly
@ kVideoOnly
Hide pictures.
Definition: imagemanager.h:80
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:915
GalleryThumbView::StopScan
void StopScan()
Definition: gallerythumbview.h:104
GalleryThumbView::Start
void Start()
Start Thumbnail screen.
Definition: gallerythumbview.cpp:599
MenuSubjects::m_hiddenMarked
bool m_hiddenMarked
Is any marked item hidden ?
Definition: galleryviews.h:71
MythUIButtonListItem::NotChecked
@ NotChecked
Definition: mythuibuttonlist.h:32
GalleryThumbView::RepeatOn
static void RepeatOn(int on=1)
Definition: gallerythumbview.h:113
ImageManagerFe::DetectLocalDevices
bool DetectLocalDevices()
Detect and scan local devices.
Definition: imagemanager.cpp:2404