Support Events for Grabbers generically

This commit is contained in:
Lord-Grey
2023-11-09 18:14:26 +01:00
parent 77b5bb633d
commit c3daeef077
8 changed files with 25 additions and 15 deletions

View File

@@ -23,3 +23,8 @@ endif(UNIX)
target_include_directories(events PUBLIC
${CURRENT_HEADER_DIR}
)
target_link_libraries(events
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
)

View File

@@ -2,8 +2,6 @@
#include <grabber/VideoWrapper.h>
#include <events/EventHandler.h>
// qt includes
#include <QTimer>
@@ -24,8 +22,6 @@ VideoWrapper::VideoWrapper()
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
QObject::connect(EventHandler::getInstance(), &EventHandler::signalEvent, this, &VideoWrapper::handleEvent);
}
VideoWrapper::~VideoWrapper()
@@ -44,11 +40,6 @@ void VideoWrapper::stop()
GrabberWrapper::stop();
}
void VideoWrapper::handleEvent(Event event)
{
_grabber.handleEvent(event);
}
void VideoWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{
if(type == settings::V4L2 && _grabberName.startsWith("V4L2"))

View File

@@ -5,6 +5,7 @@
// utils includes
#include <utils/GlobalSignals.h>
#include <events/EventHandler.h>
// qt
#include <QTimer>
@@ -49,6 +50,8 @@ GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, i
// listen for source requests
connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest);
QObject::connect(EventHandler::getInstance(), &EventHandler::signalEvent, this, &GrabberWrapper::handleEvent);
}
GrabberWrapper::~GrabberWrapper()
@@ -83,6 +86,11 @@ void GrabberWrapper::stop()
}
}
void GrabberWrapper::handleEvent(Event event)
{
_ggrabber->handleEvent(event);
}
bool GrabberWrapper::isActive() const
{
return _timer->isActive();