Kirigami2

SelectableLabel.qml
1 /*
2  * SPDX-FileCopyrightText: 2022 Fushan Wen <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.15
8 import QtQuick.Controls 2.15 as QQC2
9 
10 /**
11  * @brief This is a label which supports text selection.
12  *
13  * You can use all elements of the QML TextArea component, in particular
14  * the "text" property to define the label text.
15  *
16  * Example usage:
17  * @code{.qml}
18  * Kirigami.SelectableLabel {
19  * text: "Label"
20  * }
21  * @endcode
22  *
23  * @see https://bugreports.qt.io/browse/QTBUG-14077
24  * @since 5.95
25  * @since org.kde.kirigami 2.20
26  * @inherit QtQuick.Controls.TextArea
27  */
28 QQC2.TextArea {
29  id: selectableLabel
30 
31  /**
32  * @brief This property holds the cursor shape that will appear whenever
33  * the mouse is hovering over the label.
34  *
35  * default: @c Qt.IBeamCursor
36  *
37  * @property Qt::CursorShape cursorShape
38  */
39  property alias cursorShape: hoverHandler.cursorShape
40 
41  padding: 0
42  leftPadding: 0
43  rightPadding: 0
44  topPadding: 0
45  bottomPadding: 0
46 
47  readOnly: true
48  wrapMode: Text.WordWrap
49  textFormat: TextEdit.AutoText
50  verticalAlignment: TextEdit.AlignTop
51 
52  Accessible.selectableText: true
53  Accessible.editable: false
54 
55  background: Item {}
56 
57  HoverHandler {
58  id: hoverHandler
59  // By default HoverHandler accepts the left button while it shouldn't accept anything,
60  // causing https://bugreports.qt.io/browse/QTBUG-106489.
61  // Qt.NoButton unfortunately is not a valid value for acceptedButtons.
62  // Disabling masks the problem, but
63  // there is no proper workaround other than an upstream fix
64  // See qqc2-desktop-style Label.qml
65  enabled: false
66  cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
67  }
68 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.