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
14
15// MythFrontend
16#include "setupwizard_audio.h"
17#include "setupwizard_general.h"
18#include "setupwizard_video.h"
19
21 QString("/samples/video/?sample=HD");
23 QString("/samples/video/?sample=SD");
25 QString("mythtv_video_test_HD_19000Kbps_H264.mkv");
27 QString("mythtv_video_test_SD_6000Kbps_H264.mkv");
28
30 MythScreenType *general,
31 MythScreenType *audio, const char *name)
32 : MythScreenType(parent, name),
33 m_generalScreen(general), m_audioScreen(audio)
34{
35 m_popupStack = GetMythMainWindow()->GetStack("popup stack");
36
38}
39
41{
42 // Load the theme for this screen
43 bool foundtheme = LoadWindowFromXML("config-ui.xml", "videowizard", this);
44 if (!foundtheme)
45 return false;
46
48 dynamic_cast<MythUIButtonList *> (GetChild("playbackprofiles"));
49
50 m_testSDButton = dynamic_cast<MythUIButton *> (GetChild("testsd"));
51 m_testHDButton = dynamic_cast<MythUIButton *> (GetChild("testhd"));
52
53 m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
54 m_prevButton = dynamic_cast<MythUIButton *> (GetChild("previous"));
55
58 {
59 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
60 return false;
61 }
62
63 m_playbackProfileButtonList->SetHelpText( tr("Select from one of the "
64 "preconfigured playback profiles. When "
65 "satisfied, you can test Standard Definition "
66 "and High Definition playback with the selected "
67 "profile before moving on.") );
68 m_testSDButton->SetHelpText( tr("Test your playback settings with Standard "
69 "Definition content. (480p)") );
70 m_testHDButton->SetHelpText( tr("Test your playback settings with High "
71 "Definition content (1080p).") );
72 m_nextButton->SetHelpText( tr("Save these changes and move on to the "
73 "next configuration step.") );
74 m_prevButton->SetHelpText(tr("Return to the previous configuration step."));
75
80
82 loadData();
83
84 return true;
85}
86
88{
90}
91
93{
95
96 for (const auto & prof : std::as_const(profiles))
97 {
99 item->SetData(prof);
100 }
101
103 if (!currentpbp.isEmpty())
104 {
108 }
109}
110
112{
113 save();
114
115 if (m_audioScreen)
116 {
118 m_audioScreen = nullptr;
119 }
120
121 if (m_generalScreen)
122 {
124 m_generalScreen = nullptr;
125 }
126
127 Close();
128}
129
131{
132 QString desiredpbp =
135}
136
138{
139 Close();
140}
141
143{
144 if (GetFocusWidget()->keyPressEvent(event))
145 return true;
146
147 bool handled = false;
148
150 handled = true;
151
152 return handled;
153}
154
156{
157 QString sdtestfile = StorageGroup::generate_file_url("Temp",
160 QString desiredpbp =
162 QString desc = tr("A short test of your system's playback of "
163 "Standard Definition content with the %1 profile.")
164 .arg(desiredpbp);
165 QString title = tr("Standard Definition Playback Test");
166
167 if (!RemoteFile::Exists(sdtestfile))
168 {
170 QString url = gCoreContext->GetSetting("ServicesRepositoryURL",
171 "https://services.mythtv.org");
173 }
174 else
175 {
176 playVideoTest(desc, title, sdtestfile);
177 }
178}
179
181{
182 QString hdtestfile = StorageGroup::generate_file_url("Temp",
185 QString desiredpbp =
187 QString desc = tr("A short test of your system's playback of "
188 "High Definition content with the %1 profile.")
189 .arg(desiredpbp);
190 QString title = tr("High Definition Playback Test");
191
192 if (!RemoteFile::Exists(hdtestfile))
193 {
195 QString url = gCoreContext->GetSetting("ServicesRepositoryURL",
196 "https://services.mythtv.org");
198 }
199 else
200 {
201 playVideoTest(desc, title, hdtestfile);
202 }
203}
204
205void VideoSetupWizard::playVideoTest(const QString& desc, const QString& title, const QString& file)
206{
207 QString desiredpbp =
210
212 GetMythMainWindow()->HandleMedia("Internal", file, desc, title);
214}
215
216void VideoSetupWizard::DownloadSample(const QString& url, const QString& dest)
217{
219 m_downloadFile = RemoteDownloadFile(url, "Temp", dest);
220}
221
223{
224 QString message = tr("Downloading Video Sample...");
226 m_popupStack, "sampledownloadprogressdialog");
227
229 {
231 }
232 else
233 {
234 delete m_progressDialog;
235 m_progressDialog = nullptr;
236 }
237}
238
240{
241 if (e->type() == MythEvent::kMythEventMessage)
242 {
243 auto *me = dynamic_cast<MythEvent *>(e);
244 if (me == nullptr)
245 return;
246
247 QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
248 if (tokens.isEmpty())
249 return;
250
251 if (tokens[0] == "DOWNLOAD_FILE")
252 {
253 QStringList args = me->ExtraDataList();
254 if ((tokens.size() != 2) ||
255 (args[1] != m_downloadFile))
256 return;
257
258 if (tokens[1] == "UPDATE")
259 {
260 QString message = tr("Downloading Video Sample...\n"
261 "(%1 of %2 MB)")
262 .arg(QString::number(args[2].toInt() / 1024.0 / 1024.0, 'f', 2),
263 QString::number(args[3].toInt() / 1024.0 / 1024.0, 'f', 2));
265 m_progressDialog->SetTotal(args[3].toInt());
266 m_progressDialog->SetProgress(args[2].toInt());
267 }
268 else if (tokens[1] == "FINISHED")
269 {
270 int fileSize = args[2].toInt();
271 int errorCode = args[4].toInt();
272
275
276 if ((m_downloadFile.startsWith("myth://")))
277 {
278 if ((errorCode == 0) &&
279 (fileSize > 0))
280 {
282 testHDVideo();
284 testSDVideo();
285 }
286 else
287 {
288 ShowOkPopup(tr("Error downloading sample to backend."));
289 }
290 }
291 }
292 }
293 }
294}
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)
const QString VIDEO_SAMPLE_HD_LOCATION
const QString VIDEO_SAMPLE_SD_LOCATION
const QString VIDEO_SAMPLE_HD_FILENAME
const QString VIDEO_SAMPLE_SD_FILENAME