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 for (auto i = transitions.cbegin(); i != transitions.cend(); ++i)
116 gc->addSelection(i.value()->objectName(), QString::number(i.key()));
117
118 return gc;
119}
120
122{
123 auto *gc = new HostSpinBoxSetting("GallerySlideShowTime", 100, 60000, 100, 5);
124
125 gc->setLabel(TR("Slide Duration (ms)"));
126 gc->setHelpText(TR("The time that a slide is displayed (between transitions), "
127 "in milliseconds."));
128 return gc;
129}
130
132{
133 auto *gc = new HostSpinBoxSetting("GalleryTransitionTime", 100, 60000, 100, 5);
134
135 gc->setLabel(TR("Transition Duration (ms)"));
136 gc->setHelpText(TR("The time that each transition lasts, in milliseconds."));
137 return gc;
138}
139
141{
142 auto *gc = new HostSpinBoxSetting("GalleryStatusDelay", 0, 10000, 50, 10);
143
144 gc->setLabel(TR("Status Delay (ms)"));
145 gc->setHelpText(TR("The delay before showing the Loading/Playing status, "
146 "in milliseconds."));
147 return gc;
148}
149
150#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
152{
153 auto *gc = new HostSpinBoxSetting("ImageMaximumSize", -1, 1024*1024, 1, 10);
154
155 gc->setLabel(TR("Maximum Image Size (MB)"));
156 gc->setHelpText(TR("The maximum image size that will be loaded, "
157 "in megabytes. (-1 means system default, 0 "
158 "means unlimited.)"));
159
160 connect(gc, &StandardSetting::ChangeSaved,
162
163 return gc;
164}
165
167{
168 int maxImageSize = gCoreContext->GetNumSetting("ImageMaximumSize", -1);
169 if (maxImageSize < 0)
170 maxImageSize = 128; // Restore Qt6 default
171 QImageReader::setAllocationLimit(maxImageSize);
172}
173#endif
174
176{
177 auto *gc = new HostCheckBoxSetting("GalleryBrowseTransition");
178
179 gc->setLabel(TR("Use transitions when browsing"));
180 gc->setHelpText(TR("When cleared, transitions will only be used "
181 "during a slideshow."));
182 return gc;
183}
184
189static StandardSetting *Import(bool enabled)
190{
191 auto *gc = new HostTextEditSetting("GalleryImportCmd");
192
193 gc->setVisible(enabled);
194 gc->setLabel(TR("Import Command"));
195 gc->setHelpText(TR("Command/script that can be run from the menu. "
196 "\n%TMPDIR% will be replaced by a new temporary directory, "
197 "which the import dialog will show automatically. The "
198 "directory will be removed when Gallery exits."));
199 return gc;
200}
201
207{
208 auto *gc = new GlobalTextEditSetting("GalleryIgnoreFilter");
209
210 gc->setVisible(enabled);
211 gc->setLabel(TR("Scanner Exclusions"));
212 gc->setHelpText(TR("Comma-separated list of filenames/directory names "
213 "to be ignored when scanning. "
214 "Glob wildcards * and ? are valid."));
215
216 connect(gc, &StandardSetting::ChangeSaved,
218
219 return gc;
220}
221
226static StandardSetting *Autorun(bool enabled)
227{
228 auto *gc = new HostCheckBoxSetting("GalleryAutoStart");
229
230 gc->setVisible(enabled);
231 gc->setLabel(TR("Start Gallery when media inserted"));
232 gc->setHelpText(TR("Set to automatically start Gallery when media "
233 "(USB/CD's containing images) are inserted."));
234 return gc;
235}
236
241static StandardSetting *Password(bool enabled)
242{
243 auto *gc = new GlobalTextEditSetting("GalleryPassword");
244
245 gc->setVisible(enabled);
246 gc->setLabel(TR("Password"));
247 gc->setHelpText(TR("When set all actions that modify the filesystem or "
248 "database are protected (copy, move, transform, "
249 "hiding, covers). Hidden items cannot be viewed. "
250 "Applies to all frontends. "
251 "\nDisabled by an empty password. "
252 "Privileges persist until Gallery exits to main menu."));
253 return gc;
254}
255
261{
262 auto *gc = new ButtonStandardSetting(TR("Reset Image Database"));
263
264 gc->setVisible(enabled);
265 gc->setLabel(TR("Reset Image Database"));
266 gc->setHelpText(TR("Clears the database and thumbnails for the Image Storage Group. "
267 "A rescan will be required. Images for local media will persist."));
268
271
272 return gc;
273}
274
276{
277 QString msg(TR("Warning! This will erase settings for: hidden images, "
278 "directory covers and re-orientations. "
279 "You will have to set them again after re-scanning."));
280 auto *stack = GetMythMainWindow()->GetStack("popup stack");
281 auto *dialog = new MythConfirmationDialog(stack, msg);
282 if (dialog->Create())
283 {
284 stack->AddScreen(dialog);
285 connect(dialog, &MythConfirmationDialog::haveResult,
286 this, [this](bool ok) { if (ok) emit ClearDbPressed(); });
287 }
288 else
289 {
290 delete dialog;
291 }
292}
293
295{
296 setLabel(TR("Gallery Settings"));
297
305#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
307#endif
309
310 // These modify the database
311 addChild(Import(enable));
312 addChild(Exclusions(enable));
313 addChild(Autorun(enable));
314 addChild(Password(enable));
315 addChild(ClearDb(enable));
316}
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