Warning, /frameworks/kirigami/src/controls/LinkButton.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.2 0008 import QtQuick.Controls 2.1 as QQC2 0009 import org.kde.kirigami 2.14 as Kirigami 0010 0011 /** 0012 * @brief A button that looks like a link. 0013 * 0014 * It uses the link color settings and triggers an action when clicked. 0015 * 0016 * Maps to the Command Link in the HIG: 0017 * https://develop.kde.org/hig/components/navigation/commandlink/ 0018 * 0019 * @since KDE Frameworks 5.52 0020 * @since org.kde.kirigami 2.6 0021 * @inherit QtQuick.Controls.Label 0022 */ 0023 QQC2.Label { 0024 id: control 0025 0026 property Action action: null 0027 0028 /** 0029 * @brief This property holds the mouse buttons that the mouse area reacts to. 0030 * @see <a href="https://doc.qt.io/qt-5/qml-qtquick-mousearea.html#acceptedButtons-prop">MouseArea.acceptedButtons</a> 0031 * @property Qt::MouseButton acceptedButtons 0032 */ 0033 property alias acceptedButtons: area.acceptedButtons 0034 0035 /** 0036 * @brief This property holds the mouse area element covering the button. 0037 * @property MouseArea area 0038 */ 0039 property alias mouseArea: area 0040 0041 activeFocusOnTab: true 0042 Accessible.role: Accessible.Button 0043 Accessible.name: text 0044 Accessible.onPressAction: control.clicked({"button": Qt.LeftButton}) 0045 0046 text: action ? action.text : "" 0047 enabled: !action || action.enabled 0048 onClicked: mouse => { 0049 if (action) { 0050 action.trigger(); 0051 } 0052 } 0053 0054 font.bold: activeFocus 0055 font.underline: control.enabled 0056 color: enabled ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor 0057 horizontalAlignment: Text.AlignHCenter 0058 verticalAlignment: Text.AlignVCenter 0059 elide: Text.ElideRight 0060 0061 signal pressed(var mouse) 0062 signal clicked(var mouse) 0063 0064 Keys.onPressed: event => { 0065 switch (event.key) { 0066 case Qt.Key_Space: 0067 case Qt.Key_Enter: 0068 case Qt.Key_Return: 0069 case Qt.Key_Select: 0070 control.clicked({"button": Qt.LeftButton}); 0071 event.accepted = true; 0072 break; 0073 case Qt.Key_Menu: 0074 control.pressed({"button": Qt.RightButton}); 0075 event.accepted = true; 0076 break; 0077 } 0078 } 0079 0080 MouseArea { 0081 id: area 0082 anchors.fill: parent 0083 hoverEnabled: true 0084 cursorShape: Qt.PointingHandCursor 0085 0086 onClicked: mouse => control.clicked(mouse) 0087 onPressed: mouse => control.pressed(mouse) 0088 } 0089 }