Kirigami-addons

FormDelegateSeparator.qml
1/*
2 * Copyright 2022 Devin Lin <devin@kde.org>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6import QtQml
7import QtQuick
8import QtQuick.Layouts
9import org.kde.kirigami as Kirigami
10
11/**
12 * @brief A context-aware separator.
13 *
14 * This is a standard Kirigami.Separator that can be hidden upon hovering
15 * the mouse over the ::above or ::below delegate, allowing for a subtle
16 * but smooth animation feedback.
17 *
18 * Its two properties are particularly useful when it is not immediately known
19 * which delegate will fill the ::above or ::below position, such as delegates
20 * provided from a model or managed by a Loader.
21 *
22 * @see Kirigami.Separator
23 *
24 * @inherit Kirigami.Separator
25 */
26Kirigami.Separator {
27 id: root
28
29 /**
30 * @brief The delegate immediately above the separator.
31 */
32 property Item above
33 /**
34 * @brief The delegate immediately below the separator.
35 */
36 property Item below
37
38 Layout.leftMargin: parent._internal_formcard_margins ? parent._internal_formcard_margins : Kirigami.Units.largeSpacing
39 Layout.rightMargin: parent._internal_formcard_margins ? parent._internal_formcard_margins : Kirigami.Units.largeSpacing
40 Layout.fillWidth: true
41
42 // We need to initialize above and below later otherwise nextItemInFocusChain
43 // will return the element itself
44 Timer {
45 interval: 500
46 running: !root.above || !root.below
47 onTriggered: {
48 if (!root.above) {
49 root.above = root.nextItemInFocusChain(true);
50 }
51 if (!root.below) {
52 root.below = root.nextItemInFocusChain(false);
53 }
54 }
55 }
56
57 opacity: (!above || above.background === null || !(above.enabled && ((above.visualFocus || above.hovered && !Kirigami.Settings.tabletMode) || above.pressed))) &&
58 (!below || below.background === null || !(below.enabled && ((below.visualFocus || below.hovered && !Kirigami.Settings.tabletMode) || below.pressed))) ? 0.5 : 0
59}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.