--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 "imageresolutionmodel.h"
+#include "qtcamimagesettings.h"
+#include <QDebug>
+
+ImageResolutionModel::ImageResolutionModel(QtCamImageSettings *settings, QObject *parent) :
+ QAbstractListModel(parent), m_settings(settings) {
+
+ QHash<int, QByteArray> roles;
+ roles[IdRole] = "resolutionId";
+ roles[NameRole] = "resolutionName";
+ roles[CaptureRole] = "captureResolution";
+ roles[PreviewRole] = "previewResolution";
+ roles[FpsRole] = "frameRate";
+ roles[NightFpsRole] = "nightFrameRate";
+ roles[MegaPixelsRole] = "megaPixels";
+ roles[AspectRatioRole] = "resolutionAspectRatio";
+
+ setRoleNames(roles);
+}
+
+ImageResolutionModel::~ImageResolutionModel() {
+ m_settings = 0;
+}
+
+int ImageResolutionModel::rowCount(const QModelIndex& parent) const {
+ if (!parent.isValid()) {
+ return m_resolutions.size();
+ }
+
+ return 0;
+}
+
+QVariant ImageResolutionModel::data(const QModelIndex& index, int role) const {
+ if (index.row() < 0 || index.row() > m_resolutions.size()) {
+ return QVariant();
+ }
+
+ const QtCamImageResolution& res = m_resolutions[index.row()];
+
+ switch (role) {
+ case IdRole:
+ return res.id();
+
+ case NameRole:
+ return res.name();
+
+ case CaptureRole:
+ return res.captureResolution();
+
+ case PreviewRole:
+ return res.previewResolution();
+
+ case FpsRole:
+ return res.frameRate();
+
+ case NightFpsRole:
+ return res.nightFrameRate();
+
+ case MegaPixelsRole:
+ return res.megaPixels();
+
+ case AspectRatioRole:
+ return res.aspectRatio();
+
+ default:
+ return QVariant();
+ }
+}
+
+QString ImageResolutionModel::aspectRatio() const {
+ return m_aspectRatio;
+}
+
+void ImageResolutionModel::setAspectRatio(const QString& aspectRatio) {
+ if (aspectRatio != m_aspectRatio) {
+
+ m_aspectRatio = aspectRatio;
+
+ emit aspectRatioChanged();
+
+ beginResetModel();
+
+ m_resolutions = m_settings->resolutions(m_aspectRatio);
+
+ endResetModel();
+ }
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 IMAGE_RESOLUTION_MODEL_H
+#define IMAGE_RESOLUTION_MODEL_H
+
+#include <QAbstractListModel>
+
+class QtCamImageSettings;
+class QtCamImageResolution;
+
+class ImageResolutionModel : public QAbstractListModel {
+ Q_OBJECT
+
+ Q_PROPERTY(QString aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged);
+
+public:
+
+ enum ResolutionRoles {
+ IdRole = Qt::UserRole + 1,
+ NameRole,
+ CaptureRole,
+ PreviewRole,
+ FpsRole,
+ NightFpsRole,
+ MegaPixelsRole,
+ AspectRatioRole,
+ };
+
+ ImageResolutionModel(QtCamImageSettings *settings, QObject *parent = 0);
+ ~ImageResolutionModel();
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+
+ QString aspectRatio() const;
+ void setAspectRatio(const QString& aspectRatio);
+
+signals:
+ void aspectRatioChanged();
+
+private:
+ QString m_aspectRatio;
+
+ QtCamImageSettings *m_settings;
+
+ QList<QtCamImageResolution> m_resolutions;
+};
+
+#endif /* IMAGE_RESOLUTION_MODEL_H */
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 "imagesettings.h"
+#include "qtcamimagesettings.h"
+#include "camera.h"
+#include "qtcamdevice.h"
+#include "qtcamimagemode.h"
+#include "imageresolutionmodel.h"
+#include <QDebug>
+
+ImageSettings::ImageSettings(QObject *parent) :
+ QObject(parent), m_cam(0), m_settings(0), m_resolutions(0) {
+
+}
+
+ImageSettings::~ImageSettings() {
+ m_settings = 0;
+}
+
+QString ImageSettings::suffix() const {
+ return m_settings ? m_settings->suffix() : QString();
+}
+
+QStringList ImageSettings::aspectRatios() const {
+ return m_settings ? m_settings->aspectRatios() : QStringList();
+}
+
+Camera *ImageSettings::camera() {
+ return m_cam;
+}
+
+void ImageSettings::setCamera(Camera *camera) {
+ if (camera == m_cam) {
+ return;
+ }
+
+ if (m_cam) {
+ QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ m_cam = camera;
+
+ if (m_cam) {
+ QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ emit cameraChanged();
+
+ if (m_cam->device()) {
+ deviceChanged();
+ }
+}
+
+void ImageSettings::deviceChanged() {
+ m_settings = m_cam->device()->imageMode()->settings();
+
+ emit settingsChanged();
+
+ delete m_resolutions;
+ m_resolutions = 0;
+
+ emit resolutionsChanged();
+}
+
+ImageResolutionModel *ImageSettings::resolutions() {
+ if (!m_settings) {
+ return 0;
+ }
+
+
+ if (!m_resolutions) {
+ m_resolutions = new ImageResolutionModel(m_settings, this);
+ }
+
+ return m_resolutions;
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 IMAGE_SETTINGS_H
+#define IMAGE_SETTINGS_H
+
+#include <QObject>
+#include <QStringList>
+
+class Camera;
+class QtCamImageSettings;
+class ImageResolutionModel;
+
+class ImageSettings : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
+ Q_PROPERTY(QString suffix READ suffix NOTIFY settingsChanged);
+ Q_PROPERTY(QStringList aspectRatios READ aspectRatios NOTIFY settingsChanged);
+ Q_PROPERTY(ImageResolutionModel *resolutions READ resolutions NOTIFY resolutionsChanged);
+
+public:
+ ImageSettings(QObject *parent = 0);
+ ~ImageSettings();
+
+ QString suffix() const;
+ QStringList aspectRatios() const;
+
+ Camera *camera();
+ void setCamera(Camera *camera);
+
+ ImageResolutionModel *resolutions();
+
+signals:
+ void settingsChanged();
+ void cameraChanged();
+ void resolutionsChanged();
+
+private slots:
+ void deviceChanged();
+
+private:
+ Camera *m_cam;
+ QtCamImageSettings *m_settings;
+ ImageResolutionModel *m_resolutions;
+};
+
+#endif /* IMAGE_SETTINGS_H */
HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
capability.h zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.h \
colortone.h exposure.h aperture.h iso.h noisereduction.h \
- flickerreduction.h mute.h metadata.h
+ flickerreduction.h mute.h metadata.h imagesettings.h imageresolutionmodel.h
SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
capability.cpp zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
- flickerreduction.cpp mute.cpp metadata.cpp
+ flickerreduction.cpp mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp
private slots:
void gotPreview(const QImage& image, const QString& fileName);
+ void deviceChanged();
protected:
virtual void preChangeMode() = 0;
Camera *m_cam;
QtCamMode *m_mode;
-private slots:
- void deviceChanged();
-
private:
unsigned long long m_seq;
};
#include "flickerreduction.h"
#include "mute.h"
#include "metadata.h"
+#include "imagesettings.h"
+#include "imageresolutionmodel.h"
#include <QtDeclarative>
qmlRegisterType<FlickerReduction>(URI, MAJOR, MINOR, "FlickerReduction");
qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
+ qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
+ qmlRegisterUncreatableType<ImageResolutionModel>(URI, MAJOR, MINOR, "ImageResolutionModel",
+ "ImageResolutionModel can be obtained from ImageSettings");
qmlRegisterType<Mode>();
qmlRegisterType<Capability>();
#include "qtcamimagesettings.h"
#include <QSharedData>
+#include <QDebug>
class QtCamImageResolutionPrivate : public QSharedData {
public:
}
}
- return d_ptr->resolutions;
+ return res;
}
QStringList QtCamImageSettings::aspectRatios() const {
}
}
- return d_ptr->resolutions;
+ return res;
}
QStringList QtCamVideoSettings::aspectRatios() const {
ButtonRow {
anchors.horizontalCenter: parent.horizontalCenter
- // TODO:
- Button { text: qsTr("16:9"); }
- Button { text: qsTr("4:3"); }
- Button { text: qsTr("3:2"); }
+ exclusive: false
+ onCheckedButtonChanged: {
+ // This is needed to initially setup the
+ // resolutions buttons
+ imageSettings.resolutions.aspectRatio = checkedButton.aspect;
+ settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
+ }
+
+ Repeater {
+ model: imageSettings.aspectRatios
+ delegate: Button {
+ property string aspect: modelData;
+ text: qsTr(modelData);
+ checked: settings.imageAspectRatio == modelData;
+ onClicked: {
+ settings.imageAspectRatio = modelData;
+ imageSettings.resolutions.aspectRatio = modelData;
+ }
+ }
+ }
}
SectionHeader {
}
ButtonRow {
+ id: resolutionsRow
anchors.horizontalCenter: parent.horizontalCenter
- // TODO:
- Button {}
- Button {}
- Button {}
+ exclusive: false
+
+ Repeater {
+ id: resolutions
+ model: imageSettings.resolutions
+
+ // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
+ function name(name, mp) {
+ return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
+ }
+
+ delegate: Button {
+ property string resolution: resolutionName
+ property string aspectRatio: resolutionAspectRatio
+ text: resolutions.name(resolutionName, megaPixels);
+ checked: settings.imageResolution == resolutionName
+ onClicked: settings.imageResolution = resolutionName;
+ }
+ }
}
CameraSettings {
background: " "
}
+ ImageSettings {
+ id: imageSettings
+ camera: cam
+ }
+
Camera {
/*
onDeviceIdChanged: {
#define PATH QString("%1%2.config%2/cameraplus.conf").arg(QDir::homePath()).arg(QDir::separator())
-#define DEFAULT_MODE 0
-#define DEFAULT_SCENE_MODE 6 // Auto
-#define DEFAULT_TIMEOUT 0
-#define DEFAULT_USE_GPS true
-#define DEFAULT_USE_GEOTAGS true
-#define DEFAULT_COLOR_FILTER 0
-#define DEFAULT_WHITE_BALANCE 0
-#define DEFAULT_EV_COMP 0.0
-#define DEFAULT_FLASH_MODE 0
-#define DEFAULT_IMAGE_ISO 0
+#define DEFAULT_MODE 0
+#define DEFAULT_SCENE_MODE 6 // Auto
+#define DEFAULT_TIMEOUT 0
+#define DEFAULT_USE_GPS true
+#define DEFAULT_USE_GEOTAGS true
+#define DEFAULT_COLOR_FILTER 0
+#define DEFAULT_WHITE_BALANCE 0
+#define DEFAULT_EV_COMP 0.0
+#define DEFAULT_FLASH_MODE 0
+#define DEFAULT_IMAGE_ISO 0
+#define DEFAULT_IMAGE_RESOLUTION "high"
+#define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
Settings::Settings(QObject *parent) :
QObject(parent),
emit imageIsoChanged();
}
}
+
+QString Settings::imageAspectRatio() const {
+ return m_settings->value("image/aspectRatio", DEFAULT_IMAGE_ASPECT_RATIO).toString();
+}
+
+void Settings::setImageAspectRatio(const QString& aspectRatio) {
+ if (aspectRatio != imageAspectRatio()) {
+ m_settings->setValue("image/aspectRatio", aspectRatio);
+ emit imageAspectRatioChanged();
+ }
+}
+
+QString Settings::imageResolution() const {
+ return m_settings->value("image/resolution", DEFAULT_IMAGE_RESOLUTION).toString();
+}
+
+void Settings::setImageResolution(const QString& resolution) {
+ if (resolution != imageResolution()) {
+ m_settings->setValue("image/resolution", resolution);
+ emit imageResolutionChanged();
+ }
+}
Q_PROPERTY(int imageFlashMode READ imageFlashMode WRITE setImageFlashMode NOTIFY imageFlashModeChanged);
Q_PROPERTY(int imageIso READ imageIso WRITE setImageIso NOTIFY imageIsoChanged);
+ Q_PROPERTY(QString imageAspectRatio READ imageAspectRatio WRITE setImageAspectRatio NOTIFY imageAspectRatioChanged);
+ Q_PROPERTY(QString imageResolution READ imageResolution WRITE setImageResolution NOTIFY imageResolutionChanged);
+
public:
Settings(QObject *parent = 0);
~Settings();
int imageIso() const;
void setImageIso(int iso);
+ QString imageAspectRatio() const;
+ void setImageAspectRatio(const QString& aspectRatio);
+
+ QString imageResolution() const;
+ void setImageResolution(const QString& resolution);
+
signals:
void modeChanged();
void creatorNameChanged();
void videoEvCompChanged();
void imageFlashModeChanged();
void imageIsoChanged();
+ void imageAspectRatioChanged();
+ void imageResolutionChanged();
private:
QSettings *m_settings;