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
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
149bool GrabberSettings::keyPressEvent(QKeyEvent *event)
150{
151 if (GetFocusWidget()->keyPressEvent(event))
152 return true;
153
154 return MythScreenType::keyPressEvent(event);
155}
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
GrabberList m_movieGrabberList
GrabberList m_gameGrabberList
MythUIButton * m_okButton
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
MythUIButtonList * m_gameGrabberButtonList
MythUICheckBox * m_dailyUpdatesCheck
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool Create(void) override
GrabberList m_tvGrabberList
MythUIButtonList * m_tvGrabberButtonList
MythUIButtonList * m_movieGrabberButtonList
MythUIButton * m_cancelButton
static GrabberList GetList(bool refresh=false)
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
int GetNumSetting(const QString &key, int defaultval=0)
void LoadInBackground(const QString &message="")
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void Close()
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
void SetValueByData(const QVariant &data)
QVariant GetDataValue() const
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
void SetHelpText(const QString &text)
Definition: mythuitype.h:177
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:138
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
@ kGrabberMovie
@ kGrabberTelevision
@ kGrabberGame
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15