MythTV  master
videometadatasettings.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 // qt
4 #include <QString>
5 
6 // myth
7 #include "mythcontext.h"
8 #include "mythdbcon.h"
9 #include "mythdirs.h"
10 #include "mythprogressdialog.h"
11 
12 #include "videometadatasettings.h"
13 
14 // ---------------------------------------------------
15 
17 {
18  // Load the theme for this screen
19  bool foundtheme = LoadWindowFromXML("video-ui.xml", "metadatasettings", this);
20  if (!foundtheme)
21  return false;
22 
24  dynamic_cast<MythUISpinBox *> (GetChild("trailernum"));
25 
27  dynamic_cast<MythUICheckBox *> (GetChild("unknownfilecheck"));
29  dynamic_cast<MythUICheckBox *> (GetChild("autometaupdatecheck"));
31  dynamic_cast<MythUICheckBox *> (GetChild("treeloadsmetacheck"));
33  dynamic_cast<MythUICheckBox *> (GetChild("randomtrailercheck"));
34 
35  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
36  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
37 
41  {
42  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
43  return false;
44  }
45 
46  int unknownSetting =
47  gCoreContext->GetNumSetting("VideoListUnknownFiletypes", 0);
48  if (unknownSetting == 1)
50 
51  int autoMetaSetting =
52  gCoreContext->GetNumSetting("mythvideo.AutoMetaDataScan", 1);
53  if (autoMetaSetting == 1)
55 
56  int loadMetaSetting =
57  gCoreContext->GetNumSetting("VideoTreeLoadMetaData", 1);
58  if (loadMetaSetting == 1)
60 
61  int trailerSetting =
62  gCoreContext->GetNumSetting("mythvideo.TrailersRandomEnabled", 0);
63  if (trailerSetting == 1)
65 
66  m_trailerSpin->SetRange(0,100,1);
68  "mythvideo.TrailersRandomCount"));
69 
72  else
73  m_trailerSpin->SetVisible(false);
74 
77 
80 
82  tr("If set, this will enable a button "
83  "called \"Watch With Trailers\" which will "
84  "play a user-specified number of trailers "
85  "before the movie."));
86  m_trailerSpin->SetHelpText(tr("Number of trailers to play before a film."));
88  tr("If set, all files below the MythVideo "
89  "directory will be displayed unless their "
90  "extension is explicitly set to be ignored."));
92  tr("If set, every time a scan for new videos "
93  "is performed, a mass metadata update of the "
94  "collection will also occur."));
96  tr("If set along with Browse Files, this "
97  "will cause the Video List to load any known video meta"
98  "data from the database. Turning this off can greatly "
99  "speed up how long it takes to load the Video List tree."));
100  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
101  m_okButton->SetHelpText(tr("Save settings and Exit"));
102 
103  BuildFocusList();
104 
105  return true;
106 }
107 
109 {
110  gCoreContext->SaveSetting("mythvideo.TrailersRandomCount",
112 
113  int listUnknownState = 0;
115  listUnknownState = 1;
116  gCoreContext->SaveSetting("VideoListUnknownFiletypes", listUnknownState);
117 
118  int autoMetaState = 0;
120  autoMetaState = 1;
121  gCoreContext->SaveSetting("mythvideo.AutoMetaDataScan", autoMetaState);
122 
123  int loadMetaState = 0;
125  loadMetaState = 1;
126  gCoreContext->SaveSetting("VideoTreeLoadMetaData", loadMetaState);
127 
128  int trailerState = 0;
130  trailerState = 1;
131  gCoreContext->SaveSetting("mythvideo.TrailersRandomEnabled", trailerState);
132 
133  Close();
134 }
135 
136 bool MetadataSettings::keyPressEvent(QKeyEvent *event)
137 {
138  if (GetFocusWidget()->keyPressEvent(event))
139  return true;
140 
141  return MythScreenType::keyPressEvent(event);
142 }
143 
145 {
146  int checkstate = 0;
148  checkstate = 1;
149 
150  m_trailerSpin->SetVisible(checkstate != 0);
151 }
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:402
MetadataSettings::Create
bool Create(void) override
Definition: videometadatasettings.cpp:16
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:131
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:25
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:112
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:172
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:25
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:16
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:933
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
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:692
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1086
mythcontext.h
MetadataSettings::m_treeLoadsMetaCheck
MythUICheckBox * m_treeLoadsMetaCheck
Definition: videometadatasettings.h:30
MetadataSettings::toggleTrailers
void toggleTrailers(void)
Definition: videometadatasettings.cpp:144
MythUISpinBox
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:17
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:902
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
MetadataSettings::slotSave
void slotSave(void)
Definition: videometadatasettings.cpp:108
MetadataSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: videometadatasettings.cpp:136
MetadataSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: videometadatasettings.h:34
MetadataSettings::m_trailerSpin
MythUISpinBox * m_trailerSpin
Definition: videometadatasettings.h:26