Warning, /maui/mauikit/src/controls.6/SwipeItemDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2018 Camilo Higuita <milo.h@aol.com> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Library General Public License as 0006 * published by the Free Software Foundation; either version 2, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details 0013 * 0014 * You should have received a copy of the GNU Library General Public 0015 * License along with this program; if not, write to the 0016 * Free Software Foundation, Inc., 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 import QtQuick 0021 import QtQuick.Layouts 0022 import QtQuick.Controls 0023 0024 import org.mauikit.controls 1.3 as Maui 0025 0026 /** 0027 * @inherit ItemDelegate 0028 * A template base for presenting an upper and under layer of content. 0029 * 0030 * This control inherits from MauiKit ItemDelegate, to checkout its inherited properties refer to the docs. 0031 0032 * This control is divided into two sections. 0033 * First, is the content, which are the elements declared ans the children of this. Those elements are always placed in the surface. 0034 * @see content 0035 * Second is a set of QQC2 Action that go to the far right side - either in the superior or inferior surface. 0036 * That behavior will depend on the `collapse` property value - where `collapse : true` means it will be displayed under the surface. 0037 0038 @note When the quick actions are displayed above in the surface, they will only be discovered upon hovering, otherwise they will stay hidden. 0039 0040 You can review the SwipeBrowserDelegate which serves as an example of how to use this control. 0041 @see SwipeBrowserDelegate 0042 * 0043 */ 0044 Maui.ItemDelegate 0045 { 0046 id: control 0047 0048 padding: Maui.Style.defaultPadding 0049 spacing: Maui.Style.space.small 0050 0051 /** 0052 * @brief The implicit height of the underneath area containing the action button. 0053 */ 0054 readonly property int buttonsHeight: Math.max(_background.implicitHeight, _swipeDelegate.implicitHeight) 0055 0056 isCurrentItem : ListView.isCurrentItem 0057 0058 /** 0059 * @brief The default content children has to be positioned manually, making use of anchors, etc. 0060 * @property list<QtObject> SwipeItemDelegate::content 0061 */ 0062 default property alias content : _content.data 0063 0064 /** 0065 * @brief Exposed to quickly append more items to the right side of this control in the far right area. 0066 *. 0067 * @property list<QtObject> SwipeItemDelegate::actionRow 0068 */ 0069 property alias actionRow : _background.data 0070 0071 /** 0072 * @brief Whether the quick actions declared as `quickActions` should be visible or not. 0073 * By default this is set to `true` 0074 */ 0075 property bool showQuickActions : true 0076 0077 /** 0078 * @brief The actions that goes underneath the control and is revealed by swiping to the left when the `collapse` property is set to `true`, otherwise the actions will be shown in the far right side above. 0079 */ 0080 property list<Action> quickActions 0081 0082 /** 0083 * @brief Whether the actions will go underneath the control or above. 0084 * By default this depends on the available space, so it can fit the information labels and the `quickAction` buttons. 0085 */ 0086 property bool collapse : width < Maui.Style.units.gridUnit * 26 || Maui.Handy.isMobile 0087 0088 onCollapseChanged: 0089 { 0090 if(_swipeDelegate.swipe.position < 0) 0091 _swipeDelegate.swipe.close() 0092 } 0093 0094 background: Rectangle 0095 { 0096 color: Qt.tint(control.Maui.Theme.textColor, Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.95)) 0097 radius: Maui.Style.radiusV 0098 } 0099 0100 SwipeDelegate 0101 { 0102 id: _swipeDelegate 0103 anchors.fill: parent 0104 hoverEnabled: true 0105 clip: true 0106 0107 onClicked: control.clicked(null) 0108 onPressed: control.pressed(null) 0109 onDoubleClicked: control.doubleClicked(null) 0110 onPressAndHold: control.pressAndHold(null) 0111 0112 swipe.enabled: control.collapse && control.showQuickActions 0113 padding: 0 0114 0115 background: null 0116 contentItem: RowLayout 0117 { 0118 spacing: control.spacing 0119 id: _background 0120 0121 Item 0122 { 0123 id: _content 0124 Layout.fillWidth: true 0125 Layout.fillHeight: true 0126 } 0127 0128 Loader 0129 { 0130 active: control.showQuickActions && !control.collapse 0131 visible: active && control.hovered 0132 asynchronous: true 0133 0134 sourceComponent: Row 0135 { 0136 spacing: control.spacing 0137 Layout.alignment: Qt.AlignRight 0138 0139 Repeater 0140 { 0141 model: control.quickActions 0142 0143 ToolButton 0144 { 0145 action: modelData 0146 } 0147 } 0148 } 0149 } 0150 0151 ToolButton 0152 { 0153 visible: control.collapse && control.quickActions.length > 0 && control.showQuickActions 0154 icon.name: _swipeDelegate.swipe.complete ? "go-next" : "go-previous" 0155 onClicked: _swipeDelegate.swipe.complete ? _swipeDelegate.swipe.close() : _swipeDelegate.swipe.open(SwipeDelegate.Right) 0156 } 0157 } 0158 0159 swipe.right: Row 0160 { 0161 id: _rowActions 0162 anchors.right: parent.right 0163 anchors.verticalCenter: parent.verticalCenter 0164 spacing: control.spacing 0165 padding: Maui.Style.space.medium 0166 // width: implicitWidth * Math.abs(_swipeDelegate.swipe.position) 0167 0168 opacity: Math.abs(_swipeDelegate.swipe.position) > 0.5 ? 1 : 0 0169 0170 Repeater 0171 { 0172 model: control.quickActions 0173 0174 ToolButton 0175 { 0176 action: modelData 0177 onClicked: _swipeDelegate.swipe.close() 0178 } 0179 } 0180 } 0181 } 0182 }