KOSMIndoorMap

OSMElementInformationDialogImageDelegate.qml
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6import QtQuick
7import org.kde.kirigami as Kirigami
9/** Delegate for showing images and logos in the OSM element information dialog. */
10Item {
11 id: root
12
13 /** URL to link to for attribution/source information. */
14 required property string url
15 /** URL of the image to show. */
16 property alias source: img.source
17 /** Maximum height for the image, scale down if the source is heigher than this. */
18 property int maximumHeight: implicitHeight
19
20 property alias topMargin: img.y
21 property real bottomMargin: 0
22
23
24 implicitHeight: img.implicitHeight + root.topMargin + root.bottomMargin
25 implicitWidth: img.implicitWidth
26 height: img.status === Image.Ready ? img.height + root.topMargin + root.bottomMargin : 0
27
28 Rectangle {
29 // most logos with an alpha channel assume a light background
30 id: background
31 anchors.centerIn: img
32 // TODO only for logos with an alpha channel we might want a margin here...
33 width: img.paintedWidth
34 height: img.paintedHeight
35 color: Kirigami.Theme.textColor
36 visible: Kirigami.Theme.backgroundColor.hslLightness < 0.5
37 }
38
39 Image {
40 id: img
41
42 anchors.horizontalCenter: root.horizontalCenter
43 width: Math.min(root.width, img.implicitWidth)
44 height: Math.min(img.width / img.implicitWidth * img.implicitHeight, root.maximumHeight)
45
46 fillMode: Image.PreserveAspectFit
47
48 // weird, but TapHandler doesn't forward unhandled drags to our parent ListView but the map area behind this dialog...
49 MouseArea {
50 anchors.fill: img
51 onClicked: Qt.openUrlExternally(root.url);
52 HoverHandler {
53 cursorShape: Qt.PointingHandCursor
54 }
55 }
56 }
57}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:16:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.