DialerView.qml 5.7 KB
Newer Older
1 2 3
import QtQuick 2.9
import QtQuick.Controls 2.3
import org.kde.mauikit 1.0 as Maui
4
import org.kde.kirigami 2.6 as Kirigami
Camilo higuita's avatar
Camilo higuita committed
5 6 7
import QtQuick.Layouts 1.3
import UnionModels 1.0
import "../contacts"
8 9 10 11

Maui.Page
{
    id: control
Camilo higuita's avatar
Camilo higuita committed
12
    property alias dialString : _textField.text
Camilo higuita's avatar
Camilo higuita committed
13

Camilo higuita's avatar
Camilo higuita committed
14
    property int buttonSize : Math.min( iconSizes.big * 2 , control.width * 0.25)
15 16 17
    onDialStringChanged:
    {
        //        Qt.inputMethod.hide();
Camilo higuita's avatar
Camilo higuita committed
18
        _contacsView.list.query = "tel=" + dialString
19
    }
20
//    colorScheme.backgroundColor: backgroundColor
Camilo higuita's avatar
Camilo higuita committed
21 22
    headBar.visible: false

23 24 25 26 27 28
    //    footBar.middleContent: Maui.ToolButton
    //    {
    //        iconName: "view-list-icons"
    //        onClicked: _dialerPad.visible = !_dialerPad.visible
    //        checkable: true
    //        checked: _dialerPad.visible
Camilo higuita's avatar
Camilo higuita committed
29

30
    //    }
Camilo higuita's avatar
Camilo higuita committed
31

32 33 34
    //    floatingBar: true
    //    footBarOverlap: true
    //    footBarAligment: Qt.AlignRight
Camilo higuita's avatar
Camilo higuita committed
35

Camilo higuita's avatar
Camilo higuita committed
36 37 38 39 40 41 42 43 44
    footBar.drawBorder:false
    footBar.implicitHeight:  iconSizes.big * 3
    footBar.middleContent: [

        Item
        {
            Layout.fillHeight: true
            Layout.fillWidth: true

45
            Button
Camilo higuita's avatar
Camilo higuita committed
46 47
            {
                icon.name: "send-sms"
camilo higuita's avatar
camilo higuita committed
48
                icon.color: Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
49 50 51
                height: buttonSize
                width: height
                anchors.centerIn: parent
Camilo higuita's avatar
Camilo higuita committed
52
//                bg.radius: Math.max(width, height)
Camilo higuita's avatar
Camilo higuita committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
                //                colorScheme.backgroundColor: infoColor
                onClicked:
                {
                    _messageComposer.contact = ({tel : dialString})
                    _messageComposer.open()
                }
            }

        },

        Item
        {
            Layout.fillHeight: true
            Layout.fillWidth: true

68
            Button
Camilo higuita's avatar
Camilo higuita committed
69 70 71 72 73 74
            {
                icon.name: "dialer-call"
                icon.color: "white"
                height: buttonSize
                width: height
                anchors.centerIn: parent
Camilo higuita's avatar
Camilo higuita committed
75
//                bg.radius: Math.max(width, height)
76
                Kirigami.Theme.backgroundColor: suggestedColor
Camilo higuita's avatar
Camilo higuita committed
77 78 79 80 81

                onClicked:
                {
                    if(isAndroid)
                        Maui.Android.call(dialString)
82 83
                    else
                        Qt.openUrlExternally("call://" + dialString)
Camilo higuita's avatar
Camilo higuita committed
84 85 86 87 88 89 90 91 92
                }
            }
        },

        Item
        {
            Layout.fillHeight: true
            Layout.fillWidth: true

93
            Button
Camilo higuita's avatar
Camilo higuita committed
94 95
            {
                icon.name: "edit-clear"
camilo higuita's avatar
camilo higuita committed
96
                icon.color: Kirigami.Theme.textColor
Camilo higuita's avatar
Camilo higuita committed
97 98 99
                height: iconSizes.big * 2
                width: height
                anchors.centerIn: parent
Camilo higuita's avatar
Camilo higuita committed
100
//                bg.radius: Math.max(width, height)
Camilo higuita's avatar
Camilo higuita committed
101 102 103 104 105 106 107 108 109 110
                //                colorScheme.backgroundColor: warningColor

                onClicked:
                {
                    dialString = dialString.slice(0, -1);
                }
            }
        }
    ]

Camilo higuita's avatar
Camilo higuita committed
111 112 113
    ColumnLayout
    {
        id: _layout
114
        width: Math.min(isWide ? control.width * 0.8 : control.width * 0.95, unit * 500)
Camilo higuita's avatar
Camilo higuita committed
115 116 117 118 119
        height: parent.height
        anchors.centerIn: parent
        spacing: space.big


120
        Rectangle
Camilo higuita's avatar
Camilo higuita committed
121
        {
122
            Layout.preferredHeight: toolBarHeight * 1.3
Camilo higuita's avatar
Camilo higuita committed
123
            Layout.fillWidth: true
Camilo higuita's avatar
Camilo higuita committed
124
            Layout.alignment: Qt.AlignTop
Camilo higuita's avatar
Camilo higuita committed
125
            color: cardColor
126 127
            //        border.color: borderColor
            radius: radiusV * 2
128

Camilo higuita's avatar
Camilo higuita committed
129
            Maui.TextField
130
            {
Camilo higuita's avatar
Camilo higuita committed
131 132 133 134 135 136 137 138 139 140
                id: _textField
                anchors.fill: parent
                inputMethodHints: Qt.ImhDialableCharactersOnly
                placeholderText: qsTr("Number...")
                readOnly: true
                font.bold: true
                font.weight: Font.Bold
                font.pointSize: fontSizes.huge
                font.letterSpacing: space.tiny

camilo higuita's avatar
camilo higuita committed
141

Camilo higuita's avatar
Camilo higuita committed
142
                //            enabled: false
143
            }
Camilo higuita's avatar
Camilo higuita committed
144 145 146 147 148 149 150
        }

        ListView
        {
            id: _suggestionListView
            spacing: space.big
            clip: true
151
            visible: dialString.length
Camilo higuita's avatar
Camilo higuita committed
152
            Layout.fillWidth: true
153
            Layout.minimumHeight: (unit * 80) * 1.5
Camilo higuita's avatar
Camilo higuita committed
154
            Layout.fillHeight: true
155
            Layout.preferredHeight: control.height * 0.3
Camilo higuita's avatar
Camilo higuita committed
156

157
            model: _contacsView.listModel
Camilo higuita's avatar
Camilo higuita committed
158 159 160 161 162

            delegate: ContactDelegate
            {
                id: _delegate

163
                height: unit * 60
Camilo higuita's avatar
Camilo higuita committed
164 165
                width: _layout.width
                anchors.horizontalCenter: parent.horizontalCenter
Camilo higuita's avatar
Camilo higuita committed
166

167
                quickButtons: ToolButton
Camilo higuita's avatar
Camilo higuita committed
168
                {
169
                    icon.name: "view-fullscreen"
Camilo higuita's avatar
Camilo higuita committed
170 171 172 173 174 175
                    onClicked:
                    {
                        _suggestionListView.currentIndex = index
                        control.dialString = _contacsView.list.get(_suggestionListView.currentIndex).tel
                    }
                }
Camilo higuita's avatar
Camilo higuita committed
176 177 178 179 180 181 182 183

                Connections
                {
                    target: _delegate
                    onClicked:
                    {
                        _suggestionListView.currentIndex = index
                        if(isAndroid)
184
                            Maui.Android.call(_contacsView.list.get(_suggestionListView.currentIndex).tel)
Camilo higuita's avatar
Camilo higuita committed
185 186 187 188 189
                    }
                }
            }
        }

190 191 192 193 194
        Item
        {
            id: _dialerPad
            Layout.fillHeight: true
            Layout.fillWidth: true
Camilo higuita's avatar
Camilo higuita committed
195 196
            Layout.minimumHeight: unit*300
            Layout.maximumHeight: unit*300
197

Camilo higuita's avatar
Camilo higuita committed
198
            Layout.alignment: Qt.AlignBottom
199
            //            visible: true
Camilo higuita's avatar
Camilo higuita committed
200

201 202 203 204 205 206 207
            Dialer
            {
                height: parent.height
                width: parent.width
                anchors.centerIn: parent
            }
        }
Camilo higuita's avatar
Camilo higuita committed
208
    }
209
}