Move error list to settings page (as overlaysheet)

This commit is contained in:
Bart De Vries 2021-06-22 12:18:37 +02:00
parent 159688035a
commit e86111ed55
8 changed files with 173 additions and 117 deletions

View File

@ -137,6 +137,7 @@ if(ANDROID)
arrow-down
overflow-menu
checkbox
error
)
else()
target_link_libraries(kasts PRIVATE Qt::Widgets Qt::DBus)

View File

@ -55,11 +55,6 @@ Kirigami.Page {
height: tabBarHeight
text: i18n("Completed")
}
Controls.TabButton {
width: parent.parent.width / parent.count
height: tabBarHeight
text: i18n("Error Log")
}
}
}
@ -84,9 +79,5 @@ Kirigami.Page {
title: i18n("Completed")
episodeType: EpisodeModel.Downloaded
}
ErrorListPage {
title: i18n("Error Log")
}
}
}

View File

@ -0,0 +1,99 @@
/**
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.14
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kasts 1.0
Kirigami.OverlaySheet {
id: errorOverlay
showCloseButton: true
header: Kirigami.Heading {
text: i18n("Error Log")
level: 2
wrapMode: Text.Wrap
}
footer: Controls.DialogButtonBox {
Controls.Button {
text: i18n("Clear All Errors")
icon.name: "edit-clear-all"
onClicked: ErrorLogModel.clearAll()
enabled: errorList.count > 0
}
}
Kirigami.PlaceholderMessage {
id: placeholder
visible: errorList.count == 0
text: i18n("No Errors Logged")
}
ListView {
id: errorList
visible: errorList.count > 0
implicitWidth: Kirigami.Units.gridUnit * 20
model: ErrorLogModel
Component {
id: errorListDelegate
Kirigami.SwipeListItem {
// workaround to get rid of "_swipeFilter" errors
alwaysVisibleActions: true
contentItem: RowLayout {
Kirigami.Icon {
source: "data-error"
property int size: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: size
Layout.preferredWidth: size
}
ColumnLayout {
spacing: Kirigami.Units.smallSpacing
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Controls.Label {
text: error.description + " · " + error.date.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + " · " + error.date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)
Layout.fillWidth: true
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
}
Controls.Label {
text: error.title
Layout.fillWidth: true
elide: Text.ElideRight
font.weight: Font.Normal
opacity: 1
}
Controls.Label {
text: i18n("Error Code: ") + error.code + (error.message ? " · " + error.message : "")
Layout.fillWidth: true
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
}
}
}
}
}
delegate: Kirigami.DelegateRecycler {
width: errorList.width
sourceComponent: errorListDelegate
}
}
contentItem: errorList.count > 0 ? errorList : placeholder
}

View File

@ -1,86 +0,0 @@
/**
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.14
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kasts 1.0
Kirigami.ScrollablePage {
padding: 0
Kirigami.PlaceholderMessage {
visible: errorList.count === 0
width: Kirigami.Units.gridUnit * 20
anchors.centerIn: parent
text: i18n("No Errors Logged")
}
Component {
id: errorListDelegate
Kirigami.SwipeListItem {
contentItem: RowLayout {
Kirigami.Icon {
source: "data-error"
property int size: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: size
Layout.preferredWidth: size
}
ColumnLayout {
spacing: Kirigami.Units.smallSpacing
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Controls.Label {
text: error.description + " · " + error.date.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + " · " + error.date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)
Layout.fillWidth: true
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
}
Controls.Label {
text: error.title
Layout.fillWidth: true
elide: Text.ElideRight
font.weight: Font.Normal
opacity: 1
}
Controls.Label {
text: i18n("Error Code: ") + error.code + (error.message ? " · " + error.message : "")
Layout.fillWidth: true
elide: Text.ElideRight
font: Kirigami.Theme.smallFont
opacity: 0.7
}
}
}
}
}
ListView {
id: errorList
anchors.fill: parent
visible: count !== 0
model: ErrorLogModel
delegate: Kirigami.DelegateRecycler {
width: errorList.width
sourceComponent: errorListDelegate
}
}
actions.main: Kirigami.Action {
text: i18n("Clear All Errors")
iconName: "edit-clear-all"
visible: errorList.count > 0
onTriggered: ErrorLogModel.clearAll()
}
}

View File

@ -0,0 +1,52 @@
/**
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14 as Controls
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kasts 1.0
Kirigami.InlineMessage {
id: inlineMessage
anchors {
bottom: parent.bottom
right: parent.right
left: parent.left
margins: Kirigami.Units.gridUnit
bottomMargin: bottomMessageSpacing
}
type: Kirigami.MessageType.Error
showCloseButton: true
actions: [
Kirigami.Action {
icon.name: "error"
text: "Show Error Log"
onTriggered: errorOverlay.open()
}
]
Timer {
id: hideTimer
interval: 10000
repeat: false
onTriggered: inlineMessage.visible = false;
}
Connections {
target: ErrorLogModel
function onNewErrorLogged(error) {
inlineMessage.text = error.description;
inlineMessage.visible = true;
hideTimer.start();
}
}
}

View File

@ -10,13 +10,12 @@ import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14
import org.kde.kirigami 2.12 as Kirigami
import org.kde.kasts 1.0
Kirigami.ScrollablePage {
title: i18n("Settings")
// TODO: Remove old kasts settings from the kcfg and the qml code
Kirigami.FormLayout {
Kirigami.Heading {
@ -104,5 +103,16 @@ Kirigami.ScrollablePage {
onToggled: SettingsManager.articleFontUseSystem = checked
}
Kirigami.Heading {
Kirigami.FormData.isSection: true
text: i18n("Errors")
}
Controls.Button {
icon.name: "error"
text: i18n("Show Error Log")
onClicked: errorOverlay.open()
}
}
}

View File

@ -203,28 +203,16 @@ Kirigami.ApplicationWindow {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: bottomMessageSpacing + ( inlineMessage.visible ? inlineMessage.height + Kirigami.Units.largeSpacing : 0 )
bottomMargin: bottomMessageSpacing + ( errorNotification.visible ? errorNotification.height + Kirigami.Units.largeSpacing : 0 )
}
}
Kirigami.InlineMessage {
id: inlineMessage
anchors {
bottom: parent.bottom
right: parent.right
left: parent.left
margins: Kirigami.Units.gridUnit
bottomMargin: bottomMessageSpacing
}
type: Kirigami.MessageType.Error
showCloseButton: true
ErrorNotification {
id: errorNotification
}
Connections {
target: ErrorLogModel
function onNewErrorLogged(error) {
inlineMessage.text = error.description + "\n" + i18n("Check Error Log Tab (under Downloads) for more details");
inlineMessage.visible = true;
}
}
// overlay with log of all errors that have happened
ErrorListOverlay {
id: errorOverlay
}
}

View File

@ -16,7 +16,7 @@
<file alias="FooterBar.qml">qml/FooterBar.qml</file>
<file alias="QueuePage.qml">qml/QueuePage.qml</file>
<file alias="EpisodeListPage.qml">qml/EpisodeListPage.qml</file>
<file alias="ErrorListPage.qml">qml/ErrorListPage.qml</file>
<file alias="ErrorListOverlay.qml">qml/ErrorListOverlay.qml</file>
<file alias="EpisodeSwipePage.qml">qml/EpisodeSwipePage.qml</file>
<file alias="DownloadSwipePage.qml">qml/DownloadSwipePage.qml</file>
<file alias="GenericHeader.qml">qml/GenericHeader.qml</file>
@ -24,6 +24,7 @@
<file alias="ImageWithFallback.qml">qml/ImageWithFallback.qml</file>
<file alias="UpdateNotification.qml">qml/UpdateNotification.qml</file>
<file alias="HeaderBar.qml">qml/HeaderBar.qml</file>
<file alias="ErrorNotification.qml">qml/ErrorNotification.qml</file>
<file>qtquickcontrols2.conf</file>
<file alias="logo.svg">../kasts.svg</file>
</qresource>