This allows us to specify any device specific quirks to workaround from the UI side.
Also added N9 quirks
[%General]
preview-supported=true
+
+[quirks-0]
+quirks = NoSceneModeChangeDuringRecording
+
+[quirks-1]
+quirks = NoNightSceneMode, NoFlash, NoVideoTorch, NoAutoFocus, NoSceneModeChangeDuringRecording
\ No newline at end of file
#include "videomute.h"
#include "videotorch.h"
#include "cameraconfig.h"
+#include "quirks.h"
Camera::Camera(QObject *parent) :
QObject(parent),
m_roi(0),
m_videoMute(0),
m_videoTorch(0),
- m_config(new CameraConfig(this)) {
+ m_config(new CameraConfig(this)),
+ m_quirks(0) {
m_config->componentComplete();
}
delete m_roi;
delete m_videoMute;
delete m_videoTorch;
+ delete m_quirks;
}
int Camera::deviceCount() const {
delete m_videoTorch;
m_videoTorch = new VideoTorch(dev, this);
emit videoTorchChanged();
+
+ delete m_quirks;
+ m_quirks = new Quirks(dev->config()->quirks(dev->id()), this);
+ emit quirksChanged();
}
Zoom *Camera::zoom() const {
CameraConfig *Camera::cameraConfig() const {
return m_config;
}
+
+Quirks *Camera::quirks() const {
+ return m_quirks;
+}
class VideoMute;
class VideoTorch;
class CameraConfig;
+class Quirks;
class Camera : public QObject {
Q_OBJECT
Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
+ Q_PROPERTY(Quirks *quirks READ quirks NOTIFY quirksChanged);
+
// TODO: We need a setter here too.
Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
VideoMute *videoMute() const;
VideoTorch *videoTorch() const;
+ Quirks *quirks() const;
+
CameraConfig *cameraConfig() const;
signals:
void videoMuteChanged();
void videoTorchChanged();
void renderingEnabledChanged();
+ void quirksChanged();
private:
bool applyMode();
VideoMute *m_videoMute;
VideoTorch *m_videoTorch;
CameraConfig *m_config;
+ Quirks *m_quirks;
};
#endif /* CAMERA_H */
#include <QQmlInfo>
#endif
+// TODO: share that with qtcamera. We now have 2 instances of QtCamConfig
+
CameraConfig::CameraConfig(QObject *parent) :
QObject(parent),
m_config(0) {
imageresolutionmodel.h videosettings.h videoresolutionmodel.h \
notificationscontainer.h sounds.h focus.h autofocus.h \
roi.h cameraconfig.h videoplayer.h viewfinder.h capability.h \
- imageresolution.h videoresolution.h
+ imageresolution.h videoresolution.h quirks.h
SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
imageresolutionmodel.cpp videosettings.cpp videoresolutionmodel.cpp \
notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp \
roi.cpp cameraconfig.cpp videoplayer.cpp viewfinder.cpp capability.cpp \
- imageresolution.cpp videoresolution.cpp
+ imageresolution.cpp videoresolution.cpp quirks.cpp
PLUGIN_IMPORT_PATH = QtCamera
target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
#include "capability.h"
#include "imageresolution.h"
#include "videoresolution.h"
+#include "quirks.h"
#if defined(QT4)
#include <QDeclarativeEngine>
#elif defined(QT5)
qmlRegisterType<ImageResolution>(uri, MAJOR, MINOR, "ImageResolution");
qmlRegisterType<VideoResolution>(uri, MAJOR, MINOR, "VideoResolution");
+
+ qmlRegisterUncreatableType<Quirks>(uri, MAJOR, MINOR, "Quirks",
+ "Quirks can be obtained from Camera");
}
#if defined(QT4)
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "quirks.h"
+
+Quirks::Quirks(QtCamQuirks *quirks, QObject *parent) :
+ QObject(parent),
+ m_quirks(quirks) {
+
+}
+
+Quirks::~Quirks() {
+ delete m_quirks;
+ m_quirks = 0;
+}
+
+bool Quirks::hasQuirk(const QuirkType& type) {
+ return m_quirks->quirks().testFlag(QtCamQuirks::QuirkType(type));
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QUIRKS_H
+#define QUIRKS_H
+
+#include <QObject>
+#include "qtcamquirks.h"
+
+class Quirks : public QObject {
+ Q_OBJECT
+
+ Q_ENUMS(QuirkType);
+
+public:
+ Quirks(QtCamQuirks *quirks, QObject *parent = 0);
+ ~Quirks();
+
+ typedef enum {
+ NoNightSceneMode = QtCamQuirks::NoNightSceneMode,
+ NoFlash = QtCamQuirks::NoFlash,
+ NoVideoTorch = QtCamQuirks::NoVideoTorch,
+ NoAutoFocus = QtCamQuirks::NoAutoFocus,
+ NoSceneModeChangeDuringRecording = QtCamQuirks::NoSceneModeChangeDuringRecording,
+ NoRedEyeFlash = QtCamQuirks::NoRedEyeFlash,
+ } QuirkType;
+
+ Q_INVOKABLE bool hasQuirk(const QuirkType& type);
+
+private:
+ QtCamQuirks *m_quirks;
+};
+
+#endif /* QUIRKS_H */
qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
qtcamvideomute.h qtcamnotifications.h qtcamfocus.h qtcamautofocus.h \
- qtcamanalysisbin.h qtcampropertysetter.h qtcamroi.h
+ qtcamanalysisbin.h qtcampropertysetter.h qtcamroi.h qtcamquirks.h
SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
qtcamwhitebalance.cpp qtcamcolortone.cpp qtcamflickerreduction.cpp \
qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
qtcamvideomute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp \
- qtcamanalysisbin.cpp qtcampropertysetter.cpp qtcamroi.cpp
+ qtcamanalysisbin.cpp qtcampropertysetter.cpp qtcamroi.cpp qtcamquirks.cpp
HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h \
qtcamnotifications_p.h qtcamflash_p.h qtcamroi_p.h
*/
#include "qtcamconfig.h"
+#include "qtcamimagesettings.h"
+#include "qtcamvideosettings.h"
+#include "qtcamquirks.h"
#include <QSettings>
#include <QStringList>
#include <QDebug>
+#include <QMetaEnum>
#define CONFIGURATION_FILE DATA_DIR"/qtcamera.ini"
return new QtCamVideoSettings(id.toString(), suffix, profileName, profilePath, resolutions);
}
+QtCamQuirks *QtCamConfig::quirks(const QVariant& id) {
+ QString group = QString("quirks-%1").arg(id.toString());
+ d_ptr->conf->beginGroup(group);
+ QStringList quirks = d_ptr->conf->value("quirks").toStringList();
+ d_ptr->conf->endGroup();
+
+ QMetaObject m = QtCamQuirks::staticMetaObject;
+ int index = m.indexOfEnumerator("QuirkType");
+ if (index == -1) {
+ qCritical() << "Failed to obtain QuirkType index";
+ return 0;
+ }
+
+ QMetaEnum e = m.enumerator(index);
+
+ int value = 0;
+
+ foreach (const QString& quirk, quirks) {
+ int val = e.keyToValue(quirk.toLatin1().constData());
+
+ if (val == -1) {
+ qWarning() << "Unknown quirk" << quirk;
+ }
+ else {
+ value |= val;
+ }
+ }
+
+ QtCamQuirks::QuirkTypes types = (QtCamQuirks::QuirkTypes)value;
+
+ return new QtCamQuirks(types);
+}
+
QString QtCamConfig::imageEncodingProfileName() const {
return d_ptr->conf->value("image/profile-name").toString();
}
#define QT_CAM_CONFIG_H
#include <QObject>
-#include "qtcamimagesettings.h"
-#include "qtcamvideosettings.h"
#include <QStringList>
+class QtCamImageSettings;
+class QtCamVideoSettings;
+class QtCamQuirks;
+
#define SCANNER_TYPE_V4L2 "v4l2"
#define SCANNER_TYPE_ENUM "enum"
QtCamImageSettings *imageSettings(const QVariant& id);
QtCamVideoSettings *videoSettings(const QVariant& id);
+ QtCamQuirks *quirks(const QVariant& id);
QString imageEncodingProfileName() const;
QString imageEncodingProfilePath() const;
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "qtcamquirks.h"
+#include "qtcamconfig.h" // For DATA_DIR
+
+#define CONFIGURATION_FILE DATA_DIR"/qtcamera.ini"
+
+class QtCamQuirksPrivate {
+public:
+ QtCamQuirks::QuirkTypes types;
+};
+
+QtCamQuirks::QtCamQuirks(const QuirkTypes& types, QObject *parent) :
+ QObject(parent),
+ d_ptr(new QtCamQuirksPrivate) {
+
+ d_ptr->types = types;
+}
+
+QtCamQuirks::~QtCamQuirks() {
+ delete d_ptr; d_ptr = 0;
+}
+
+QtCamQuirks::QuirkTypes QtCamQuirks::quirks() const {
+ return d_ptr->types;
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QT_CAM_QUIRKS_H
+#define QT_CAM_QUIRKS_H
+
+#include <QObject>
+
+class QtCamQuirksPrivate;
+class QtCamDevice;
+
+class QtCamQuirks : public QObject {
+ Q_OBJECT
+
+ Q_ENUMS(QuirkType);
+
+public:
+ typedef enum {
+ NoNightSceneMode = 0x1,
+ NoFlash = 0x2,
+ NoVideoTorch = 0x4,
+ NoAutoFocus = 0x8,
+ NoSceneModeChangeDuringRecording = 0x10,
+ NoRedEyeFlash = 0x20,
+ } QuirkType;
+
+ Q_DECLARE_FLAGS(QuirkTypes, QuirkType);
+
+ QtCamQuirks(const QuirkTypes& types, QObject *parent = 0);
+ ~QtCamQuirks();
+
+ QuirkTypes quirks() const;
+
+private:
+ QtCamQuirksPrivate *d_ptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QtCamQuirks::QuirkTypes);
+
+#endif /* QT_CAM_QUIRKS_H */