MythTV  master
setupwizard_video.cpp
Go to the documentation of this file.
1 // qt
2 #include <QString>
3 #include <QVariant>
4 #include <QFileInfo>
5 
6 // myth
7 #include "mythcontext.h"
8 #include "mythdbcon.h"
9 #include "mythdirs.h"
10 #include "mythprogressdialog.h"
11 #include "mythcoreutil.h"
12 #include "videoutils.h"
13 #include "remotefile.h"
14 
15 #include "setupwizard_general.h"
16 #include "setupwizard_audio.h"
17 #include "setupwizard_video.h"
18 
19 const QString VIDEO_SAMPLE_HD_LOCATION =
20  QString("http://services.mythtv.org/samples/video/?sample=HD");
21 const QString VIDEO_SAMPLE_SD_LOCATION =
22  QString("http://services.mythtv.org/samples/video/?sample=SD");
23 const QString VIDEO_SAMPLE_HD_FILENAME =
24  QString("mythtv_video_test_HD_19000Kbps_H264.mkv");
25 const QString VIDEO_SAMPLE_SD_FILENAME =
26  QString("mythtv_video_test_SD_6000Kbps_H264.mkv");
27 
29  MythScreenType *general,
30  MythScreenType *audio, const char *name)
31  : MythScreenType(parent, name),
32  m_generalScreen(general), m_audioScreen(audio)
33 {
34  m_popupStack = GetMythMainWindow()->GetStack("popup stack");
35 
37 }
38 
40 {
41  // Load the theme for this screen
42  bool foundtheme = LoadWindowFromXML("config-ui.xml", "videowizard", this);
43  if (!foundtheme)
44  return false;
45 
47  dynamic_cast<MythUIButtonList *> (GetChild("playbackprofiles"));
48 
49  m_testSDButton = dynamic_cast<MythUIButton *> (GetChild("testsd"));
50  m_testHDButton = dynamic_cast<MythUIButton *> (GetChild("testhd"));
51 
52  m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
53  m_prevButton = dynamic_cast<MythUIButton *> (GetChild("previous"));
54 
57  {
58  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
59  return false;
60  }
61 
62  m_playbackProfileButtonList->SetHelpText( tr("Select from one of the "
63  "preconfigured playback profiles. When "
64  "satisfied, you can test Standard Definition "
65  "and High Definition playback with the selected "
66  "profile before moving on.") );
67  m_testSDButton->SetHelpText( tr("Test your playback settings with Standard "
68  "Definition content. (480p)") );
69  m_testHDButton->SetHelpText( tr("Test your playback settings with High "
70  "Definition content (1080p).") );
71  m_nextButton->SetHelpText( tr("Save these changes and move on to the "
72  "next configuration step.") );
73  m_prevButton->SetHelpText(tr("Return to the previous configuration step."));
74 
75  connect(m_testSDButton, SIGNAL(Clicked()), this, SLOT(testSDVideo()));
76  connect(m_testHDButton, SIGNAL(Clicked()), this, SLOT(testHDVideo()));
77  connect(m_nextButton, SIGNAL(Clicked()), this, SLOT(slotNext()));
78  connect(m_prevButton, SIGNAL(Clicked()), this, SLOT(slotPrevious()));
79 
81  loadData();
82 
83  return true;
84 }
85 
87 {
89 }
90 
92 {
94 
95  for (QStringList::const_iterator i = profiles.begin();
96  i != profiles.end(); ++i)
97  {
99  item->SetData(*i);
100  }
101 
103  if (!currentpbp.isEmpty())
104  {
105  MythUIButtonListItem *set =
108  }
109 }
110 
112 {
113  save();
114 
115  if (m_audioScreen)
116  {
117  m_audioScreen->Close();
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 
142 bool VideoSetupWizard::keyPressEvent(QKeyEvent *event)
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 = 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  {
171  }
172  else
173  playVideoTest(desc, title, sdtestfile);
174 }
175 
177 {
178  QString hdtestfile = generate_file_url("Temp",
181  QString desiredpbp =
183  QString desc = tr("A short test of your system's playback of "
184  "High Definition content with the %1 profile.")
185  .arg(desiredpbp);
186  QString title = tr("High Definition Playback Test");
187 
188  if (!RemoteFile::Exists(hdtestfile))
189  {
192  }
193  else
194  playVideoTest(desc, title, hdtestfile);
195 }
196 
197 void VideoSetupWizard::playVideoTest(const QString& desc, const QString& title, const QString& file)
198 {
199  QString desiredpbp =
202 
204  GetMythMainWindow()->HandleMedia("Internal", file, desc, title);
206 }
207 
208 void VideoSetupWizard::DownloadSample(const QString& url, const QString& dest)
209 {
211  m_downloadFile = RemoteDownloadFile(url, "Temp", dest);
212 }
213 
215 {
216  QString message = tr("Downloading Video Sample...");
218  m_popupStack, "sampledownloadprogressdialog");
219 
220  if (m_progressDialog->Create())
221  {
223  }
224  else
225  {
226  delete m_progressDialog;
227  m_progressDialog = nullptr;
228  }
229 }
230 
232 {
233  if (e->type() == MythEvent::MythEventMessage)
234  {
235  auto *me = dynamic_cast<MythEvent *>(e);
236  if (me == nullptr)
237  return;
238 
239 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
240  QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);
241 #else
242  QStringList tokens = me->Message().split(" ", Qt::SkipEmptyParts);
243 #endif
244  if (tokens.isEmpty())
245  return;
246 
247  if (tokens[0] == "DOWNLOAD_FILE")
248  {
249  QStringList args = me->ExtraDataList();
250  if ((tokens.size() != 2) ||
251  (args[1] != m_downloadFile))
252  return;
253 
254  if (tokens[1] == "UPDATE")
255  {
256  QString message = tr("Downloading Video Sample...\n"
257  "(%1 of %2 MB)")
258  .arg(QString::number(args[2].toInt() / 1024.0 / 1024.0, 'f', 2))
259  .arg(QString::number(args[3].toInt() / 1024.0 / 1024.0, 'f', 2));
260  m_progressDialog->SetMessage(message);
261  m_progressDialog->SetTotal(args[3].toInt());
262  m_progressDialog->SetProgress(args[2].toInt());
263  }
264  else if (tokens[1] == "FINISHED")
265  {
266  int fileSize = args[2].toInt();
267  int errorCode = args[4].toInt();
268 
269  if (m_progressDialog)
271 
272  QFileInfo file(m_downloadFile);
273  if ((m_downloadFile.startsWith("myth://")))
274  {
275  if ((errorCode == 0) &&
276  (fileSize > 0))
277  {
279  testHDVideo();
280  else if (m_testType == ttStandardDefinition)
281  testSDVideo();
282  }
283  else
284  {
285  ShowOkPopup(tr("Error downloading sample to backend."));
286  }
287  }
288  }
289  }
290  }
291 }
VideoSetupWizard::m_generalScreen
MythScreenType * m_generalScreen
Definition: setupwizard_video.h:48
VideoSetupWizard::~VideoSetupWizard
~VideoSetupWizard() override
Definition: setupwizard_video.cpp:86
build_compdb.args
args
Definition: build_compdb.py:11
MythUIProgressDialog::Create
bool Create(void) override
Definition: mythprogressdialog.cpp:130
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1417
generate_file_url
QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
Definition: videoutils.h:65
VIDEO_SAMPLE_HD_LOCATION
const QString VIDEO_SAMPLE_HD_LOCATION
Definition: setupwizard_video.cpp:19
build_compdb.dest
dest
Definition: build_compdb.py:9
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:73
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
MythCoreContext::GetMasterHostName
QString GetMasterHostName(void)
Definition: mythcorecontext.cpp:825
VideoSetupWizard::playVideoTest
void playVideoTest(const QString &desc, const QString &title, const QString &file)
Definition: setupwizard_video.cpp:197
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:550
VideoSetupWizard::ttHighDefinition
@ ttHighDefinition
Definition: setupwizard_video.h:41
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
RemoteFile::Exists
static bool Exists(const QString &url, struct stat *fileinfo)
Definition: remotefile.cpp:462
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
VideoSetupWizard::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: setupwizard_video.cpp:142
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:130
VideoSetupWizard::testSDVideo
void testSDVideo(void)
Definition: setupwizard_video.cpp:155
VideoSetupWizard::initProgressDialog
void initProgressDialog()
Definition: setupwizard_video.cpp:214
VIDEO_SAMPLE_HD_FILENAME
const QString VIDEO_SAMPLE_HD_FILENAME
Definition: setupwizard_video.cpp:23
VIDEO_SAMPLE_SD_FILENAME
const QString VIDEO_SAMPLE_SD_FILENAME
Definition: setupwizard_video.cpp:25
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
mythcoreutil.h
VideoSetupWizard::Create
bool Create(void) override
Definition: setupwizard_video.cpp:39
setupwizard_general.h
MythScreenStack
Definition: mythscreenstack.h:15
mythdbcon.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
VideoSetupWizard::save
void save(void)
Definition: setupwizard_video.cpp:130
build_compdb.file
file
Definition: build_compdb.py:55
mythdirs.h
MythUIProgressDialog::SetMessage
void SetMessage(const QString &message)
Definition: mythprogressdialog.cpp:205
setupwizard_video.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:309
mythprogressdialog.h
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
VideoSetupWizard::customEvent
void customEvent(QEvent *e) override
Definition: setupwizard_video.cpp:231
VIDEO_SAMPLE_SD_LOCATION
const QString VIDEO_SAMPLE_SD_LOCATION
Definition: setupwizard_video.cpp:21
MythUIButtonList::GetItemByData
MythUIButtonListItem * GetItemByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1684
VideoSetupWizard::ttStandardDefinition
@ ttStandardDefinition
Definition: setupwizard_video.h:42
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
VideoSetupWizard::m_downloadFile
QString m_downloadFile
Definition: setupwizard_video.h:45
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
MythUIButtonListItem
Definition: mythuibuttonlist.h:27
VideoDisplayProfile::SetDefaultProfileName
static void SetDefaultProfileName(const QString &ProfileName, const QString &HostName)
Definition: videodisplayprofile.cpp:962
VideoSetupWizard::m_playbackProfileButtonList
MythUIButtonList * m_playbackProfileButtonList
Definition: setupwizard_video.h:51
remotefile.h
MythUIProgressDialog
Definition: mythprogressdialog.h:59
MythUIProgressDialog::SetProgress
void SetProgress(uint count)
Definition: mythprogressdialog.cpp:199
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:150
VideoSetupWizard::slotPrevious
void slotPrevious(void)
Definition: setupwizard_video.cpp:137
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
VideoSetupWizard::m_progressDialog
MythUIProgressDialog * m_progressDialog
Definition: setupwizard_video.h:53
VideoSetupWizard::VideoSetupWizard
VideoSetupWizard(MythScreenStack *parent, MythScreenType *general, MythScreenType *audio, const char *name=nullptr)
Definition: setupwizard_video.cpp:28
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
setupwizard_audio.h
VideoDisplayProfile::GetProfiles
static QStringList GetProfiles(const QString &HostName)
Definition: videodisplayprofile.cpp:916
VideoSetupWizard::m_nextButton
MythUIButton * m_nextButton
Definition: setupwizard_video.h:58
MythUIButtonListItem::GetText
QString GetText(const QString &name="") const
Definition: mythuibuttonlist.cpp:3313
VideoSetupWizard::m_testType
TestType m_testType
Definition: setupwizard_video.h:46
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
VideoSetupWizard::m_prevButton
MythUIButton * m_prevButton
Definition: setupwizard_video.h:59
MythMainWindow::HandleMedia
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="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Definition: mythmainwindow.cpp:1491
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
MythUIProgressDialog::SetTotal
void SetTotal(uint total)
Definition: mythprogressdialog.cpp:193
mythcontext.h
VideoSetupWizard::slotNext
void slotNext(void)
Definition: setupwizard_video.cpp:111
VideoSetupWizard::testHDVideo
void testHDVideo(void)
Definition: setupwizard_video.cpp:176
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:107
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:856
VideoSetupWizard::m_testSDButton
MythUIButton * m_testSDButton
Definition: setupwizard_video.h:55
VideoSetupWizard::loadData
void loadData(void)
Definition: setupwizard_video.cpp:91
VideoSetupWizard::DownloadSample
void DownloadSample(const QString &url, const QString &dest)
Definition: setupwizard_video.cpp:208
VideoSetupWizard::m_testHDButton
MythUIButton * m_testHDButton
Definition: setupwizard_video.h:56
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:143
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:49
RemoteDownloadFile
QString RemoteDownloadFile(const QString &url, const QString &storageGroup, const QString &filename)
Definition: mythcoreutil.cpp:298
VideoSetupWizard::m_audioScreen
MythScreenType * m_audioScreen
Definition: setupwizard_video.h:49
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55
VideoDisplayProfile::GetDefaultProfileName
static QString GetDefaultProfileName(const QString &HostName)
Definition: videodisplayprofile.cpp:936
videoutils.h
VideoSetupWizard::m_popupStack
MythScreenStack * m_popupStack
Definition: setupwizard_video.h:52