Changeset View
Changeset View
Standalone View
Standalone View
smsapp/qml/ConversationDisplay.qml
Show All 15 Lines | |||||
16 | * You should have received a copy of the GNU Lesser General Public | 16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with this library; if not, write to the Free Software | 17 | * License along with this library; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.1 | 21 | import QtQuick 2.1 | ||
22 | import QtQuick.Controls 2.1 | 22 | import QtQuick.Controls 2.1 | ||
23 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
24 | import org.kde.people 1.0 | ||||
24 | import org.kde.kirigami 2.2 as Kirigami | 25 | import org.kde.kirigami 2.2 as Kirigami | ||
25 | import org.kde.kdeconnect.sms 1.0 | 26 | import org.kde.kdeconnect.sms 1.0 | ||
26 | 27 | | |||
27 | Kirigami.ScrollablePage | 28 | Kirigami.ScrollablePage | ||
28 | { | 29 | { | ||
29 | id: page | 30 | id: page | ||
30 | property QtObject person | 31 | property alias personUri: person.personUri | ||
32 | readonly property QtObject person: PersonData { | ||||
33 | id: person | ||||
34 | } | ||||
31 | property QtObject device | 35 | property QtObject device | ||
36 | property string conversationId | ||||
32 | 37 | | |||
33 | readonly property string phoneNumber: person.contactCustomProperty("phoneNumber") | 38 | property string phoneNumber | ||
34 | readonly property QtObject telephony: device ? TelephonyDbusInterfaceFactory.create(device.id()) : null | 39 | title: person && person.name ? i18n("%1: %2", person.name, phoneNumber) : phoneNumber | ||
35 | title: i18n("%1: %2", person.name, phoneNumber) | | |||
36 | 40 | | |||
37 | ListView { | 41 | ListView { | ||
38 | model: ConversationModel { | 42 | model: ConversationModel { | ||
39 | id: model | 43 | id: model | ||
40 | deviceId: device.id() | 44 | deviceId: device.id() | ||
41 | threadId: "xxxx" | 45 | threadId: page.conversationId | ||
42 | } | 46 | } | ||
43 | 47 | | |||
44 | delegate: Kirigami.BasicListItem { | 48 | delegate: Kirigami.BasicListItem { | ||
45 | readonly property real margin: 100 | 49 | readonly property real margin: 100 | ||
46 | x: fromMe ? Kirigami.Units.gridUnit : margin | 50 | x: fromMe ? Kirigami.Units.gridUnit : margin | ||
47 | width: parent.width - margin - Kirigami.Units.gridUnit | 51 | width: parent.width - margin - Kirigami.Units.gridUnit | ||
48 | contentItem: Label { text: model.display } | 52 | contentItem: Label { text: model.display } | ||
49 | } | 53 | } | ||
50 | } | 54 | } | ||
51 | footer: RowLayout { | 55 | footer: RowLayout { | ||
52 | enabled: page.device | 56 | enabled: page.device | ||
53 | TextField { | 57 | TextField { | ||
54 | id: message | 58 | id: message | ||
55 | Layout.fillWidth: true | 59 | Layout.fillWidth: true | ||
56 | placeholderText: i18n("Say hi...") | 60 | placeholderText: i18n("Say hi...") | ||
57 | onAccepted: { | 61 | onAccepted: { | ||
58 | console.log("sending sms", page.phoneNumber) | 62 | console.log("sending sms", page.phoneNumber) | ||
59 | page.telephony.sendSms(page.phoneNumber, message.text) | 63 | model.sendReplyToConversation(message.text) | ||
60 | } | 64 | } | ||
61 | } | 65 | } | ||
62 | Button { | 66 | Button { | ||
63 | text: "Send" | 67 | text: "Send" | ||
64 | onClicked: { | 68 | onClicked: { | ||
65 | message.accepted() | 69 | message.accepted() | ||
66 | } | 70 | } | ||
67 | } | 71 | } | ||
68 | } | 72 | } | ||
69 | } | 73 | } |