diff --git a/assets/PostItem.qml b/assets/PostItem.qml index dc93478..7b847d3 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -149,11 +149,13 @@ Container { WebImageView { url: { var oembed = "" - ListItemData.raw.forEach(function (item) { - if (item["type"] == "io.pnut.core.oembed") { - oembed = item["value"]["url"] - } - }) + if (typeof ListItemData.raw !== "undefined") { + ListItemData.raw.forEach(function (item) { + if (item["type"] == "io.pnut.core.oembed") { + oembed = item["value"]["url"] + } + }) + } return oembed } scalingMethod: ScalingMethod.AspectFit @@ -247,6 +249,18 @@ Container { postitem.ListItem.view.copyText(ListItemData.content.text) } } + InvokeActionItem { + title: "Share" + query { + mimeType: "text/plain" + invokeActionId: "bb.action.SHARE" + } + data: { + var text = "@" + ListItemData.user.username + ": " + ListItemData.content.text + text = text + "\n\n" + "https://posts.pnut.io/" + ListItemData.id + return text + } + } // ActionItem { // id: edItem // enabled: (ListItemData.user.username === postitem.ListItem.view.getUserName()) diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 54dd8db..9ba167a 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -365,4 +365,9 @@ NavigationPane { pnut.sinceId = 0 pnut.getStream(endpoint, Pnut.STREAM_OLDER); } + function createPost(text) { + newPostSheet.open() + newPostSheet.text = text + newPostSheet.input.requestFocus(); + } } diff --git a/assets/main.qml b/assets/main.qml index 1138ac3..a163feb 100644 --- a/assets/main.qml +++ b/assets/main.qml @@ -179,6 +179,7 @@ TabbedPane { } else if (style === "2") { Application.themeSupport.setVisualStyle(VisualStyle.Dark) } + _app.createPost.connect(activePane.createPost) } } diff --git a/bar-descriptor.xml b/bar-descriptor.xml index e677c7f..d2b96cc 100644 --- a/bar-descriptor.xml +++ b/bar-descriptor.xml @@ -107,4 +107,13 @@ run_native + + + application + + bb.action.SHARE + text/plain + + + diff --git a/src/applicationui.cpp b/src/applicationui.cpp index cadc3ff..b3eab78 100644 --- a/src/applicationui.cpp +++ b/src/applicationui.cpp @@ -31,6 +31,11 @@ using namespace bb::cascades; ApplicationUI::ApplicationUI() : QObject() { + // setup the invoke manager + invokeManager = new bb::system::InvokeManager(this); + connect(invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), + this, SLOT(onInvoke(const bb::system::InvokeRequest&))); + // prepare the localization m_pTranslator = new QTranslator(this); m_pLocaleHandler = new LocaleHandler(this); @@ -102,3 +107,11 @@ void ApplicationUI::copyText(QByteArray text) clipboard.clear(); clipboard.insert("text/plain", text); } + +void ApplicationUI::onInvoke(const bb::system::InvokeRequest& request) +{ + if (request.action() == "bb.action.SHARE") + { + emit createPost(request.data()); + } +} diff --git a/src/applicationui.hpp b/src/applicationui.hpp index 740cdfe..c73540d 100644 --- a/src/applicationui.hpp +++ b/src/applicationui.hpp @@ -19,6 +19,8 @@ #include #include +#include +#include namespace bb { @@ -46,12 +48,19 @@ public: Q_INVOKABLE void setSetting(const QString &key, const QString &value); Q_INVOKABLE QString appversion(); Q_INVOKABLE void copyText(QByteArray text); + +Q_SIGNALS: + void createPost(QByteArray text); + private slots: void onSystemLanguageChanged(); + void onInvoke(const bb::system::InvokeRequest &request); + private: QTranslator* m_pTranslator; bb::cascades::LocaleHandler* m_pLocaleHandler; QSettings* m_appSettings; + bb::system::InvokeManager *invokeManager; }; #endif /* ApplicationUI_HPP_ */ diff --git a/translations/Goober.ts b/translations/Goober.ts index 3f1c23b..724f462 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -30,52 +30,52 @@ PostItem - + Reply - + Reply All - + Add Bookmark - + Delete Bookmark - + Repost - + Delete Repost - + Quote - + View Profile - + Copy text - + Delete