Warning, /plasma/discover/discover/qml/BasicAbstractCard.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010 import org.kde.kirigami as Kirigami
0011 
0012 /*
0013  * An AbstractCard with a default background but without any fancy sizing
0014  * features of an AbstractCard.
0015  */
0016 Kirigami.AbstractCard {
0017     id: root
0018 
0019     property Item content
0020 
0021     implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
0022                             (content?.implicitWidth ?? 0) + leftPadding + rightPadding)
0023 
0024     implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
0025                              (content?.implicitHeight ?? 0) + topPadding + bottomPadding)
0026 
0027     padding: Kirigami.Units.largeSpacing
0028     topPadding: undefined
0029     leftPadding: undefined
0030     rightPadding: undefined
0031     bottomPadding: undefined
0032     verticalPadding: undefined
0033     horizontalPadding: undefined
0034 
0035     Component.onCompleted: {
0036         initContent();
0037     }
0038 
0039     onContentChanged: {
0040         initContent();
0041     }
0042 
0043     function initContent() {
0044         if (!content) {
0045             return;
0046         }
0047 
0048         content.parent = this;
0049         content.anchors.top = top;
0050         content.anchors.left = left;
0051         content.anchors.right = right;
0052         content.anchors.bottom = bottom;
0053         content.anchors.topMargin = topPadding;
0054         content.anchors.leftMargin = Qt.binding(() => mirrored ? rightPadding : leftPadding);
0055         content.anchors.rightMargin = Qt.binding(() => mirrored ? leftPadding : rightPadding);
0056         content.anchors.bottomMargin = bottomPadding;
0057     }
0058 }