diff --git a/src/controls/LinkButton.qml b/src/controls/LinkButton.qml index f3849ff4..2757e4f6 100644 --- a/src/controls/LinkButton.qml +++ b/src/controls/LinkButton.qml @@ -1,52 +1,53 @@ /* * SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez * * SPDX-License-Identifier: LGPL-2.0-or-later */ import QtQuick 2.2 import org.kde.kirigami 2.0 import QtQuick.Controls 2.1 as QQC2 /** * Shows a Button that looks like a link * * Uses the link color settings and allows to trigger an action when clicked. * * Maps to the Command Link in the HIG: * https://hig.kde.org/components/navigation/commandlink.html * * @since 5.52 * @since org.kde.kirigami 2.6 */ QQC2.Label { id: control property Action action: null property alias acceptedButtons: area.acceptedButtons + property alias mouseArea: area Accessible.role: Accessible.Button Accessible.name: text Accessible.onPressAction: control.clicked(null) text: action ? action.text : "" enabled: !action || action.enabled onClicked: if (action) action.trigger() font.underline: control.enabled && area.containsMouse color: enabled ? Theme.linkColor : Theme.textColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight signal pressed(QtObject mouse) signal clicked(QtObject mouse) MouseArea { id: area anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: control.clicked(mouse) onPressed: control.pressed(mouse) } } diff --git a/src/controls/UrlButton.qml b/src/controls/UrlButton.qml index d3432237..d428ed06 100644 --- a/src/controls/UrlButton.qml +++ b/src/controls/UrlButton.qml @@ -1,42 +1,48 @@ /* * SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez * * SPDX-License-Identifier: LGPL-2.0-or-later */ import QtQuick 2.2 import org.kde.kirigami.private 2.6 as KirigamiPrivate import QtQuick.Controls 2.1 as QQC2 /** * A link button that contains a URL * * It will open the url by default, allow to copy it if triggered with the * secondary mouse button. * * @since 5.63 * @since org.kde.kirigami 2.6 */ LinkButton { id: button property string url text: url visible: text.length > 0 acceptedButtons: Qt.LeftButton | Qt.RightButton onPressed: if (mouse.button === Qt.RightButton) { menu.popup() } onClicked: if (mouse.button !== Qt.RightButton) { Qt.openUrlExternally(url) } + QQC2.ToolTip { + // If button's text has been overridden, show a tooltip to expose the raw URL + visible: button.text != button.url && button.mouseArea.containsMouse + text: url + } + QQC2.Menu { id: menu QQC2.MenuItem { text: qsTr("Copy link address") onClicked: KirigamiPrivate.CopyHelperPrivate.copyTextToClipboard(button.url) } } }