Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
Posts: 9
Registered: ‎07-14-2013
My Device: Z10
My Carrier: Z10-STL-1

i can't invoking adobe reader PDF !?

please someone helping me ...

 

i have problem with invocation ! in QML

 

Page {
    Container {
        
        attachedObjects: [
            
            Invocation {
                
                id:pdf
                query {
                    mimeType: "application/pdf"
                    uri: "file:/‪/psd/x.pdf‬"
                    invokeActionId: "bb.action.OPEN"
                }
            
            
            
            }       
        ]
        Button {
            
            onClicked: {
                
                
                pdf.trigger("bb.action.OPEN")
            }
        }
    }
}

 

i added file (x.pdf) in folder (psd)

 

psd have

 

basic files 

 

Java Script Resources , Binaries , Includes , src , arm , assets , (x.pdf = added) ...etc

 

i put x.pdf with basic files 

 

...

 

 in console i see that

 

InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="application/pdf"
   uri=QUrl("file:///‪/psd/x.pdf‬") 
   data= "" 
   metadata= QMap() 
   perimeter= 0 
   action= "bb.action.OPEN" 
   target= "" 
   invokerIncluded= false 
InvocationPrivate::onQueryResolved: no result matching query, no armed signal sent. 

 

also i edit it to 

 

file:///path/to/my/content.pdf

 still same problem ! Smiley Sad

 

i check that source 

 

help ! 

 

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: i can't invoking adobe reader PDF !?

Hi,

Most likely it can't find the file. I'm not sure if I understood correctly, but if you've just copied it to project folder, it won't be deployed to device.

If you add pdf to assets/, it can be referenced at uri:

asset:///x.pdf

Andrey Fidrya, @zmeyc on twitter
New Contributor
Posts: 9
Registered: ‎07-14-2013
My Device: Z10
My Carrier: Z10-STL-1

