#include "focus.h"
#include "autofocus.h"
+#include "videomute.h"
+#include "videotorch.h"
+
// TODO: a viewfinder class that inherits QDeclarativeItem
Camera::Camera(QDeclarativeItem *parent) :
m_noiseReduction(0),
m_flickerReduction(0),
m_focus(0),
- m_autoFocus(0) {
-
+ m_autoFocus(0),
+ m_videoMute(0),
+ m_videoTorch(0) {
// TODO:
}
delete m_flickerReduction;
delete m_focus;
delete m_autoFocus;
-
+ delete m_videoMute;
+ delete m_videoTorch;
// TODO: cleanup
}
delete m_autoFocus;
m_autoFocus = new AutoFocus(dev, this);
emit autoFocusChanged();
+
+ delete m_videoMute;
+ m_videoMute = new VideoMute(dev, this);
+ emit videoMuteChanged();
+
+ delete m_videoTorch;
+ m_videoTorch = new VideoTorch(dev, this);
+ emit videoTorchChanged();
}
Zoom *Camera::zoom() const {
AutoFocus *Camera::autoFocus() const {
return m_autoFocus;
}
+
+VideoMute *Camera::videoMute() const {
+ return m_videoMute;
+}
+
+VideoTorch *Camera::videoTorch() const {
+return m_videoTorch;
+}
class FlickerReduction;
class Focus;
class AutoFocus;
+class VideoMute;
+class VideoTorch;
class Camera : public QDeclarativeItem {
Q_OBJECT
Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
+ Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
+ Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
+
Q_ENUMS(CameraMode);
public:
Focus *focus() const;
AutoFocus *autoFocus() const;
+ VideoMute *videoMute() const;
+ VideoTorch *videoTorch() const;
+
signals:
void deviceCountChanged();
void deviceIdChanged();
void focusChanged();
void autoFocusChanged();
+ void videoMuteChanged();
+ void videoTorchChanged();
+
protected:
void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
FlickerReduction *m_flickerReduction;
Focus *m_focus;
AutoFocus *m_autoFocus;
+
+ VideoMute *m_videoMute;
+ VideoTorch *m_videoTorch;
};
#endif /* CAMERA_H */
HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.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 imagesettings.h imageresolutionmodel.h \
- videosettings.h videoresolutionmodel.h notifications.h \
- notificationscontainer.h sounds.h focus.h autofocus.h
+ flickerreduction.h videomute.h metadata.h imagesettings.h \
+ imageresolutionmodel.h videosettings.h videoresolutionmodel.h \
+ notifications.h notificationscontainer.h sounds.h focus.h autofocus.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 \
colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
- flickerreduction.cpp mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp \
- videosettings.cpp videoresolutionmodel.cpp notifications.cpp \
- notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp
+ flickerreduction.cpp videomute.cpp metadata.cpp imagesettings.cpp \
+ imageresolutionmodel.cpp videosettings.cpp videoresolutionmodel.cpp \
+ notifications.cpp notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp
+++ /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 "mute.h"
-#include "qtcammute.h"
-#include "camera.h"
-#include "qtcamdevice.h"
-
-Mute::Mute(QObject *parent) :
- QObject(parent), m_cam(0), m_mute(0) {
-
-}
-
-Mute::~Mute() {
- m_cam = 0;
-}
-
-Camera *Mute::camera() {
- return m_cam;
-}
-
-void Mute::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();
-
- deviceChanged();
-}
-
-bool Mute::isEnabled() const {
- return m_mute ? m_mute->isEnabled() : false;
-}
-
-void Mute::setEnabled(bool enabled) {
- if (m_mute) {
- m_mute->setEnabled(enabled);
- }
-}
-
-void Mute::deviceChanged() {
- if (m_mute) {
- delete m_mute; m_mute = 0;
- }
-
- if (m_cam->device()) {
- m_mute = new QtCamMute(m_cam->device(), this);
- QObject::connect(m_mute, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
-
- emit stateChanged();
- }
-}
#include "flickerreduction.h"
#include "focus.h"
#include "autofocus.h"
-#include "mute.h"
+#include "videomute.h"
#include "metadata.h"
#include "imagesettings.h"
#include "imageresolutionmodel.h"
qmlRegisterUncreatableType<Focus>(URI, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus"));
qmlRegisterUncreatableType<AutoFocus>(URI, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus"));
- qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
- qmlRegisterType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch");
+ qmlRegisterUncreatableType<VideoMute>(URI, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute"));
+ qmlRegisterUncreatableType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch"));
qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
--- /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 "videomute.h"
+#include "qtcamvideomute.h"
+
+VideoMute::VideoMute(QtCamDevice *dev, QObject *parent) :
+ QObject(parent),
+ m_mute(new QtCamVideoMute(dev, this)) {
+
+ QObject::connect(m_mute, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
+}
+
+VideoMute::~VideoMute() {
+ delete m_mute; m_mute = 0;
+}
+
+bool VideoMute::isEnabled() const {
+ return m_mute->isEnabled();
+}
+
+void VideoMute::setEnabled(bool enabled) {
+ m_mute->setEnabled(enabled);
+}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MUTE_H
-#define MUTE_H
+#ifndef VIDEO_MUTE_H
+#define VIDEO_MUTE_H
#include <QObject>
-class Camera;
-class QtCamMute;
+class QtCamVideoMute;
+class QtCamDevice;
-class Mute : public QObject {
+class VideoMute : public QObject {
Q_OBJECT
- Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY stateChanged);
public:
- Mute(QObject *parent = 0);
- ~Mute();
-
- Camera *camera();
- void setCamera(Camera *camera);
+ VideoMute(QtCamDevice *dev, QObject *parent = 0);
+ ~VideoMute();
bool isEnabled() const;
void setEnabled(bool enabled);
signals:
void stateChanged();
- void cameraChanged();
-
-private slots:
- void deviceChanged();
private:
- Camera *m_cam;
- QtCamMute *m_mute;
+ QtCamVideoMute *m_mute;
};
-#endif /* MUTE_H */
+#endif /* VIDEO_MUTE_H */
#include "videotorch.h"
#include "qtcamvideotorch.h"
-#include "camera.h"
-#include "qtcamdevice.h"
-#include "qtcamvideomode.h"
-VideoTorch::VideoTorch(QObject *parent) :
- QObject(parent), m_cam(0), m_torch(0) {
+VideoTorch::VideoTorch(QtCamDevice *dev, QObject *parent) :
+ QObject(parent),
+ m_torch(new QtCamVideoTorch(dev, this)) {
+ QObject::connect(m_torch, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
}
VideoTorch::~VideoTorch() {
- m_cam = 0;
-}
-
-Camera *VideoTorch::camera() {
- return m_cam;
-}
-
-void VideoTorch::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();
-
- deviceChanged();
+ delete m_torch; m_torch = 0;
}
bool VideoTorch::isOn() const {
- return m_torch ? m_torch->isOn() : false;
+ return m_torch->isOn();
}
void VideoTorch::setOn(bool on) {
- if (m_torch) {
- m_torch->setOn(on);
- }
-}
-
-void VideoTorch::deviceChanged() {
- if (m_torch) {
- delete m_torch; m_torch = 0;
- }
-
- if (m_cam->device()) {
- m_torch = new QtCamVideoTorch(m_cam->device(), this);
- QObject::connect(m_torch, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
-
- emit stateChanged();
- }
+ m_torch->setOn(on);
}
#include <QObject>
-class Camera;
class QtCamVideoTorch;
+class QtCamDevice;
class VideoTorch : public QObject {
Q_OBJECT
- Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
Q_PROPERTY(bool on READ isOn WRITE setOn NOTIFY stateChanged);
public:
- VideoTorch(QObject *parent = 0);
+ VideoTorch(QtCamDevice *dev, QObject *parent = 0);
~VideoTorch();
- Camera *camera();
- void setCamera(Camera *camera);
-
bool isOn() const;
void setOn(bool on);
signals:
void stateChanged();
- void cameraChanged();
-
-private slots:
- void deviceChanged();
private:
- Camera *m_cam;
QtCamVideoTorch *m_torch;
};
qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
- qtcammute.h qtcamnotifications.h qtcamfocus.h qtcamautofocus.h
+ qtcamvideomute.h qtcamnotifications.h qtcamfocus.h qtcamautofocus.h
SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
qtcamzoom.cpp qtcamflash.cpp qtcamscene.cpp qtcamevcomp.cpp qtcamvideotorch.cpp \
qtcamwhitebalance.cpp qtcamcolortone.cpp qtcamflickerreduction.cpp \
qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
- qtcammute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp
+ qtcamvideomute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp
HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h
friend class QtCamMetaData;
friend class QtCamCapability;
friend class QtCamVideoTorch;
- friend class QtCamMute;
+ friend class QtCamVideoMute;
friend class QtCamAutoFocusPrivate;
QtCamDevicePrivate *d_ptr;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "qtcammute.h"
+#include "qtcamvideomute.h"
#include "qtcamdevice.h"
#include "qtcamdevice_p.h"
#include <QPointer>
-class QtCamMutePrivate {
+class QtCamVideoMutePrivate {
public:
- static void mute_notify(GObject *gobject, GParamSpec *pspec, QtCamMute *q) {
+ static void mute_notify(GObject *gobject, GParamSpec *pspec, QtCamVideoMute *q) {
Q_UNUSED(gobject);
Q_UNUSED(pspec);
gulong handler;
};
-QtCamMute::QtCamMute(QtCamDevice *dev, QObject *parent) :
- QObject(parent), d_ptr(new QtCamMutePrivate) {
+QtCamVideoMute::QtCamVideoMute(QtCamDevice *dev, QObject *parent) :
+ QObject(parent), d_ptr(new QtCamVideoMutePrivate) {
d_ptr->dev = dev;
d_ptr->handler = 0;
if (d_ptr->dev->d_ptr->cameraBin) {
d_ptr->handler = g_signal_connect(d_ptr->dev->d_ptr->cameraBin,
"notify::mute",
- G_CALLBACK(QtCamMutePrivate::mute_notify), this);
+ G_CALLBACK(QtCamVideoMutePrivate::mute_notify), this);
}
}
-QtCamMute::~QtCamMute() {
+QtCamVideoMute::~QtCamVideoMute() {
if (d_ptr->dev && d_ptr->handler) {
g_signal_handler_disconnect(d_ptr->dev->d_ptr->cameraBin, d_ptr->handler);
}
delete d_ptr; d_ptr = 0;
}
-void QtCamMute::setEnabled(bool enabled) {
+void QtCamVideoMute::setEnabled(bool enabled) {
gboolean val = enabled ? TRUE : FALSE;
if (d_ptr->dev->d_ptr->cameraBin) {
}
}
-bool QtCamMute::isEnabled() const {
+bool QtCamVideoMute::isEnabled() const {
gboolean val = FALSE;
if (d_ptr->dev->d_ptr->cameraBin) {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef QT_CAM_MUTE_H
-#define QT_CAM_MUTE_H
+#ifndef QT_CAM_VIDEO_MUTE_H
+#define QT_CAM_VIDEO_MUTE_H
#include <QObject>
class QtCamDevice;
-class QtCamMutePrivate;
+class QtCamVideoMutePrivate;
-class QtCamMute : public QObject {
+class QtCamVideoMute : public QObject {
Q_OBJECT
public:
- QtCamMute(QtCamDevice *dev, QObject *parent = 0);
- ~QtCamMute();
+ QtCamVideoMute(QtCamDevice *dev, QObject *parent = 0);
+ ~QtCamVideoMute();
void setEnabled(bool enabled);
bool isEnabled() const;
void stateChanged();
private:
- QtCamMutePrivate *d_ptr;
+ QtCamVideoMutePrivate *d_ptr;
};
-#endif /* QT_CAM_MUTE_H */
+#endif /* QT_CAM_VIDEO_MUTE_H */
VideoTorchButton {
id: torch
+ camera: cam
visible: videoControlsVisible
anchors.top: parent.top
anchors.left: parent.left
height: 56
opacity: 0.5
- iconSource: torch.on ? "image://theme/icon-m-camera-torch-on" : "image://theme/icon-m-camera-torch-off"
- onClicked: torch.on = !torch.on
- VideoTorch {
- id: torch
- camera: cam
+ property Camera camera: null
+
+ iconSource: settings.videoTorchOn ? "image://theme/icon-m-camera-torch-on" : "image://theme/icon-m-camera-torch-off"
+ onClicked: settings.videoTorchOn = !settings.videoTorchOn
+
+ Binding {
+ target: camera.videoTorch
+ property: "on"
+ value: settings.videoTorchOn
}
}
#define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
#define DEFAULT_VIDEO_RESOLUTION "high"
#define DEFAULT_SOUND_ENABLED true
+#define DEFAULT_VIDEO_TORCH_ON false
Settings::Settings(QObject *parent) :
QObject(parent),
emit soundEnabledChanged();
}
}
+
+bool Settings::isVideoTorchOn() const {
+ return m_settings->value("video/torchOn", DEFAULT_VIDEO_TORCH_ON).toBool();
+}
+
+void Settings::setVideoTorchOn(bool on) {
+ if (isVideoTorchOn() != on) {
+ m_settings->setValue("video/torchOn", on);
+ emit videoTorchOnChanged();
+ }
+}
Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged);
+ Q_PROPERTY(bool videoTorchOn READ isVideoTorchOn WRITE setVideoTorchOn NOTIFY videoTorchOnChanged);
public:
Settings(QObject *parent = 0);
bool isSoundEnabled() const;
void setSoundEnabled(bool enabled);
+ bool isVideoTorchOn() const;
+ void setVideoTorchOn(bool on);
+
signals:
void modeChanged();
void creatorNameChanged();
void videoAspectRatioChanged();
void videoResolutionChanged();
void soundEnabledChanged();
+ void videoTorchOnChanged();
private:
QSettings *m_settings;