[v4l2ucp] - Fix handling of special control flags
Hans de Goede
jwrdegoede at fedoraproject.org
Sat Mar 12 21:33:42 UTC 2011
commit e7e4914fc402cdb2e0d5e69fdb5175e19ca14aa0
Author: Hans de Goede <hdegoede at redhat.com>
Date: Sat Mar 12 22:37:14 2011 +0100
- Fix handling of special control flags
v4l2ucp-2.0.1-flags.patch | 217 +++++++++++++++++++++++++++++++++++++++++++++
v4l2ucp.spec | 7 ++-
2 files changed, 223 insertions(+), 1 deletions(-)
---
diff --git a/v4l2ucp-2.0.1-flags.patch b/v4l2ucp-2.0.1-flags.patch
new file mode 100644
index 0000000..a576bc3
--- /dev/null
+++ b/v4l2ucp-2.0.1-flags.patch
@@ -0,0 +1,217 @@
+--- v4l2ucp-2.0.1/src/mainWindow.cpp 2011-03-12 22:20:37.781578096 +0100
++++ v4l2ucp-2.0.1.new/src/mainWindow.cpp 2011-03-12 22:18:09.217435401 +0100
+@@ -249,16 +249,16 @@
+
+ switch(ctrl.type) {
+ case V4L2_CTRL_TYPE_INTEGER:
+- w = new V4L2IntegerControl(fd, ctrl, parent);
++ w = new V4L2IntegerControl(fd, ctrl, parent, this);
+ break;
+ case V4L2_CTRL_TYPE_BOOLEAN:
+- w = new V4L2BooleanControl(fd, ctrl, parent);
++ w = new V4L2BooleanControl(fd, ctrl, parent, this);
+ break;
+ case V4L2_CTRL_TYPE_MENU:
+- w = new V4L2MenuControl(fd, ctrl, parent);
++ w = new V4L2MenuControl(fd, ctrl, parent, this);
+ break;
+ case V4L2_CTRL_TYPE_BUTTON:
+- w = new V4L2ButtonControl(fd, ctrl, parent);
++ w = new V4L2ButtonControl(fd, ctrl, parent, this);
+ break;
+ case V4L2_CTRL_TYPE_INTEGER64:
+ case V4L2_CTRL_TYPE_CTRL_CLASS:
+@@ -274,7 +274,8 @@
+ }
+
+ layout->addWidget(w);
+- if(ctrl.flags & V4L2_CTRL_FLAG_GRABBED) {
++ if(ctrl.flags & (V4L2_CTRL_FLAG_GRABBED|V4L2_CTRL_FLAG_INACTIVE|
++ V4L2_CTRL_FLAG_READ_ONLY)) {
+ w->setEnabled(false);
+ }
+
+@@ -397,6 +398,11 @@
+ emit(updateNow());
+ }
+
++void MainWindow::updateAll()
++{
++ emit(updateNow());
++}
++
+ void MainWindow::startPreview()
+ {
+ if (previewProcess && previewProcess->state() != QProcess::NotRunning)
+--- v4l2ucp-2.0.1/src/mainWindow.h 2009-09-10 22:02:50.000000000 +0200
++++ v4l2ucp-2.0.1.new/src/mainWindow.h 2011-03-12 22:15:48.887189771 +0100
+@@ -49,6 +49,7 @@
+ public:
+ static MainWindow *openFile(const char *fileName);
+ ~MainWindow();
++ void updateAll();
+
+ private:
+ QMenu *updateMenu, *resetMenu;
+--- v4l2ucp-2.0.1/src/v4l2controls.cpp 2011-03-12 22:20:37.786578033 +0100
++++ v4l2ucp-2.0.1.new/src/v4l2controls.cpp 2011-03-12 22:20:25.456732180 +0100
+@@ -28,10 +28,11 @@
+ #include <QMessageBox>
+
+ #include "v4l2controls.h"
++#include "mainWindow.h"
+
+ V4L2Control::V4L2Control(int fd, const struct v4l2_queryctrl &ctrl,
+- QWidget *parent) :
+- QWidget(parent), cid(ctrl.id), default_value(ctrl.default_value)
++ QWidget *parent, MainWindow *mw) :
++ QWidget(parent), cid(ctrl.id), default_value(ctrl.default_value), mw(mw)
+ {
+ this->fd = fd;
+ strncpy(name, (const char *)ctrl.name, sizeof(name));
+@@ -49,7 +50,10 @@
+ msg.sprintf("Unable to set %s\n%s", name, strerror(errno));
+ QMessageBox::warning(this, "Unable to set control", msg, "OK");
+ }
+- updateStatus();
++ if(flags & V4L2_CTRL_FLAG_UPDATE)
++ mw->updateAll();
++ else
++ updateStatus();
+ }
+
+ void V4L2Control::updateStatus()
+@@ -73,7 +78,12 @@
+ strerror(errno));
+ QMessageBox::warning(this, "Unable to get control status", msg, "OK");
+ } else {
+- setEnabled(ctrl.flags == 0);
++ flags = ctrl.flags;
++ if(ctrl.flags & (V4L2_CTRL_FLAG_GRABBED|V4L2_CTRL_FLAG_INACTIVE|
++ V4L2_CTRL_FLAG_READ_ONLY))
++ setEnabled(false);
++ else
++ setEnabled(true);
+ }
+ }
+
+@@ -89,8 +99,8 @@
+ * V4L2IntegerControl
+ */
+ V4L2IntegerControl::V4L2IntegerControl
+- (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent) :
+- V4L2Control(fd, ctrl, parent),
++ (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw) :
++ V4L2Control(fd, ctrl, parent, mw),
+ minimum(ctrl.minimum), maximum(ctrl.maximum), step(ctrl.step)
+ {
+ int pageStep = (maximum-minimum)/10;
+@@ -170,8 +180,8 @@
+ * V4L2BooleanControl
+ */
+ V4L2BooleanControl::V4L2BooleanControl
+- (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent) :
+- V4L2Control(fd, ctrl, parent),
++ (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw) :
++ V4L2Control(fd, ctrl, parent, mw),
+ cb(new QCheckBox(this))
+ {
+ this->layout.addWidget(cb);
+@@ -193,8 +203,8 @@
+ * V4L2MenuControl
+ */
+ V4L2MenuControl::V4L2MenuControl
+- (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent) :
+- V4L2Control(fd, ctrl, parent)
++ (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw) :
++ V4L2Control(fd, ctrl, parent, mw)
+ {
+ cb = new QComboBox(this);
+ this->layout.addWidget(cb);
+@@ -239,8 +249,8 @@
+ * V4L2ButtonControl
+ */
+ V4L2ButtonControl::V4L2ButtonControl
+- (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent) :
+- V4L2Control(fd, ctrl, parent)
++ (int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw) :
++ V4L2Control(fd, ctrl, parent, mw)
+ {
+ QPushButton *pb = new QPushButton((const char *)ctrl.name, this);
+ this->layout.addWidget(pb);
+@@ -257,7 +267,12 @@
+ strerror(errno));
+ QMessageBox::warning(this, "Unable to get control status", msg, "OK");
+ } else {
+- setEnabled(ctrl.flags == 0);
++ flags = ctrl.flags;
++ if(ctrl.flags & (V4L2_CTRL_FLAG_GRABBED|V4L2_CTRL_FLAG_INACTIVE|
++ V4L2_CTRL_FLAG_READ_ONLY))
++ setEnabled(false);
++ else
++ setEnabled(true);
+ }
+ }
+
+--- v4l2ucp-2.0.1/src/v4l2controls.h 2009-06-20 14:28:12.000000000 +0200
++++ v4l2ucp-2.0.1.new/src/v4l2controls.h 2011-03-12 22:19:02.438770043 +0100
+@@ -27,6 +27,8 @@
+ #include <QComboBox>
+ #include <QLineEdit>
+
++class MainWindow;
++
+ class V4L2Control : public QWidget
+ {
+ Q_OBJECT
+@@ -40,19 +42,21 @@
+ virtual int getValue() = 0;
+
+ protected:
+- V4L2Control(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent);
++ V4L2Control(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw);
+ int fd;
+ int cid;
+ int default_value;
++ int flags;
+ char name[32];
+ QHBoxLayout layout;
++ MainWindow *mw;
+ };
+
+ class V4L2IntegerControl : public V4L2Control
+ {
+ Q_OBJECT
+ public:
+- V4L2IntegerControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent);
++ V4L2IntegerControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw);
+
+ public slots:
+ void setValue(int val);
+@@ -76,7 +80,7 @@
+ {
+ Q_OBJECT
+ public:
+- V4L2BooleanControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent);
++ V4L2BooleanControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw);
+
+ public slots:
+ void setValue(int val);
+@@ -92,7 +96,7 @@
+ {
+ Q_OBJECT
+ public:
+- V4L2MenuControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent);
++ V4L2MenuControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw);
+
+ public slots:
+ void setValue(int val);
+@@ -115,7 +119,7 @@
+ void resetToDefault();
+
+ public:
+- V4L2ButtonControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent);
++ V4L2ButtonControl(int fd, const struct v4l2_queryctrl &ctrl, QWidget *parent, MainWindow *mw);
+
+ public slots:
+ void setValue(int) {};
diff --git a/v4l2ucp.spec b/v4l2ucp.spec
index 5137884..92ea3ff 100644
--- a/v4l2ucp.spec
+++ b/v4l2ucp.spec
@@ -1,6 +1,6 @@
Name: v4l2ucp
Version: 2.0.1
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: Video4linux universal control panel
Group: Applications/Multimedia
License: GPLv2+
@@ -10,6 +10,7 @@ Patch0: v4l2ucp-1.3-libv4l.patch
Patch1: v4l2ucp-2.0.1-desktop.patch
Patch2: v4l2ucp-2.0.1-better-textinput.patch
Patch3: v4l2ucp-2.0.1-no-more-v4l1.patch
+Patch4: v4l2ucp-2.0.1-flags.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: qt-devel libXi-devel libXmu-devel libv4l-devel cmake
BuildRequires: desktop-file-utils
@@ -30,6 +31,7 @@ controls to their default state.
%patch1 -p1
%patch2 -p1
%patch3 -p1
+%patch4 -p1
%build
@@ -77,6 +79,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
+* Sat Mar 12 2011 Hans de Goede <hdegoede at redhat.com> - 2.0.1-5
+- Fix handling of special control flags
+
* Thu Feb 17 2011 Hans de Goede <hdegoede at redhat.com> - 2.0.1-4
- Fix building with newer kernel headers (no more linux/videodev.h)
More information about the scm-commits
mailing list