| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import QtQuick |
| 6 |
import QtQuick.Controls |
| 7 |
import im.nheko |
| 8 |
|
| 9 |
TextArea { |
| 10 |
id: r |
| 11 |
|
| 12 |
property alias cursorShape: cs.cursorShape |
| 13 |
|
| 14 |
ToolTip.text: Nheko.punyLink(hoveredLink) |
| 15 |
ToolTip.visible: hoveredLink || false |
| 16 |
background: null |
| 17 |
bottomInset: 0 |
| 18 |
bottomPadding: 0 |
| 19 |
// this always has to be enabled, otherwise you can't click links anymore! |
| 20 |
//enabled: selectByMouse |
| 21 |
color: palette.text |
| 22 |
focus: false |
| 23 |
leftInset: 0 |
| 24 |
leftPadding: 0 |
| 25 |
readOnly: true |
| 26 |
rightInset: 0 |
| 27 |
rightPadding: 0 |
| 28 |
textFormat: TextEdit.RichText |
| 29 |
topInset: 0 |
| 30 |
topPadding: 0 |
| 31 |
wrapMode: Text.Wrap |
| 32 |
|
| 33 |
// Setting a tooltip delay makes the hover text empty .-. |
| 34 |
//ToolTip.delay: Nheko.tooltipDelay |
| 35 |
Component.onCompleted: { |
| 36 |
TimelineManager.fixImageRendering(r.textDocument, r); |
| 37 |
} |
| 38 |
onLinkActivated: (link) => Nheko.openLink(link) |
| 39 |
|
| 40 |
// propagate events up |
| 41 |
onPressAndHold: event => event.accepted = false |
| 42 |
onPressed: event => event.accepted = (event.button == Qt.LeftButton) |
| 43 |
|
| 44 |
NhekoCursorShape { |
| 45 |
id: cs |
| 46 |
|
| 47 |
anchors.fill: parent |
| 48 |
cursorShape: hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor |
| 49 |
} |
| 50 |
} |