share feeditems

This commit is contained in:
Hauke Schade 2013-06-02 18:07:49 +02:00
parent 9191838f87
commit 74bee46e22
6 changed files with 114 additions and 5 deletions

View file

@ -138,6 +138,11 @@
<source>Open in Web Browser</source>
<translation>Open in Web Browser</translation>
</message>
<message>
<location filename="../qml/ttrss/FeedItem.qml" line="235"/>
<source>Share</source>
<translation>Share</translation>
</message>
</context>
<context>
<name>FeedItems</name>

View file

@ -6,6 +6,7 @@
#include "settings.hh"
#include "mynetworkmanager.hh"
#include "qmlutils.hh"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
@ -35,6 +36,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
viewer.rootContext()->setContextProperty("APP_VERSION", APP_VERSION);
viewer.rootContext()->setContextProperty("QMLUtils", QMLUtils::instance());
viewer.rootContext()->setContextProperty("settings", Settings::instance());
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);

View file

@ -231,6 +231,11 @@ Page {
Qt.openUrlExternally(url);
}
}
MenuItem {
text: qsTr("Share")
enabled: url && (url != "")
onClicked: QMLUtils.share(url, pageTitle);
}
SettingsItem {}
AboutItem {}
}

59
qmlutils.cpp Normal file
View file

@ -0,0 +1,59 @@
//Copyright Hauke Schade, 2012-2013
//
//This file is part of TTRss.
//
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
//TTRss 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 General Public License for more details.
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
#include "qmlutils.hh"
#ifdef Q_OS_HARMATTAN
#include <MDataUri>
#include <maemo-meegotouch-interfaces/shareuiinterface.h>
#endif
QScopedPointer<QMLUtils> QMLUtils::m_instance(0);
QMLUtils::QMLUtils(QObject *parent) : QObject(parent) {
}
QMLUtils *QMLUtils::instance() {
if (m_instance.isNull())
m_instance.reset(new QMLUtils);
return m_instance.data();
}
void QMLUtils::share(const QString &link, const QString &title) {
#ifdef Q_OS_HARMATTAN
MDataUri uri;
uri.setMimeType("text/x-url");
uri.setTextData(link);
if (!title.isEmpty())
uri.setAttribute("title", title);
if (!uri.isValid()) {
qCritical("QMLUtils::shareLink(): Invalid URI");
return;
}
ShareUiInterface shareIf("com.nokia.ShareUi");
if (!shareIf.isValid()) {
qCritical("QMLUtils::shareLink(): Invalid Share UI interface");
return;
}
shareIf.share(QStringList() << uri.toString());
#else
qWarning("QMLUtils::shareLink(): This function only available on Harmattan");
Q_UNUSED(title)
Q_UNUSED(link)
#endif
}

35
qmlutils.hh Normal file
View file

@ -0,0 +1,35 @@
//Copyright Hauke Schade, 2012-2013
//
//This file is part of TTRss.
//
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
//TTRss 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 General Public License for more details.
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
#ifndef QMLUTILS_HH
#define QMLUTILS_HH
#include <QtCore/QObject>
#include <QtCore/QVariant>
#include <QtCore/QScopedPointer>
class QMLUtils : public QObject
{
Q_OBJECT
public:
static QMLUtils *instance();
// Share a link using Harmattan Share UI
Q_INVOKABLE void share(const QString &link, const QString &title = QString());
private:
static QScopedPointer<QMLUtils> m_instance;
explicit QMLUtils(QObject *parent = 0);
Q_DISABLE_COPY(QMLUtils)
};
#endif // QMLUTILS_HH

View file

@ -1,4 +1,4 @@
VERSION = 0.2.1
VERSION = 0.2.2
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
# Add more folders to ship with the application, here
@ -27,15 +27,17 @@ symbian:TARGET.CAPABILITY += NetworkServices
# MOBILITY +=
# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
CONFIG += qdeclarative-boostable
CONFIG += shareuiinterface-maemo-meegotouch share-ui-plugin share-ui-common qdeclarative-boostable
DEFINES += Q_OS_HARMATTAN
# Add dependency to Symbian components
# CONFIG += qt-components
# The .cpp file which was generated for your project. Feel free to hack it.
# The .cpp files
SOURCES += main.cpp \
settings.cpp \
mynetworkmanager.cpp
mynetworkmanager.cpp \
qmlutils.cpp
# Please do not modify the following two lines. Required for deployment.
include(qmlapplicationviewer/qmlapplicationviewer.pri)
@ -46,4 +48,5 @@ RESOURCES += \
HEADERS += \
settings.hh \
mynetworkmanager.hh
mynetworkmanager.hh \
qmlutils.hh