Debian Codegraph @

resources/qml/MessageInputWarning.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick 2.9
6 import QtQuick.Controls 2.3
7 import QtQuick.Layouts 1.2
8 import im.nheko 1.0
9
10 Rectangle {
11 id: warningRoot
12
13 property color bubbleColor: Nheko.theme.error
14 required property string text
15 property bool showRemove: false
16
17 signal removeClicked();
18
19 Layout.fillWidth: true
20 color: palette.window // required to hide the timeline behind this warning
21 height: implicitHeight
22 implicitHeight: visible ? warningDisplay.implicitHeight + 4 * Nheko.paddingSmall : 0
23
24 Rectangle {
25 id: warningRect
26
27 anchors.fill: parent
28 anchors.margins: visible ? Nheko.paddingSmall : 0
29 border.color: bubbleColor
30 border.width: 1
31 // TODO: Qt.alpha() would make more sense but it wasn't working...
32 color: Qt.rgba(bubbleColor.r, bubbleColor.g, bubbleColor.b, 0.3)
33 radius: 3
34 visible: warningRoot.visible
35 z: 3
36
37 Label {
38 id: warningDisplay
39
40 anchors.left: parent.left
41 anchors.right: parent.right
42 anchors.margins: Nheko.paddingSmall
43 anchors.rightMargin: warningRoot.showRemove ? (Nheko.paddingSmall*3 + removeButton.width) : Nheko.paddingSmall
44 anchors.verticalCenter: parent.verticalCenter
45 text: warningRoot.text
46 textFormat: Text.PlainText
47 }
48
49 ImageButton {
50 id: removeButton
51
52 visible: warningRoot.showRemove
53
54 anchors.right: parent.right
55 anchors.margins: Nheko.paddingSmall
56 anchors.verticalCenter: parent.verticalCenter
57
58 image: ":/icons/icons/ui/dismiss.svg"
59 hoverEnabled: true
60 ToolTip.visible: hovered
61 ToolTip.text: qsTr("Don't mention them in this message")
62 onClicked: {
63 warningRoot.removeClicked();
64 }
65 }
66 }
67 }