MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
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 using namespace std;
15 
16 // ---------------------------------------------------
17 
19  : MythScreenType(parent, name),
20  m_trailerSpin(NULL),
21  m_unknownFileCheck(NULL), m_autoMetaUpdateCheck(NULL),
22  m_treeLoadsMetaCheck(NULL), m_randomTrailerCheck(NULL),
23  m_okButton(NULL), m_cancelButton(NULL)
24 {
25 }
26 
28 {
29  bool foundtheme = false;
30 
31  // Load the theme for this screen
32  foundtheme = LoadWindowFromXML("video-ui.xml", "metadatasettings", this);
33 
34  if (!foundtheme)
35  return false;
36 
38  dynamic_cast<MythUISpinBox *> (GetChild("trailernum"));
39 
41  dynamic_cast<MythUICheckBox *> (GetChild("unknownfilecheck"));
43  dynamic_cast<MythUICheckBox *> (GetChild("autometaupdatecheck"));
45  dynamic_cast<MythUICheckBox *> (GetChild("treeloadsmetacheck"));
47  dynamic_cast<MythUICheckBox *> (GetChild("randomtrailercheck"));
48 
49  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
50  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
51 
55  {
56  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
57  return false;
58  }
59 
60  int unknownSetting =
61  gCoreContext->GetNumSetting("VideoListUnknownFiletypes", 0);
62  if (unknownSetting == 1)
64 
65  int autoMetaSetting =
66  gCoreContext->GetNumSetting("mythvideo.AutoMetaDataScan", 1);
67  if (autoMetaSetting == 1)
69 
70  int loadMetaSetting =
71  gCoreContext->GetNumSetting("VideoTreeLoadMetaData", 1);
72  if (loadMetaSetting == 1)
74 
75  int trailerSetting =
76  gCoreContext->GetNumSetting("mythvideo.TrailersRandomEnabled", 0);
77  if (trailerSetting == 1)
79 
80  m_trailerSpin->SetRange(0,100,1);
82  "mythvideo.TrailersRandomCount"));
83 
86  else
87  m_trailerSpin->SetVisible(false);
88 
89  connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
90  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
91 
92  connect(m_randomTrailerCheck, SIGNAL(valueChanged()),
93  SLOT(toggleTrailers()));
94 
96  tr("If set, this will enable a button "
97  "called \"Watch With Trailers\" which will "
98  "play a user-specified number of trailers "
99  "before the movie."));
100  m_trailerSpin->SetHelpText(tr("Number of trailers to play before a film."));
102  tr("If set, all files below the MythVideo "
103  "directory will be displayed unless their "
104  "extension is explicitly set to be ignored."));
106  tr("If set, every time a scan for new videos "
107  "is performed, a mass metadata update of the "
108  "collection will also occur."));
110  tr("If set along with Browse Files, this "
111  "will cause the Video List to load any known video meta"
112  "data from the database. Turning this off can greatly "
113  "speed up how long it takes to load the Video List tree."));
114  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
115  m_okButton->SetHelpText(tr("Save settings and Exit"));
116 
117  BuildFocusList();
118 
119  return true;
120 }
121 
123 {
124 }
125 
127 {
128  gCoreContext->SaveSetting("mythvideo.TrailersRandomCount",
130 
131  int listUnknownState = 0;
133  listUnknownState = 1;
134  gCoreContext->SaveSetting("VideoListUnknownFiletypes", listUnknownState);
135 
136  int autoMetaState = 0;
138  autoMetaState = 1;
139  gCoreContext->SaveSetting("mythvideo.AutoMetaDataScan", autoMetaState);
140 
141  int loadMetaState = 0;
143  loadMetaState = 1;
144  gCoreContext->SaveSetting("VideoTreeLoadMetaData", loadMetaState);
145 
146  int trailerState = 0;
148  trailerState = 1;
149  gCoreContext->SaveSetting("mythvideo.TrailersRandomEnabled", trailerState);
150 
151  Close();
152 }
153 
154 bool MetadataSettings::keyPressEvent(QKeyEvent *event)
155 {
156  if (GetFocusWidget()->keyPressEvent(event))
157  return true;
158 
159  bool handled = false;
160 
161  if (!handled && MythScreenType::keyPressEvent(event))
162  handled = true;
163 
164  return handled;
165 }
166 
168 {
169  int checkstate = 0;
171  checkstate = 1;
172 
173  m_trailerSpin->SetVisible(checkstate);
174 }