Kirigami-addons

FormLinkDelegate.qml
1// SPDX-FileCopyrightText: 2025 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4import QtQuick
5import QtQuick.Controls as Controls
6import org.kde.kirigami as Kirigami
7import org.kde.kirigamiaddons.components as Components
8import org.kde.kirigamiaddons.formcard as FormCard
9
10/**
11 * @brief A form delegate that contains a URL.
12 *
13 * It will open the url by default, allow to copy it if triggered with the
14 * secondary mouse button.
15 *
16 * @since 1.8.0
17 * @inherit FormButtonDelegate
18 */
19FormCard.FormButtonDelegate {
20 id: root
21
22 /**
23 * This property holds the url used by the form link delegate.
24 */
25 property string url
26
27 trailingLogo.source: 'open-link-symbolic'
28 visible: url.length > 0
29
30 onClicked: Qt.openUrlExternally(url);
31 onPressAndHold: {
32 const menuItem = menu.createObject(root);
33 menuItem.popup();
34 }
35
36 TapHandler {
37 acceptedButtons: Qt.RightButton
38 onTapped: {
39 const menuItem = menu.createObject(root);
40 menuItem.popup(root.Controls.Overlay.overlay);
41 }
42 }
43
44 Component {
45 id: menu
46
47 Components.ConvergentContextMenu {
48 parent: root.Controls.Overlay.overlay
49
50 Controls.Action {
51 text: i18ndc("kirigamiaddons6", "@action:inmnenu", "Open Link")
52 icon.name: "edit-copy-symbolic"
53 onTriggered: Qt.openUrlExternally(root.url);
54 }
55
56 Controls.Action {
57 text: i18ndc("kirigamiaddons6", "@action:inmnenu", "Copy Link to Clipboard")
58 icon.name: "edit-copy-symbolic"
59 onTriggered: {
60 FormCard.AboutComponent.copyTextToClipboard(root.url)
61 const application = root.Controls.ApplicationWindow.window as Kirigami.AbstractApplicationWindow;
62 if (application) {
63 application.showPassiveNotification(i18ndc("kirigamiaddons6", "@info:status", "Url copied to clipboard."))
64 }
65 }
66 }
67 }
68 }
69}
A single card that follows a form style.
Definition FormCard.qml:35
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:11 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.