Commit c6fc74ed authored by Sergey Chupligin's avatar Sergey Chupligin Committed by Sergey Chupligin

[PageStack] be pageStack sagety

parent 98f52ccf
import QtQuick 2.6
SomeBrokenPage {
}
......@@ -133,6 +133,10 @@ ApplicationWindow {
title: "Notifications"
page: "content/NotificationsPage.qml"
}
ListElement {
title: "Broken page"
page: "content/BrokenPage.qml"
}
}
......
......@@ -27,8 +27,9 @@ QML_FILES += \
qml/DatePicker.qml \
qml/TimePicker.qml \
qml/ScrollDecorator.qml \
qml/dialogs/QueryDialog.qml \
qml/TextField.qml \
qml/ErrorStackPage.qml \
qml/dialogs/QueryDialog.qml \
qml/dialogs/SelectionDialog.qml \
qml/dialogs/Dialog.qml
......
......@@ -66,6 +66,50 @@ NemoWindow {
}
}
//Safety version of pageStack.push - if we can't load component - show error page page with
//error message and back button
function push(url, params) {
if(!params){
params = {}
}
console.log("##", url, params, pageStack)
var component = Qt.createComponent(url)
if (component.status === Component.Ready) {
pageStack.push(component.createObject(pageStack, params))
} else {
console.warn("Error loading component", url, component.errorString())
pageStack.push(Qt.resolvedUrl("ErrorStackPage.qml"), {error: component.errorString()})
}
}
Timer {
id: _errorTimer
property string errorString
interval: 50
repeat: false
onTriggered: {
pageStack.replace(Qt.resolvedUrl("ErrorStackPage.qml"), {error: errorString})
errorString = ""
}
}
Connections {
target: pageStack
onBusyChanged: {
if (_errorTimer.errorString && !pageStack.busy) {
_errorTimer.start()
}
}
onCurrentItemChanged: {
var qmltype = pageStack.currentItem.toString()
if (qmltype.slice(0, 10) === "QQuickText") {
_errorTimer.errorString = pageStack.currentItem.text
}
}
}
function orientationConstraintsChanged()
{
//if the current orientation is not allowed anymore, fallback to an allowed one
......
/****************************************************************************************
**
** Copyright (C) 2018 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
import QtQuick 2.6
import QtQuick.Controls.Styles.Nemo 1.0
Page {
id: root
property alias error: errorLabel.text
headerTools: HeaderToolsLayout {
showBackButton: true;
title: qsTr("Error")
}
Column {
spacing: 40
width: parent.width
anchors.centerIn: parent
Label {
id: errorLabel
width: parent.width
text: qsTr("We got some error")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment