MythTV  master
galleryconfig.cpp
Go to the documentation of this file.
1 #include "galleryconfig.h"
2 
3 #include <QStringBuilder>
4 
5 #include "mythcorecontext.h"
6 #include "mythdate.h"
7 #include "gallerytransitions.h"
8 
9 #define TR GallerySettings::tr
10 
12 {
13  auto *gc = new HostComboBoxSetting("GalleryImageOrder");
14 
15  gc->setLabel(TR("Image Order"));
16  gc->setHelpText(TR("The order that pictures/videos are shown in thumbnail "
17  "view and ordered slideshows."));
18 
19  gc->addSelection(TR("Filename (A-Z)"),
20  QString::number(kSortByNameAsc));
21  gc->addSelection(TR("Reverse Filename (Z-A)"),
22  QString::number(kSortByNameDesc));
23  gc->addSelection(TR("Exif Date (oldest first)"),
24  QString::number(kSortByDateAsc));
25  gc->addSelection(TR("Reverse Exif Date (newest first)"),
26  QString::number(kSortByDateDesc));
27  gc->addSelection(TR("File Modified Time (oldest first)"),
28  QString::number(kSortByModTimeAsc));
29  gc->addSelection(TR("Reverse File Modified Time (newest first)"),
30  QString::number(kSortByModTimeDesc));
31  gc->addSelection(TR("File Extension (A-Z)"),
32  QString::number(kSortByExtAsc));
33  gc->addSelection(TR("Reverse File Extension (Z-A)"),
34  QString::number(kSortByExtDesc));
35  gc->addSelection(TR("File Size (smallest first)"),
36  QString::number(kSortBySizeAsc));
37  gc->addSelection(TR("Reverse File Size (largest first)"),
38  QString::number(kSortBySizeDesc));
39 
40  connect(gc, &StandardSetting::ChangeSaved,
42 
43  return gc;
44 }
45 
47 {
48  auto *gc = new HostComboBoxSetting("GalleryDirOrder");
49 
50  gc->setLabel(TR("Directory Order"));
51  gc->setHelpText(TR("The order that dirctories are shown and traversed "
52  "in recursive slideshows."));
53 
54  gc->addSelection(TR("Filename (A-Z)"), QString::number(kSortByNameAsc));
55  gc->addSelection(TR("Reverse Filename (Z-A)"), QString::number(kSortByNameDesc));
56  gc->addSelection(TR("File Modified Time (oldest first)"), QString::number(kSortByModTimeAsc));
57  gc->addSelection(TR("Reverse File Modified Time (newest first)"), QString::number(kSortByModTimeDesc));
58 
59  connect(gc, &StandardSetting::ChangeSaved,
61 
62  return gc;
63 }
64 
65 static void AddFormat(HostComboBoxSetting* gc, const QDateTime& date, const QString& format)
66 { gc->addSelection(gCoreContext->GetQLocale().toString(date, format), format); }
67 
69 {
70  auto *gc = new HostComboBoxSetting("GalleryDateFormat");
71 
72  gc->setLabel(TR("Date Format"));
73  gc->setHelpText(TR("Date format of thumbnail captions. Other places use the system date format. "
74  "Sample shows 3rd May 2002."));
75 
76  QDateTime sampdate = MythDate::fromString("2002-05-03");
77 
78  AddFormat(gc, sampdate, "dd/MM/yy");
79  AddFormat(gc, sampdate, "dd-MM-yy");
80  AddFormat(gc, sampdate, "dd.MM.yy");
81  AddFormat(gc, sampdate, "d/M/yy");
82  AddFormat(gc, sampdate, "d-M-yy");
83  AddFormat(gc, sampdate, "d.M.yy");
84  AddFormat(gc, sampdate, "MM/dd/yy");
85  AddFormat(gc, sampdate, "MM-dd-yy");
86  AddFormat(gc, sampdate, "MM.dd.yy");
87  AddFormat(gc, sampdate, "M/d/yy");
88  AddFormat(gc, sampdate, "M-d-yy");
89  AddFormat(gc, sampdate, "M.d.yy");
90  AddFormat(gc, sampdate, "yyyy/MM/dd");
91  AddFormat(gc, sampdate, "yyyy-MM-dd");
92  AddFormat(gc, sampdate, "yyyy.MM.dd");
93  AddFormat(gc, sampdate, QString("yyyy") % QChar(0x5E74) %
94  "M" % QChar(0x6708) % "d" % QChar(0x65E5)); // yyyy年M月d日
95 
96  connect(gc, &StandardSetting::ChangeSaved,
98 
99  return gc;
100 }
101 
103 {
104  auto *gc = new HostComboBoxSetting("GalleryTransitionType");
105 
106  gc->setLabel(TR("Transition"));
107  gc->setHelpText(TR("Effect to use between slides"));
108 
109  // Initialise selected transition
110  TransitionRegistry availableTransitions(GetMythPainter()->SupportsAnimation());
111  TransitionMap transitions = availableTransitions.GetAll();
112  QMapIterator<int, Transition*> i(transitions);
113  while (i.hasNext())
114  {
115  i.next();
116  gc->addSelection(i.value()->objectName(), QString::number(i.key()));
117  }
118 
119  return gc;
120 }
121 
123 {
124  auto *gc = new HostSpinBoxSetting("GallerySlideShowTime", 100, 60000, 100, 5);
125 
126  gc->setLabel(TR("Slide Duration (ms)"));
127  gc->setHelpText(TR("The time that a slide is displayed (between transitions), "
128  "in milliseconds."));
129  return gc;
130 }
131 
133 {
134  auto *gc = new HostSpinBoxSetting("GalleryTransitionTime", 100, 60000, 100, 5);
135 
136  gc->setLabel(TR("Transition Duration (ms)"));
137  gc->setHelpText(TR("The time that each transition lasts, in milliseconds."));
138  return gc;
139 }
140 
142 {
143  auto *gc = new HostSpinBoxSetting("GalleryStatusDelay", 0, 10000, 50, 10);
144 
145  gc->setLabel(TR("Status Delay (ms)"));
146  gc->setHelpText(TR("The delay before showing the Loading/Playing status, "
147  "in milliseconds."));
148  return gc;
149 }
150 
152 {
153  auto *gc = new HostCheckBoxSetting("GalleryBrowseTransition");
154 
155  gc->setLabel(TR("Use transitions when browsing"));
156  gc->setHelpText(TR("When cleared, transitions will only be used "
157  "during a slideshow."));
158  return gc;
159 }
160 
165 static StandardSetting *Import(bool enabled)
166 {
167  auto *gc = new HostTextEditSetting("GalleryImportCmd");
168 
169  gc->setVisible(enabled);
170  gc->setLabel(TR("Import Command"));
171  gc->setHelpText(TR("Command/script that can be run from the menu. "
172  "\n%TMPDIR% will be replaced by a new temporary directory, "
173  "which the import dialog will show automatically. The "
174  "directory will be removed when Gallery exits."));
175  return gc;
176 }
177 
183 {
184  auto *gc = new GlobalTextEditSetting("GalleryIgnoreFilter");
185 
186  gc->setVisible(enabled);
187  gc->setLabel(TR("Scanner Exclusions"));
188  gc->setHelpText(TR("Comma-separated list of filenames/directory names "
189  "to be ignored when scanning. "
190  "Glob wildcards * and ? are valid."));
191 
192  connect(gc, &StandardSetting::ChangeSaved,
194 
195  return gc;
196 }
197 
202 static StandardSetting *Autorun(bool enabled)
203 {
204  auto *gc = new HostCheckBoxSetting("GalleryAutoStart");
205 
206  gc->setVisible(enabled);
207  gc->setLabel(TR("Start Gallery when media inserted"));
208  gc->setHelpText(TR("Set to automatically start Gallery when media "
209  "(USB/CD's containing images) are inserted."));
210  return gc;
211 }
212 
217 static StandardSetting *Password(bool enabled)
218 {
219  auto *gc = new GlobalTextEditSetting("GalleryPassword");
220 
221  gc->setVisible(enabled);
222  gc->setLabel(TR("Password"));
223  gc->setHelpText(TR("When set all actions that modify the filesystem or "
224  "database are protected (copy, move, transform, "
225  "hiding, covers). Hidden items cannot be viewed. "
226  "Applies to all frontends. "
227  "\nDisabled by an empty password. "
228  "Privileges persist until Gallery exits to main menu."));
229  return gc;
230 }
231 
237 {
238  auto *gc = new ButtonStandardSetting(TR("Reset Image Database"));
239 
240  gc->setVisible(enabled);
241  gc->setLabel(TR("Reset Image Database"));
242  gc->setHelpText(TR("Clears the database and thumbnails for the Image Storage Group. "
243  "A rescan will be required. Images for local media will persist."));
244 
245  connect(gc, &ButtonStandardSetting::clicked,
247 
248  return gc;
249 }
250 
252 {
253  QString msg(TR("Warning! This will erase settings for: hidden images, "
254  "directory covers and re-orientations. "
255  "You will have to set them again after re-scanning."));
256  auto stack = GetMythMainWindow()->GetStack("popup stack");
257  auto dialog = new MythConfirmationDialog(stack, msg);
258  if (dialog->Create())
259  {
260  stack->AddScreen(dialog);
261  connect(dialog, &MythConfirmationDialog::haveResult,
262  this, [this](bool ok) { if (ok) emit ClearDbPressed(); });
263  }
264  else
265  delete dialog;
266 }
267 
269 {
270  setLabel(TR("Gallery Settings"));
271 
272  addChild(ImageOrder());
273  addChild(DirOrder());
274  addChild(DateFormat());
280 
281  // These modify the database
282  addChild(Import(enable));
283  addChild(Exclusions(enable));
284  addChild(Autorun(enable));
285  addChild(Password(enable));
286  addChild(ClearDb(enable));
287 }
File size Largest -> Smallest.
Definition: imagetypes.h:52
static StandardSetting * Import(bool enabled)
Setting for Importing via script.
Name Z-A.
Definition: imagetypes.h:46
static StandardSetting * TransitionType()
StandardSetting * ImageOrder()
Dialog asking for user confirmation.
Extension Z-A.
Definition: imagetypes.h:50
void addSelection(const QString &label, QString value=QString(), bool select=false)
MythPainter * GetMythPainter(void)
StandardSetting * Exclusions(bool enabled)
Setting for excluding image files by pattern.
MythScreenStack * GetStack(const QString &stackname)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static void AddFormat(HostComboBoxSetting *gc, const QDateTime &date, const QString &format)
Exif date Latest -> Earliest.
Definition: imagetypes.h:54
StandardSetting * ClearDb(bool enabled)
Setting for clearing image database.
Provides Gallery configuration screens.
GallerySettings(bool enable)
#define TR
Name A-Z.
Definition: imagetypes.h:45
virtual void setLabel(QString str)
static StandardSetting * TransitionDuration()
static StandardSetting * SlideDuration()
Extension A-Z.
Definition: imagetypes.h:49
Provides transitions for slideshows.
StandardSetting * DirOrder()
File modified time Latest -> Earliest.
Definition: imagetypes.h:48
QMap< int, Transition * > TransitionMap
virtual void addChild(StandardSetting *child)
MythMainWindow * GetMythMainWindow(void)
static StandardSetting * UseTransitions()
static StandardSetting * Password(bool enabled)
Setting for changing password.
Exif date Earliest -> Latest.
Definition: imagetypes.h:53
QLocale GetQLocale(void)
const TransitionMap GetAll() const
static StandardSetting * Autorun(bool enabled)
Setting for running gallery on start-up.
File modified time Earliest -> Latest.
Definition: imagetypes.h:47
void ExclusionsChanged()
void ClearDbPressed()
static StandardSetting * StatusDelay()
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
Manages transitions available to s psinter.
StandardSetting * DateFormat()
File size Smallest -> Largest.
Definition: imagetypes.h:51