MythTV  master
galleryconfig.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QStringBuilder>
3 
4 // MythTV
6 #include "libmythbase/mythdate.h"
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 
43  connect(gc, &StandardSetting::ChangeSaved,
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 
62  connect(gc, &StandardSetting::ChangeSaved,
64 
65  return gc;
66 }
67 
68 static 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 
99  connect(gc, &StandardSetting::ChangeSaved,
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 
193 static 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 
230 static 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 
245 static 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 
273  connect(gc, &ButtonStandardSetting::clicked,
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  delete dialog;
294 }
295 
297 {
298  setLabel(TR("Gallery Settings"));
299 
300  addChild(ImageOrder());
301  addChild(DirOrder());
302  addChild(DateFormat());
307 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
309 #endif
311 
312  // These modify the database
313  addChild(Import(enable));
314  addChild(Exclusions(enable));
315  addChild(Autorun(enable));
316  addChild(Password(enable));
317  addChild(ClearDb(enable));
318 }
Password
static StandardSetting * Password(bool enabled)
Setting for changing password.
Definition: galleryconfig.cpp:245
SlideDuration
static StandardSetting * SlideDuration()
Definition: galleryconfig.cpp:125
kSortByNameDesc
@ kSortByNameDesc
Name Z-A.
Definition: imagetypes.h:47
GallerySettings::DateFormat
StandardSetting * DateFormat() const
Definition: galleryconfig.cpp:71
GallerySettings::DateChanged
void DateChanged()
GallerySettings::ExclusionsChanged
void ExclusionsChanged()
kSortByExtDesc
@ kSortByExtDesc
Extension Z-A.
Definition: imagetypes.h:51
ButtonStandardSetting
Definition: standardsettings.h:450
HostTextEditSetting
Definition: standardsettings.h:168
TransitionMap
QMap< int, Transition * > TransitionMap
Definition: gallerytransitions.h:69
TransitionType
static StandardSetting * TransitionType()
Definition: galleryconfig.cpp:105
MythConfirmationDialog::haveResult
void haveResult(bool)
HostCheckBoxSetting
Definition: standardsettings.h:417
TR
#define TR
Definition: galleryconfig.cpp:12
ButtonStandardSetting::clicked
void clicked()
UseTransitions
static StandardSetting * UseTransitions()
Definition: galleryconfig.cpp:179
kSortByDateDesc
@ kSortByDateDesc
Exif date Latest -> Earliest.
Definition: imagetypes.h:55
StandardSetting::addChild
virtual void addChild(StandardSetting *child)
Definition: standardsettings.cpp:71
gallerytransitions.h
Provides transitions for slideshows.
mythdate.h
MythCoreContext::GetQLocale
QLocale GetQLocale(void)
Definition: mythcorecontext.cpp:1863
kSortByNameAsc
@ kSortByNameAsc
Name A-Z.
Definition: imagetypes.h:46
StatusDelay
static StandardSetting * StatusDelay()
Definition: galleryconfig.cpp:144
GallerySettings::ImageSizeChanged
static void ImageSizeChanged()
Definition: galleryconfig.cpp:170
GallerySettings::ImageMaximumSize
StandardSetting * ImageMaximumSize() const
Definition: galleryconfig.cpp:155
GallerySettings::DirOrder
StandardSetting * DirOrder() const
Definition: galleryconfig.cpp:49
kSortByExtAsc
@ kSortByExtAsc
Extension A-Z.
Definition: imagetypes.h:50
GallerySettings::ClearDbPressed
void ClearDbPressed()
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
GallerySettings::OrderChanged
void OrderChanged()
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:912
GallerySettings::GallerySettings
GallerySettings(bool enable)
Definition: galleryconfig.cpp:296
StandardSetting::setLabel
virtual void setLabel(QString str)
Definition: standardsettings.h:34
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:34
TransitionRegistry
Manages transitions available to s psinter.
Definition: gallerytransitions.h:184
GlobalTextEditSetting
Definition: standardsettings.h:175
kSortByModTimeDesc
@ kSortByModTimeDesc
File modified time Latest -> Earliest.
Definition: imagetypes.h:49
HostSpinBoxSetting
Definition: standardsettings.h:364
MythUIComboBoxSetting::addSelection
void addSelection(const QString &label, QString value=QString(), bool select=false)
Definition: standardsettings.cpp:499
Import
static StandardSetting * Import(bool enabled)
Setting for Importing via script.
Definition: galleryconfig.cpp:193
MythConfirmationDialog
Dialog asking for user confirmation. Ok and optional Cancel button.
Definition: mythdialogbox.h:272
mythcorecontext.h
GallerySettings::ClearDb
StandardSetting * ClearDb(bool enabled) const
Setting for clearing image database.
Definition: galleryconfig.cpp:264
kSortByDateAsc
@ kSortByDateAsc
Exif date Earliest -> Latest.
Definition: imagetypes.h:54
GallerySettings::ImageOrder
StandardSetting * ImageOrder() const
Definition: galleryconfig.cpp:14
HostComboBoxSetting
Definition: standardsettings.h:257
GallerySettings::Exclusions
StandardSetting * Exclusions(bool enabled) const
Setting for excluding image files by pattern.
Definition: galleryconfig.cpp:210
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
StandardSetting::ChangeSaved
void ChangeSaved()
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:320
StandardSetting
Definition: standardsettings.h:29
kSortByModTimeAsc
@ kSortByModTimeAsc
File modified time Earliest -> Latest.
Definition: imagetypes.h:48
galleryconfig.h
Provides Gallery configuration screens.
GetMythPainter
MythPainter * GetMythPainter(void)
Definition: mythmainwindow.cpp:117
kSortBySizeAsc
@ kSortBySizeAsc
File size Smallest -> Largest.
Definition: imagetypes.h:52
TransitionRegistry::GetAll
TransitionMap GetAll() const
Definition: gallerytransitions.h:189
Autorun
static StandardSetting * Autorun(bool enabled)
Setting for running gallery on start-up.
Definition: galleryconfig.cpp:230
kSortBySizeDesc
@ kSortBySizeDesc
File size Largest -> Smallest.
Definition: imagetypes.h:53
GallerySettings::ShowConfirmDialog
void ShowConfirmDialog()
Definition: galleryconfig.cpp:279
AddFormat
static void AddFormat(HostComboBoxSetting *gc, const QDateTime &date, const QString &format)
Definition: galleryconfig.cpp:68
TransitionDuration
static StandardSetting * TransitionDuration()
Definition: galleryconfig.cpp:135