Plasma-framework

ShadowedLabel.qml
1/*
2 * SPDX-FileCopyrightText: 2013 Bhushan Shah <bhush94@gmail.com>
3 * SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
4 * SPDX-FileCopyrightText: 2022 ivan tkachenko <me@ratijas.tk>
5 * SPDX-FileCopyrightText: 2023 Mike Noe <noeerover@gmail.com>
6 * SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>
7 *
8 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
9 */
10
11import QtQuick
12import Qt5Compat.GraphicalEffects
13
14import org.kde.plasma.components as PlasmaComponents3
15import org.kde.kirigami as Kirigami
16
17/**
18 * @brief White text label with a black shadow behind it
19 *
20 * A standardized label with white text and a black shadow behind it. When using
21 * software rendering such that the shadow is not available, a black rounded
22 * rectangle is used in its stead.
23 *
24 * By default it elides text on the right, wraps in a way that prefers word
25 * boundaries, and uses plain text formatting.
26 *
27 * The most important property is "text", which applies to the text property of
28 * the underlying Label component. See the Label component from QtQuick.Controls
29 * 2 and primitive QML Text element API for additional properties, methods, and
30 * signals.
31 *
32 * @inherit org.kde.plasma.components.Label
33 */
34PlasmaComponents3.Label {
35 /**
36 * This property can be used to conditionally *not* render the shadow, even
37 * when it's technically possible to render it.
38 *
39 * default: ``true``
40 */
41 property bool renderShadow: true
42
43 elide: Text.ElideRight
44 wrapMode: Text.Wrap
45 textFormat: Text.PlainText
46
47 color: "white"
48
49 layer.enabled: renderShadow && GraphicsInfo.api !== GraphicsInfo.Software
50 layer.effect: DropShadow {
51 horizontalOffset: 1
52 verticalOffset: 1
53
54 radius: 4.0
55 samples: radius * 2 + 1
56 spread: 0.35
57 color: "black"
58 }
59
60 // Fallback background when we can't draw the text shadow because hardware
61 // rendering isn't available
62 Rectangle {
63 anchors {
64 fill: parent
65 margins: -Kirigami.Units.smallSpacing
66 }
67
68 color: "black"
69 radius: Kirigami.Units.smallSpacing
70 opacity: 0.45
71
72 visible: GraphicsInfo.api === GraphicsInfo.Software
73 }
74}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.