Warning, /pim/kube/framework/qml/GenericListDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002   Copyright (C) 2021 Christian Mollekopf, <christian@mkpf.ch>
0003 
0004   This program is free software; you can redistribute it and/or modify
0005   it under the terms of the GNU General Public License as published by
0006   the Free Software Foundation; either version 2 of the License, 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 General Public License along
0015   with this program; if not, write to the Free Software Foundation, Inc.,
0016   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017 */
0018 
0019 import QtQuick 2.9
0020 import QtQuick.Controls 2.0
0021 import QtQuick.Layouts 1.1
0022 
0023 import org.kube.framework 1.0 as Kube
0024 
0025 Kube.ListDelegate {
0026     id: delegateRoot
0027     property bool buttonsVisible: delegateRoot.hovered
0028 
0029     property var mainText
0030     property var subText: null
0031     property var disabled: false
0032     property var active: false
0033     property var strikeout: false
0034     property var bold: false
0035     property var dateText
0036     property var dotColor: null
0037     property var counter: 0
0038     property var subtextVisible: delegateRoot.hovered
0039     property var subtextDisabled: false
0040     property Component buttonDelegate: null
0041     property Component statusDelegate: null
0042 
0043 
0044     signal dropped(var dropAction, var dropTarget)
0045 
0046     height: Kube.Units.gridUnit * 3 + 2 * Kube.Units.smallSpacing
0047 
0048     color: Kube.Colors.viewBackgroundColor
0049     border.color: Kube.Colors.backgroundColor
0050     border.width: 1
0051 
0052     MouseArea {
0053         id: mouseArea
0054         anchors.fill: parent
0055         hoverEnabled: true
0056         drag.target: parent
0057         drag.filterChildren: true
0058         onReleased: {
0059             var dropAction = parent.Drag.drop()
0060             delegateRoot.dropped(dropAction, parent.Drag.target)
0061         }
0062         onClicked: delegateRoot.clicked()
0063     }
0064 
0065     states: [
0066         State {
0067             name: "dnd"
0068             when: mouseArea.drag.active
0069 
0070             PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor}
0071             PropertyChanges {target: delegateRoot; opacity: 0.5}
0072             ParentChange {target: delegateRoot; parent: root; x: x; y: y}
0073         }
0074     ]
0075 
0076     Drag.active: mouseArea.drag.active
0077     Drag.hotSpot.x: mouseArea.mouseX
0078     Drag.hotSpot.y: mouseArea.mouseY
0079     Drag.source: delegateRoot
0080 
0081     Item {
0082         id: content
0083 
0084         anchors {
0085             fill: parent
0086             margins: Kube.Units.smallSpacing
0087         }
0088 
0089        property color unreadColor: delegateRoot.disabled ? delegateRoot.disabledTextColor : ((delegateRoot.active && !delegateRoot.highlighted) ? Kube.Colors.highlightColor : delegateRoot.textColor)
0090 
0091         Rectangle {
0092             id: colorDot
0093             anchors {
0094                 verticalCenter: parent.verticalCenter
0095                 left: parent.left
0096             }
0097             visible: delegateRoot.dotColor
0098             width: Kube.Units.smallSpacing
0099             height: width
0100             radius: width / 2
0101 
0102             color: delegateRoot.dotColor ? delegateRoot.dotColor : ""
0103         }
0104         Column {
0105             anchors {
0106                 verticalCenter: parent.verticalCenter
0107                 left: parent.left
0108                 leftMargin: colorDot.visible ? Kube.Units.largeSpacing : Kube.Units.smallSpacing
0109             }
0110 
0111             Kube.Label{
0112                 id: mainLabel
0113                 width: content.width - Kube.Units.gridUnit * 3
0114                 text: delegateRoot.mainText
0115                 color: content.unreadColor
0116                 font.strikeout: delegateRoot.strikeout
0117                 font.bold: delegateRoot.bold
0118                 maximumLineCount: 2
0119                 wrapMode: Text.WordWrap
0120                 elide: Text.ElideRight
0121             }
0122             Kube.Label {
0123                 id: subLabel
0124                 visible: delegateRoot.subtextVisible
0125                 text: delegateRoot.subText ? delegateRoot.subText : ""
0126                 color: delegateRoot.subtextDisabled ? delegateRoot.disabledTextColor : delegateRoot.textColor
0127                 font.italic: true
0128                 width: delegateRoot.width - Kube.Units.gridUnit * 3
0129                 elide: Text.ElideRight
0130             }
0131         }
0132 
0133         Kube.Label {
0134             id: dateLabel
0135             anchors {
0136                 right: parent.right
0137                 bottom: parent.bottom
0138             }
0139 
0140             visible: delegateRoot.dateText && !delegateRoot.buttonsVisible
0141             text: delegateRoot.dateText
0142             font.italic: true
0143             color: delegateRoot.disabledTextColor
0144             font.pointSize: Kube.Units.tinyFontSize
0145         }
0146        Kube.Label {
0147            id: counter
0148            anchors {
0149                right: parent.right
0150                margins: Kube.Units.smallSpacing
0151            }
0152            text: delegateRoot.counter ? delegateRoot.counter : ""
0153            color: content.unreadColor
0154            visible: delegateRoot.counter > 1 && !delegateRoot.buttonsVisible
0155 
0156        }
0157     }
0158 
0159     Loader {
0160         anchors {
0161             right: parent.right
0162             verticalCenter: parent.verticalCenter
0163             // We use twice the margin to compensate for button padding
0164             margins: delegateRoot.buttonsVisible ? Kube.Units.smallSpacing : 2 * Kube.Units.smallSpacing
0165         }
0166         active: delegateRoot.buttonsVisible && delegateRoot.buttonDelegate || delegateRoot.statusDelegate
0167         opacity: delegateRoot.buttonsVisible ? 0.7 : 1
0168         sourceComponent: delegateRoot.buttonsVisible ? delegateRoot.buttonDelegate : delegateRoot.statusDelegate
0169     }
0170 }