property bool pressed: focusReticle.locked || preview.animationRunning
|| (loader.item ? loader.item.pressed : false)
property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
+ property bool inhibitDim: loader.item ? loader.item.inhibitDim : false
camera: cam
cameraConfig: cam.cameraConfig
property bool pressed: capture.pressed || zoomSlider.pressed || modeButton.pressed
property bool controlsVisible: imageMode.canCapture && cam.running && !animationRunning
&& dimmer.opacity == 0.0 && !cameraMode.busy
+ property bool inhibitDim: false
signal previewAvailable(string uri)
}
property alias dimmer: camDimmer
+
+ PlatformQuirks {
+ id: platformQuirks
+ }
+
+ DisplayState {
+ id: displayState
+ inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
+ }
+
CameraPositionSource {
id: positionSource
- active: settings.useGps
- // TODO: we cannot bind to cam.running because camera will stop
- // when the connection dialog pops up and we end up with an infinite loop
- // active: cam.running && settings.useGps
+ active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
}
ReverseGeocode {
id: geocode
- active: viewfinder.camera.running && settings.useGps && settings.useGeotags
+ active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
}
DeviceInfo {
property int policyMode: view.currentItem && view.currentItem.playing ?
CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
CameraResources.Image
+ property bool inhibitDim: pressed
property bool isCurrent: mainView.currentIndex == 2 && !mainView.moving
property bool inCameraMode: root.inCaptureMode && !mainView.moving
property Camera camera: null
property int policyMode: settings.mode == Camera.VideoMode ? CameraResources.Video
: CameraResources.Image
+ property bool pressed: false
+ property bool inhibitDim: false
Loader {
id: loader
&& dimmer.opacity == 0.0 && !cameraMode.busy
property bool pressed: overlay.recording || capture.pressed ||
zoomSlider.pressed || modeButton.pressed
+ property bool inhibitDim: recording
signal previewAvailable(string uri)
}
}
- DisplayState {
- inhibitDim: overlay.recording
- }
-
Connections {
target: Qt.application
onActiveChanged: {
#include <QDebug>
DisplayState::DisplayState(QObject *parent) :
- QObject(parent), m_state(new MeeGo::QmDisplayState(this)), m_timer(new QTimer(this)) {
+ QObject(parent),
+ m_state(new MeeGo::QmDisplayState(this)),
+ m_timer(new QTimer(this)) {
m_timer->setSingleShot(false);
m_timer->setInterval(50 * 1000);
QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
+
+ QObject::connect(m_state, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)),
+ this, SLOT(displayStateChanged()));
}
DisplayState::~DisplayState() {
qWarning() << "Failed to inhibit display dimming!";
}
}
+
+bool DisplayState::isOn() {
+ return m_state->get() == MeeGo::QmDisplayState::On;
+}
+
+void DisplayState::displayStateChanged() {
+ emit isOnChanged();
+}
class DisplayState : public QObject {
Q_OBJECT
Q_PROPERTY(bool inhibitDim READ isDimInhibited WRITE setInhibitDim NOTIFY inhibitDimChanged);
+ Q_PROPERTY(bool isOn READ isOn NOTIFY isOnChanged);
public:
DisplayState(QObject *parent = 0);
bool isDimInhibited() const;
void setInhibitDim(bool inhibit);
+ bool isOn();
+
signals:
void inhibitDimChanged();
+ void isOnChanged();
private slots:
void timeout();
+ void displayStateChanged();
private:
MeeGo::QmDisplayState *m_state;
HEADERS += quillitem.h soundvolumecontrol.h deviceinfo.h geocode.h \
batteryinfo.h compass.h devicekeys.h \
- displaystate.h fsmonitor.h orientation.h phoneprofile.h
+ displaystate.h fsmonitor.h orientation.h phoneprofile.h \
+ platformquirks.h
SOURCES += quillitem.cpp soundvolumecontrol.cpp deviceinfo.cpp geocode.cpp \
batteryinfo.cpp compass.cpp devicekeys.cpp \
- displaystate.cpp fsmonitor.cpp orientation.cpp phoneprofile.cpp
+ displaystate.cpp fsmonitor.cpp orientation.cpp phoneprofile.cpp \
+ platformquirks.cpp
--- /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 "platformquirks.h"
+#include <QApplication>
+#include <QEvent>
+#include <QX11Info>
+#include <X11/Xlib.h>
+
+PlatformQuirks::PlatformQuirks(QObject *parent) :
+ QObject(parent),
+ m_state(false),
+ m_check(true) {
+
+ qApp->installEventFilter(this);
+}
+
+PlatformQuirks::~PlatformQuirks() {
+
+}
+
+bool PlatformQuirks::isOnForced() {
+ if (!m_check) {
+ return m_state;
+ }
+
+ int param = 0;
+ char *winName = 0;
+ Window winFocus;
+
+ Display *d = QX11Info::display();
+
+ XGetInputFocus(d, &winFocus, ¶m);
+ XFetchName(d, winFocus, &winName);
+
+ m_state = (QLatin1String(winName) == "location-ui" || QLatin1String(winName) == "conndlgs");
+ XFree(winName);
+
+ m_check = false;
+ return m_state;
+}
+
+bool PlatformQuirks::eventFilter(QObject *obj, QEvent *event) {
+ if (event->type() == QEvent::ApplicationActivate) {
+ m_check = false;
+
+ if (!m_state) {
+ m_state = true;
+ emit forceOnChanged();
+ }
+ }
+ else if (event->type() == QEvent::ApplicationDeactivate) {
+ m_check = true;
+ emit forceOnChanged();
+ }
+
+ return QObject::eventFilter(obj, event);
+}
--- /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 PLATFORM_QUIRKS_H
+#define PLATFORM_QUIRKS_H
+
+#include <QObject>
+
+class PlatformQuirks : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool forceOn READ isOnForced NOTIFY forceOnChanged);
+
+public:
+ PlatformQuirks(QObject *parent = 0);
+ ~PlatformQuirks();
+
+ bool isOnForced();
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+signals:
+ void forceOnChanged();
+
+private:
+ bool m_state;
+ bool m_check;
+};
+
+#endif /* PLATFORM_QUIRKS_H */
#include "platformsettings.h"
#include "dbusservice.h"
#include "phoneprofile.h"
+#include "platformquirks.h"
#include <MDeclarativeCache>
#ifdef QMLJSDEBUGGER
qmlRegisterType<DeviceKeys>("CameraPlus", 1, 0, "DeviceKeys");
qmlRegisterType<PlatformSettings>("CameraPlus", 1, 0, "PlatformSettings");
qmlRegisterType<PhoneProfile>("CameraPlus", 1, 0, "PhoneProfile");
+ qmlRegisterType<PlatformQuirks>("CameraPlus", 1, 0, "PlatformQuirks");
view->setSource(QUrl("qrc:/qml/main.qml"));