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 {
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())

View file

@ -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();
}
}

View file

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

View file

@ -107,4 +107,13 @@
<permission system="true">run_native</permission>
<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>

View file

@ -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());
}
}

View file

@ -19,6 +19,8 @@
#include <QObject>
#include <QSettings>
#include <bb/system/InvokeManager>
#include <bb/system/InvokeRequest>
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_ */

View file

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