property alias acquired: policy.acquired
property alias hijacked: policy.hijacked
+ property alias scaleAcquired: policy.scaleAcquired
property Camera camera: null
property Item currentPage: pageStack.currentPage
}
}
+ // TODO: auto-hide this
CameraToolBar {
id: toolBar
onModeChanged: slider.value = camera.zoom.minimum;
}
+ Connections {
+ target: keys
+ // TODO: state change for slider to "visible"
+ onVolumeUpPressed: {
+ slider.value = Math.min(slider.value + slider.stepSize, slider.maximumValue);
+ }
+
+ onVolumeDownPressed: {
+ slider.value = Math.max(slider.value - slider.stepSize, slider.minimumValue);
+ }
+ }
+
orientation: Qt.Horizontal
width: 500
height: 50
policyLost: pipelineManager.state == "policyLost"
show: !pageStack.currentPage || (pageStack.currentPage.standbyVisible && pageStack.currentPage.status == PageStatus.Active && pipelineManager.showStandBy)
}
+
+ DeviceKeys {
+ id: keys
+ active: Qt.application.active && pipelineManager.scaleAcquired
+ }
}
m_thread.start();
qRegisterMetaType<CameraResources::Mode>("CameraResources::Mode");
- qRegisterMetaType<CameraResources::ResourceType>("CameraResources::ResourceType");
qRegisterMetaType<bool *>("bool *");
QObject::connect(m_worker, SIGNAL(acquiredChanged()), this, SIGNAL(acquiredChanged()));
QObject::connect(m_worker, SIGNAL(hijackedChanged()), this, SIGNAL(hijackedChanged()));
QObject::connect(m_worker, SIGNAL(updated()), this, SIGNAL(updated()));
+ QObject::connect(m_worker, SIGNAL(acquiredChanged()), this, SIGNAL(scaleAcquisitionChanged()));
+ QObject::connect(m_worker, SIGNAL(hijackedChanged()), this, SIGNAL(scaleAcquisitionChanged()));
+ QObject::connect(m_worker, SIGNAL(updated()), this, SIGNAL(scaleAcquisitionChanged()));
}
CameraResources::~CameraResources() {
m_worker = 0;
}
-bool CameraResources::isResourceGranted(const ResourceType& resource) {
+bool CameraResources::isResourceGranted(const ResourcePolicy::ResourceType& resource) const {
bool ok = false;
QMetaObject::invokeMethod(m_worker, "isResourceGranted", Qt::BlockingQueuedConnection,
- Q_ARG(bool *, &ok), Q_ARG(CameraResources::ResourceType, resource));
+ Q_ARG(bool *, &ok), Q_ARG(int, resource));
return ok;
}
return ok;
}
+bool CameraResources::isScaleAcquired() const {
+ return isResourceGranted(ResourcePolicy::ScaleButtonType);
+}
+
CameraResourcesWorker::CameraResourcesWorker(QObject *parent) :
QObject(parent),
m_set(0),
}
}
-void CameraResourcesWorker::isResourceGranted(bool *ok,
- const CameraResources::ResourceType& resource) {
+void CameraResourcesWorker::isResourceGranted(bool *ok, int resource) {
ResourcePolicy::ResourceType rt = (ResourcePolicy::ResourceType)resource;
Q_PROPERTY(bool acquired READ acquired NOTIFY acquiredChanged);
Q_PROPERTY(bool hijacked READ hijacked NOTIFY hijackedChanged);
+ Q_PROPERTY(bool scaleAcquired READ isScaleAcquired NOTIFY scaleAcquisitionChanged);
Q_ENUMS(Mode);
Q_ENUMS(ResourceType);
PostCapture,
} Mode;
- typedef enum {
- AudioPlaybackType = ResourcePolicy::AudioPlaybackType,
- VideoPlaybackType = ResourcePolicy::VideoPlaybackType,
- AudioRecorderType = ResourcePolicy::AudioRecorderType,
- VideoRecorderType = ResourcePolicy::VideoRecorderType,
- ScaleButtonType = ResourcePolicy::ScaleButtonType,
- SnapButtonType = ResourcePolicy::SnapButtonType,
- LensCoverType = ResourcePolicy::LensCoverType,
- } ResourceType;
-
CameraResources(QObject *parent = 0);
~CameraResources();
Q_INVOKABLE bool acquire(const Mode& mode);
- Q_INVOKABLE bool isResourceGranted(const ResourceType& resource);
-
bool acquired() const;
bool hijacked() const;
+ bool isScaleAcquired() const;
signals:
void acquiredChanged();
void hijackedChanged();
void updated();
+ void scaleAcquisitionChanged();
private:
+ bool isResourceGranted(const ResourcePolicy::ResourceType& resource) const;
+
CameraResourcesWorker *m_worker;
QThread m_thread;
};
void acquire(bool *ok, const CameraResources::Mode& mode);
void acquired(bool *ok);
void hijacked(bool *ok);
- void isResourceGranted(bool *ok, const CameraResources::ResourceType& resource);
+ void isResourceGranted(bool *ok, int resource);
signals:
void acquiredChanged();
--- /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 "devicekeys.h"
+#include <QDebug>
+
+DeviceKeys::DeviceKeys(QObject *parent) :
+ QObject(parent),
+ m_keys(0) {
+
+}
+
+DeviceKeys::~DeviceKeys() {
+ setActive(false);
+}
+
+bool DeviceKeys::isActive() const {
+ return m_keys != 0;
+}
+
+void DeviceKeys::setActive(bool active) {
+ if (active == isActive()) {
+ return;
+ }
+
+ if (!active) {
+ m_keys->deleteLater();
+ m_keys = 0;
+ }
+ else {
+ m_keys = new MeeGo::QmKeys(this);
+ QObject::connect(m_keys, SIGNAL(keyEvent(MeeGo::QmKeys::Key, MeeGo::QmKeys::State)),
+ this, SLOT(keyEvent(MeeGo::QmKeys::Key, MeeGo::QmKeys::State)));
+ }
+
+ emit activeChanged();
+}
+
+void DeviceKeys::keyEvent(MeeGo::QmKeys::Key key, MeeGo::QmKeys::State state) {
+ if (key == MeeGo::QmKeys::VolumeUp) {
+ if (state == MeeGo::QmKeys::KeyUp) {
+ emit volumeUpReleased();
+ }
+ else if (state == MeeGo::QmKeys::KeyDown) {
+ emit volumeUpPressed();
+ }
+ }
+ else if (key == MeeGo::QmKeys::VolumeDown) {
+ if (state == MeeGo::QmKeys::KeyUp) {
+ emit volumeDownReleased();
+ }
+ else if (state == MeeGo::QmKeys::KeyDown) {
+ emit volumeDownPressed();
+ }
+ }
+}
+
--- /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 DEVICE_KEYS_H
+#define DEVICE_KEYS_H
+
+#include <QObject>
+#include <qmkeys.h>
+
+class DeviceKeys : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged);
+
+public:
+ DeviceKeys(QObject *parent = 0);
+ ~DeviceKeys();
+
+ bool isActive() const;
+ void setActive(bool active);
+
+signals:
+ void activeChanged();
+ void volumeUpPressed();
+ void volumeUpReleased();
+ void volumeDownPressed();
+ void volumeDownReleased();
+
+private slots:
+ void keyEvent(MeeGo::QmKeys::Key key, MeeGo::QmKeys::State state);
+
+private:
+ MeeGo::QmKeys *m_keys;
+};
+
+#endif /* DEVICE_KEYS_H */
#include "batteryinfo.h"
#include "gridlines.h"
#include "deviceinfo.h"
+#include "devicekeys.h"
#ifdef QMLJSDEBUGGER
#include "qt_private/qdeclarativedebughelper_p.h"
qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
qmlRegisterType<GridLines>("CameraPlus", 1, 0, "GridLines");
qmlRegisterType<DeviceInfo>("CameraPlus", 1, 0, "DeviceInfo");
+ qmlRegisterType<DeviceKeys>("CameraPlus", 1, 0, "DeviceKeys");
view.setSource(QUrl("qrc:/qml/main.qml"));
SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \
cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
- postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp
+ postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp
HEADERS += settings.h filenaming.h quillitem.h displaystate.h fsmonitor.h \
cameraresources.h compass.h orientation.h geocode.h mountprotector.h \
trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \
- postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h
+ postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h
RESOURCES += ../qml/qml.qrc