Implemented own DeviceInfo
authorMohammed Sameer <msameer@foolab.org>
Tue, 1 Jan 2013 16:04:28 +0000 (18:04 +0200)
committerMohammed Sameer <msameer@foolab.org>
Tue, 1 Jan 2013 16:04:28 +0000 (18:04 +0200)
qml/main.qml
src/deviceinfo.cpp [new file with mode: 0644]
src/deviceinfo.h [new file with mode: 0644]
src/main.cpp
src/src.pro

index fb722be..9b98779 100644 (file)
@@ -25,7 +25,6 @@ import com.nokia.meego 1.1
 import com.nokia.extras 1.1
 import QtCamera 1.0
 import CameraPlus 1.0
-import QtMobility.systeminfo 1.2 as Qtm
 import QtMobility.location 1.2
 
 // TODO: flash not ready (battery low or flash not ready message)
@@ -116,7 +115,7 @@ PageStackWindow {
                 camera: cam
         }
 
-        Qtm.DeviceInfo {
+        DeviceInfo {
                 id: deviceInfo
         }
 
diff --git a/src/deviceinfo.cpp b/src/deviceinfo.cpp
new file mode 100644 (file)
index 0000000..3fda9ed
--- /dev/null
@@ -0,0 +1,48 @@
+/*!
+ * 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 "deviceinfo.h"
+#include <QSystemDeviceInfo>
+
+DeviceInfo::DeviceInfo(QObject *parent) :
+  QObject(parent),
+  m_info(new QtMobility::QSystemDeviceInfo(this)) {
+
+}
+
+DeviceInfo::~DeviceInfo() {
+
+}
+
+QString DeviceInfo::manufacturer() {
+  if (m_manufacturer.isEmpty()) {
+    m_manufacturer = m_info->manufacturer();
+  }
+
+  return m_manufacturer;
+}
+
+QString DeviceInfo::model() {
+  if (m_model.isEmpty()) {
+    m_model = m_info->model();
+  }
+
+  return m_model;
+}
diff --git a/src/deviceinfo.h b/src/deviceinfo.h
new file mode 100644 (file)
index 0000000..5710b27
--- /dev/null
@@ -0,0 +1,52 @@
+// -*- 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_INFO_H
+#define DEVICE_INFO_H
+
+#include <QObject>
+
+namespace QtMobility {
+class QSystemDeviceInfo;
+};
+
+class DeviceInfo : public QObject {
+  Q_OBJECT
+
+  Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT);
+  Q_PROPERTY(QString model READ model CONSTANT);
+
+public:
+  DeviceInfo(QObject *parent = 0);
+  ~DeviceInfo();
+
+  QString manufacturer();
+  QString model();
+
+private:
+  QtMobility::QSystemDeviceInfo *m_info;
+
+  QString m_manufacturer;
+  QString m_model;
+};
+
+#endif /* DEVICE_INFO_H */
index f55d153..1763a34 100644 (file)
@@ -46,6 +46,7 @@
 #include "postcapturemodel.h"
 #include "batteryinfo.h"
 #include "gridlines.h"
+#include "deviceinfo.h"
 
 static void initQuill() {
   // TODO: All these are hardcoded.
@@ -94,6 +95,7 @@ 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");
+  qmlRegisterType<DeviceInfo>("CameraPlus", 1, 0, "DeviceInfo");
 
   view.setSource(QUrl("qrc:/qml/main.qml"));
 
index 6c8fe69..66f221e 100644 (file)
@@ -8,7 +8,7 @@ QT += declarative opengl dbus
 CONFIG += link_pkgconfig debug static mobility qtsparql galleryinterface-maemo-meegotouch \
           shareuiinterface-maemo-meegotouch
 
-MOBILITY += location
+MOBILITY += location systeminfo
 
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
             gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1
@@ -18,11 +18,11 @@ LIBS +=  -L../imports/ -limports -L../lib/ -lqtcamera
 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
+           postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.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
+           postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h
 
 RESOURCES += ../qml/qml.qrc