added invoke hooks for issue #15 and resolved a crash for issue #18

This commit is contained in:
Morgan McMillian 2017-02-17 17:39:50 -08:00
parent 317c09aca8
commit 8ae45d5cae
7 changed files with 66 additions and 15 deletions

View file

@ -149,11 +149,13 @@ Container {
WebImageView { WebImageView {
url: { url: {
var oembed = "" var oembed = ""
ListItemData.raw.forEach(function (item) { if (typeof ListItemData.raw !== "undefined") {
if (item["type"] == "io.pnut.core.oembed") { ListItemData.raw.forEach(function (item) {
oembed = item["value"]["url"] if (item["type"] == "io.pnut.core.oembed") {
} oembed = item["value"]["url"]
}) }
})
}
return oembed return oembed
} }
scalingMethod: ScalingMethod.AspectFit scalingMethod: ScalingMethod.AspectFit
@ -247,6 +249,18 @@ Container {
postitem.ListItem.view.copyText(ListItemData.content.text) 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 { // ActionItem {
// id: edItem // id: edItem
// enabled: (ListItemData.user.username === postitem.ListItem.view.getUserName()) // enabled: (ListItemData.user.username === postitem.ListItem.view.getUserName())

View file

@ -365,4 +365,9 @@ NavigationPane {
pnut.sinceId = 0 pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER); pnut.getStream(endpoint, Pnut.STREAM_OLDER);
} }
function createPost(text) {
newPostSheet.open()
newPostSheet.text = text
newPostSheet.input.requestFocus();
}
} }

View file

@ -179,6 +179,7 @@ TabbedPane {
} else if (style === "2") { } else if (style === "2") {
Application.themeSupport.setVisualStyle(VisualStyle.Dark) Application.themeSupport.setVisualStyle(VisualStyle.Dark)
} }
_app.createPost.connect(activePane.createPost)
} }
} }

View file

@ -107,4 +107,13 @@
<permission system="true">run_native</permission> <permission system="true">run_native</permission>
<env var="LD_LIBRARY_PATH" value="app/native/lib:/usr/lib/qt4/lib"/> <env var="LD_LIBRARY_PATH" value="app/native/lib:/usr/lib/qt4/lib"/>
<!-- invokation bits -->
<invoke-target id="com.monkeystew.goober.new">
<invoke-target-type>application</invoke-target-type>
<filter>
<action>bb.action.SHARE</action>
<mime-type>text/plain</mime-type>
</filter>
</invoke-target>
</qnx> </qnx>

View file

@ -31,6 +31,11 @@ using namespace bb::cascades;
ApplicationUI::ApplicationUI() : ApplicationUI::ApplicationUI() :
QObject() 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 // prepare the localization
m_pTranslator = new QTranslator(this); m_pTranslator = new QTranslator(this);
m_pLocaleHandler = new LocaleHandler(this); m_pLocaleHandler = new LocaleHandler(this);
@ -102,3 +107,11 @@ void ApplicationUI::copyText(QByteArray text)
clipboard.clear(); clipboard.clear();
clipboard.insert("text/plain", text); clipboard.insert("text/plain", text);
} }
void ApplicationUI::onInvoke(const bb::system::InvokeRequest& request)
{
if (request.action() == "bb.action.SHARE")
{
emit createPost(request.data());
}
}

View file

@ -19,6 +19,8 @@
#include <QObject> #include <QObject>
#include <QSettings> #include <QSettings>
#include <bb/system/InvokeManager>
#include <bb/system/InvokeRequest>
namespace bb namespace bb
{ {
@ -46,12 +48,19 @@ public:
Q_INVOKABLE void setSetting(const QString &key, const QString &value); Q_INVOKABLE void setSetting(const QString &key, const QString &value);
Q_INVOKABLE QString appversion(); Q_INVOKABLE QString appversion();
Q_INVOKABLE void copyText(QByteArray text); Q_INVOKABLE void copyText(QByteArray text);
Q_SIGNALS:
void createPost(QByteArray text);
private slots: private slots:
void onSystemLanguageChanged(); void onSystemLanguageChanged();
void onInvoke(const bb::system::InvokeRequest &request);
private: private:
QTranslator* m_pTranslator; QTranslator* m_pTranslator;
bb::cascades::LocaleHandler* m_pLocaleHandler; bb::cascades::LocaleHandler* m_pLocaleHandler;
QSettings* m_appSettings; QSettings* m_appSettings;
bb::system::InvokeManager *invokeManager;
}; };
#endif /* ApplicationUI_HPP_ */ #endif /* ApplicationUI_HPP_ */

View file

@ -30,52 +30,52 @@
<context> <context>
<name>PostItem</name> <name>PostItem</name>
<message> <message>
<location filename="../assets/PostItem.qml" line="187"/> <location filename="../assets/PostItem.qml" line="189"/>
<source>Reply</source> <source>Reply</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="196"/> <location filename="../assets/PostItem.qml" line="198"/>
<source>Reply All</source> <source>Reply All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="206"/> <location filename="../assets/PostItem.qml" line="208"/>
<source>Add Bookmark</source> <source>Add Bookmark</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="206"/> <location filename="../assets/PostItem.qml" line="208"/>
<source>Delete Bookmark</source> <source>Delete Bookmark</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="217"/> <location filename="../assets/PostItem.qml" line="219"/>
<source>Repost</source> <source>Repost</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="217"/> <location filename="../assets/PostItem.qml" line="219"/>
<source>Delete Repost</source> <source>Delete Repost</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="228"/> <location filename="../assets/PostItem.qml" line="230"/>
<source>Quote</source> <source>Quote</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="237"/> <location filename="../assets/PostItem.qml" line="239"/>
<source>View Profile</source> <source>View Profile</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="244"/> <location filename="../assets/PostItem.qml" line="246"/>
<source>Copy text</source> <source>Copy text</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="262"/> <location filename="../assets/PostItem.qml" line="276"/>
<source>Delete</source> <source>Delete</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>