Warning, /frameworks/kirigami/src/controls/Card.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.6 0008 import QtQuick.Layouts 1.2 0009 import QtQuick.Controls 2.0 as QQC2 0010 import org.kde.kirigami 2.12 as Kirigami 0011 import "private" as P 0012 0013 /** 0014 * @brief This component implements a standard layout of a card. 0015 * 0016 * It is recommended to use this class when the concept of Cards is needed 0017 * in the application. 0018 * 0019 * This Card has default items as AbstractCard::header and AbstractCard::footer. The header is an 0020 * image that can contain an optional title and icon, accessible via the 0021 * ::banner grouped property. 0022 * 0023 * The footer will show a series of toolbuttons (and eventual overflow menu) 0024 * representing the actions list accessible with the list property actions. 0025 * It is possible even tough is discouraged to override the footer: 0026 * in this case the actions property shouldn't be used. 0027 * 0028 * @see <a href="https://develop.kde.org/hig/components/editing/card">KDE Human Interface Guidelines on Cards</a> 0029 * @since org.kde.kirigami 2.4 0030 * @inherit kirigami::AbstractCard 0031 */ 0032 Kirigami.AbstractCard { 0033 id: root 0034 0035 /** 0036 * @brief This property holds visible actions that will be available in the footer 0037 * of the card. 0038 * 0039 * The actions will be represented by a list of ToolButtons with an optional overflow 0040 * menu, when not all of them will fit in the available Card width. 0041 * 0042 * @property list<kirigami::Action> Card::actions 0043 */ 0044 property list<QtObject> actions 0045 0046 /** 0047 * @brief This property holds hidden actions that will be available in the footer. 0048 * 0049 * These actions will only be shown in the overflow menu, even when there is enough space. 0050 * 0051 * @deprecated Use actions with a ``Kirigami.DisplayHint.AlwaysHide`` as displayHint. 0052 * @see kirigami::DisplayHint 0053 * @since org.kde.kirigami 2.6 0054 * @property list<kirigami::Action> hiddenActions 0055 */ 0056 property alias hiddenActions: actionsToolBar.hiddenActions 0057 0058 /** 0059 * @brief This grouped property controls the banner image present in the header. 0060 * 0061 * This grouped property has the following sub-properties: 0062 * * ``source: url``: The source for the image. It understands any URL valid for an Image component. 0063 * * ``titleIcon: string``: The optional icon to put in the banner, either a freedesktop-compatible 0064 * icon name (recommended) or any URL supported by QtQuick.Image. 0065 * * ``title: string``: The title for the banner, shown as contrasting text over the image. 0066 * * ``titleAlignment: Qt::Alignment``: The alignment of the title inside the image. 0067 * default: ``Qt.AlignTop | Qt.AlignLeft`` 0068 * * ``titleLevel: int``: The Kirigami.Heading level for the title, which controls the font size. 0069 * default: ``1``, which is the largest size. 0070 * * ``titleWrapMode: QtQuick.Text.wrapMode``: Whether the header text should be able to wrap. 0071 * default: ``Text.NoWrap`` 0072 * 0073 * It also has the full set of properties that QtQuick.Image has, such as sourceSize and fillMode. 0074 * 0075 * @see kirigami::private::BannerImage 0076 * @property Image banner 0077 */ 0078 readonly property alias banner: bannerImage 0079 0080 0081 header: P.BannerImage { 0082 id: bannerImage 0083 anchors.leftMargin: -root.leftPadding + root.background.border.width 0084 anchors.topMargin: -root.topPadding + root.background.border.width 0085 anchors.rightMargin: root.headerOrientation === Qt.Vertical ? -root.rightPadding + root.background.border.width : 0 0086 anchors.bottomMargin: root.headerOrientation === Qt.Horizontal ? -root.bottomPadding + root.background.border.width : 0 0087 //height: Layout.preferredHeight 0088 implicitWidth: root.headerOrientation === Qt.Horizontal ? sourceSize.width : Layout.preferredWidth 0089 Layout.preferredHeight: (source.toString() !== "" ? width / (sourceSize.width / sourceSize.height) : Layout.minimumHeight) + anchors.topMargin + anchors.bottomMargin 0090 0091 readonly property real widthWithBorder: width + root.background.border.width * 2 0092 readonly property real heightWithBorder: height + root.background.border.width * 2 0093 readonly property real radiusFromBackground: root.background.radius - root.background.border.width 0094 0095 corners.topLeftRadius: radiusFromBackground 0096 corners.topRightRadius: (root.headerOrientation === Qt.Horizontal && widthWithBorder < root.width) ? 0 : radiusFromBackground 0097 corners.bottomLeftRadius: (root.headerOrientation !== Qt.Horizontal && heightWithBorder < root.height) ? 0 : radiusFromBackground 0098 corners.bottomRightRadius: heightWithBorder < root.height ? 0 : radiusFromBackground 0099 } 0100 0101 onHeaderChanged: { 0102 if (!header) { 0103 return; 0104 } 0105 0106 header.anchors.leftMargin = Qt.binding(() => -root.leftPadding); 0107 header.anchors.topMargin = Qt.binding(() => -root.topPadding); 0108 header.anchors.rightMargin = Qt.binding(() => root.headerOrientation === Qt.Vertical ? -root.rightPadding : 0); 0109 header.anchors.bottomMargin = Qt.binding(() => root.headerOrientation === Qt.Horizontal ? -root.bottomPadding : 0); 0110 } 0111 0112 footer: Kirigami.ActionToolBar { 0113 id: actionsToolBar 0114 actions: root.actions 0115 position: QQC2.ToolBar.Footer 0116 visible: root.footer === actionsToolBar 0117 } 0118 }