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