MythTV  master
videoglobalsettings.cpp
Go to the documentation of this file.
1 #include <map>
2 #include <vector>
3 
4 #include <QDir>
5 
6 #include "mythdirs.h"
7 #include "globals.h"
8 
9 #include "videodlg.h"
10 #include "videoglobalsettings.h"
11 
12 namespace
13 {
14 // General Settings
15 HostComboBoxSetting *VideoDefaultParentalLevel()
16 {
17  auto *gc = new HostComboBoxSetting("VideoDefaultParentalLevel");
18 
19  gc->setLabel(VideoGeneralSettings::tr("Starting Parental Level"));
20 
21  gc->addSelection(VideoGeneralSettings::tr("4 - Highest"),
22  QString::number(ParentalLevel::plHigh));
23  gc->addSelection(VideoGeneralSettings::tr("1 - Lowest"),
24  QString::number(ParentalLevel::plLowest));
25  gc->addSelection(QString::number(ParentalLevel::plLow));
26  gc->addSelection(QString::number(ParentalLevel::plMedium));
27 
28  gc->setHelpText(VideoGeneralSettings::tr("This is the 'level' that Video "
29  "starts at. Any videos with a "
30  "level at or below this will be "
31  "shown in the list or while "
32  "browsing by default. The "
33  "Parental PIN should be set to "
34  "limit changing of the default "
35  "level."));
36  return gc;
37 }
38 
39 const char *password_clue =
40  QT_TRANSLATE_NOOP("VideoGeneralSettings", "Setting this value to all "
41  "numbers will make your life "
42  "much easier.");
43 
44 HostTextEditSetting *VideoAdminPassword()
45 {
46  auto *gc = new HostTextEditSetting("VideoAdminPassword");
47 
48  gc->setLabel(VideoGeneralSettings::tr("Parental Level 4 PIN"));
49 
50  gc->setHelpText(QString("%1 %2")
51  .arg(VideoGeneralSettings::tr("This PIN is used to enter Parental "
52  "Control Level 4 as well as the Video "
53  "Manager."),
54  VideoGeneralSettings::tr(password_clue)));
55 
56  return gc;
57 }
58 
59 HostTextEditSetting *VideoAdminPasswordThree()
60 {
61  auto *gc = new HostTextEditSetting("VideoAdminPasswordThree");
62 
63  gc->setLabel(VideoGeneralSettings::tr("Parental Level 3 PIN"));
64 
65  gc->setHelpText(QString("%1 %2")
66  .arg(VideoGeneralSettings::tr("This PIN is used to enter Parental "
67  "Control Level 3."),
68  VideoGeneralSettings::tr(password_clue)));
69 
70  return gc;
71 }
72 
73 HostTextEditSetting *VideoAdminPasswordTwo()
74 {
75  auto *gc = new HostTextEditSetting("VideoAdminPasswordTwo");
76 
77  gc->setLabel(VideoGeneralSettings::tr("Parental Level 2 PIN"));
78 
79  gc->setHelpText(QString("%1 %2")
80  .arg(VideoGeneralSettings::tr("This PIN is used to enter Parental "
81  "Control Level 2."),
82  VideoGeneralSettings::tr(password_clue)));
83 
84  return gc;
85 }
86 
87 HostCheckBoxSetting *VideoAggressivePC()
88 {
89  auto *gc = new HostCheckBoxSetting("VideoAggressivePC");
90 
91  gc->setLabel(VideoGeneralSettings::tr("Aggressive Parental Control"));
92  gc->setValue(false);
93 
94  gc->setHelpText(VideoGeneralSettings::tr("If set, you will not be able to "
95  "return to this screen and reset "
96  "the Parental PIN without first "
97  "entering the current PIN. You "
98  "have been warned."));
99  return gc;
100 }
101 
102 HostTextEditSetting *VideoStartupDirectory()
103 {
104  auto *gc = new HostTextEditSetting("VideoStartupDir");
105 
106  gc->setLabel(VideoGeneralSettings::tr("Directories that hold videos"));
107 
108  gc->setValue(DEFAULT_VIDEOSTARTUP_DIR);
109 
110  gc->setHelpText(VideoGeneralSettings::tr("Multiple directories can be "
111  "separated by ':'. Each "
112  "directory must exist and be "
113  "readable by the user running "
114  "the frontend."));
115  return gc;
116 }
117 
118 HostTextEditSetting *VideoArtworkDirectory()
119 {
120  auto *gc = new HostTextEditSetting("VideoArtworkDir");
121 
122  gc->setLabel(VideoGeneralSettings::tr("Directory that holds movie "
123  "posters"));
124 
125  gc->setValue(GetConfDir() + "/Video/Artwork");
126 
127  gc->setHelpText(VideoGeneralSettings::tr("This directory must exist, and "
128  "the user running the frontend "
129  "needs to have read/write "
130  "permission to the directory."));
131  return gc;
132 }
133 
134 HostTextEditSetting *VideoScreenshotDirectory()
135 {
136  auto *gc = new HostTextEditSetting("mythvideo.screenshotDir");
137 
138  gc->setLabel(VideoGeneralSettings::tr("Directory that holds movie "
139  "screenshots"));
140 
141  gc->setValue(GetConfDir() + "/Video/Screenshots");
142 
143  gc->setHelpText(VideoGeneralSettings::tr("This directory must exist, and "
144  "the user running the frontend "
145  "needs to have read/write "
146  "permission to the directory."));
147  return gc;
148 }
149 
150 HostTextEditSetting *VideoBannerDirectory()
151 {
152  auto *gc = new HostTextEditSetting("mythvideo.bannerDir");
153 
154  gc->setLabel(VideoGeneralSettings::tr("Directory that holds movie/TV "
155  "Banners"));
156 
157  gc->setValue(GetConfDir() + "/Video/Banners");
158 
159  gc->setHelpText(VideoGeneralSettings::tr("This directory must exist, and "
160  "the user running the frontend "
161  "needs to have read/write "
162  "permission to the directory."));
163  return gc;
164 }
165 
166 HostTextEditSetting *VideoFanartDirectory()
167 {
168  auto *gc = new HostTextEditSetting("mythvideo.fanartDir");
169 
170  gc->setLabel(VideoGeneralSettings::tr("Directory that holds movie fanart"));
171 
172  gc->setValue(GetConfDir() + "/Video/Fanart");
173 
174  gc->setHelpText(VideoGeneralSettings::tr("This directory must exist, and "
175  "the user running the frontend "
176  "needs to have read/write "
177  "permission to the directory."));
178  return gc;
179 }
180 
181 HostTextEditSetting *TrailerDirectory()
182 {
183  auto *gc = new HostTextEditSetting("mythvideo.TrailersDir");
184 
185  gc->setLabel(VideoGeneralSettings::tr("Directory that holds movie "
186  "trailers"));
187 
188  gc->setValue(GetConfDir() + "/Video/Trailers");
189 
190  gc->setHelpText(VideoGeneralSettings::tr("This directory must exist, and "
191  "the user running the frontend "
192  "needs to have read/write "
193  "permission to the directory."));
194  return gc;
195 }
196 
200 
201 // General Settings
202 
203 HostComboBoxSetting *SetOnInsertDVD()
204 {
205  auto *gc = new HostComboBoxSetting("DVDOnInsertDVD");
206 
207  gc->setLabel(VideoGeneralSettings::tr("On DVD insertion"));
208 
209  gc->addSelection(VideoGeneralSettings::tr("Display mythdvd menu"),"1");
210  gc->addSelection(VideoGeneralSettings::tr("Do nothing"),"0");
211  gc->addSelection(VideoGeneralSettings::tr("Play DVD"),"2");
212 
213  gc->setHelpText(VideoGeneralSettings::tr("Media Monitoring should be "
214  "turned on to allow this feature "
215  "(Setup -> General -> CD/DVD "
216  "Monitor)."));
217  return gc;
218 }
219 
220 HostCheckBoxSetting *VideoTreeRemember()
221 {
222  auto *gc = new HostCheckBoxSetting("mythvideo.VideoTreeRemember");
223 
224  gc->setLabel(VideoGeneralSettings::tr("Video Tree remembers last selected "
225  "position"));
226 
227  gc->setValue(false);
228 
229  gc->setHelpText(VideoGeneralSettings::tr("If set, the current position in "
230  "the Video Tree is persistent."));
231  return gc;
232 }
233 
234 HostCheckBoxSetting *RatingsToPL()
235 {
236  auto *r2pl = new HostCheckBoxSetting("mythvideo.ParentalLevelFromRating");
237 
238  r2pl->setLabel(VideoGeneralSettings::tr("Enable automatic Parental "
239  "Level from rating"));
240  r2pl->setValue(false);
241 
242  r2pl->setHelpText(VideoGeneralSettings::tr("If enabled, searches will "
243  "automatically set the "
244  "Parental Level to the one "
245  "matching the rating "
246  "below."));
247 
248  using r2pl_map = std::map<ParentalLevel::Level, QString>;
249 
250  r2pl_map r2pl_defaults;
251 
252  r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLowest,
253  VideoGeneralSettings::tr("G", "PL 1 default search string.")));
254  r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLow,
255  VideoGeneralSettings::tr("PG", "PL 2 default search string.")));
256  r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plMedium,
257  VideoGeneralSettings::tr("PG-13", "PL3 default search "
258  "string.")));
259  r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plHigh,
260  VideoGeneralSettings::tr("R:NC-17", "PL4 default search "
261  "string.")));
262 
264  pl.GetLevel() <= ParentalLevel::plHigh && pl.good(); ++pl)
265  {
266  auto *hle = new HostTextEditSetting(QString("mythvideo.AutoR2PL%1")
267  .arg(pl.GetLevel()));
268 
269  hle->setLabel(VideoGeneralSettings::tr("Level %1")
270  .arg(pl.GetLevel()));
271 
272  hle->setHelpText(VideoGeneralSettings::tr("Ratings containing "
273  "these strings "
274  "(separated by :) will "
275  "be assigned to Parental "
276  "Level %1.")
277  .arg(pl.GetLevel()));
278 
279  auto def_setting = r2pl_defaults.find(pl.GetLevel());
280  if (def_setting != r2pl_defaults.end())
281  {
282  hle->setValue(def_setting->second);
283  }
284 
285  r2pl->addTargetedChild("1", hle);
286  }
287 
288  return r2pl;
289 }
290 
291 } // namespace
292 
294 {
295  setLabel(tr("General Settings"));
296 
297  addChild(VideoStartupDirectory());
298  addChild(TrailerDirectory());
299  addChild(VideoArtworkDirectory());
300  addChild(VideoScreenshotDirectory());
301  addChild(VideoBannerDirectory());
302  addChild(VideoFanartDirectory());
303 
304  addChild(SetOnInsertDVD());
305  addChild(VideoTreeRemember());
306 
307  auto *pctrl = new GroupSetting();
308  pctrl->setLabel(tr("Parental Control Settings"));
309  pctrl->addChild(VideoDefaultParentalLevel());
310  pctrl->addChild(VideoAdminPassword());
311  pctrl->addChild(VideoAdminPasswordThree());
312  pctrl->addChild(VideoAdminPasswordTwo());
313  pctrl->addChild(VideoAggressivePC());
314  pctrl->addChild(RatingsToPL());
315 
316  addChild(pctrl);
317 }
ParentalLevel::plLowest
@ plLowest
Definition: parentalcontrols.h:12
HostTextEditSetting
Definition: standardsettings.h:168
ParentalLevel::plMedium
@ plMedium
Definition: parentalcontrols.h:12
ParentalLevel::plHigh
@ plHigh
Definition: parentalcontrols.h:13
ParentalLevel::plLow
@ plLow
Definition: parentalcontrols.h:12
GroupSetting::GroupSetting
GroupSetting()=default
mythdirs.h
HostCheckBoxSetting
Definition: standardsettings.h:417
StandardSetting::addChild
virtual void addChild(StandardSetting *child)
Definition: standardsettings.cpp:70
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
VideoGeneralSettings::VideoGeneralSettings
VideoGeneralSettings()
Definition: videoglobalsettings.cpp:293
globals.h
videoglobalsettings.h
DEFAULT_VIDEOSTARTUP_DIR
const QString DEFAULT_VIDEOSTARTUP_DIR
Definition: globals.cpp:45
StandardSetting::setLabel
virtual void setLabel(QString str)
Definition: standardsettings.h:34
ParentalLevel
Definition: parentalcontrols.h:9
HostComboBoxSetting
Definition: standardsettings.h:257
ParentalLevel::GetLevel
Level GetLevel() const
Definition: parentalcontrols.cpp:128
videodlg.h