matrixion/qml/ElidedLabel.qml

33 lines
885 B
QML
Raw Permalink Normal View History

2021-05-19 20:34:10 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-05-19 20:34:10 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.9
2021-06-13 02:48:11 +03:00
import QtQuick.Controls 2.5
import im.nheko
2021-05-19 20:34:10 +03:00
Label {
id: root
property alias elideWidth: metrics.elideWidth
2022-04-16 03:13:01 +03:00
property alias fullText: metrics.text
property int fullTextWidth: Math.ceil(metrics2.advanceWidth + 4)
2021-05-19 20:34:10 +03:00
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.text
2021-05-19 20:34:10 +03:00
elide: Text.ElideRight
2022-04-16 03:13:01 +03:00
maximumLineCount: 1
text: (textFormat == Text.PlainText) ? metrics.elidedText : TimelineManager.escapeEmoji(TimelineManager.htmlEscape(metrics.elidedText))
2021-05-19 20:34:10 +03:00
textFormat: Text.PlainText
TextMetrics {
id: metrics
elide: Text.ElideRight
2022-04-16 03:13:01 +03:00
font: root.font
}
TextMetrics {
id: metrics2
//elide: Text.ElideRight
font: root.font
text: metrics.text
2021-05-19 20:34:10 +03:00
}
}