Warning, /libraries/kirigami-addons/src/formcard/FormDelegateSeparator.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 QtQml 2.15
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 import org.kde.kirigami 2.4 as Kirigami
0010 
0011 /**
0012  * @brief A context-aware separator.
0013  *
0014  * This is a standard Kirigami.Separator that can be hidden upon hovering
0015  * the mouse over the ::above or ::below delegate, allowing for a subtle
0016  * but smooth animation feedback.
0017  *
0018  * Its two properties are particularly useful when it is not immediately known
0019  * which delegate will fill the ::above or ::below position, such as delegates
0020  * provided from a model or managed by a Loader.
0021  *
0022  * @see Kirigami.Separator
0023  *
0024  * @inherit Kirigami.Separator
0025  */
0026 Kirigami.Separator {
0027     id: root
0028 
0029     /**
0030      * @brief The delegate immediately above the separator.
0031      */
0032     property Item above
0033     /**
0034      * @brief The delegate immediately below the separator.
0035      */
0036     property Item below
0037 
0038     Layout.leftMargin: Kirigami.Units.largeSpacing
0039     Layout.rightMargin: Kirigami.Units.largeSpacing
0040     Layout.fillWidth: true
0041 
0042     // We need to initialize above and below later otherwise nextItemInFocusChain
0043     // will return the element itself
0044     Timer {
0045         interval: 500
0046         running: !root.above || !root.below
0047         onTriggered: {
0048             if (!root.above) {
0049                 root.above = root.nextItemInFocusChain(true);
0050             }
0051             if (!root.below) {
0052                 root.below = root.nextItemInFocusChain(false);
0053             }
0054         }
0055     }
0056 
0057     opacity: (!above || above.background === null || !(above.enabled && ((above.visualFocus || above.hovered && !Kirigami.Settings.tabletMode) || above.pressed))) &&
0058         (!below || below.background === null || !(below.enabled && ((below.visualFocus || below.hovered && !Kirigami.Settings.tabletMode) || below.pressed))) ? 0.5 : 0
0059 }