ContactDelegate.qml 6.17 KB
Newer Older
Camilo higuita's avatar
Camilo higuita committed
1 2 3 4 5 6 7 8 9 10 11 12 13
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0

import org.kde.mauikit 1.0 as Maui
import org.kde.kirigami 2.2 as Kirigami


ItemDelegate
{
    id: control
    hoverEnabled: true
Camilo higuita's avatar
Camilo higuita committed
14
    clip: true
Camilo higuita's avatar
Camilo higuita committed
15 16
    background: Rectangle
    {
Camilo higuita's avatar
Camilo higuita committed
17 18
        color: backgroundColor
        opacity: hovered ?  1  : 0.75
Camilo higuita's avatar
Camilo higuita committed
19
        //        border.color: borderColor
Camilo higuita's avatar
Camilo higuita committed
20
        radius: radiusV * 2
Camilo higuita's avatar
Camilo higuita committed
21 22 23 24 25 26 27 28 29 30 31 32
    }

    RowLayout
    {
        id: _layout

        anchors.fill: parent
        anchors.margins: space.big

        Item
        {
            id: _contactPic
Camilo higuita's avatar
Camilo higuita committed
33 34
            visible: control.width >  Kirigami.Units.gridUnit * 15

Camilo higuita's avatar
Camilo higuita committed
35 36
            Layout.fillHeight: true
            Layout.preferredWidth: iconSizes.huge
Camilo higuita's avatar
Camilo higuita committed
37
            clip: true
Camilo higuita's avatar
Camilo higuita committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
            Rectangle
            {
                height: parent.height
                width: height
                anchors.centerIn: parent
                radius: Math.min(width, height)
                color: Qt.rgba(Math.random(),Math.random(),Math.random(),1);
                border.color: Qt.darker(color, 1.5)


                Loader
                {
                    id: _contactPicLoader
                    anchors.fill: parent
                    sourceComponent: model.photo ? _imgComponent : _iconComponent
                }

                Component
                {
                    id: _imgComponent

                    Image
                    {
                        id: _img
                        width: parent.width
                        height: width

                        anchors.centerIn: parent

                        sourceSize.width: parent.width
                        sourceSize.height: parent.height

                        fillMode: Image.PreserveAspectCrop
                        cache: true
                        antialiasing: true
                        smooth: true
                        asynchronous: true

76
                        source: /*"file://"+ */model.photo
Camilo higuita's avatar
Camilo higuita committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132

                        layer.enabled: true
                        layer.effect: OpacityMask
                        {
                            maskSource: Item
                            {
                                width: _img.width
                                height: _img.height

                                Rectangle
                                {
                                    anchors.centerIn: parent
                                    width: _img.width
                                    height: _img.height
                                    radius: Math.min(width, height)
                                    border.color: borderColor
                                }
                            }
                        }
                    }
                }

                Component
                {
                    id: _iconComponent

                    //                    Maui.ToolButton
                    //                    {
                    //                        iconName: "view-media-artist"
                    //                        size: iconSizes.big
                    //                        iconColor: "white"
                    //                    }

                    Label
                    {
                        anchors.fill: parent
                        horizontalAlignment: Qt.AlignHCenter
                        verticalAlignment: Qt.AlignVCenter

                        color: "white"
                        font.pointSize: fontSizes.huge
                        font.bold: true
                        font.weight: Font.Bold
                        text: model.n[0]
                    }
                }

            }
        }

        Item
        {
            id: _contactInfo

            Layout.fillHeight: true
            Layout.fillWidth: true
Camilo higuita's avatar
Camilo higuita committed
133
            clip: true
Camilo higuita's avatar
Camilo higuita committed
134 135 136 137 138 139 140 141 142 143 144 145 146

            ColumnLayout
            {
                anchors.fill: parent

                Label
                {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    text: model.n
                    font.pointSize: fontSizes.big
                    font.bold: true
                    font.weight: Font.Bold
Camilo higuita's avatar
Camilo higuita committed
147
                    elide: Text.ElideMiddle
Camilo higuita's avatar
Camilo higuita committed
148 149 150 151 152 153 154 155 156
                }

                Label
                {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    text: model.title
                    font.pointSize: fontSizes.small
                    font.weight: Font.Light
Camilo higuita's avatar
Camilo higuita committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
                    wrapMode: Text.WrapAnywhere
                    elide: Text.ElideMiddle
                }
            }
        }

        Item
        {
            visible: control.width >  Kirigami.Units.gridUnit * 20
            Layout.fillHeight: true
            Layout.fillWidth: true
            clip: true

            ColumnLayout
            {
                anchors.fill: parent

                Label
                {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignRight
                    horizontalAlignment: Qt.AlignRight

                    text: model.email
                    font.pointSize: fontSizes.small
                    font.weight: Font.Light
                    wrapMode: Text.WrapAnywhere
                    elide: Text.ElideMiddle
                }

                Label
                {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignRight
                    horizontalAlignment: Qt.AlignRight
                    text: model.tel
                    font.pointSize: fontSizes.small
                    font.weight: Font.Light
                    wrapMode: Text.WrapAnywhere
                    elide: Text.ElideMiddle
Camilo higuita's avatar
Camilo higuita committed
199 200 201 202
                }
            }
        }

Camilo higuita's avatar
Camilo higuita committed
203

Camilo higuita's avatar
Camilo higuita committed
204 205 206
        Item
        {
            Layout.fillHeight: true
Camilo higuita's avatar
Camilo higuita committed
207
            Layout.preferredWidth: iconSizes.big
Camilo higuita's avatar
Camilo higuita committed
208
            Layout.alignment: Qt.AlignRight
Camilo higuita's avatar
Camilo higuita committed
209
            Layout.margins: space.big
Camilo higuita's avatar
Camilo higuita committed
210 211 212 213 214 215 216 217 218 219 220

            Maui.ToolButton
            {
                anchors.centerIn: parent
                iconName: "overflow-menu"
            }
        }
    }


}