Warning, /libraries/kirigami-addons/src/components/BottomDrawer.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im> 0002 // 0003 // SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import org.kde.kirigami as Kirigami 0008 import QtQuick.Layouts 0009 0010 /** 0011 * @brief A bottom drawer component with a drag indicator. 0012 * 0013 * Example: 0014 * @code{.qml} 0015 * import org.kde.kirigamiaddons.delegates 1.0 as Delegates 0016 * import org.kde.kirigamiaddons.components 1.0 as Components 0017 * 0018 * Components.BottomDrawer { 0019 * id: drawer 0020 * 0021 * headerContentItem: Kirigami.Heading { 0022 * text: "Drawer" 0023 * } 0024 * 0025 * Delegates.RoundedItemDelegate { 0026 * text: "Action 1" 0027 * icon.name: "list-add" 0028 * onClicked: { 0029 * doSomething() 0030 * drawer.close() 0031 * } 0032 * } 0033 0034 * Delegates.RoundedItemDelegate { 0035 * text: "Action 1" 0036 * icon.name: "list-add" 0037 * onClicked: { 0038 * doSomething() 0039 * drawer.close() 0040 * } 0041 * } 0042 * } 0043 * @endcode 0044 * 0045 * @image html bottomdrawer.png 0046 * 0047 * @since KirigamiAddons 0.12.0 0048 */ 0049 QQC2.Drawer { 0050 id: root 0051 0052 /** 0053 * @brief This property holds the content item of the drawer 0054 */ 0055 default property alias drawerContentItem: drawerContent.contentItem 0056 0057 /** 0058 * @brief This property holds the content item of the drawer header 0059 * 0060 * when no headerContentItem is set, the header will not be displayed 0061 */ 0062 property alias headerContentItem: headerContent.contentItem 0063 0064 component Handle: Rectangle { 0065 color: Kirigami.Theme.textColor 0066 radius: height 0067 opacity: 0.5 0068 0069 implicitWidth: Math.round(Kirigami.Units.gridUnit * 2.5) 0070 implicitHeight: Math.round(Kirigami.Units.gridUnit / 4) 0071 0072 Layout.margins: Kirigami.Units.mediumSpacing 0073 Layout.alignment: Qt.AlignHCenter 0074 } 0075 0076 edge: Qt.BottomEdge 0077 width: applicationWindow().width 0078 height: Math.min(contentItem.implicitHeight, Math.round(applicationWindow().height * 0.8)) 0079 0080 // makes sure the drawer is not able to be opened when not trigered 0081 interactive : false 0082 0083 background: Kirigami.ShadowedRectangle { 0084 corners { 0085 topRightRadius: Kirigami.Units.largeSpacing 0086 topLeftRadius: Kirigami.Units.largeSpacing 0087 } 0088 0089 shadow { 0090 size: Kirigami.Units.gridUnit 0091 color: Qt.rgba(0, 0, 0, 0.5) 0092 } 0093 0094 color: Kirigami.Theme.backgroundColor 0095 } 0096 0097 onAboutToShow: root.interactive = true 0098 onClosed: root.interactive = false 0099 0100 contentItem: ColumnLayout { 0101 spacing: 0 0102 0103 Kirigami.ShadowedRectangle { 0104 id: headerBackground 0105 0106 visible: headerContentItem 0107 height: header.implicitHeight 0108 0109 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0110 color: Kirigami.Theme.backgroundColor 0111 0112 Layout.fillWidth: true 0113 0114 corners { 0115 topRightRadius: 10 0116 topLeftRadius: 10 0117 } 0118 0119 ColumnLayout{ 0120 id:header 0121 0122 anchors.fill: parent 0123 spacing:0 0124 clip: true 0125 0126 Handle { 0127 // drag indicator displayed when there is a headerContentItem 0128 id: handle 0129 } 0130 0131 QQC2.Control { 0132 id: headerContent 0133 0134 topPadding: 0 0135 leftPadding: Kirigami.Units.mediumSpacing + handle.height 0136 rightPadding: Kirigami.Units.mediumSpacing + handle.height 0137 bottomPadding: Kirigami.Units.mediumSpacing + handle.height 0138 0139 Layout.fillHeight: true 0140 Layout.fillWidth: true 0141 } 0142 } 0143 } 0144 0145 Handle { 0146 // drag indecator displayed when there is no headerContentItem 0147 visible: !headerContentItem 0148 Layout.topMargin: Kirigami.Units.largeSpacing 0149 Layout.bottomMargin: Kirigami.Units.largeSpacing 0150 } 0151 0152 Kirigami.Separator { 0153 Layout.fillWidth: true 0154 } 0155 0156 QQC2.Control { 0157 id: drawerContent 0158 0159 Layout.fillWidth: true 0160 Layout.fillHeight: true 0161 0162 leftPadding: 0 0163 rightPadding: 0 0164 topPadding: 0 0165 bottomPadding: 0 0166 0167 background: Rectangle { 0168 Kirigami.Theme.colorSet: Kirigami.Theme.View 0169 Kirigami.Theme.inherit: false 0170 color: Kirigami.Theme.backgroundColor 0171 } 0172 } 0173 } 0174 }