Warning, /maui/mauikit/src/controls.5/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 2.14
0021 import QtQuick.Layouts 1.3
0022 import QtQuick.Controls 2.14
0023
0024 import org.mauikit.controls 1.3 as Maui
0025
0026 /**
0027 * SwipeItemDelegate
0028 * A global sidebar for the application window that can be collapsed.
0029 *
0030 *
0031 *
0032 *
0033 *
0034 *
0035 */
0036 Maui.ItemDelegate
0037 {
0038 id: control
0039 padding: Maui.Style.defaultPadding
0040 spacing: Maui.Style.defaultSpacing
0041 isCurrentItem : ListView.isCurrentItem
0042
0043 /**
0044 * content : Item.data
0045 */
0046 default property alias content : _content.data
0047
0048 property alias actionRow : _background.data
0049 /**
0050 * showQuickActions : bool
0051 */
0052 property bool showQuickActions : true
0053
0054 /**
0055 * quickActions : list<Action>
0056 */
0057 property list<Action> quickActions
0058
0059 /**
0060 * collapse : bool
0061 */
0062 property bool collapse : width < Maui.Style.units.gridUnit * 26 || Maui.Handy.isMobile
0063
0064 onCollapseChanged:
0065 {
0066 if(_swipeDelegate.swipe.position < 0)
0067 _swipeDelegate.swipe.close()
0068 }
0069
0070 background: null
0071
0072 SwipeDelegate
0073 {
0074 id: _swipeDelegate
0075 anchors.fill: parent
0076 hoverEnabled: true
0077 clip: true
0078
0079 onClicked: control.clicked(null)
0080 onPressed: control.pressed(null)
0081 onDoubleClicked: control.doubleClicked(null)
0082 onPressAndHold: control.pressAndHold(null)
0083
0084 swipe.enabled: control.collapse && control.showQuickActions
0085 padding: Maui.Style.space.small
0086 topPadding: padding
0087 bottomPadding: padding
0088 leftPadding: padding
0089 rightPadding: padding
0090
0091 background: Rectangle
0092 {
0093 id: _bg
0094 // anchors.fill: _swipeDelegate.background
0095 //z: _swipeDelegate.background.z -1
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 // opacity: Math.abs( _swipeDelegate.swipe.position)
0099 }
0100
0101 contentItem: RowLayout
0102 {
0103 spacing: control.spacing
0104 id: _background
0105
0106 // transform: Translate {
0107 // x: _swipeDelegate.swipe.position * control.width * 0.33
0108 // }
0109 Item
0110 {
0111 id: _content
0112 Layout.fillWidth: true
0113 Layout.fillHeight: true
0114 }
0115
0116 Row
0117 {
0118 id: _buttonsRow
0119 spacing: control.spacing
0120 visible: control.hovered && control.showQuickActions && !control.collapse
0121 Layout.fillHeight: true
0122 Layout.preferredWidth: Math.max(Maui.Style.space.big, _buttonsRow.implicitWidth)
0123 Layout.alignment: Qt.AlignRight
0124 // Layout.margins: Maui.Style.space.medium
0125
0126 Behavior on Layout.preferredWidth
0127 {
0128 NumberAnimation
0129 {
0130 duration: Maui.Style.units.longDuration
0131 easing.type: Easing.InOutQuad
0132 }
0133 }
0134
0135 Repeater
0136 {
0137 model: !control.collapse && control.showQuickActions ? control.quickActions : undefined
0138
0139 ToolButton
0140 {
0141 action: modelData
0142 anchors.verticalCenter: parent.verticalCenter
0143 }
0144 }
0145 }
0146
0147 Item
0148 {
0149 visible: control.collapse && control.quickActions.length > 0 && control.showQuickActions
0150 Layout.fillHeight: true
0151 Layout.preferredWidth: Maui.Style.iconSizes.big + Maui.Style.space.small
0152 Layout.margins: Maui.Style.space.small
0153
0154 ToolButton
0155 {
0156 anchors.centerIn: parent
0157 icon.name: "overflow-menu"
0158 onClicked: _swipeDelegate.swipe.complete ? _swipeDelegate.swipe.close() : _swipeDelegate.swipe.open(SwipeDelegate.Right)
0159 }
0160 }
0161 }
0162
0163 swipe.right: Row
0164 {
0165 id: _rowActions
0166 anchors.right: parent.right
0167 anchors.verticalCenter: parent.verticalCenter
0168 spacing: control.spacing
0169 padding: Maui.Style.space.medium
0170 // width: implicitWidth * Math.abs(_swipeDelegate.swipe.position)
0171 height: parent.height
0172
0173 opacity: Math.abs(_swipeDelegate.swipe.position) > 0.5 ? 1 : 0
0174 // Behavior on width
0175 // {
0176 // NumberAnimation
0177 // {
0178 // duration: Maui.Style.units.longDuration
0179 // easing.type: Easing.InOutQuad
0180 // }
0181 // }
0182
0183 Repeater
0184 {
0185 model: control.collapse && control.showQuickActions ? control.quickActions : undefined
0186
0187 ToolButton
0188 {
0189 action: modelData
0190 anchors.verticalCenter: parent.verticalCenter
0191 onClicked: _swipeDelegate.swipe.close()
0192 }
0193 }
0194 }
0195 }
0196 }