Warning, /maui/buho/src/widgets/CardDelegate.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.15
0002 import QtQml 2.15
0003 import QtQuick.Controls 2.15
0004 import QtQuick.Layouts 1.3
0005 
0006 import org.mauikit.controls 1.3 as Maui
0007 
0008 Maui.ItemDelegate
0009 {
0010     id: control
0011 
0012     implicitWidth: 200
0013     implicitHeight: Math.min(120, _layout.implicitHeight)
0014 
0015     property int cardRadius: Maui.Style.radiusV
0016 
0017     property bool checkable: false
0018     property bool checked : false
0019 
0020     signal toggled(bool state)
0021 
0022     draggable: true
0023 
0024     Drag.keys: ["text/uri-list"]
0025     Drag.mimeData: Drag.active ?
0026                        {
0027                            "text/uri-list": control.filterSelectedItems(model.path)
0028                        } : {}
0029 
0030 Rectangle
0031 {
0032     anchors.fill: parent
0033     color: Qt.darker(Maui.Theme.textColor)
0034     opacity: 0.2
0035     visible: control.checkable || control.checked
0036     radius: control.cardRadius
0037 }
0038 
0039 background: Rectangle
0040 {
0041     readonly property color m_color : Qt.tint(Qt.lighter(control.Maui.Theme.textColor), Qt.rgba(control.Maui.Theme.backgroundColor.r, control.Maui.Theme.backgroundColor.g, control.Maui.Theme.backgroundColor.b, 0.9))
0042 
0043     color: control.isCurrentItem || control.hovered || control.containsPress ? Qt.rgba(control.Maui.Theme.highlightColor.r, control.Maui.Theme.highlightColor.g, control.Maui.Theme.highlightColor.b, 0.2) : Qt.rgba(m_color.r, m_color.g, m_color.b, 0.4)
0044     radius: control.cardRadius
0045 
0046     Maui.ShadowedRectangle
0047     {
0048         id: _tagColor
0049         visible:  model.color && model.color.length
0050         color: visible ? model.color : "transparent"
0051 
0052         anchors.left: parent.left
0053         anchors.top: parent.top
0054         anchors.bottom: parent.bottom
0055         width: visible ? 12 : 0
0056 
0057         corners
0058         {
0059             topLeftRadius: control.cardRadius
0060             topRightRadius: 0
0061             bottomLeftRadius: control.cardRadius
0062             bottomRightRadius: 0
0063         }
0064     }
0065 
0066     Rectangle
0067     {
0068         anchors.fill: parent
0069         color: "transparent"
0070         border.color: control.isCurrentItem || control.checked ? Maui.Theme.highlightColor : "transparent"
0071         radius: control.cardRadius
0072     }
0073 }
0074 
0075 Maui.Holder
0076 {
0077     anchors.fill: parent
0078     visible: !body.visible && !title.visible
0079     title: i18n("Empty")
0080     body: i18n("Edit this note")
0081 }
0082 
0083 Maui.Icon
0084 {
0085     anchors.right: parent.right
0086     anchors.bottom: parent.bottom
0087     anchors.margins: Maui.Style.space.medium
0088     source: "love"
0089     color: model.color ? Qt.darker(model.color, 3) : Maui.Theme.textColor
0090     height: Maui.Style.iconSizes.small
0091     width: height
0092     visible: model.favorite == 1
0093 }
0094 
0095 CheckBox
0096 {
0097 
0098     visible: control.checkable || control.checked
0099     anchors.margins: Maui.Style.space.medium
0100     anchors.right: parent.right
0101     anchors.bottom: parent.bottom
0102     Binding on checked
0103     {
0104         value: control.checked
0105         restoreMode: Binding.RestoreBinding
0106     }
0107     onToggled:
0108     {
0109         control.checked = state
0110         control.toggled(state)
0111     }
0112 }
0113 
0114 ColumnLayout
0115 {
0116     id: _layout
0117     anchors.fill: parent
0118     anchors.margins: Maui.Style.space.medium
0119     anchors.leftMargin: _tagColor.width + Maui.Style.space.medium
0120     spacing: Maui.Style.space.medium
0121     clip: true
0122 
0123     Label
0124     {
0125         id: date
0126         padding: 0
0127         visible: text.length > 0
0128         opacity: 0.7
0129         Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0130 
0131         Layout.fillWidth: true
0132         text: Qt.formatDateTime(new Date(model.modified), "h:mm d MMM yyyy")
0133         color: Maui.Theme.textColor
0134         elide: Qt.ElideRight
0135         wrapMode: TextEdit.NoWrap
0136         font.family: settings.font.family
0137         font.weight: Font.Bold
0138         font.bold: true
0139         font.pointSize: Maui.Style.fontSizes.small
0140     }
0141 
0142     Label
0143     {
0144         id: title
0145         padding: 0
0146         visible: title.text.length > 0
0147 
0148         Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0149         Layout.preferredHeight: model.preview ? parent.height * 0.4 : implicitHeight
0150 
0151         Layout.fillWidth: true
0152 
0153         text: model.title
0154         color: Maui.Theme.textColor
0155         elide: Qt.ElideRight
0156         wrapMode: TextEdit.WrapAnywhere
0157         font.family: settings.font.family
0158         font.weight: Font.Bold
0159         font.bold: true
0160         font.pointSize: Maui.Style.fontSizes.large
0161         clip: true
0162     }
0163 
0164     Text
0165     {
0166         id: body
0167         Layout.fillHeight: true
0168         Layout.fillWidth: true
0169         padding: 0
0170         visible: model.content && text.length > 0
0171         text: model.content ? model.content : ""
0172         color: Maui.Theme.textColor
0173         wrapMode: TextEdit.WrapAnywhere
0174         font.family: settings.font.family
0175         textFormat : TextEdit.PlainText
0176         font.pointSize: Maui.Style.fontSizes.medium
0177 
0178     }
0179 }
0180 
0181 }