Thx for comment .. but still problem :(

 

..

 

i move (x.pdf) to (assets)

 

with change uri

 

to

 

‪/psd/assets/x.pdf‬

asset:///x.pdf‬

 

tested both but didn't works Smiley Sad 

 

 

Retired
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Thx for comment .. but still problem :(

Hi Devils_Needs_Me -

 

I've created function to retrive the file path in the asset folder and it works fine.You can share the QDir object directly to QML if you want as alternative to get the file path. 

 

//in QML

Page {
    Container {
        attachedObjects: [
            Invocation {
                id: pdf
                query {
                    mimeType: "application/pdf"
                    uri: "file:///" + app.getAssetPath("filename.pdf")
                    invokeActionId: "bb.action.OPEN"
                }

            }
        ]
        Button {
            onClicked: {
                pdf.trigger("bb.action.OPEN")
            }
        }
    }
}

//in C++, 

//in .hpp public: Q_INVOKABLE QString getAssetPath(QString Filename); //in .cpp: QString ApplicationUI::getAssetPath(QString assetName) { return QDir::currentPath() + "/app/native/assets/" + assetName; }

 

Thanks,

Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
New Contributor
Posts: 9
Registered: ‎07-14-2013
My Device: Z10
My Carrier: Z10-STL-1

Thx Mr.Kareem for .That but i have problem !

[ Edited ]
import bb.cascades 1.0

Page {
    Container {
        attachedObjects: [
            Invocation {
                id: pdf
                query {
                    mimeType: "application/pdf"
                    uri: "file:///" + app.getAssetPath("x.pdf")
                    invokeActionId: "bb.action.OPEN"
                }
            
            }
        ]
        Button {
            onClicked: {
                pdf.trigger("bb.action.OPEN")
            }
        }
    }
}

 x.pdf in ‪(assets/x.pdf‬)

 

i write in C++ like that ( i don't know it's true or not .. i'm not sure ! )

 

//CPP

#include "applicationui.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/LocaleHandler>

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :

        QObject(app)

{
    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);



    bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    // This is only available in Debug builds
    Q_ASSERT(res);


    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning
    Q_UNUSED(res);

    // initial load
    onSystemLanguageChanged();


    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);



    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();


    // Set created root object as the application scene
    app->setScene(root);

}

void ApplicationUI::onSystemLanguageChanged()
{
    QCoreApplication::instance()->removeTranslator(m_pTranslator);

    // Initiate, load and install the application translation files.


    QString locale_string = QLocale().name();
    QString file_name = QString("PDF_%1").arg(locale_string);

    if (m_pTranslator->load(file_name, "app/native/qm")) {
        QCoreApplication::instance()->installTranslator(m_pTranslator);
    }
}

QString ApplicationUI::getAssetPath(QString assetName) {
   return QDir::currentPath() + "/app/native/assets/" + assetName;
}

 

//hpp

#ifndef ApplicationUI_HPP_
#define ApplicationUI_HPP_

#include <QObject>

namespace bb
{
    namespace cascades
    {
        class Application;
        class LocaleHandler;
    }
}

class QTranslator;

/*!
 * @brief Application object
 *
 *
 */

class ApplicationUI : public QObject
{
    Q_OBJECT
public:


    Q_INVOKABLE QString getAssetPath(QString Filename);


    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI() { }
private slots:
    void onSystemLanguageChanged();
private:
    QTranslator* m_pTranslator;
    bb::cascades::LocaleHandler* m_pLocaleHandler;


};

#endif /* ApplicationUI_HPP_ */

 

that message come in console 

 

Qml debugging is enabled. Only use this in a safe environment!
OrientationSupportPrivate::getSupportedDisplayOrientation:  auto 
OrientationSupportPrivate::initDirectionAndOrientation: 
   isCardOrViewer:  false 
   manifestDisplayOrientation: All 
   displayOrientation: All 
   uiOrientation: Portrait 
   displayDirection: North 
   nativeDisplayOrientation: Portrait 
CS Debugging enabled: false 
asset:///main.qml:26: ReferenceError: Can't find variable: app
InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="application/pdf"
   uri=QUrl("") 
   data= "" 
   metadata= QMap() 
   perimeter= 0 
   action= "bb.action.OPEN" 
   target= "" 
   invokerIncluded= false 
InvocationPrivate::onQueryResolved: no result matching query, no armed signal sent. 

 X_X 

Retired
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Thx Mr.Kareem for .That but i have problem !

[ Edited ]

the error message says: 

asset:///main.qml:26: ReferenceError: Can't find variable: app

You just need to add this line in the constructor function:

 

qml->setContextProperty("app", this);

After this line:

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

 

Thanks,

Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
New Contributor
Posts: 9
Registered: ‎07-14-2013
My Device: Z10
My Carrier: Z10-STL-1

Mr.Kareem

i thinks this problem in invoking from blackberry 

 

i did like u said .. and all thing is done 

 

i see that in console 

 

InvocationPrivate::onQueryResolved: no result matching query, no armed signal sent. 

 i can invoking any thing .. just only PDF 

 

..

 

and Mr.kareem i need ur help about Qsetting with fontSize 

 

http://supportforums.blackberry.com/t5/Native-Development/Qsetting-with-property/td-p/2739923

 

please Mr.Kareem 

 

 

Retired
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Mr.Kareem

On The invocation Issue, It's not clear what would be the issue here, I've attached a working sample shows how to open pdf file using the invocation framework in both c++ & QML.  

 

Thanks,

Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
Highlighted
New Developer
Posts: 7
Registered: ‎02-17-2013
My Device: none
My Carrier: HTC

Re: Mr.Kareem

[ Edited ]

Kareem_ELSayed wrote:

On The invocation Issue, It's not clear what would be the issue here, I've attached a working sample shows how to open pdf file using the invocation framework in both c++ & QML.  

 

Thanks,

Kareem.


will this link help a little.

http://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/adobereader...