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 using namespace std;
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 
25  m_trailerSpin =
26  dynamic_cast<MythUISpinBox *> (GetChild("trailernum"));
27 
28  m_unknownFileCheck =
29  dynamic_cast<MythUICheckBox *> (GetChild("unknownfilecheck"));
30  m_autoMetaUpdateCheck =
31  dynamic_cast<MythUICheckBox *> (GetChild("autometaupdatecheck"));
32  m_treeLoadsMetaCheck =
33  dynamic_cast<MythUICheckBox *> (GetChild("treeloadsmetacheck"));
34  m_randomTrailerCheck =
35  dynamic_cast<MythUICheckBox *> (GetChild("randomtrailercheck"));
36 
37  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
38  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
39 
40  if (!m_trailerSpin || !m_autoMetaUpdateCheck ||
41  !m_unknownFileCheck || !m_treeLoadsMetaCheck ||
42  !m_randomTrailerCheck ||!m_okButton || !m_cancelButton)
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)
51  m_unknownFileCheck->SetCheckState(MythUIStateType::Full);
52 
53  int autoMetaSetting =
54  gCoreContext->GetNumSetting("mythvideo.AutoMetaDataScan", 1);
55  if (autoMetaSetting == 1)
56  m_autoMetaUpdateCheck->SetCheckState(MythUIStateType::Full);
57 
58  int loadMetaSetting =
59  gCoreContext->GetNumSetting("VideoTreeLoadMetaData", 1);
60  if (loadMetaSetting == 1)
61  m_treeLoadsMetaCheck->SetCheckState(MythUIStateType::Full);
62 
63  int trailerSetting =
64  gCoreContext->GetNumSetting("mythvideo.TrailersRandomEnabled", 0);
65  if (trailerSetting == 1)
66  m_randomTrailerCheck->SetCheckState(MythUIStateType::Full);
67 
68  m_trailerSpin->SetRange(0,100,1);
69  m_trailerSpin->SetValue(gCoreContext->GetNumSetting(
70  "mythvideo.TrailersRandomCount"));
71 
72  if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
73  m_trailerSpin->SetVisible(true);
74  else
75  m_trailerSpin->SetVisible(false);
76 
77  connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
78  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
79 
80  connect(m_randomTrailerCheck, SIGNAL(valueChanged()),
81  SLOT(toggleTrailers()));
82 
83  m_randomTrailerCheck->SetHelpText(
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."));
89  m_unknownFileCheck->SetHelpText(
90  tr("If set, all files below the MythVideo "
91  "directory will be displayed unless their "
92  "extension is explicitly set to be ignored."));
93  m_autoMetaUpdateCheck->SetHelpText(
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."));
97  m_treeLoadsMetaCheck->SetHelpText(
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",
113  m_trailerSpin->GetValue());
114 
115  int listUnknownState = 0;
116  if (m_unknownFileCheck->GetCheckState() == MythUIStateType::Full)
117  listUnknownState = 1;
118  gCoreContext->SaveSetting("VideoListUnknownFiletypes", listUnknownState);
119 
120  int autoMetaState = 0;
121  if (m_autoMetaUpdateCheck->GetCheckState() == MythUIStateType::Full)
122  autoMetaState = 1;
123  gCoreContext->SaveSetting("mythvideo.AutoMetaDataScan", autoMetaState);
124 
125  int loadMetaState = 0;
126  if (m_treeLoadsMetaCheck->GetCheckState() == MythUIStateType::Full)
127  loadMetaState = 1;
128  gCoreContext->SaveSetting("VideoTreeLoadMetaData", loadMetaState);
129 
130  int trailerState = 0;
131  if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
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;
149  if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
150  checkstate = 1;
151 
152  m_trailerSpin->SetVisible(checkstate != 0);
153 }
void SaveSetting(const QString &key, int newValue)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
bool keyPressEvent(QKeyEvent *) override
Key event handler.
int GetNumSetting(const QString &key, int defaultval=0)
bool keyPressEvent(QKeyEvent *) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool Create(void) override