From bc05d531a37c37fd68a013fe5cc83b9c261f6531 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Sun, 22 Oct 2017 19:39:11 +0300 Subject: [PATCH] refactor(video): Add video settings interface --- CMakeLists.txt | 1 + src/persistence/settings.h | 36 ++++++++++++++++++------------------ src/video/ivideosettings.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 src/video/ivideosettings.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ac8bb1230..4c8050ff2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,6 +312,7 @@ set(${PROJECT_NAME}_SOURCES src/video/genericnetcamview.h src/video/groupnetcamview.cpp src/video/groupnetcamview.h + src/video/ivideosettings.h src/video/netcamview.cpp src/video/netcamview.h src/video/videoframe.cpp diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 6e243cd0b..162d0aa21 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -25,6 +25,7 @@ #include "src/core/icoresettings.h" #include "src/core/toxencrypt.h" #include "src/core/toxfile.h" +#include "src/video/ivideosettings.h" #include #include @@ -42,7 +43,7 @@ namespace Db { enum class syncType; } -class Settings : public QObject, public ICoreSettings, public IAudioSettings +class Settings : public QObject, public ICoreSettings, public IAudioSettings, public IVideoSettings { Q_OBJECT @@ -225,13 +226,6 @@ signals: void dbSyncTypeChanged(Db::syncType type); void blackListChanged(QStringList& blist); - // Video - void videoDevChanged(const QString& name); - void camVideoResChanged(const QRect& resolution); - void screenRegionChanged(const QRect& region); - void screenGrabbedChanged(bool enabled); - void camVideoFPSChanged(quint16 fps); - public: bool getMakeToxPortable() const; void setMakeToxPortable(bool newValue); @@ -379,20 +373,26 @@ public: SIGNAL_IMPL(Settings, enableTestSoundChanged, bool newValue) SIGNAL_IMPL(Settings, enableBackend2Changed, bool enabled) - QString getVideoDev() const; - void setVideoDev(const QString& deviceSpecifier); + QString getVideoDev() const override; + void setVideoDev(const QString& deviceSpecifier) override; - QRect getScreenRegion() const; - void setScreenRegion(const QRect& value); + QRect getScreenRegion() const override; + void setScreenRegion(const QRect& value) override; - bool getScreenGrabbed() const; - void setScreenGrabbed(bool value); + bool getScreenGrabbed() const override; + void setScreenGrabbed(bool value) override; - QRect getCamVideoRes() const; - void setCamVideoRes(QRect newValue); + QRect getCamVideoRes() const override; + void setCamVideoRes(QRect newValue) override; - unsigned short getCamVideoFPS() const; - void setCamVideoFPS(unsigned short newValue); + unsigned short getCamVideoFPS() const override; + void setCamVideoFPS(unsigned short newValue) override; + + SIGNAL_IMPL(Settings, videoDevChanged, const QString& device) + SIGNAL_IMPL(Settings, screenRegionChanged, const QRect& region) + SIGNAL_IMPL(Settings, screenGrabbedChanged, bool enabled) + SIGNAL_IMPL(Settings, camVideoResChanged, const QRect& region) + SIGNAL_IMPL(Settings, camVideoFPSChanged, unsigned short fps) bool isAnimationEnabled() const; void setAnimationEnabled(bool newValue); diff --git a/src/video/ivideosettings.h b/src/video/ivideosettings.h new file mode 100644 index 000000000..b01593120 --- /dev/null +++ b/src/video/ivideosettings.h @@ -0,0 +1,33 @@ +#ifndef I_VIDEO_SETTINGS_H +#define I_VIDEO_SETTINGS_H + +#include "src/model/interface.h" + +#include +#include + +class IVideoSettings { +public: + virtual QString getVideoDev() const = 0; + virtual void setVideoDev(const QString& deviceSpecifier) = 0; + + virtual QRect getScreenRegion() const = 0; + virtual void setScreenRegion(const QRect& value) = 0; + + virtual bool getScreenGrabbed() const = 0; + virtual void setScreenGrabbed(bool value) = 0; + + virtual QRect getCamVideoRes() const = 0; + virtual void setCamVideoRes(QRect newValue) = 0; + + virtual unsigned short getCamVideoFPS() const = 0; + virtual void setCamVideoFPS(unsigned short newValue) = 0; + + DECLARE_SIGNAL(videoDevChanged, const QString& device); + DECLARE_SIGNAL(screenRegionChanged, const QRect& region); + DECLARE_SIGNAL(screenGrabbedChanged, bool enabled); + DECLARE_SIGNAL(camVideoResChanged, const QRect& region); + DECLARE_SIGNAL(camVideoFPSChanged, unsigned short fps); +}; + +#endif // I_VIDEO_SETTINGS_H