Added gallery integration
authorMohammed Sameer <msameer@foolab.org>
Fri, 28 Dec 2012 09:47:46 +0000 (11:47 +0200)
committerMohammed Sameer <msameer@foolab.org>
Fri, 28 Dec 2012 09:48:32 +0000 (11:48 +0200)
qml/PostCapturePage.qml
src/galleryhelper.cpp [new file with mode: 0644]
src/galleryhelper.h [new file with mode: 0644]
src/main.cpp
src/src.pro

index 0d1a337..74a1ecb 100644 (file)
@@ -29,7 +29,7 @@ import CameraPlus 1.0
 // TODO: losing resources while playback won't show an error
 // TODO: show something if we have no files.
 // TODO: favorites
-// TODO: menu
+
 CameraPage {
         id: page
 
@@ -48,6 +48,31 @@ CameraPage {
                 return new Date(dates[0], dates[1], dates[2], times[0], times[1], times[2]);
         }
 
+
+        function launchGallery() {
+                if (!gallery.launch()) {
+                        showError(qsTr("Failed to launch gallery"));
+                }
+        }
+
+        function showInGallery() {
+                if (!available) {
+                        return;
+                }
+
+                if (!gallery.show(currentItem.itemUrl)) {
+                        showError(qsTr("Failed to launch gallery"));
+                }
+        }
+
+        Menu {
+                id: menu
+                MenuLayout {
+                        MenuItem {text: qsTr("Captures in gallery"); onClicked: launchGallery(); }
+                        MenuItem {text: qsTr("View in gallery"); enabled: available; onClicked: showInGallery(); }
+                }
+        }
+
         function deleteCurrentItem() {
                 if (!available) {
                         return;
@@ -88,6 +113,10 @@ CameraPage {
                 id: share
         }
 
+        GalleryHelper {
+                id: gallery
+        }
+
         Rectangle {
                 color: "black"
                 anchors.fill: parent
@@ -142,7 +171,7 @@ CameraPage {
                         ToolIcon { iconId: available ? "icon-m-toolbar-favorite-mark-white" : "icon-m-toolbar-favorite-mark-dimmed-white"}
                         ToolIcon { iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"; onClicked: shareCurrentItem(); }
                         ToolIcon { iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"; onClicked: deleteCurrentItem(); }
-                        ToolIcon { iconId: "icon-m-toolbar-view-menu-white" }
+                        ToolIcon { iconId: "icon-m-toolbar-view-menu-white"; onClicked: menu.open(); }
                 }
         }
 
diff --git a/src/galleryhelper.cpp b/src/galleryhelper.cpp
new file mode 100644 (file)
index 0000000..d2befa1
--- /dev/null
@@ -0,0 +1,53 @@
+/*!
+ * 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 "galleryhelper.h"
+#include <maemo-meegotouch-interfaces/galleryinterface.h>
+#include <QStringList>
+#include <QUrl>
+#include <QDeclarativeInfo>
+
+GalleryHelper::GalleryHelper(QObject *parent) :
+  QObject(parent),
+  m_iface(new GalleryInterface) {
+
+}
+
+GalleryHelper::~GalleryHelper() {
+  delete m_iface;
+}
+
+bool GalleryHelper::show(const QUrl& path) {
+  if (!m_iface->isValid()) {
+    qmlInfo(this) << "Failed to get gallery interface";
+    return false;
+  }
+
+  return m_iface->showMediaInFullScreen(QStringList() << path.toLocalFile());
+}
+
+bool GalleryHelper::launch() {
+  if (!m_iface->isValid()) {
+    qmlInfo(this) << "Failed to get gallery interface";
+    return false;
+  }
+
+  return m_iface->showCameraRoll();
+}
diff --git a/src/galleryhelper.h b/src/galleryhelper.h
new file mode 100644 (file)
index 0000000..d10e19d
--- /dev/null
@@ -0,0 +1,45 @@
+// -*- 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 GALLERY_HELPER_H
+#define GALLERY_HELPER_H
+
+#include <QObject>
+
+class QUrl;
+class GalleryInterface;
+
+class GalleryHelper : public QObject {
+  Q_OBJECT
+
+public:
+  GalleryHelper(QObject *parent = 0);
+  ~GalleryHelper();
+
+  Q_INVOKABLE bool show(const QUrl& path);
+  Q_INVOKABLE bool launch();
+
+private:
+  GalleryInterface *m_iface;
+};
+
+#endif /* GALLERY_HELPER_H */
index 88b910f..f49dab1 100644 (file)
@@ -42,6 +42,7 @@
 #include "focusrectangle.h"
 #include "sharehelper.h"
 #include "deletehelper.h"
+#include "galleryhelper.h"
 
 static void initQuill() {
   // TODO: All these are hardcoded.
@@ -86,6 +87,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) {
   qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
   qmlRegisterType<ShareHelper>("CameraPlus", 1, 0, "ShareHelper");
   qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
+  qmlRegisterType<GalleryHelper>("CameraPlus", 1, 0, "GalleryHelper");
 
   QUrl sourceUrl = QUrl::fromLocalFile(QDir::currentPath() + "/main.qml");
   view.setSource(sourceUrl);
index d61b5ff..e6808b9 100644 (file)
@@ -5,20 +5,20 @@ INCLUDEPATH += . ../
 
 QT += declarative opengl dbus
 
-CONFIG += link_pkgconfig debug static mobility qtsparql
+CONFIG += link_pkgconfig debug static mobility qtsparql galleryinterface-maemo-meegotouch \
+          shareuiinterface-maemo-meegotouch
 
 MOBILITY += location
 
 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 \
-            ShareUiInterface-maemo-meegotouch
+            gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1
 
 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
+           trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.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
+           trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h