View Single Post
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#3
Okay, progress!, I now have a working shortcut on my cover, with extended thanks to Merlin1991, as initially, I couldn't make his code work at all, that is until I moved CoverPage.qml into the pages directory and removed cover directory completely, then with one minor change to Merlin's code ('appWindow' to 'window') and now I have a basic cover action, but......

A few little problems with the now working shortcut, firstly, I get a glimpse of the first page of the app as the Search page is spawned from cover and if I minimise the spawned search page and go back to the cover, tap the search icon, then another search page is spawned on to the stack, making 2 search pages.....?

So, how to stop the glimpse of the first page as Search page spawns and how to prevent the stacking up of search pages with each tap on the cover shortcut?

Here's the working code;

Code:
import QtQuick 2.4
import Sailfish.Silica 1.0

CoverBackground {
    id: cover
    CoverPlaceholder {
        id: coverPlaceholder
        text: "National Rail"
        icon.source: "../images/harbour-nationalrail.png"
    }
    CoverActionList {
        CoverAction {
            iconSource: "image://theme/icon-cover-search"
            onTriggered: showSearch()

            function showSearch() {
                pageStack.push(Qt.resolvedUrl("Search.qml"))
                window.activate();
            }
        }
    }
}
More progress: I've stopped the glimpse of the first page when search is spawning from cover action, just a minor change to the onTriggered portion of the code while also removing the 'function' call;

Code:
CoverBackground {
    id: cover
    CoverPlaceholder {
        id: coverPlaceholder
        text: "National Rail"
        icon.source: "../images/harbour-nationalrail.png"
    }
    CoverActionList {
        CoverAction {
            iconSource: "image://theme/icon-cover-search"
            onTriggered: {
                window.activate()
                pageStack.push("Search.qml", {}, PageStackAction.Immediate)
            }
        }
    }
}
Now to prevent search from spawning more than once!
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..

Last edited by Markkyboy; 2017-09-10 at 12:05.
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post: