Kirigami2

ShadowedImage.qml
1/*
2 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
3 * SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8import QtQuick
9import org.kde.kirigami as Kirigami
10
11/**
12 * @brief An image with a shadow.
13 *
14 * This item will render a image, with a shadow below it. The rendering is done
15 * using distance fields, which provide greatly improved performance. The shadow is
16 * rendered outside of the item's bounds, so the item's width and height are the
17 * don't include the shadow.
18 *
19 * Example usage:
20 * @code
21 * import org.kde.kirigami
22 *
23 * ShadowedImage {
24 * source: 'qrc:/myKoolGearPicture.png'
25 *
26 * radius: 20
27 *
28 * shadow.size: 20
29 * shadow.xOffset: 5
30 * shadow.yOffset: 5
31 *
32 * border.width: 2
33 * border.color: Kirigami.Theme.textColor
34 *
35 * corners.topLeftRadius: 4
36 * corners.topRightRadius: 5
37 * corners.bottomLeftRadius: 2
38 * corners.bottomRightRadius: 10
39 * }
40 * @endcode
41 *
42 * @since 5.69
43 * @since 2.12
44 * @inherit Item
45 */
46Item {
47 id: root
48
49//BEGIN properties
50 /**
51 * @brief This property holds the color that will be underneath the image.
52 *
53 * This will be visible if the image has transparancy.
54 *
55 * @see org::kde::kirigami::ShadowedRectangle::radius
56 * @property color color
57 */
58 property alias color: shadowRectangle.color
59
60 /**
61 * @brief This propery holds the corner radius of the image.
62 * @see org::kde::kirigami::ShadowedRectangle::radius
63 * @property real radius
64 */
65 property alias radius: shadowRectangle.radius
66
67 /**
68 * @brief This property holds shadow's properties group.
69 * @see org::kde::kirigami::ShadowedRectangle::shadow
70 * @property org::kde::kirigami::ShadowedRectangle::ShadowGroup shadow
71 */
72 property alias shadow: shadowRectangle.shadow
74 /**
75 * @brief This propery holds the border's properties of the image.
76 * @see org::kde::kirigami::ShadowedRectangle::border
77 * @property org::kde::kirigami::ShadowedRectangle::BorderGroup border
78 */
79 property alias border: shadowRectangle.border
80
81 /**
82 * @brief This propery holds the corner radius properties of the image.
83 * @see org::kde::kirigami::ShadowedRectangle::corners
84 * @property org::kde::kirigami::ShadowedRectangle::CornersGroup corners
85 */
86 property alias corners: shadowRectangle.corners
87
88 /**
89 * @brief This propery holds the source of the image.
90 * @brief QtQuick.Image::source
91 */
92 property alias source: image.source
93
94 /**
95 * @brief This property sets whether this image should be loaded asynchronously.
96 *
97 * Set this to false if you want the main thread to load the image, which
98 * blocks it until the image is loaded. Setting this to true loads the
99 * image in a separate thread which is useful when maintaining a responsive
100 * user interface is more desirable than having images immediately visible.
101 *
102 * @see QtQuick.Image::asynchronous
103 * @property bool asynchronous
104 */
105 property alias asynchronous: image.asynchronous
106
107 /**
108 * @brief This property defines what happens when the source image has a different
109 * size than the item.
110 * @see QtQuick.Image::fillMode
111 * @property int fillMode
112 */
113 property alias fillMode: image.fillMode
114
115 /**
116 * @brief This property holds whether the image uses mipmap filtering when scaled
117 * or transformed.
118 * @see QtQuick.Image::mipmap
119 * @property bool mipmap
120 */
121 property alias mipmap: image.mipmap
123 /**
124 * @brief This property holds the scaled width and height of the full-frame image.
125 * @see QtQuick.Image::sourceSize
126 */
127 property alias sourceSize: image.sourceSize
128
129 /**
130 * @brief This property holds the status of image loading.
131 * @see QtQuick.Image::status
132 * @since 6.5
133 */
134 readonly property alias status: image.status
135//END properties
136
137 Image {
138 id: image
139 anchors.fill: parent
140 }
141
142 ShaderEffectSource {
143 id: textureSource
144 sourceItem: image
145 hideSource: !shadowRectangle.softwareRendering
146 }
147
148 Kirigami.ShadowedTexture {
149 id: shadowRectangle
150 anchors.fill: parent
151 source: (image.status === Image.Ready && !softwareRendering) ? textureSource : null
152 }
153}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:05:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.