ActionItem and SystemToast

Hi guys,.

I wonder, how to make an application (one on the top) with actionItem menu which shows SystemToast on triggered (in C++).  (Not much in C++, be so kind

So far, I've done this, but I don't know what I'm missing?

In main.cpp:

void App::showToast() {
    SystemToast *toast = new SystemToast(this);
    toast->setBody("bla bla bla");
    toast->show();
}

void App::handleAction()
{
        showToast();

}

int main(int argc, char **argv)
{
    Application app(argc, argv);
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
    AbstractPane *root = qml->createRootObject();
    app.setScene(root);

    Menu *menu = new Menu;
                    ActionItem *actionOne = ActionItem::create()
                                            .title("About");
                    menu->addAction(actionOne);
                    Application::instance()->setMenu(menu);
    bool res = QObject::connect(actionOne, SIGNAL(triggered()), menu, SLOT(handleAction()));
    Q_ASSERT(res); // when this is uncomented application doesn't start
    Q_UNUSED(res);

    return Application::exec();

}

When this line is décommentée, application does not start.

Q_ASSERT(res);

In App.hpp:

void showToast();
public slots:
    void handleAction();

OK, I managed to solve it. All the time, I was working in main.cpp, everything moved to App.cpp, and finally it works.

Tags: BlackBerry Developers

Similar Questions

  • Shared files

    Development for BB10

    I need to have an actionItem that selected once goes to an example of a shared file directory: "file://accounts/1000//shared/music/" or "file://accounts/1000//shared/documents".

    QML I have something like this

    {ActionItem}
    Title: 'music '.
    ActionBar.placement: ActionBarPlacement.InOverflow
    onTriggered: {}

    What should I do here?
    }

    And I have CPP:

    QString workingDir is QDir::currentPath();.

    QDeclarativePropertyMap * dirPaths = new QDeclarativePropertyMap;
    dirPaths-> insert ('music', QVariant (QString ("file://" + workingDir + "/ shared/music /")));
    QML-> setContextProperty ("dirPaths", dirPaths);

    How can I make this point QML action open the path for this URI?

    TKS in advance

    Not sure I get what you want...

    Do you want a FilePicker to open when the user click on your ActionItem? Then, attach a FilePicker to your ActionItem and call filePickerName.open)
    https://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__pickers__filepicker.html
    Use the "directories" property if you want the FilePicker to open it in a specific directory, like this:
    directories: [' / accounts/1000/shared/music "]

    Do you want a specific file (file of music as your ActionItem name suggests) to play when user click on your ActionItem? Then, attach a MediaPlayer to your ActionItem and call mediaPlayerName.play)
    https://developer.BlackBerry.com/native/reference/Cascades/bb__multimedia__mediaplayer.html

  • Open the browser

    How can I open the browser by a button? Is perhaps something very simple but I usually use an actionitem and I do not know how with a button

    Thank you

    Please see the link below.

    https://gist.github.com/40/3752815

  • ERROR: UIObjectPrivate::notifyMessage: unable to set the property

    I get this error now in the console (by pulling down the menu definition) after the addition of the ActionItem and this error (at the outbreak of the ActionItem to show this SystemDialog)

    Everything seems to work properly on the device, the icon image and everything.

    I have another menu ActionItems he never says this error before adding this ActionItem and I another SystemDialog that he never shows this error for.

    I was wondering what it could mean

    Thank you

    ActionItem {

    ID: reset

    imageSource: "icons/ic_clear_list.png.

    Title: qsTr ("Reset")

    onTriggered: {}

    resetPrompt.show)

    }

    }

    And the dialog box

    SystemDialog {

    ID: resetPrompt

    body: qsTr ("what you would like to reset?")

    confirmButton.label: qsTr ("whole table")

    customButton.label: qsTr ("cell widths only")

    onFinished: {}

    If (result is SystemUiResult.ConfirmButtonSelection)

    {

    resetWarning.show)

    } Else if (result == SystemUiResult.CustomButtonSelection)

    {

    app.resetCellWidths)

    }

    }

    }

    ignore it. It's just a warning in the console.

  • Setting visible false "ActionItem".

    IM use QML "ActionItem", I want it to be visible in some cases and invisible to some of my use case.

    But if I see the option available, there is no property not called 'visible '.

    I don't want to use the property called 'enable '.

    Is thera in no way meet the visible true or false?

    Thank you

    Ganesh

    @oniongarlic is right, you should accept his answer as a solution if operate you.

    Look at the code of @ekke for a simple example of remove ActionItem:
    https://appbus.WordPress.com/2014/09/13/supporting-BlackBerry-Passport-10-3-themes-signatureaction-t...

    Look for the section titled "don't use no disabled Signature Actions."

    It has a different use for the ActionItem remove, he does it to ensure that it is visually easy to know whether or not a Signature ActionItem is disabled, but the code is quite similar in your case.

  • TabbedPane NavigationPane and return

    Hi all

    I am currently working on an application that has a TabbedPane as root control, one of the tabs has a grid of buttons which, once clicked will be display a NavigationPanel which will allow the user to scroll through the different pages.

    The problem I have is how to return to the TabbedPane, once I'm done with the NavigationPane. Is the closest I have set up an action close in the action menu that displays the last page, then tries to restore the tabs panel display using the "Application::instance()-> setScene (root);", unfortunately, this causes app to freeze.

    Ideally, I would go back to the TabbedPane using the default back button on the first page, but it seems to be disabled, adding that a custom button also fails IE does not appear.

    So I was wondering if I'm missing something, IE the TabbedPane need to recreate?

    Thanks for any help, how to integrate the different controls seems a little light on documentation.

    Thanks and greetings

    James

    You don't need to return the pane tabs - use the following structure:

    TabbedPane {
    
      Tab {
        id: tab1
        title: "First Tab"    NavigationPane {
          id: nav1
    
          Page {        id: page1
            /* put your buttons here */
          }      onPopTransitionEnded: { page.destroy(); }
        }  }
    
      Tab {
        id: tab2
      }
    }
    

    The structure above would output a blank page in your first tab. There will be no back along the action bar button, and the action bar itself will be invisible unless you put some ActionItems in there. Put your buttons on this first page (put it in a separate QML file so that your main.qml is sharper).

    When you press a button on your home page (page1), pushing an extra page for 'nav1' it will be pushed ontop of page1 - and you'll get a back button this time. You have no need to do something to get back to the basic page, except by pressing the back button. When the top of the page gets jumped, you will automatically return to the base of the base. Be sure to destroy the pages you create in the onPopTransitionEnded handler.

  • Tabs and action items as in the hub

    Hi guys,.

    I'm trying to get a TabbedPane working with action on bar points and overflow as you can see in the hub, but I can't get the two working together. If I use a TabbedPane followed do not appear on bar or overflow. If I use a NavigationPane action items work, but I can't use the tabs...

    This is an image I found in the native BlackBerry documentation. Here, you see the button on the tab on the left, three elements of action on bar and the overflow action items opener.

    Can someone please give me a hint or example?

    Kind regards

    Jan

    You must add the ActionItem to the Page, as follows:

    import "Webview"
    import "Account"
    
    TabbedPane {
        tabs: [
            Tab {
                title: qsTr("A Tab")
                Page {
                    Label {
                        text: "Hello World"
                    }
                    actions: [
                        ActionItem {
                            ActionBar.placement: ActionBarPlacement.OnBar
                            title: "An action item"
                        }
                    ]
                }
            }
        ]
    }
    
  • onPeekStarted and onPeekEnded signals not firing

    Here's a simple QML which shows that the onPeekStarted and onPeekEneded signals not shooting. What I am doing wrong?

    NavigationPane {
        id: navigationPane
        Page {
            Container {
                Button {
                    id: button
                    text: "Navigate"
                    onClicked: {
                        var page = pageDef.createObject();
                        navigationPane.push(page);
                    }
                }
            }
        }
        attachedObjects: [
            ComponentDefinition {
                id: pageDef
                Page {
                    id: secondPage
                    Label {
                        text: "Second page"
                    }
                    paneProperties: NavigationPaneProperties {
                        backButton: ActionItem {
                            title: "First page"
                            imageSource: "back.png"
                            onTriggered: {
                                navigationPane.pop();
                            }
                        }
                    }
                }
            }
        ]
        onPopTransitionEnded: {
            page.destroy();
            button.text = "Page destroyed"
        }
        onPeekStarted: {
            button.text = "peek started";
        }
        onPeekEnded: {
            button.text = "Peek ended";
        }
    }
    

    Reading the documentation, the onPeekStarted and onPeekEneded signals are sent to the Page and not the NavigationPane. It makes sense that the Page is the component that is to be read on.

    
    NavigationPane {
        id: navigationPane
        Page {
            onPeekStarted: {
                button.text = "Peek started";
            }
            onPeekEnded: {
               button.text = "Peek Ended";
            }
            Container {
                Button {
                    id: button
                    text: "Navigate"
                    onClicked: {
                        var page = pageDef.createObject();
                        navigationPane.push(page);
                    }
                }
            }
        }
        attachedObjects: [
            ComponentDefinition {
                id: pageDef
                Page {
                    id: secondPage
                    Label {
                        text: "Second page"
                    }
                    paneProperties: NavigationPaneProperties {
                        backButton: ActionItem {
                            title: "First page"
                            imageSource: "back.png"
                            onTriggered: {
                                navigationPane.pop();
                            }
                        }
                    }
                }
            }
        ]
        onPopTransitionEnded: {
            page.destroy();
            button.text = "Page destroyed"
        }
    }
    
  • ActionItem in OnBar only

    Hello

    I have a quik question: can I do ActionItem to show that in the OnBar and do not display in InOverflow?

    ActionBar.placment is only a sugestion to ActionItem. With InOverflow it will not display on OnBar but with 3 + OnBar Actions will apear in InOverflow. But I need do not show this OnBar one more time in InOverflow. Is it possible to hide in InOverflow?

    Thank you

    Turdidae

    I know this thread is old - but not resolved and I found it Googling for the same problem. I know that this behavior is not itended to have with waterfalls, but sometimes you're not the one making the decisions.

    My solution is to listen to the signal actionMenuVisualStateChanged and removes all the elements of adverse action to the State "AnimatingToVisibleFull" and add them to the "AnimatingToHidden". To restore all the items in the original order, you must remove all of the remaining elements and add them in the original order once again.

  • 'Open in browser' and 'Share' problem

    Hi all

    Working on my first application. I'm done for the most part, but I can't for the life of figure me out how to get the invocations of work.

    The application load an arbitrary URL, found in the detailView.url variable in a WebView. It works very well. However, I can't spend detailView.url on an Invocation to open in a browser or a share. If I have the detailView.url on the console output, it gives me the correct URL.

    That's what I have so far:

                   attachedObjects: [
                        Invocation
                        {
                            id: invokeBrowser
                            query: InvokeQuery
                            {
                                mimeType: "text/html"
                                invokeActionId: "bb.action.OPEN"
                            }
                        }
                    ]
    
                    actions: [
                        ActionItem {
                            title: "Open in Browser"
                            imageSource: "asset:///images/ic_open.png"
                            ActionBar.placement: ActionBarPlacement.OnBar
                            onTriggered: {
                                invokeBrowser.query.uri = detailView.url;
                                console.log(detailView.url);
                                invokeBrowser.trigger("bb.action.OPEN");
                            }
                        }
                    ]
                }
    

    In the console, it gives me the following error:

    InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
       mimeType="text/html"
       uri=QUrl("")
       data= ""
       metadata= QMap()
       perimeter= 0
       action= "bb.action.OPEN"
       target= ""
       invokerIncluded= false
    

    I tried to understand this point for a few days now and just can't seem to wrap my head around it. Does anyone have any suggestions?

    Thank you!

    I suggest to use an InvokeActionItem instead, here's an example that I have to change the data in the call, I'm sure you can adapt for your code...

    {
        [ ... ]
    
        actions: [
            InvokeActionItem {
                id: iaiBrowser
                title: "Invoke Browser"
                query.invokeActionId: "bb.action.OPEN"
                query.invokeTargetId: "sys.browser"
                query.uri: "http://www.stok.biz"
            }
        ]
    
        onCreationCompleted: {
            iaiBrowser.query.uri = "http://www.google.com"
        }
    
        [ ... ]
    
    }
    
  • The default value of block SystemToast after setWallpaper

    Hello

    Every time I call bb/platform/HomeScreen.setWallpaper via QML and the call succeeds, a default value for SystemToast is shown with the text "photo set as wallpaper." It's pretty much the same that appears when you change the wallpaper via the settings > display.

    When I show a SystemToast with a different message right after calling setWallpaper, two notifications appear both on the other. If you see carefully the attached screen you can see my custom behind the default notification message.

    How can I stop this from happening?

    OS version 10.2.1.1055, using the SDK 10.2.1 gold.

    See you soon.

    I'm not sure that you would be able to prevent the system, but you can postpone your one or change its position...

    http://developer.BlackBerry.com/native/reference/Cascades/bb__system__systemtoast.html#property-posi...

  • inserting and removing pages hide the navigation bar

    My application has a page of 'low' which has a page of menu shoot upward.

    Page menu:

    m_menuPage = new Page();
    ActionItem* backAction = ActionItem::create();
    connect(backAction, SIGNAL(triggered()), m_navPane, SLOT(pop()));
    m_menuPage->setPaneProperties(NavigationPaneProperties::create().backButton(backAction));
    m_menuPage->setContent(m_menuView) //  a custom control
    

    I then push the start page:

    m_navPane->push(m_startPage);
    

    Later, I push the menu page:

    m_navPane->push(m_menuPage);
    

    So, I want to change the start page:

    m_navPane->insert(-1, m_nextPage);
    m_navPane->remove(m_startPage);
    

    Then the "back" button & nav bar disappear from the bottom.  That is what it is?  I thought that the back button has been associated with the menu page?

    May be a bug. Try to insert the new page at index 1, and then delete the page at index 0.

    If it disappears again, try commenting on 'remove' - it will return to newly inserted page correctly?

  • webView: load a URL from an ActionItem

    Hello.

    trying to do a simple display web app for a forum site and I want to put a "View Active Topics" button in the action menu and on triggered it must load the active topics page.

    im a beginner...

    has got everything in place, but when to trigger the button in the action menu of racing it does nothing with the following code.

    {ActionItem}
    Title: "View Active Topics".

    onTriggered: "'http://www.site.com/forum/search.php?search_id=active_topics ' "

    ActionBar.placement: ActionBarPlacement.InOverflow
    }

    You just need to assign the URL property of webview within the onTriggered function.

        actions: [
            ActionItem {
                ActionBar.placement: ActionBarPlacement.InOverflow
                title: "Active Topics"
                onTriggered: {                  //Using WebView ID
                      webView.url = "http://www.site.com/forum/search.php?search_id=active_topics"
                }
            }
        ]
    
    WebView {
                id: webView
                url: "www.google.com"
    }
    

    Thank you

    Kareem.

  • SystemToast onTriggered?

    Hi, how I trigger something when you press a button on SystemToast?

    I don't know how to say.

    Anythought please?

    SystemToast * toast = new SystemToast (0);

    Toast-> setBody ("Success.");
    Toast-> button()-> setLabel ("Ok");
    Toast-> show();

    Connect you to the signal of finished() after creation, this thread has an example:

    http://supportforums.BlackBerry.com/T5/Cascades-development/finished-signal-for-a-system-toast/m-p/2...

    Some other value parent class of SystemToast on creating, for example new SystemToast (this).

    In this way it will be destroyed when the parent is destroyed.

    You might also want to destroy in the onFinished() slot as well. This can be done like this:

    void YourClass::onFinished(bb::system::SystemUiResult::Type uiResult){
      ... process the result ...  SystemToast *toast = qobject_cast(sender());
      toast->deleteLater();
    }
    

    Otherwise the instance will continue to exist and will be destroyed only when its parent is destroyed.

  • Issue of RouteInvoker and LocationInvoker with 10.2

    Hey guys,.

    I'm trying to update my application for 10.2 and for a reason that my RouteInvoker function seems to not work with the new OS.  Here's my QML code for the function:

    import bb.cascades 1.0import PersistenObjectsLib 1.0import QtMonility.sensors 1.2import bb.cascades.maps 1.0import QtMobilitySubset.location 1.1import bb.platform 1.0import bb.data 1.0import bb.system 1.0
    
    Tab {
            title: qsTr("Saved Locations") + Retranslate.onLanguageChanged
            imageSource: "asset:///images/url.png"
            Page {
                onCreationCompleted: {
                    _app.setStorageLocation.App.StoreInFile;
                }
    
                actions: [
                    ActionItem {
                        title: qsTr("Get Route") + Retranslate.onLocaleOrLanguageChanged
                        imageSource: "asset:///images/ic_nav_to.png"
                        ActionBar.placement: ActionBarPlacement.OnBar
                        onTriggered: routeInvoker.go()
                    },
                    ActionItem {
                        title: qsTr("See Map") + Retranslate.onLocaleOrLanguageChanged
                        imageSource: "asset:///images/pin.png"
                        ActionBar.placement: ActionBarPlacement.OnBar
                        onTriggered: locationInvoker.go()
                    }
    
                ]
                titleBar: TitleBar {
                    title: qsTr("Saved Locations") + Retranslate.onLanguageChanged
                }
    
                    ListView {
                        function getApp() { // 1
                            return _app
                        }
    
                        id: listView
                        property string selectedItemID
                        dataModel: _app.dataModel
    
                        listItemComponents: [ // 2
    
                            ListItemComponent {
                                type: "item"
                                StandardListItem {
                                    id: rootItem // 3
                                    title: ListItemData.name
                                    description: ListItemData.description
                                    status: ListItemData.datefield
                                    imageSource: "asset:///images/pin.png"
    
                                    contextActions: [
                                        ...
                                    ]
                                }
                            }
                        ]
                        onTriggered: {
                            clearSelection()
                            select(indexPath)
    
                            locationInvoker.locationLatitude = dataModel.data(indexPath).lat
                            locationInvoker.locationLongitude = dataModel.data(indexPath).lon
                            routeInvoker.endLatitude = dataModel.data(indexPath).lat
                            routeInvoker.endLongitude = dataModel.data(indexPath).lon
                        }
                    }
                }
                attachedObjects: [
                    LocationMapInvoker {
                        id: locationInvoker
    
                        centerLatitude: 27.74949
                        centerLongitude: -97.41918
    
                    },
                    RouteMapInvoker {
                        id: routeInvoker
    
                        // Use fixed coordinates for start position ...
                        // Note: This does not work with current BB10 version but will work with future ones
                        startLatitude: 42.814513
                        startLongitude: -73.94206
    
                        // ... and center the map view around them.
                        centerLatitude: startLatitude
                        centerLongitude: startLongitude
                    }
                ]
                //! [0]
            }
        }
    

    Here are my main CPP:

    #include "app.hpp"
    #include "ActiveFrame.h"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    
    using ::bb::cascades::Application;
    // this allows us to write "Application"
    // instead of "bb::cascades::Application"
    
    void myMessageOutput(QtMsgType type, const char* msg) {
        Q_UNUSED(type);
       fprintf(stdout, "%s\n", msg);
       fflush(stdout);
    }
    // main() is the entry point of the application. It will be called by the
    // operating system when you start the application. You should never call this
    // yourself.
    Q_DECL_EXPORT int main(int argc, char **argv)
    {
    
        qmlRegisterType("bb.platform", 1, 0, "RouteMapInvoker");
            bb::data::DataSource::registerQmlTypes();
            qmlRegisterType("bb.platform", 1, 0, "LocationMapInvoker");
            bb::data::DataSource::registerQmlTypes();
        // "Application" is the BB cascades class that handles interaction the
        // with BB10 operating system.
        Application app(argc, argv);
    
    #ifndef QT_NO_DEBUG
       qInstallMsgHandler(myMessageOutput);
       #endif
    
        QTranslator translator;
            QString locale_string = QLocale().name();
            QString filename = QString("App_%1").arg(locale_string);
            if (translator.load(filename, "app/native/qm")) {
                app.installTranslator(&translator);
            }
    
        // Register this type so qml can refer to enums and other symbols
        // declared in the App class.
        qmlRegisterType("PersistentObjectsLib", 1, 0, "App");
    
        // Create an instance of App on the stack. App's
        // constructor registers itself with Application object using setScene().
        // See app.cpp
        app.setCover(new ActiveFrame());
        App mainApp;
    
        // Start the application event loop (run-loop).
        return Application::exec();
    
        // When the loop is exited the Application deletes the scene which deletes
        // all its children (per Qt rules for children)
    }
    

    what Miss me?  or what I need to add?  It worked very well in 10.1.

    Thanks in advance for your help.  Tastes and solutions will give answers.

    Solution was to change:

    attachedObjects:]
    {LocationMapInvoker}
    ID: locationInvoker

    centerLatitude: 27.74949
    centerLongitude:-97.41918

    },
    {RouteMapInvoker}
    ID: routeInvoker

    Use fixed coordinates for the starting position.
    Note: This does not work with the current version of BB10 but will work with future generations
    startLatitude: 42.814513
    startLongitude:-73.94206

    ... and Center the view card around them.
    centerLatitude: startLatitude
    centerLongitude: startLongitude
    }
    ]

    TO:

    attachedObjects:]
    {LocationMapInvoker}
    ID: locationInvoker

    },
    {RouteMapInvoker}
    ID: routeInvoker

    }
    ]

Maybe you are looking for

  • How Apple can for me if my Apple Watch was stolen?

    How Apple can for me if my Apple Watch was stolen?

  • NFC I2C can not be activated on Win10, TP 10

    The NFC provided I2C does not work well in the device manager after having upgraded to Win10. No one knows how to fix this though? Much appreciated!

  • Applying a mathematical operation of string data

    I am a PSU (E3631A Agilent) interfacing via GPIB. When the power supply is turned on to 12v and a device consumes current 104mA, vi reading gives a data string + 1.04485600E - 01. Now shown data are right, but I want it to appear on the front panel a

  • Unable to connect to wireless networks news two for a long time.

    I can't connect to new wireless networks.  I click 'connect to' and this message appears error loading C:\Windows\system32\van.dll the specific module could not be found.  Someone please help because I need to be able to use the network to my work an

  • GPS accuracy.

    I'm trying to figure out how to get the gps in my "BOLD" to lock as precisely as possible. I noticed that google maps he regularly gets up to 3meters, and yet I rarely saw him at least 10-15 m with my code. I use the following to initialize my locati