/*************************************************************/ /* */ /* Copyright (C) Microsoft Corporation. All rights reserved. */ /* */ /*************************************************************/ import Colors 1.0 import Fonts 1.0 import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 import QtQml 2.2 import "HelperFunctions.js" as HelperFunctions // Errors view in the Activity Center, comprised of a back-link banner // and a list of error items Rectangle { id: errorViewRoot property var messageColors: (errorsModel.isWarningsOnly) ? Colors.errors_list.warning : Colors.errors_list.error color: "transparent" // Allow base color to show through // Called by the loader so that references are only used once the qml is loaded, // Sets the key handler and active focus setter for the provided loader, to expose to ActivityCenter.qml // errorsViewRect = Loader with "property var keyHandler" and "signal setFocusOnChanged" function setHandlers(errorsViewRect) { errorsViewRect.keyHandler = errorsList; } ListView { id: errorsList objectName: "errorsList" anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right // Remove the model when hidden to prevent perf hit - data being loaded for all items on close model: isErrorViewCurrentlyVisible ? errorsModel : undefined delegate: ErrorsListItem { } clip: true activeFocusOnTab: true keyNavigationWraps: true ScrollBar.vertical: ScrollBar { active: true onActiveChanged: { active = true; /* Keeps scrollbar visible always */} Accessible.ignored: ((errorsList.count == 0) || !parent.visible) } Accessible.role: Accessible.List Accessible.focusable: true Accessible.ignored: ((errorsList.count == 0) || !visible) Accessible.name: errorsModel.errorListAccessibleText highlightFollowsCurrentItem: true function updateIndexAndScrollToItem(theIndex) { var newIndex = Math.max(theIndex, 0); newIndex = Math.min(newIndex, (errorsList.count - 1)); errorsList.currentIndex = newIndex; errorsList.positionViewAtIndex(newIndex, ListView.Visible); } Keys.onPressed: { if (errorsList.count > 0) { var newIndex = -1; var itemHeight = 68; // Min item height var pageIncrement = errorsList.height / itemHeight; // How many items to scroll if (event.key === Qt.Key_End) { newIndex = errorsList.count - 1; updateIndexAndScrollToItem(newIndex); } else if (event.key === Qt.Key_Home) { newIndex = 0; updateIndexAndScrollToItem(newIndex); } else if (event.key === Qt.Key_PageUp) { newIndex = errorsList.currentIndex - pageIncrement; updateIndexAndScrollToItem(newIndex); } else if (event.key === Qt.Key_PageDown) { newIndex = errorsList.currentIndex + pageIncrement; updateIndexAndScrollToItem(newIndex); } } } } }