diff --git a/discover/qml/PageHeader.qml b/discover/qml/PageHeader.qml index c6423b4f..29a4f0e2 100644 --- a/discover/qml/PageHeader.qml +++ b/discover/qml/PageHeader.qml @@ -1,79 +1,89 @@ /* * Copyright (C) 2015 Aleix Pol Gonzalez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library/Lesser General Public License * version 2, or (at your option) any later version, as published by the * Free Software Foundation * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library/Lesser General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Layouts 1.2 import QtQuick.Templates 2.0 as T2 import org.kde.discover.app 1.0 import org.kde.kirigami 2.1 as Kirigami T2.Control { id: root property string search: "" property alias extra: extraLoader.sourceComponent property alias backgroundImage: actualHeader.backgroundImage anchors { left: parent.left right: parent.right } implicitHeight: actualHeader.implicitHeight + extraLoader.actualHeight z: actualHeader.z contentItem: Kirigami.ItemViewHeader { + function escapeHtml(unsafe) { + return unsafe + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } + + id: actualHeader view: root.ListView.view - title: root.search.length>0 && page.title.length>0 ? i18n("Search: %1 + %2", root.search, page.title) - : root.search.length>0 ? i18n("Search: %1", root.search) + title: root.search.length>0 && page.title.length>0 ? i18n("Search: %1 + %2", escapeHtml(root.search), page.title) + : root.search.length>0 ? i18n("Search: %1", escapeHtml(root.search)) : page.title backgroundImage.asynchronous: false } bottomPadding: extraLoader.actualHeight Loader { id: extraLoader anchors { left: parent.left right: parent.right bottom: parent.bottom leftMargin: item ? item.anchors.leftMargin : 0 rightMargin: item ? item.anchors.rightMargin : 0 bottomMargin: item ? item.anchors.bottomMargin + distance : 0 } property real distance: root.ListView.view.atYBeginning ? 0 : actualHeight Behavior on distance { PropertyAnimation {} } readonly property real actualHeight: item ? item.height + item.anchors.topMargin + item.anchors.bottomMargin : 0 visible: item && distance