Initial Qt5 port
authorMohammed Sameer <msameer@foolab.org>
Sat, 27 Jul 2013 20:09:11 +0000 (23:09 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 27 Jul 2013 20:09:11 +0000 (23:09 +0300)
35 files changed:
cameraplus.pri
declarative/camera.cpp
declarative/cameraconfig.cpp
declarative/cameraconfig.h
declarative/declarative.pro
declarative/imageresolutionmodel.cpp
declarative/imageresolutionmodel.h
declarative/plugin.cpp
declarative/plugin.h
declarative/previewprovider.cpp
declarative/previewprovider.h
declarative/sounds.cpp
declarative/videoplayer.cpp
declarative/videoplayer.h
declarative/videoresolutionmodel.cpp
declarative/videoresolutionmodel.h
declarative/viewfinder.cpp
declarative/viewfinder.h
lib/lib.pro
src/batteryinfo.cpp
src/dbusservice.cpp
src/deletehelper.cpp
src/displaystate.cpp
src/filenaming.cpp
src/focusrectangle.cpp
src/focusrectangle.h
src/gridlines.cpp
src/gridlines.h
src/main.cpp
src/mountprotector.cpp
src/nemo/nemo.pri
src/postcapturemodel.cpp
src/postcapturemodel.h
src/src.pro
src/trackerstore.cpp

index 58ac6fb..c975c78 100644 (file)
@@ -8,3 +8,13 @@ contains(MEEGO_EDITION, "harmattan") {
     DEFINES += NEMO
     CONFIG += nemo
 }
+
+equals(QT_MAJOR_VERSION, 4) {
+    CONFIG += qt4
+    DEFINES += QT4
+}
+
+equals(QT_MAJOR_VERSION, 5) {
+    CONFIG += qt5
+    DEFINES += QT5
+}
index c04741b..96298b5 100644 (file)
 #include "qtcammode.h"
 #include "qtcamimagemode.h"
 #include "qtcamvideomode.h"
-#include "qtcamgraphicsviewfinder.h"
 #include "qtcamconfig.h"
 #include "sounds.h"
 #include "notificationscontainer.h"
 #include "sounds.h"
+#if defined(QT4)
 #include <QDeclarativeInfo>
-
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include "zoom.h"
 #include "flash.h"
 #include "scene.h"
index 6085ed5..1c1678a 100644 (file)
 
 #include "cameraconfig.h"
 #include "qtcamconfig.h"
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 CameraConfig::CameraConfig(QObject *parent) :
   QObject(parent),
index 71da9ba..cd53d7d 100644 (file)
 #define CAMERA_CONFIG_H
 
 #include <QObject>
+#if defined(QT4)
 #include <QDeclarativeParserStatus>
+#elif defined(QT5)
+#include <QQmlParserStatus>
+#endif
 
 class QtCamConfig;
 
+#if defined(QT4)
 class CameraConfig : public QObject, public QDeclarativeParserStatus {
+#elif defined(QT5)
+class CameraConfig : public QObject, public QQmlParserStatus {
+#endif
+
   Q_OBJECT
 
   Q_PROPERTY(QString configPath READ configPath WRITE setConfigPath NOTIFY configPathChanged);
index 1578489..e1fe398 100644 (file)
@@ -10,7 +10,10 @@ PKGCONFIG = gstreamer-pbutils-0.10 libcanberra
 
 LIBS += -L../lib/ -lqtcamera
 
-QT += declarative dbus
+QT += dbus
+
+qt4:QT += declarative
+qt5:QT += qml quick
 
 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 \
index 783aa29..16778f4 100644 (file)
 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);
+  m_roles[IdRole] = "resolutionId";
+  m_roles[NameRole] = "resolutionName";
+  m_roles[CaptureRole] = "captureResolution";
+  m_roles[PreviewRole] = "previewResolution";
+  m_roles[FpsRole] = "frameRate";
+  m_roles[NightFpsRole] = "nightFrameRate";
+  m_roles[MegaPixelsRole] = "megaPixels";
+  m_roles[AspectRatioRole] = "resolutionAspectRatio";
 
   m_resolutions = m_settings->resolutions(m_aspectRatio);
 }
@@ -107,3 +104,7 @@ void ImageResolutionModel::setAspectRatio(const QString& aspectRatio) {
     emit aspectRatioChanged();
   }
 }
+
+QHash<int, QByteArray> ImageResolutionModel::roleNames() const {
+  return m_roles;
+}
index dfadfca..294c89f 100644 (file)
@@ -56,6 +56,8 @@ public:
   QString aspectRatio() const;
   void setAspectRatio(const QString& aspectRatio);
 
+  QHash<int, QByteArray> roleNames() const;
+
 signals:
   void aspectRatioChanged();
 
@@ -65,6 +67,8 @@ private:
   QtCamImageSettings *m_settings;
 
   QList<QtCamImageResolution> m_resolutions;
+
+  QHash<int, QByteArray> m_roles;
 };
 
 #endif /* IMAGE_RESOLUTION_MODEL_H */
index bf0e68d..13ffdbb 100644 (file)
 #include "cameraconfig.h"
 #include "videoplayer.h"
 #include "viewfinder.h"
-#include <QtDeclarative>
+#if defined(QT4)
+#include <QDeclarativeEngine>
+#elif defined(QT5)
+#include <QQmlEngine>
+#endif
 
 #define MAJOR 1
 #define MINOR 0
 
 Plugin::Plugin(QObject *parent) :
+#if defined(QT4)
   QDeclarativeExtensionPlugin(parent) {
+#elif defined(QT5)
+  QQmlExtensionPlugin(parent) {
+#endif
 
 }
 
@@ -62,7 +70,11 @@ Plugin::~Plugin() {
 
 }
 
+#if defined(QT4)
 void Plugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+#elif defined(QT5)
+void Plugin::initializeEngine(QQmlEngine *engine, const char *uri) {
+#endif
   Q_UNUSED(uri);
 
   engine->addImageProvider("preview", new PreviewProvider);
@@ -110,4 +122,6 @@ void Plugin::registerTypes(const char *uri) {
   qmlRegisterType<Viewfinder>(uri, MAJOR, MINOR, "Viewfinder");
 }
 
+#if defined(QT4)
 Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin);
+#endif
index 3799f2d..0bb4fae 100644 (file)
 #ifndef PLUGIN_H
 #define PLUGIN_H
 
+#if defined(QT4)
 #include <QDeclarativeExtensionPlugin>
+#elif defined(QT5)
+#include <QQmlExtensionPlugin>
+#endif
 
+#if defined(QT4)
 class Plugin : public QDeclarativeExtensionPlugin {
+#elif defined(QT5)
+class Plugin : public QQmlExtensionPlugin {
+#endif
+
   Q_OBJECT
 
+#if defined(QT5)
+  Q_PLUGIN_METADATA(IID "QtCamera");
+#endif
+
 public:
   Plugin(QObject *parent = 0);
   ~Plugin();
 
+#if defined(QT4)
   void initializeEngine(QDeclarativeEngine *engine, const char *uri);
+#elif defined(QT5)
+  void initializeEngine(QQmlEngine *engine, const char *uri);
+#endif
+
   void registerTypes(const char *uri);
 };
 
index 7ef351c..defaa55 100644 (file)
 PreviewProvider *PreviewProvider::m_instance = 0;
 
 PreviewProvider::PreviewProvider() :
+#if defined(QT4)
   QDeclarativeImageProvider(QDeclarativeImageProvider::Image) {
+#elif defined(QT5)
+  QQuickImageProvider(QQuickImageProvider::Image) {
+#endif
 
   m_instance = this;
 }
index 5c9751e..ab52be1 100644 (file)
 #ifndef PREVIEW_PROVIDER_H
 #define PREVIEW_PROVIDER_H
 
+#if defined(QT4)
 #include <QDeclarativeImageProvider>
+#elif defined(QT5)
+#include <QQuickImageProvider>
+#endif
 #include <QMutex>
 
+#if defined(QT4)
 class PreviewProvider : public QDeclarativeImageProvider {
+#elif defined(QT5)
+class PreviewProvider : public QQuickImageProvider {
+#endif
+
 public:
   PreviewProvider();
   ~PreviewProvider();
index a45dbfc..084b094 100644 (file)
 #include <QWaitCondition>
 #include <QDBusServiceWatcher>
 #include <QDBusConnection>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 #define CAMERA_IMAGE_START_SOUND_ID  "camera-image-start"
 #define CAMERA_IMAGE_END_SOUND_ID    "camera-image-end"
index 1f449d0..8b6310a 100644 (file)
  */
 
 #include "videoplayer.h"
+#if defined(QT4)
 #include <QDeclarativeInfo>
-#include "qtcamgraphicsviewfinder.h"
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include "cameraconfig.h"
 #include <QTimer>
+#include "qtcamviewfinderrenderer.h"
+#include <QPainter>
 
+#if defined(QT4)
 VideoPlayer::VideoPlayer(QDeclarativeItem *parent) :
   QDeclarativeItem(parent),
+#elif defined(QT5)
+VideoPlayer::VideoPlayer(QQuickItem *parent) :
+  QQuickPaintedItem(parent),
+#endif
   m_config(0),
-  m_vf(0),
+  m_renderer(0),
   m_bin(0),
   m_state(VideoPlayer::StateStopped),
   m_timer(new QTimer(this)),
@@ -36,6 +46,10 @@ VideoPlayer::VideoPlayer(QDeclarativeItem *parent) :
   m_timer->setSingleShot(false);
   m_timer->setInterval(500);
   QObject::connect(m_timer, SIGNAL(timeout()), this, SIGNAL(positionChanged()));
+
+#if defined(QT4)
+  setFlag(QGraphicsItem::ItemHasNoContents, false);
+#endif
 }
 
 VideoPlayer::~VideoPlayer() {
@@ -48,7 +62,23 @@ VideoPlayer::~VideoPlayer() {
 }
 
 void VideoPlayer::componentComplete() {
+  if (!m_config) {
+    qmlInfo(this) << "CameraConfig not set";
+    return;
+  }
+
+  m_renderer = QtCamViewfinderRenderer::create(m_config->config(), this);
+  if (!m_renderer) {
+    qmlInfo(this) << "Failed to create viewfinder renderer";
+    return;
+  }
 
+  m_renderer->resize(QSizeF(width(), height()));
+  QObject::connect(m_renderer, SIGNAL(updateRequested()), this, SLOT(updateRequested()));
+
+  if (m_bin) {
+    g_object_set(m_bin, "video-sink", m_renderer->sinkElement(), NULL);
+  }
 }
 
 void VideoPlayer::classBegin() {
@@ -102,14 +132,8 @@ void VideoPlayer::setCameraConfig(CameraConfig *config) {
 
   if (m_config != config) {
     m_config = config;
-    m_vf = new QtCamGraphicsViewfinder(m_config->config(), this);
-    m_vf->resize(QSizeF(width(), height()));
     emit cameraConfigChanged();
   }
-
-  if (m_bin) {
-    g_object_set(m_bin, "video-sink", m_vf->sinkElement(), NULL);
-  }
 }
 
 qint64 VideoPlayer::duration() const {
@@ -198,11 +222,33 @@ bool VideoPlayer::stop() {
 }
 
 void VideoPlayer::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
+#if defined(QT4)
   QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+#elif defined(QT5)
+  QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
+#endif
+
+  if (m_renderer) {
+    m_renderer->resize(newGeometry.size());
+  }
+}
+
+#if defined(QT4)
+void VideoPlayer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                      QWidget *widget) {
 
-  if (m_vf) {
-    m_vf->resize(newGeometry.size());
+  Q_UNUSED(widget);
+  Q_UNUSED(option);
+#elif defined(QT5)
+void VideoPlayer::paint(QPainter *painter) {
+#endif
+  painter->fillRect(boundingRect(), Qt::black);
+
+  if (!m_renderer) {
+    return;
   }
+
+  m_renderer->paint(painter);
 }
 
 VideoPlayer::State VideoPlayer::state() const {
@@ -348,3 +394,7 @@ gboolean VideoPlayer::bus_call(GstBus *bus, GstMessage *msg, gpointer data) {
 
   return TRUE;  
 }
+
+void VideoPlayer::updateRequested() {
+  update();
+}
index 388b621..d944b3b 100644 (file)
 #ifndef VIDEO_PLAYER_H
 #define VIDEO_PLAYER_H
 
+#if defined(QT4)
 #include <QDeclarativeItem>
+#elif defined(QT5)
+#include <QQuickPaintedItem>
+#endif
 #include <gst/gst.h>
 
 class CameraConfig;
-class QtCamGraphicsViewfinder;
+class QtCamViewfinderRenderer;
 
+#if defined(QT4)
 class VideoPlayer : public QDeclarativeItem {
+#elif defined(QT5)
+class VideoPlayer : public QQuickPaintedItem {
+#endif
+
   Q_OBJECT
 
   Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged);
@@ -40,12 +49,24 @@ class VideoPlayer : public QDeclarativeItem {
   Q_ENUMS(State);
 
 public:
+
+#if defined(QT4)
   VideoPlayer(QDeclarativeItem *parent = 0);
+#elif defined(QT5)
+  VideoPlayer(QQuickItem *parent = 0);
+#endif
+
   ~VideoPlayer();
 
   virtual void componentComplete();
   virtual void classBegin();
 
+#if defined(QT4)
+  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+#elif defined(QT5)
+  void paint(QPainter *painter);
+#endif
+
   QUrl source() const;
   void setSource(const QUrl& source);
 
@@ -81,13 +102,16 @@ signals:
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
 
+private slots:
+  void updateRequested();
+
 private:
   static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data);
 
   bool setState(const State& state);
 
   CameraConfig *m_config;
-  QtCamGraphicsViewfinder *m_vf;
+  QtCamViewfinderRenderer *m_renderer;
   QUrl m_url;
 
   GstElement *m_bin;
index 784e166..60ba7bf 100644 (file)
 VideoResolutionModel::VideoResolutionModel(QtCamVideoSettings *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[ResolutionRole] = "resolution";
-  roles[AspectRatioRole] = "resolutionAspectRatio";
-
-  setRoleNames(roles);
+  m_roles[IdRole] = "resolutionId";
+  m_roles[NameRole] = "resolutionName";
+  m_roles[CaptureRole] = "captureResolution";
+  m_roles[PreviewRole] = "previewResolution";
+  m_roles[FpsRole] = "frameRate";
+  m_roles[NightFpsRole] = "nightFrameRate";
+  m_roles[ResolutionRole] = "resolution";
+  m_roles[AspectRatioRole] = "resolutionAspectRatio";
 
   m_resolutions = m_settings->resolutions(m_aspectRatio);
 }
@@ -107,3 +104,7 @@ void VideoResolutionModel::setAspectRatio(const QString& aspectRatio) {
     endResetModel();
   }
 }
+
+QHash<int, QByteArray> VideoResolutionModel::roleNames() const {
+  return m_roles;
+}
index 0fe775c..77bd1bf 100644 (file)
@@ -56,6 +56,8 @@ public:
   QString aspectRatio() const;
   void setAspectRatio(const QString& aspectRatio);
 
+  QHash<int, QByteArray> roleNames() const;
+
 signals:
   void aspectRatioChanged();
 
@@ -65,6 +67,8 @@ private:
   QtCamVideoSettings *m_settings;
 
   QList<QtCamVideoResolution> m_resolutions;
+
+  QHash<int, QByteArray> m_roles;
 };
 
 #endif /* VIDEO_RESOLUTION_MODEL_H */
index d212c35..c0cbd8f 100644 (file)
 #include "camera.h"
 #include "cameraconfig.h"
 #include "qtcamviewfinderrenderer.h"
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include <QPainter>
 #include "qtcamdevice.h"
 
+#if defined(QT4)
 Viewfinder::Viewfinder(QDeclarativeItem *parent) :
   QDeclarativeItem(parent),
+#elif defined(QT5)
+Viewfinder::Viewfinder(QQuickItem *parent) :
+  QQuickPaintedItem(parent),
+#endif
   m_renderer(0),
   m_cam(0),
   m_conf(0),
   m_enabled(true) {
 
+#if defined(QT4)
   setFlag(QGraphicsItem::ItemHasNoContents, false);
+#endif
 }
 
 Viewfinder::~Viewfinder() {
@@ -117,12 +128,15 @@ void Viewfinder::setCameraConfig(CameraConfig *config) {
   emit cameraConfigChanged();
 }
 
+#if defined(QT4)
 void Viewfinder::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                       QWidget *widget) {
 
   Q_UNUSED(widget);
   Q_UNUSED(option);
-
+#elif defined(QT5)
+void Viewfinder::paint(QPainter *painter) {
+#endif
   painter->fillRect(boundingRect(), Qt::black);
 
   if (!m_renderer || !m_enabled) {
@@ -141,7 +155,11 @@ QSizeF Viewfinder::videoResolution() const {
 }
 
 void Viewfinder::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
+#if defined(QT4)
   QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+#elif defined(QT5)
+  QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
+#endif
 
   if (m_renderer) {
     m_renderer->resize(newGeometry.size());
index 42ea853..868099c 100644 (file)
 #ifndef VIEWFINDER_H
 #define VIEWFINDER_H
 
+#if defined(QT4)
 #include <QDeclarativeItem>
+#elif defined(QT5)
+#include <QQuickPaintedItem>
+#endif
 #include "qtcamviewfinder.h"
 
 class QtCamViewfinderRenderer;
 class Camera;
 class CameraConfig;
 
+#if defined(QT4)
 class Viewfinder : public QDeclarativeItem, public QtCamViewfinder {
+#elif defined(QT5)
+class Viewfinder : public QQuickPaintedItem, public QtCamViewfinder {
+#endif
+
   Q_OBJECT
 
   Q_PROPERTY(QRectF renderArea READ renderArea NOTIFY renderAreaChanged);
@@ -40,7 +49,12 @@ class Viewfinder : public QDeclarativeItem, public QtCamViewfinder {
   Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig WRITE setCameraConfig NOTIFY cameraConfigChanged);
 
 public:
+#if defined(QT4)
   Viewfinder(QDeclarativeItem *parent = 0);
+#elif defined(QT5)
+  Viewfinder(QQuickItem *parent = 0);
+#endif
+
   ~Viewfinder();
 
   QRectF renderArea() const;
@@ -55,7 +69,11 @@ public:
   CameraConfig *cameraConfig() const;
   void setCameraConfig(CameraConfig *config);
 
+#if defined(QT4)
   void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+#elif defined(QT5)
+  void paint(QPainter *painter);
+#endif
 
   GstElement *sinkElement();
   bool setDevice(QtCamDevice *device);
index 9b3beba..0f27035 100644 (file)
@@ -16,7 +16,7 @@ harmattan:PKGCONFIG += meego-gstreamer-interfaces-0.10
 
 HEADERS += qtcamconfig.h qtcamera.h qtcamscanner.h qtcamdevice.h qtcamviewfinder.h \
            qtcammode.h qtcamgstreamermessagehandler.h qtcamgstreamermessagelistener.h \
-           qtcamgraphicsviewfinder.h qtcamviewfinderrenderer.h \
+           qtcamviewfinderrenderer.h \
            qtcamviewfinderrenderergeneric.h qtcamimagesettings.h qtcamvideosettings.h \
            qtcamimagemode.h qtcamvideomode.h qtcammetadata.h qtcamcapability.h \
            qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
@@ -27,7 +27,7 @@ HEADERS += qtcamconfig.h qtcamera.h qtcamscanner.h qtcamdevice.h qtcamviewfinder
 
 SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
            qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
-           qtcamgraphicsviewfinder.cpp qtcamviewfinderrenderer.cpp \
+           qtcamviewfinderrenderer.cpp \
            qtcamviewfinderrenderergeneric.cpp qtcamimagesettings.cpp qtcamvideosettings.cpp \
            qtcamimagemode.cpp qtcamvideomode.cpp qtcammetadata.cpp qtcamcapability.cpp \
            qtcamzoom.cpp qtcamflash.cpp qtcamscene.cpp qtcamevcomp.cpp qtcamvideotorch.cpp \
@@ -47,5 +47,8 @@ SOURCES += gst/gstcopy.cpp
 harmattan:SOURCES += qtcamviewfinderrenderermeego.cpp
 harmattan:HEADERS += qtcamviewfinderrenderermeego.h
 
+qt4:SOURCES += qtcamgraphicsviewfinder.cpp
+qt4:HEADERS += qtcamgraphicsviewfinder.h
+
 target.path = /usr/lib/
 INSTALLS += target
index 5cd25cb..95ffe19 100644 (file)
 
 #include "batteryinfo.h"
 #include <qmbattery.h>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 BatteryInfo::BatteryInfo(QObject *parent) :
   QObject(parent), m_battery(0) {
index 6c10d3f..6dd1649 100644 (file)
 #include "dbusservice.h"
 #include <QDBusInterface>
 #include "platformsettings.h"
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include <QDBusPendingCall>
 
 // We cannot use ADBusInterface because it will try to introspect the service upon
index 59c1fad..aa09ab3 100644 (file)
 #include "deletehelper.h"
 #include <QUrl>
 #include <QFile>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 DeleteHelper::DeleteHelper(QObject *parent) :
   QObject(parent) {
index 29360c8..cb612bc 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "displaystate.h"
-#include <qmsystem2/qmdisplaystate.h>
+#include <qmdisplaystate.h>
 #include <QTimer>
 #include <QDebug>
 
index 1ea5b7f..3c72211 100644 (file)
 #include <QDir>
 #include <QDate>
 #include <QFile>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 #define PATH QString("%1%2MyDocs%2DCIM%2").arg(QDir::homePath()).arg(QDir::separator())
 #define TEMP_PATH QString("%1%2MyDocs%2.cameraplus%2").arg(QDir::homePath()).arg(QDir::separator())
index d78377c..293fa0e 100644 (file)
 
 #include "focusrectangle.h"
 #include <QPainter>
-#include <QDebug>
 
 #define WIDTH  4
 #define LENGTH 30
 
+#if defined(QT4)
 FocusRectangle::FocusRectangle(QDeclarativeItem *parent) :
   QDeclarativeItem(parent),
+#elif defined(QT5)
+FocusRectangle::FocusRectangle(QQuickItem *parent) :
+  QQuickPaintedItem(parent),
+#endif
   m_color(Qt::white) {
 
+#if defined(QT4)
   setFlag(QGraphicsItem::ItemHasNoContents, false);
+#endif
 }
 
 FocusRectangle::~FocusRectangle() {
@@ -49,10 +55,14 @@ void FocusRectangle::setColor(const QColor& color) {
   }
 }
 
+#if defined(QT4)
 void FocusRectangle::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
                           QWidget* widget) {
 
   QDeclarativeItem::paint(painter, option, widget);
+#elif defined(QT5)
+void FocusRectangle::paint(QPainter* painter) {
+#endif
 
   painter->save();
 
@@ -66,7 +76,11 @@ void FocusRectangle::paint(QPainter* painter, const QStyleOptionGraphicsItem* op
 }
 
 void FocusRectangle::geometryChanged( const QRectF& newGeometry, const QRectF& oldGeometry) {
+#if defined(QT4)
   QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+#elif defined(QT5)
+  QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
+#endif
 
   qreal w = width();
   qreal h = height();
index 845e0d9..3f26764 100644 (file)
 #ifndef FOCUS_RECTANGLE_H
 #define FOCUS_RECTANGLE_H
 
+#if defined(QT4)
 #include <QDeclarativeItem>
+#elif defined(QT5)
+#include <QQuickPaintedItem>
+#endif
+#include <QPainterPath>
 
+#if defined(QT4)
 class FocusRectangle : public QDeclarativeItem {
+#elif defined(QT5)
+class FocusRectangle : public QQuickPaintedItem {
+#endif
+
   Q_OBJECT
 
   Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged);
 
 public:
+#if defined(QT4)
   FocusRectangle(QDeclarativeItem *parent = 0);
+#elif defined(QT5)
+  FocusRectangle(QQuickItem *parent = 0);
+#endif
+
   ~FocusRectangle();
 
   QColor color() const;
   void setColor(const QColor& color);
 
+#if defined(QT4)
   void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+#elif defined(QT5)
+  void paint(QPainter* painter);
+#endif
 
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
index 970bc7c..b7cbe3d 100644 (file)
 #include "gridlines.h"
 #include <QPainter>
 
+#if defined(QT4)
 GridLines::GridLines(QDeclarativeItem *parent) :
   QDeclarativeItem(parent) {
+#elif defined(QT5)
+GridLines::GridLines(QQuickItem *parent) :
+  QQuickPaintedItem(parent) {
+#endif
 
+#if defined(QT4)
   setFlag(QGraphicsItem::ItemHasNoContents, false);
+#endif
 }
 
 GridLines::~GridLines() {
 
 }
 
-void GridLines::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
-  Q_UNUSED(option);
-  Q_UNUSED(widget);
+#if defined(QT4)
+void GridLines::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
+                          QWidget* widget) {
+
+  QDeclarativeItem::paint(painter, option, widget);
+#elif defined(QT5)
+void GridLines::paint(QPainter* painter) {
+#endif
 
   painter->save();
   painter->setPen(QPen(Qt::black, 3));
@@ -45,7 +57,11 @@ void GridLines::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
 }
 
 void GridLines::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
+#if defined(QT4)
   QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+#elif defined(QT5)
+  QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
+#endif
 
   qreal width = newGeometry.width();
   qreal height = newGeometry.height();
index 91bfdc8..28db500 100644 (file)
 #ifndef GRID_LINES_H
 #define GRID_LINES_H
 
+#if defined(QT4)
 #include <QDeclarativeItem>
+#elif defined(QT5)
+#include <QQuickPaintedItem>
+#endif
+#include <QLineF>
 
+#if defined(QT4)
 class GridLines : public QDeclarativeItem {
+#elif defined(QT5)
+class GridLines : public QQuickPaintedItem {
+#endif
+
   Q_OBJECT
 
 public:
+#if defined(QT4)
   GridLines(QDeclarativeItem *parent = 0);
+#elif defined(QT5)
+  GridLines(QQuickItem *parent = 0);
+#endif
   ~GridLines();
 
+#if defined(QT4)
   void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+#elif defined(QT5)
+  void paint(QPainter* painter);
+#endif
 
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
index 9ea3d26..8dfdd0f 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#if defined(QT4)
 #include <QApplication>
 #include <QDeclarativeView>
 #include <QDeclarativeContext>
 #include <QDeclarativeEngine>
 #include <QtDeclarative>
 #include <QGLWidget>
+#elif defined(QT5)
+#include <QGuiApplication>
+#include <QQuickView>
+#endif
 
 #include "settings.h"
 #include "filenaming.h"
@@ -36,7 +41,9 @@
 #include "cameraresources.h"
 #include "compass.h"
 #include "orientation.h"
+#if defined(QT4) // TODO:
 #include "geocode.h"
+#endif
 #include "mountprotector.h"
 #include "trackerstore.h"
 #include "focusrectangle.h"
 #include "platformsettings.h"
 #include "dbusservice.h"
 
+#ifdef HAVE_BOOSTER
+#include <MDeclarativeCache>
+#endif
+
 #ifdef QMLJSDEBUGGER
 #include "qt_private/qdeclarativedebughelper_p.h"
 #endif /* QMLJSDEBUGGER */
 
+#if defined(QT4)
 #include <QAbstractFileEngineHandler>
 #include "qmlfileengine.h"
 
@@ -68,24 +80,42 @@ class QmlFileEngineHandler : public QAbstractFileEngineHandler {
     return 0;
   }
 };
+#endif
 
 Q_DECL_EXPORT int main(int argc, char *argv[]) {
+#if defined(QT4)
   QApplication::setAttribute(Qt::AA_X11InitThreads, true);
-  QApplication app(argc, argv);
+  QApplication *app = new QApplication(argc, argv);
 
   QmlFileEngineHandler handler;
   Q_UNUSED(handler);
 
+  QDeclarativeView *view = new QDeclarativeView;
+#elif defined(HAVE_BOOSTER)
+  QGuiApplication *app = MDeclarativeCache::qApplication(argc, argv);
+  QQuickView *view = MDeclarativeCache::qQuickView();
+#elif defined(QT5)
+  QGuiApplication::setAttribute(Qt::AA_X11InitThreads, true);
+  QGuiApplication *app = new QGuiApplication(argc, argv);
+  QQuickView *view = new QQuickView;
+#endif
+
 #ifdef QMLJSDEBUGGER
   QDeclarativeDebugHelper::enableDebugging();
 #endif /* QMLJSDEBUGGER */
 
-  QDeclarativeView view;
-  view.setAttribute(Qt::WA_NoSystemBackground);
-  view.setViewport(new QGLWidget);
-  view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
-  view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
-  view.viewport()->setAttribute(Qt::WA_NoSystemBackground);
+#if defined(QT4)
+  view->setAttribute(Qt::WA_NoSystemBackground);
+  view->setViewport(new QGLWidget);
+  view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+  view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+  view->viewport()->setAttribute(Qt::WA_NoSystemBackground);
+#endif
+
+#if defined(QT5)
+  view->setResizeMode(QQuickView::SizeRootObjectToView);
+  // TODO:
+#endif
 
   qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
   qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
@@ -98,7 +128,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) {
   qmlRegisterType<CameraResources>("CameraPlus", 1, 0, "CameraResources");
   qmlRegisterType<Compass>("CameraPlus", 1, 0, "Compass");
   qmlRegisterType<Orientation>("CameraPlus", 1, 0, "Orientation");
+#if defined(QT4) // TODO:
   qmlRegisterType<Geocode>("CameraPlus", 1, 0, "ReverseGeocode");
+#endif
   qmlRegisterType<MountProtector>("CameraPlus", 1, 0, "MountProtector");
   qmlRegisterType<TrackerStore>("CameraPlus", 1, 0, "TrackerStore");
   qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
@@ -108,14 +140,20 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) {
   qmlRegisterType<PostCaptureModel>("CameraPlus", 1, 0, "PostCaptureModel");
   qmlRegisterType<BatteryInfo>("CameraPlus", 1, 0, "BatteryInfo");
   qmlRegisterType<GridLines>("CameraPlus", 1, 0, "GridLines");
+#if defined(QT4) // TODO:
   qmlRegisterType<DeviceInfo>("CameraPlus", 1, 0, "DeviceInfo");
+#endif
   qmlRegisterType<DeviceKeys>("CameraPlus", 1, 0, "DeviceKeys");
   qmlRegisterType<PlatformSettings>("CameraPlus", 1, 0, "PlatformSettings");
 
-  view.setSource(QUrl("qrc:/qml/main.qml"));
+  view->setSource(QUrl("qrc:/qml/main.qml"));
+
+  view->showFullScreen();
+
+  int ret = app->exec();
 
-  view.showFullScreen();
+  delete view;
+  delete app;
 
-  int ret = app.exec();
   return ret;
 }
index 04d9fca..ad7d135 100644 (file)
 #include "mountprotector.h"
 #include <QDir>
 #include <QTemporaryFile>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 
 MountProtector::MountProtector(QObject *parent) :
   QObject(parent), m_file(0) {
index 646c14f..5fc04a6 100644 (file)
@@ -3,5 +3,5 @@ INCLUDEPATH += nemo .
 
 PKGCONFIG += 
 
-HEADERS += soundvolumecontrol.h
-SOURCES += soundvolumecontrol.cpp
+HEADERS += nemo/soundvolumecontrol.h
+SOURCES += nemo/soundvolumecontrol.cpp
index d7b9c67..54e7c31 100644 (file)
 #include <QSparqlQuery>
 #include <QSparqlResult>
 #include <QSparqlError>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include <QDateTime>
 #include <QDBusConnection>
 #include <QStringList>
@@ -73,10 +77,6 @@ PostCaptureModel::PostCaptureModel(QObject *parent) :
   m_connection(0),
   m_connected(false) {
 
-  QHash<int, QByteArray> roles;
-  roles.insert(Item, "item");
-  setRoleNames(roles);
-
   qDBusRegisterMetaType<Quad>();
   qDBusRegisterMetaType<QList<Quad> >();
 }
@@ -88,6 +88,12 @@ PostCaptureModel::~PostCaptureModel() {
   delete m_connection; m_connection = 0;
 }
 
+QHash<int, QByteArray> PostCaptureModel::roleNames() const {
+  QHash<int, QByteArray> roles;
+  roles.insert(Item, "item");
+  return roles;
+}
+
 void PostCaptureModel::reload() {
   delete m_connection; m_connection = 0;
 
index b04be38..69f5130 100644 (file)
@@ -56,6 +56,8 @@ public:
   QString model() const;
   void setModel(const QString& model);
 
+  QHash<int, QByteArray> roleNames() const;
+
 signals:
   void error(const QString& msg);
 
index feb4a1d..0fb2890 100644 (file)
@@ -4,25 +4,33 @@ DEPENDPATH += . ../
 INCLUDEPATH += . ../
 include(../cameraplus.pri)
 
-QT += declarative opengl dbus
-
-CONFIG += link_pkgconfig mobility qtsparql
-
-MOBILITY += location systeminfo
+QT += dbus
+CONFIG += link_pkgconfig
+
+qt4 {
+    QT += declarative opengl
+    CONFIG += mobility
+    MOBILITY += location systeminfo
+    PKGCONFIG += qtsparql qmsystem2 libresourceqt1
+}
 
-PKGCONFIG = qmsystem2 libresourceqt1
+qt5 {
+    QT += qml quick
+    PKGCONFIG += Qt5Sparql qmsystem2-qt5 libresourceqt5 qdeclarative5-boostable
+    DEFINES += HAVE_BOOSTER
+}
 
 SOURCES += main.cpp settings.cpp filenaming.cpp displaystate.cpp fsmonitor.cpp \
-           cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
+           cameraresources.cpp compass.cpp orientation.cpp mountprotector.cpp \
            trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
-           postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp \
-           platformsettings.cpp dbusservice.cpp qmlfileengine.cpp
+           postcapturemodel.cpp batteryinfo.cpp gridlines.cpp devicekeys.cpp \
+           platformsettings.cpp dbusservice.cpp
 
 HEADERS += settings.h filenaming.h displaystate.h fsmonitor.h \
-           cameraresources.h compass.h orientation.h geocode.h mountprotector.h \
+           cameraresources.h compass.h orientation.h mountprotector.h \
            trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \
-           postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h \
-           platformsettings.h dbusservice.h qmlfileengine.h
+           postcapturemodel.h batteryinfo.h gridlines.h devicekeys.h \
+           platformsettings.h dbusservice.h
 
 RESOURCES += ../qml/qml.qrc
 
@@ -42,5 +50,11 @@ nemo {
     RESOURCES += ../qml/harmattan/harmattan.qrc
 }
 
+qt4 {
+# TODO: geocode.*
+    SOURCES += qmlfileengine.cpp geocode.cpp deviceinfo.cpp
+    HEADERS += qmlfileengine.h geocode.h deviceinfo.h
+}
+
 target.path = /usr/bin/
 INSTALLS += target
index 2a907b6..a0f73e2 100644 (file)
 #include <QSparqlConnection>
 #include <QSparqlQuery>
 #include <QUrl>
+#if defined(QT4)
 #include <QDeclarativeInfo>
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
 #include <QSparqlResult>
 #include <QScopedPointer>
 #include <QSparqlError>