From e41353892372484cea152d3ba59939f30ec90d7b Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Fri, 28 Dec 2012 04:31:48 +0200 Subject: [PATCH] Invoke share UI when share button gets tapped --- qml/PostCaptureItem.qml | 1 + qml/PostCapturePage.qml | 15 +++++++++++++-- src/main.cpp | 2 ++ src/sharehelper.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/sharehelper.h | 41 +++++++++++++++++++++++++++++++++++++++++ src/src.pro | 6 +++--- 6 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 src/sharehelper.cpp create mode 100644 src/sharehelper.h diff --git a/qml/PostCaptureItem.qml b/qml/PostCaptureItem.qml index 8b3d243..a9d83df 100644 --- a/qml/PostCaptureItem.qml +++ b/qml/PostCaptureItem.qml @@ -36,6 +36,7 @@ Item { property string creationDate: created property string itemTitle: title property bool itemAvailable: available + property url itemUrl: url function startPlayback() { openFileNow("VideoPlayerPage.qml"); diff --git a/qml/PostCapturePage.qml b/qml/PostCapturePage.qml index 0ddb1cc..29a3470 100644 --- a/qml/PostCapturePage.qml +++ b/qml/PostCapturePage.qml @@ -29,7 +29,6 @@ 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: share // TODO: menu CameraPage { id: page @@ -68,6 +67,18 @@ CameraPage { } } + function shareCurrentItem() { + if (!available) { + return; + } + + share.share(currentItem.itemUrl); + } + + ShareHelper { + id: share + } + Rectangle { color: "black" anchors.fill: parent @@ -120,7 +131,7 @@ CameraPage { id: layout ToolIcon { iconId: "icon-m-toolbar-back-white"; onClicked: { pageStack.pop(); } } 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" } + 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" } } diff --git a/src/main.cpp b/src/main.cpp index 1fde073..179e980 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,7 @@ #include "mountprotector.h" #include "trackerstore.h" #include "focusrectangle.h" +#include "sharehelper.h" static void initQuill() { // TODO: All these are hardcoded. @@ -82,6 +83,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) { qmlRegisterType("CameraPlus", 1, 0, "MountProtector"); qmlRegisterType("CameraPlus", 1, 0, "TrackerStore"); qmlRegisterType("CameraPlus", 1, 0, "FocusRectangle"); + qmlRegisterType("CameraPlus", 1, 0, "ShareHelper"); QUrl sourceUrl = QUrl::fromLocalFile(QDir::currentPath() + "/main.qml"); view.setSource(sourceUrl); diff --git a/src/sharehelper.cpp b/src/sharehelper.cpp new file mode 100644 index 0000000..74470ba --- /dev/null +++ b/src/sharehelper.cpp @@ -0,0 +1,41 @@ +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012 Mohammed Sameer + * + * 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 "sharehelper.h" +#include +#include +#include +#include + +ShareHelper::ShareHelper(QObject *parent) : + QObject(parent) { + +} + +ShareHelper::~ShareHelper() { + +} + +void ShareHelper::share(const QUrl& path) { + QDBusInterface iface("com.nokia.ShareUi", "/", "com.nokia.maemo.meegotouch.ShareUiInterface", + QDBusConnection::sessionBus()); + + iface.call("share", QStringList() << path.toLocalFile()); +} diff --git a/src/sharehelper.h b/src/sharehelper.h new file mode 100644 index 0000000..4e42e87 --- /dev/null +++ b/src/sharehelper.h @@ -0,0 +1,41 @@ +// -*- c++ -*- + +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012 Mohammed Sameer + * + * 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 SHARE_HELPER_H +#define SHARE_HELPER_H + +#include + +class QUrl; + +class ShareHelper : public QObject { + Q_OBJECT + +public: + ShareHelper(QObject *parent = 0); + ~ShareHelper(); + +public slots: + void share(const QUrl& path); +}; + +#endif /* SHARE_HELPER_H */ diff --git a/src/src.pro b/src/src.pro index d1057e1..8f466a8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -3,7 +3,7 @@ TARGET = cameraplus DEPENDPATH += . ../ INCLUDEPATH += . ../ -QT += declarative opengl +QT += declarative opengl dbus CONFIG += link_pkgconfig debug static mobility qtsparql @@ -16,8 +16,8 @@ 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 + trackerstore.cpp focusrectangle.cpp sharehelper.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 + trackerstore.h focusrectangle.h sharehelper.h -- 2.25.1