Warning, /libraries/kirigami-addons/src/formcard/FormDelegateBackground.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2022 Devin Lin <devin@kde.org> 0003 * SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.15 0007 import QtQuick.Layouts 1.15 0008 import QtQuick.Templates 2.15 as T 0009 import org.kde.kirigami 2.20 as Kirigami 0010 0011 /** 0012 * @brief A background for Form delegates. 0013 * 0014 * This is a simple background that provides opacity feedback to the user 0015 * when the control has focus or is currently being pressed, for example. 0016 * 0017 * This is used in AbstractFormDelegate so that new delegates provide this 0018 * feedback by default, and can be easily overriden with a QtQuick.Item. 0019 * 0020 * @since KirigamiAddons 0.11.0 0021 * 0022 * @see AbstractFormDelegate 0023 * 0024 * @inherit QtQuick.Rectangle 0025 */ 0026 Rectangle { 0027 /** 0028 * @brief The control to which the background will be assigned. 0029 */ 0030 required property T.Control control 0031 0032 color: { 0033 let colorOpacity = 0; 0034 0035 if (!control.enabled) { 0036 colorOpacity = 0; 0037 } else if (control.pressed) { 0038 colorOpacity = 0.2; 0039 } else if (control.visualFocus) { 0040 colorOpacity = 0.1; 0041 } else if (!Kirigami.Settings.tabletMode && control.hovered) { 0042 colorOpacity = 0.07; 0043 } 0044 0045 return Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, colorOpacity) 0046 } 0047 0048 Behavior on color { 0049 ColorAnimation { duration: Kirigami.Units.shortDuration } 0050 } 0051 }