MythTV  master
grabbersettings.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 // Qt
4 #include <QString>
5 #include <QStringList>
6 
7 // MythTV
10 #include "libmythbase/mythdirs.h"
14 
15 // MythFrontend
16 #include "grabbersettings.h"
17 
18 // ---------------------------------------------------
19 
21 {
22  // Load the theme for this screen
23  bool foundtheme = LoadWindowFromXML("config-ui.xml", "grabbersettings", this);
24  if (!foundtheme)
25  return false;
26 
27  m_movieGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("moviegrabber"));
28  m_tvGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("tvgrabber"));
29  m_gameGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("gamegrabber"));
30 
31  m_dailyUpdatesCheck = dynamic_cast<MythUICheckBox *> (GetChild("dailyupdates"));
32 
33  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
34  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
35 
38  {
39  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
40  return false;
41  }
42 
43  m_movieGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
44  "information and artwork about movies."));
45  m_tvGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
46  "information and artwork about television."));
47  m_gameGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
48  "information and artwork about video games."));
49  m_okButton->SetHelpText(tr("Save your changes and close this window."));
50  m_cancelButton->SetHelpText(tr("Discard your changes and close this window."));
51 
52  m_dailyUpdatesCheck->SetHelpText(tr("If set, the backend will attempt to "
53  "perform artwork updates for recordings daily. When "
54  "new seasons begin to record, this will attempt to "
55  "provide you with fresh, relevant artwork while "
56  "preserving the artwork assigned to old recordings."));
57 
60 
62 
63  QString message = tr("Searching for data sources...");
64  LoadInBackground(message);
65 
66  return true;
67 }
68 
70 {
74 }
75 
77 {
78  for (const auto & grabber : std::as_const(m_movieGrabberList))
79  {
80  InfoMap map;
81  grabber.toMap(map);
83  grabber.GetName());
84  item->SetData(grabber.GetRelPath());
85  item->SetTextFromMap(map);
86  }
87 
88  m_movieGrabberList.clear();
89 
90  for (const auto & grabber: std::as_const(m_tvGrabberList))
91  {
92  InfoMap map;
93  grabber.toMap(map);
95  grabber.GetName());
96  item->SetData(grabber.GetRelPath());
97  item->SetTextFromMap(map);
98  }
99 
100  m_tvGrabberList.clear();
101 
102  for (const auto & grabber : std::as_const(m_gameGrabberList))
103  {
104  InfoMap map;
105  grabber.toMap(map);
107  grabber.GetName());
108  item->SetData(grabber.GetRelPath());
109  item->SetTextFromMap(map);
110  }
111 
112  m_gameGrabberList.clear();
113 
114  // TODO
115  // pull these values from MetaGrabberScript so we're not defining them in multiple locations
116  QString currentTVGrabber = gCoreContext->GetSetting("TelevisionGrabber",
117  "metadata/Television/ttvdb4.py");
118  QString currentMovieGrabber = gCoreContext->GetSetting("MovieGrabber",
119  "metadata/Movie/tmdb3.py");
120  QString currentGameGrabber = gCoreContext->GetSetting("mythgame.MetadataGrabber",
121  "metadata/Game/giantbomb.py");
122 
123  m_movieGrabberButtonList->SetValueByData(QVariant::fromValue(currentMovieGrabber));
124  m_tvGrabberButtonList->SetValueByData(QVariant::fromValue(currentTVGrabber));
125  m_gameGrabberButtonList->SetValueByData(QVariant::fromValue(currentGameGrabber));
126 
127  int updates =
128  gCoreContext->GetNumSetting("DailyArtworkUpdates", 0);
129  if (updates == 1)
131 }
132 
134 {
135  gCoreContext->SaveSettingOnHost("TelevisionGrabber", m_tvGrabberButtonList->GetDataValue().toString(), "");
136  gCoreContext->SaveSettingOnHost("MovieGrabber", m_movieGrabberButtonList->GetDataValue().toString(), "");
137  gCoreContext->SaveSetting("mythgame.MetadataGrabber", m_gameGrabberButtonList->GetDataValue().toString());
138 
139  int dailyupdatestate = 0;
141  dailyupdatestate = 1;
142  gCoreContext->SaveSettingOnHost("DailyArtworkUpdates",
143  QString::number(dailyupdatestate), "");
144 
145  Close();
146 }
147 
148 bool GrabberSettings::keyPressEvent(QKeyEvent *event)
149 {
150  if (GetFocusWidget()->keyPressEvent(event))
151  return true;
152 
153  return MythScreenType::keyPressEvent(event);
154 }
MythUIButton::Clicked
void Clicked()
GrabberSettings::Create
bool Create(void) override
Definition: grabbersettings.cpp:20
MythScreenType::LoadInBackground
void LoadInBackground(const QString &message="")
Definition: mythscreentype.cpp:283
GrabberSettings::m_gameGrabberButtonList
MythUIButtonList * m_gameGrabberButtonList
Definition: grabbersettings.h:36
GrabberSettings::m_dailyUpdatesCheck
MythUICheckBox * m_dailyUpdatesCheck
Definition: grabbersettings.h:38
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1566
kGrabberGame
@ kGrabberGame
Definition: metadatagrabber.h:25
MetaGrabberScript::GetList
static GrabberList GetList(bool refresh=false)
Definition: metadatagrabber.cpp:58
kGrabberMovie
@ kGrabberMovie
Definition: metadatagrabber.h:22
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:138
mythdbcon.h
grabbersettings.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
mythdirs.h
mythprogressdialog.h
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:110
mythsystemlegacy.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
kGrabberTelevision
@ kGrabberTelevision
Definition: metadatagrabber.h:23
GrabberSettings::m_okButton
MythUIButton * m_okButton
Definition: grabbersettings.h:40
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:203
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythUIButtonList::GetDataValue
QVariant GetDataValue() const
Definition: mythuibuttonlist.cpp:1643
GrabberSettings::m_movieGrabberButtonList
MythUIButtonList * m_movieGrabberButtonList
Definition: grabbersettings.h:34
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
GrabberSettings::m_tvGrabberList
GrabberList m_tvGrabberList
Definition: grabbersettings.h:31
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
GrabberSettings::Load
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
Definition: grabbersettings.cpp:69
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:401
mythcorecontext.h
GrabberSettings::m_gameGrabberList
GrabberList m_gameGrabberList
Definition: grabbersettings.h:32
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:687
GrabberSettings::m_tvGrabberButtonList
MythUIButtonList * m_tvGrabberButtonList
Definition: grabbersettings.h:35
GrabberSettings::slotSave
void slotSave(void)
Definition: grabbersettings.cpp:133
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:27
GrabberSettings::m_movieGrabberList
GrabberList m_movieGrabberList
Definition: grabbersettings.h:30
GrabberSettings::Init
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
Definition: grabbersettings.cpp:76
GrabberSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: grabbersettings.cpp:148
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:885
GrabberSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: grabbersettings.h:41
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
metadatacommon.h
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:895
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:902