moment/src/gui/Base/HSelectableLabel.qml

49 lines
1.1 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
TextEdit {
id: label
font.family: theme.fontFamily.sans
font.pixelSize: theme.fontSize.normal
color: theme.colors.text
textFormat: Label.PlainText
tabStopDistance: 4 * 4 // 4 spaces
readOnly: true
persistentSelection: true
activeFocusOnPress: false
focus: false
onLinkActivated: Qt.openUrlExternally(link)
function selectWordAt(position) {
label.cursorPosition = positionAt(position.x, position.y)
label.selectWord()
}
function selectAllText() {
label.selectAll()
}
2020-03-25 02:26:17 +11:00
// XXX
// TapHandler {
// acceptedButtons: Qt.LeftButton
// onTapped: {
// tapCount === 2 ? selectWordAt(eventPoint.position) :
// tapCount === 3 ? selectAllText() :
// null
// }
// }
2019-09-12 05:25:57 +10:00
MouseArea {
anchors.fill: label
acceptedButtons: Qt.NoButton
cursorShape: label.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
}
}