MythTV master
setupwizard_video.cpp
Go to the documentation of this file.
1// Qt
2#include <QFileInfo>
3#include <QString>
4#include <QVariant>
5
6// MythTV
15
16// MythFrontend
17#include "setupwizard_audio.h"
18#include "setupwizard_general.h"
19#include "setupwizard_video.h"
20
22 QString("/samples/video/?sample=HD");
24 QString("/samples/video/?sample=SD");
26 QString("mythtv_video_test_HD_19000Kbps_H264.mkv");
28 QString("mythtv_video_test_SD_6000Kbps_H264.mkv");
29
31 MythScreenType *general,
32 MythScreenType *audio, const char *name)
33 : MythScreenType(parent, name),
34 m_generalScreen(general), m_audioScreen(audio)
35{
36 m_popupStack = GetMythMainWindow()->GetStack("popup stack");
37
39}
40
42{
43 // Load the theme for this screen
44 bool foundtheme = LoadWindowFromXML("config-ui.xml", "videowizard", this);
45 if (!foundtheme)
46 return false;
47
49 dynamic_cast<MythUIButtonList *> (GetChild("playbackprofiles"));
50
51 m_testSDButton = dynamic_cast<MythUIButton *> (GetChild("testsd"));
52 m_testHDButton = dynamic_cast<MythUIButton *> (GetChild("testhd"));
53
54 m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
55 m_prevButton = dynamic_cast<MythUIButton *> (GetChild("previous"));
56
59 {
60 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
61 return false;
62 }
63
64 m_playbackProfileButtonList->SetHelpText( tr("Select from one of the "
65 "preconfigured playback profiles. When "
66 "satisfied, you can test Standard Definition "
67 "and High Definition playback with the selected "
68 "profile before moving on.") );
69 m_testSDButton->SetHelpText( tr("Test your playback settings with Standard "
70 "Definition content. (480p)") );
71 m_testHDButton->SetHelpText( tr("Test your playback settings with High "
72 "Definition content (1080p).") );
73 m_nextButton->SetHelpText( tr("Save these changes and move on to the "
74 "next configuration step.") );
75 m_prevButton->SetHelpText(tr("Return to the previous configuration step."));
76
81
83 loadData();
84
85 return true;
86}
87
89{
91}
92
94{
96
97 for (const auto & prof : std::as_const(profiles))
98 {
100 item->SetData(prof);
101 }
102
104 if (!currentpbp.isEmpty())
105 {
109 }
110}
111
113{
114 save();
115
116 if (m_audioScreen)
117 {
119 m_audioScreen = nullptr;
120 }
121
122 if (m_generalScreen)
123 {
125 m_generalScreen = nullptr;
126 }
127
128 Close();
129}
130
132{
133 QString desiredpbp =
136}
137
139{
140 Close();
141}
142
144{
145 if (GetFocusWidget()->keyPressEvent(event))
146 return true;
147
148 bool handled = false;
149
151 handled = true;
152
153 return handled;
154}
155
157{
158 QString sdtestfile = StorageGroup::generate_file_url("Temp",
161 QString desiredpbp =
163 QString desc = tr("A short test of your system's playback of "
164 "Standard Definition content with the %1 profile.")
165 .arg(desiredpbp);
166 QString title = tr("Standard Definition Playback Test");
167
168 if (!RemoteFile::Exists(sdtestfile))
169 {
171 QString url = gCoreContext->GetSetting("ServicesRepositoryURL",
172 "https://services.mythtv.org");
174 }
175 else
176 {
177 playVideoTest(desc, title, sdtestfile);
178 }
179}
180
182{
183 QString hdtestfile = StorageGroup::generate_file_url("Temp",
186 QString desiredpbp =
188 QString desc = tr("A short test of your system's playback of "
189 "High Definition content with the %1 profile.")
190 .arg(desiredpbp);
191 QString title = tr("High Definition Playback Test");
192
193 if (!RemoteFile::Exists(hdtestfile))
194 {
196 QString url = gCoreContext->GetSetting("ServicesRepositoryURL",
197 "https://services.mythtv.org");
199 }
200 else
201 {
202 playVideoTest(desc, title, hdtestfile);
203 }
204}
205
206void VideoSetupWizard::playVideoTest(const QString& desc, const QString& title, const QString& file)
207{
208 QString desiredpbp =
211
213 GetMythMainWindow()->HandleMedia("Internal", file, desc, title);
215}
216
217void VideoSetupWizard::DownloadSample(const QString& url, const QString& dest)
218{
220 m_downloadFile = RemoteDownloadFile(url, "Temp", dest);
221}
222
224{
225 QString message = tr("Downloading Video Sample...");
227 m_popupStack, "sampledownloadprogressdialog");
228
230 {
232 }
233 else
234 {
235 delete m_progressDialog;
236 m_progressDialog = nullptr;
237 }
238}
239
241{
242 if (e->type() == MythEvent::kMythEventMessage)
243 {
244 auto *me = dynamic_cast<MythEvent *>(e);
245 if (me == nullptr)
246 return;
247
248 QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
249 if (tokens.isEmpty())
250 return;
251
252 if (tokens[0] == "DOWNLOAD_FILE")
253 {
254 QStringList args = me->ExtraDataList();
255 if ((tokens.size() != 2) ||
256 (args[1] != m_downloadFile))
257 return;
258
259 if (tokens[1] == "UPDATE")
260 {
261 QString message = tr("Downloading Video Sample...\n"
262 "(%1 of %2 MB)")
263 .arg(QString::number(args[2].toInt() / 1024.0 / 1024.0, 'f', 2),
264 QString::number(args[3].toInt() / 1024.0 / 1024.0, 'f', 2));
266 m_progressDialog->SetTotal(args[3].toInt());
267 m_progressDialog->SetProgress(args[2].toInt());
268 }
269 else if (tokens[1] == "FINISHED")
270 {
271 int fileSize = args[2].toInt();
272 int errorCode = args[4].toInt();
273
276
277 if ((m_downloadFile.startsWith("myth://")))
278 {
279 if ((errorCode == 0) &&
280 (fileSize > 0))
281 {
283 testHDVideo();
285 testSDVideo();
286 }
287 else
288 {
289 ShowOkPopup(tr("Error downloading sample to backend."));
290 }
291 }
292 }
293 }
294 }
295}
QString GetHostName(void)
QString GetSetting(const QString &key, const QString &defaultval="")
QString GetMasterHostName(void)
This class is used as a container for messages.
Definition: mythevent.h:17
const QString & Message() const
Definition: mythevent.h:65
static const Type kMythEventMessage
Definition: mythevent.h:79
MythScreenStack * GetStack(const QString &Stackname)
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
void addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void Close()
QString GetText(const QString &name="") const
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
MythUIButtonListItem * GetItemCurrent() const
void SetItemCurrent(MythUIButtonListItem *item)
MythUIButtonListItem * GetItemByData(const QVariant &data)
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
bool Create(void) override
void SetProgress(uint count)
void SetMessage(const QString &message)
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 QString GetDefaultProfileName(const QString &HostName)
static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
static QStringList GetProfiles(const QString &HostName)
static bool Exists(const QString &url, struct stat *fileinfo)
Definition: remotefile.cpp:461
static QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
bool Create(void) override
MythUIProgressDialog * m_progressDialog
void playVideoTest(const QString &desc, const QString &title, const QString &file)
MythScreenType * m_audioScreen
MythScreenType * m_generalScreen
MythUIButtonList * m_playbackProfileButtonList
void customEvent(QEvent *e) override
MythUIButton * m_testHDButton
~VideoSetupWizard() override
MythUIButton * m_nextButton
MythUIButton * m_testSDButton
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void DownloadSample(const QString &url, const QString &dest)
MythScreenStack * m_popupStack
MythUIButton * m_prevButton
VideoSetupWizard(MythScreenStack *parent, MythScreenType *general, MythScreenType *audio, const char *name=nullptr)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
QString RemoteDownloadFile(const QString &url, const QString &storageGroup, const QString &filename)
Definition: remoteutil.cpp:609
const QString VIDEO_SAMPLE_HD_LOCATION
const QString VIDEO_SAMPLE_SD_LOCATION
const QString VIDEO_SAMPLE_HD_FILENAME
const QString VIDEO_SAMPLE_SD_FILENAME