diff --git a/src/video/channel.cpp b/src/video/channel.cpp index 70e87ac4675d59215968b2b28852c09c1ee6dc2b..2fe55ce7acddf3fd933dd79e010924c0b3d99404 100644 --- a/src/video/channel.cpp +++ b/src/video/channel.cpp @@ -19,6 +19,7 @@ //Ring #include "resolution.h" +#include "rate.h" #include "device.h" #include "../dbus/videomanager.h" #include "../private/videochannel_p.h" @@ -81,7 +82,7 @@ bool Video::Channel::setActiveResolution(int idx) bool Video::Channel::setActiveResolution(Video::Resolution* res) { if ((!res) || d_ptr->m_lValidResolutions.indexOf(res) == -1 || res->name().isEmpty()) { - qWarning() << "Invalid active resolution" << (res?res->name():"NULL"); + qWarning() << "Invalid active resolution: " << (res?res->name():"NULL"); return false; } @@ -93,6 +94,23 @@ bool Video::Channel::setActiveResolution(Video::Resolution* res) { return true; } +bool Video::Channel::setActiveMode(int resIndex, int rateIndex) { + if (resIndex < 0 || resIndex >= d_ptr->m_lValidResolutions.size()) return false; + auto res = d_ptr->m_lValidResolutions[resIndex]; + if (rateIndex < 0 || rateIndex >= res->validRates().size()) return false; + auto rate = res->validRates()[rateIndex]; + + if (d_ptr->m_pCurrentResolution == res && + res->activeRate() == rate) { + qWarning() << "Mode already set: " << (res ? res->name() : "NULL") << (rate ? rate->name() : "NULL"); + return false; + } + + d_ptr->m_pCurrentResolution = res; + d_ptr->m_pCurrentResolution->setActiveRate(rate); + return true; +} + Video::Resolution* Video::Channel::activeResolution() { //If it is the current device, then there is "current" resolution diff --git a/src/video/channel.h b/src/video/channel.h index 257f805d635ae696841d5e2b4115c650db61cc54..70d3b6a79fb9ae508b175b9f8fb963cde4d782b6 100644 --- a/src/video/channel.h +++ b/src/video/channel.h @@ -25,6 +25,7 @@ //Ring namespace Video { class Resolution; + class Rate; class Device; } class VideoChannelPrivate; @@ -46,6 +47,8 @@ public: bool setActiveResolution(Video::Resolution* res); bool setActiveResolution(int idx); + bool setActiveMode(int resIndex, int rateIndex); + //Model virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override; diff --git a/src/video/resolution.cpp b/src/video/resolution.cpp index 255315e2fde7abbbeffb1e41380f16120ed0cf6f..434fc6f736ed4e1a5a1ade36ac2e0e0c48b97293 100644 --- a/src/video/resolution.cpp +++ b/src/video/resolution.cpp @@ -89,7 +89,7 @@ const QList<Video::Rate*> Video::Resolution::validRates() const { bool Video::Resolution::setActiveRate(Video::Rate* rate) { if (!rate || (d_ptr->m_lValidRates.indexOf(rate) == -1)) { - qWarning() << "Trying to set an invalid rate" << rate; + qWarning() << "Trying to set an invalid rate: " << rate->name(); return false; }