From 4636d7e4146a70195b33ba9a565f01e9ed43a521 Mon Sep 17 00:00:00 2001 From: Klaas de Waal Date: Wed, 14 Aug 2019 14:54:00 +0200 Subject: [PATCH] Check video source and capture card In mythtv-setup page Channel Editor, check that a video source is selected and that the selected video source is connected to a capture card before starting the Channel Scan dialog after pressing the Channel Scan button. Give a popup message when the checks fail. --- .../programs/mythtv-setup/channeleditor.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/mythtv/programs/mythtv-setup/channeleditor.cpp b/mythtv/programs/mythtv-setup/channeleditor.cpp index 290f8dd7c18..00ea0519d46 100644 --- a/mythtv/programs/mythtv-setup/channeleditor.cpp +++ b/mythtv/programs/mythtv-setup/channeleditor.cpp @@ -2,6 +2,7 @@ #include // MythTV +#include "mythcorecontext.h" #include "mythprogressdialog.h" #include "mythuibuttonlist.h" #include "channelsettings.h" @@ -508,6 +509,55 @@ void ChannelEditor::menu() void ChannelEditor::scan(void) { #ifdef USING_BACKEND + + // Check if we have a video source selected + uint cardid = 0; + if (m_sourceFilter < 1) + { + MythConfirmationDialog *md = ShowOkPopup(QObject::tr( + "Please select a video source. 'All' cannot be used. " + "If you do not have a video source then " + "create one in the 'Video sources' menu page.")); + WaitFor(md); + return; + } + + // Check that the video source is connected to a capture card + MSqlQuery query(MSqlQuery::InitCon()); + query.prepare( + "SELECT capturecard.cardid " + "FROM capturecard, videosource " + "WHERE capturecard.sourceid = videosource.sourceid AND " + " hostname = :HOSTNAME AND " + " capturecard.sourceid = :SOURCEID AND " + " capturecard.parentid = 0"); + + query.bindValue(":HOSTNAME", gCoreContext->GetHostName()); + query.bindValue(":SOURCEID", m_sourceFilter); + + if (!query.exec() || !query.isActive()) + { + MythDB::DBError("ChannelEditor::scan()", query); + return; + } + if (query.next()) + { + cardid = query.value(0).toUInt(); + } + + if (cardid < 1) + { + MythConfirmationDialog *md = ShowOkPopup(QObject::tr( + "No capture card!" + "\n" + "Please connect video source '%1' to a capture card " + "in the 'Input Connections' menu page.") + .arg(m_sourceFilterName)); + WaitFor(md); + return; + } + + // Create the dialog now that we have a video source and a capture card MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); StandardSettingDialog *ssd = new StandardSettingDialog(mainStack, "scanwizard",