From 4dae3c34b4b1ad0c4ac4940b3d5bbcac74faa18f Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 30 Apr 2024 23:00:33 +0200 Subject: [PATCH] Move HoverLinkIndicator to separate file --- src/CMakeLists.txt | 1 + src/qml/HoverLinkIndicator.qml | 30 ++++++++++++++++++++++++++++++ src/qml/Main.qml | 24 ++++++------------------ 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 src/qml/HoverLinkIndicator.qml diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a5448607..a20e93fa3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,6 +272,7 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN qml/EditStateDialog.qml qml/ConsentDialog.qml qml/AskDirectChatConfirmation.qml + qml/HoverLinkIndicator.qml ) add_subdirectory(settings) diff --git a/src/qml/HoverLinkIndicator.qml b/src/qml/HoverLinkIndicator.qml new file mode 100644 index 000000000..71808f32d --- /dev/null +++ b/src/qml/HoverLinkIndicator.qml @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2024 Tobias Fella +// SPDX-FileCopyrightText: 2024 Carl Schwan +// SPDX-License-Identifier: LGPL-2.0-or-later + +import QtQuick +import QtQuick.Controls as QQC2 + +import org.kde.kirigami as Kirigami + +QQC2.Control { + id: root + + property string text + + visible: !root.text.startsWith("https://matrix.to/") && root.text.length > 0 + Kirigami.Theme.colorSet: Kirigami.Theme.View + + z: 20 + + Accessible.ignored: true + + contentItem: QQC2.Label { + text: root.text.startsWith("https://matrix.to/") ? "" : root.text + Accessible.description: i18nc("@info screenreader", "The currently selected link") + } + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } +} diff --git a/src/qml/Main.qml b/src/qml/Main.qml index 55ff8f4cf..4aa70a432 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -15,6 +15,8 @@ Kirigami.ApplicationWindow { id: root property NeoChatConnection connection: Controller.activeConnection + readonly property HoverLinkIndicator hoverLinkIndicator: linkIndicator + title: Config.windowTitleFocus ? activeFocusItem + " " + (activeFocusItem ? activeFocusItem.Accessible.name : "") : "NeoChat" @@ -311,25 +313,11 @@ Kirigami.ApplicationWindow { } } - property QQC2.Control hoverLinkIndicator: QQC2.Control { - parent: root.overlay.parent - property alias text: linkText.rawText - opacity: linkText.text.length > 0 ? 1 : 0 + HoverLinkIndicator { + id: linkIndicator - z: 20 - x: 0 - Accessible.ignored: true - y: parent.height - implicitHeight - contentItem: QQC2.Label { - id: linkText - property string rawText - text: rawText.startsWith("https://matrix.to/") ? "" : rawText - Accessible.description: i18nc("@info screenreader", "The currently selected link") - } - Kirigami.Theme.colorSet: Kirigami.Theme.View - background: Rectangle { - color: Kirigami.Theme.backgroundColor - } + anchors.bottom: parent.bottom + anchors.left: parent.left } Shortcut {