2023-05-16 17:48:30 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 by Felix Weilbach <felix.weilbach@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-09-09 12:18:22 +03:00
|
|
|
import QtQuick 2.15
|
2022-09-26 14:12:59 +03:00
|
|
|
import QtQuick.Layouts 1.15
|
2022-06-08 03:30:22 +03:00
|
|
|
import QtQuick.Controls 2.15
|
2021-09-09 12:18:22 +03:00
|
|
|
|
2021-09-09 14:33:57 +03:00
|
|
|
import Style 1.0
|
2022-12-02 16:51:09 +03:00
|
|
|
import "./tray"
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2021-09-09 12:18:22 +03:00
|
|
|
Item {
|
|
|
|
id: errorBox
|
2022-09-26 14:12:59 +03:00
|
|
|
|
|
|
|
signal closeButtonClicked
|
2021-09-09 12:18:22 +03:00
|
|
|
|
2022-09-26 14:12:59 +03:00
|
|
|
property string text: ""
|
2021-09-09 14:33:57 +03:00
|
|
|
|
|
|
|
property color backgroundColor: Style.errorBoxBackgroundColor
|
2022-09-26 14:12:59 +03:00
|
|
|
property bool showCloseButton: false
|
2021-09-09 12:18:22 +03:00
|
|
|
|
2022-09-26 14:12:59 +03:00
|
|
|
implicitHeight: errorMessageLayout.implicitHeight + (2 * Style.standardSpacing)
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: solidStripe
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
|
|
|
width: Style.errorBoxStripeWidth
|
|
|
|
color: errorBox.backgroundColor
|
|
|
|
}
|
2021-09-09 12:18:22 +03:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2021-09-09 14:33:57 +03:00
|
|
|
color: errorBox.backgroundColor
|
2022-09-26 14:12:59 +03:00
|
|
|
opacity: 0.2
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
|
2022-09-26 14:12:59 +03:00
|
|
|
GridLayout {
|
|
|
|
id: errorMessageLayout
|
|
|
|
|
2021-09-09 12:18:22 +03:00
|
|
|
anchors.fill: parent
|
2022-09-26 14:12:59 +03:00
|
|
|
anchors.margins: Style.standardSpacing
|
|
|
|
anchors.leftMargin: Style.standardSpacing + solidStripe.width
|
|
|
|
|
|
|
|
columns: 2
|
|
|
|
|
2022-12-02 16:51:09 +03:00
|
|
|
EnforcedPlainTextLabel {
|
2022-09-26 14:12:59 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
color: Style.ncTextColor
|
|
|
|
font.bold: true
|
|
|
|
text: qsTr("Error")
|
|
|
|
visible: errorBox.showCloseButton
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
Layout.preferredWidth: Style.iconButtonWidth
|
|
|
|
Layout.preferredHeight: Style.iconButtonWidth
|
|
|
|
|
|
|
|
background: null
|
|
|
|
icon.color: Style.ncTextColor
|
|
|
|
icon.source: "qrc:///client/theme/close.svg"
|
|
|
|
|
|
|
|
visible: errorBox.showCloseButton
|
|
|
|
enabled: visible
|
|
|
|
|
|
|
|
onClicked: errorBox.closeButtonClicked()
|
|
|
|
}
|
|
|
|
|
2022-12-02 16:51:09 +03:00
|
|
|
EnforcedPlainTextLabel {
|
2022-09-26 14:12:59 +03:00
|
|
|
id: errorMessage
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
|
|
|
|
color: Style.ncTextColor
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
text: errorBox.text
|
|
|
|
}
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
}
|