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"
15 
16 // MythFrontend
17 #include "grabbersettings.h"
18 
19 // ---------------------------------------------------
20 
22 {
23  // Load the theme for this screen
24  bool foundtheme = LoadWindowFromXML("config-ui.xml", "grabbersettings", this);
25  if (!foundtheme)
26  return false;
27 
28  m_movieGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("moviegrabber"));
29  m_tvGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("tvgrabber"));
30  m_gameGrabberButtonList = dynamic_cast<MythUIButtonList *> (GetChild("gamegrabber"));
31 
32  m_dailyUpdatesCheck = dynamic_cast<MythUICheckBox *> (GetChild("dailyupdates"));
33 
34  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
35  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
36 
39  {
40  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
41  return false;
42  }
43 
44  m_movieGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
45  "information and artwork about movies."));
46  m_tvGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
47  "information and artwork about television."));
48  m_gameGrabberButtonList->SetHelpText(tr("Select a source to use when searching for "
49  "information and artwork about video games."));
50  m_okButton->SetHelpText(tr("Save your changes and close this window."));
51  m_cancelButton->SetHelpText(tr("Discard your changes and close this window."));
52 
53  m_dailyUpdatesCheck->SetHelpText(tr("If set, the backend will attempt to "
54  "perform artwork updates for recordings daily. When "
55  "new seasons begin to record, this will attempt to "
56  "provide you with fresh, relevant artwork while "
57  "preserving the artwork assigned to old recordings."));
58 
61 
63 
64  QString message = tr("Searching for data sources...");
65  LoadInBackground(message);
66 
67  return true;
68 }
69 
71 {
75 }
76 
78 {
79  for (const auto & grabber : std::as_const(m_movieGrabberList))
80  {
81  InfoMap map;
82  grabber.toMap(map);
84  grabber.GetName());
85  item->SetData(grabber.GetRelPath());
86  item->SetTextFromMap(map);
87  }
88 
89  m_movieGrabberList.clear();
90 
91  for (const auto & grabber: std::as_const(m_tvGrabberList))
92  {
93  InfoMap map;
94  grabber.toMap(map);
96  grabber.GetName());
97  item->SetData(grabber.GetRelPath());
98  item->SetTextFromMap(map);
99  }
100 
101  m_tvGrabberList.clear();
102 
103  for (const auto & grabber : std::as_const(m_gameGrabberList))
104  {
105  InfoMap map;
106  grabber.toMap(map);
108  grabber.GetName());
109  item->SetData(grabber.GetRelPath());
110  item->SetTextFromMap(map);
111  }
112 
113  m_gameGrabberList.clear();
114 
115  // TODO
116  // pull these values from MetaGrabberScript so we're not defining them in multiple locations
117  QString currentTVGrabber = gCoreContext->GetSetting("TelevisionGrabber",
118  "metadata/Television/ttvdb4.py");
119  QString currentMovieGrabber = gCoreContext->GetSetting("MovieGrabber",
120  "metadata/Movie/tmdb3.py");
121  QString currentGameGrabber = gCoreContext->GetSetting("mythgame.MetadataGrabber",
122  "metadata/Game/giantbomb.py");
123 
124  m_movieGrabberButtonList->SetValueByData(QVariant::fromValue(currentMovieGrabber));
125  m_tvGrabberButtonList->SetValueByData(QVariant::fromValue(currentTVGrabber));
126  m_gameGrabberButtonList->SetValueByData(QVariant::fromValue(currentGameGrabber));
127 
128  int updates =
129  gCoreContext->GetNumSetting("DailyArtworkUpdates", 0);
130  if (updates == 1)
132 }
133 
135 {
136  gCoreContext->SaveSettingOnHost("TelevisionGrabber", m_tvGrabberButtonList->GetDataValue().toString(), "");
137  gCoreContext->SaveSettingOnHost("MovieGrabber", m_movieGrabberButtonList->GetDataValue().toString(), "");
138  gCoreContext->SaveSetting("mythgame.MetadataGrabber", m_gameGrabberButtonList->GetDataValue().toString());
139 
140  int dailyupdatestate = 0;
142  dailyupdatestate = 1;
143  gCoreContext->SaveSettingOnHost("DailyArtworkUpdates",
144  QString::number(dailyupdatestate), "");
145 
146  Close();
147 }
148 
149 bool GrabberSettings::keyPressEvent(QKeyEvent *event)
150 {
151  if (GetFocusWidget()->keyPressEvent(event))
152  return true;
153 
154  return MythScreenType::keyPressEvent(event);
155 }
MythUIButton::Clicked
void Clicked()
GrabberSettings::Create
bool Create(void) override
Definition: grabbersettings.cpp:21
MythScreenType::LoadInBackground
void LoadInBackground(const QString &message="")
Definition: mythscreentype.cpp:284
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:384
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:111
mythsystemlegacy.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
kGrabberTelevision
@ kGrabberTelevision
Definition: metadatagrabber.h:23
mythlogging.h
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:204
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:57
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:918
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:70
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:402
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:701
GrabberSettings::m_tvGrabberButtonList
MythUIButtonList * m_tvGrabberButtonList
Definition: grabbersettings.h:35
GrabberSettings::slotSave
void slotSave(void)
Definition: grabbersettings.cpp:134
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:77
GrabberSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: grabbersettings.cpp:149
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:887
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:897
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:904