MythTV  master
videometadatasettings.cpp
Go to the documentation of this file.
1 // C++
2 #include <iostream>
3 
4 // Qt
5 #include <QString>
6 
7 // MythTV
8 #include "libmyth/mythcontext.h"
10 #include "libmythbase/mythdirs.h"
12 
13 // MythFrontend
14 #include "videometadatasettings.h"
15 
16 // ---------------------------------------------------
17 
19 {
20  // Load the theme for this screen
21  bool foundtheme = LoadWindowFromXML("video-ui.xml", "metadatasettings", this);
22  if (!foundtheme)
23  return false;
24 
26  dynamic_cast<MythUISpinBox *> (GetChild("trailernum"));
27 
29  dynamic_cast<MythUICheckBox *> (GetChild("unknownfilecheck"));
31  dynamic_cast<MythUICheckBox *> (GetChild("autometaupdatecheck"));
33  dynamic_cast<MythUICheckBox *> (GetChild("treeloadsmetacheck"));
35  dynamic_cast<MythUICheckBox *> (GetChild("randomtrailercheck"));
36 
37  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
38  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
39 
43  {
44  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
45  return false;
46  }
47 
48  int unknownSetting =
49  gCoreContext->GetNumSetting("VideoListUnknownFiletypes", 0);
50  if (unknownSetting == 1)
52 
53  int autoMetaSetting =
54  gCoreContext->GetNumSetting("mythvideo.AutoMetaDataScan", 1);
55  if (autoMetaSetting == 1)
57 
58  int loadMetaSetting =
59  gCoreContext->GetNumSetting("VideoTreeLoadMetaData", 1);
60  if (loadMetaSetting == 1)
62 
63  int trailerSetting =
64  gCoreContext->GetNumSetting("mythvideo.TrailersRandomEnabled", 0);
65  if (trailerSetting == 1)
67 
68  m_trailerSpin->SetRange(0,100,1);
70  "mythvideo.TrailersRandomCount"));
71 
74  else
75  m_trailerSpin->SetVisible(false);
76 
79 
82 
84  tr("If set, this will enable a button "
85  "called \"Watch With Trailers\" which will "
86  "play a user-specified number of trailers "
87  "before the movie."));
88  m_trailerSpin->SetHelpText(tr("Number of trailers to play before a film."));
90  tr("If set, all files below the MythVideo "
91  "directory will be displayed unless their "
92  "extension is explicitly set to be ignored."));
94  tr("If set, every time a scan for new videos "
95  "is performed, a mass metadata update of the "
96  "collection will also occur."));
98  tr("If set along with Browse Files, this "
99  "will cause the Video List to load any known video meta"
100  "data from the database. Turning this off can greatly "
101  "speed up how long it takes to load the Video List tree."));
102  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
103  m_okButton->SetHelpText(tr("Save settings and Exit"));
104 
105  BuildFocusList();
106 
107  return true;
108 }
109 
111 {
112  gCoreContext->SaveSetting("mythvideo.TrailersRandomCount",
114 
115  int listUnknownState = 0;
117  listUnknownState = 1;
118  gCoreContext->SaveSetting("VideoListUnknownFiletypes", listUnknownState);
119 
120  int autoMetaState = 0;
122  autoMetaState = 1;
123  gCoreContext->SaveSetting("mythvideo.AutoMetaDataScan", autoMetaState);
124 
125  int loadMetaState = 0;
127  loadMetaState = 1;
128  gCoreContext->SaveSetting("VideoTreeLoadMetaData", loadMetaState);
129 
130  int trailerState = 0;
132  trailerState = 1;
133  gCoreContext->SaveSetting("mythvideo.TrailersRandomEnabled", trailerState);
134 
135  Close();
136 }
137 
138 bool MetadataSettings::keyPressEvent(QKeyEvent *event)
139 {
140  if (GetFocusWidget()->keyPressEvent(event))
141  return true;
142 
143  return MythScreenType::keyPressEvent(event);
144 }
145 
147 {
148  int checkstate = 0;
150  checkstate = 1;
151 
152  m_trailerSpin->SetVisible(checkstate != 0);
153 }
MythUIButton::Clicked
void Clicked()
videometadatasettings.h
MythUISpinBox::GetValue
QString GetValue(void) const override
Definition: mythuispinbox.h:31
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:386
MetadataSettings::Create
bool Create(void) override
Definition: videometadatasettings.cpp:18
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:135
mythdbcon.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
mythdirs.h
MetadataSettings::m_okButton
MythUIButton * m_okButton
Definition: videometadatasettings.h:33
MythUISpinBox::SetRange
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
Definition: mythuispinbox.cpp:26
MetadataSettings::m_autoMetaUpdateCheck
MythUICheckBox * m_autoMetaUpdateCheck
Definition: videometadatasettings.h:29
mythprogressdialog.h
MetadataSettings::m_unknownFileCheck
MythUICheckBox * m_unknownFileCheck
Definition: videometadatasettings.h:28
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:113
MythUISpinBox::SetValue
void SetValue(int val) override
Definition: mythuispinbox.h:26
MythUICheckBox::valueChanged
void valueChanged()
MetadataSettings::m_randomTrailerCheck
MythUICheckBox * m_randomTrailerCheck
Definition: videometadatasettings.h:31
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:206
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:25
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:61
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:935
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:404
MythUICheckBox::SetCheckState
void SetCheckState(MythUIStateType::StateType state)
Definition: mythuicheckbox.cpp:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:695
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1110
mythcontext.h
MetadataSettings::m_treeLoadsMetaCheck
MythUICheckBox * m_treeLoadsMetaCheck
Definition: videometadatasettings.h:30
MetadataSettings::toggleTrailers
void toggleTrailers(void)
Definition: videometadatasettings.cpp:146
MythUISpinBox
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:16
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:904
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
MetadataSettings::slotSave
void slotSave(void)
Definition: videometadatasettings.cpp:110
MetadataSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: videometadatasettings.cpp:138
MetadataSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: videometadatasettings.h:34
MetadataSettings::m_trailerSpin
MythUISpinBox * m_trailerSpin
Definition: videometadatasettings.h:26