2018-10-30 20:01:13 +00:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
|
|
|
|
* SPDX-FileCopyrightText: 2018 Simon Redman <simon@ergotech.com>
|
2018-10-30 20:01:13 +00:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2018-10-30 20:01:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.5
|
|
|
|
import QtQuick.Controls 2.1
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import org.kde.people 1.0
|
2020-05-06 19:19:02 +01:00
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
2018-10-30 20:01:13 +00:00
|
|
|
import org.kde.kdeconnect 1.0
|
|
|
|
import org.kde.kdeconnect.sms 1.0
|
|
|
|
|
|
|
|
Kirigami.ScrollablePage
|
|
|
|
{
|
2019-01-23 01:27:10 +00:00
|
|
|
id: page
|
2019-03-18 21:58:34 +00:00
|
|
|
ToolTip {
|
|
|
|
id: noDevicesWarning
|
2019-08-24 18:18:17 +01:00
|
|
|
visible: !page.deviceConnected
|
2019-03-18 21:58:34 +00:00
|
|
|
timeout: -1
|
2019-12-21 07:59:36 +00:00
|
|
|
text: "⚠️ " + i18nd("kdeconnect-sms", "No devices available") + " ⚠️"
|
2019-03-18 21:58:34 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
// Detect mouseover and show another tooltip with more information
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
|
|
|
|
ToolTip.visible: containsMouse
|
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
|
|
|
// TODO: Wrap text if line is too long for the screen
|
2019-12-21 07:59:36 +00:00
|
|
|
ToolTip.text: i18nd("kdeconnect-sms", "No new messages can be sent or received, but you can browse cached content")
|
2019-03-18 21:58:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-21 11:55:25 +01:00
|
|
|
contextualActions: [
|
|
|
|
Kirigami.Action {
|
2019-12-21 07:59:36 +00:00
|
|
|
text: i18nd("kdeconnect-sms", "Refresh")
|
2019-07-21 11:55:25 +01:00
|
|
|
icon.name: "view-refresh"
|
|
|
|
enabled: devicesCombo.count > 0
|
|
|
|
onTriggered: {
|
|
|
|
conversationListModel.refresh()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2020-04-13 05:02:27 +01:00
|
|
|
Label {
|
|
|
|
id: searchResultIndiactor
|
|
|
|
visible: deviceConnected && view.count == 0 && view.headerItem.childAt(0, 0).text.length != 0
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: i18nd("kdeconnect-sms", "No matched results found : (")
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
|
|
|
|
2019-08-24 18:18:17 +01:00
|
|
|
ColumnLayout {
|
|
|
|
id: loadingMessage
|
2020-04-13 05:02:27 +01:00
|
|
|
visible: deviceConnected && view.count == 0 && view.headerItem.childAt(0, 0).text.length == 0
|
2019-08-24 18:18:17 +01:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
BusyIndicator {
|
|
|
|
running: loadingMessage.visible
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
}
|
2020-02-03 01:37:25 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
text: "Loading conversations from device. If this takes a long time, please wake up your device and then click refresh."
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
Layout.preferredWidth: page.width / 2
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: "Tip: If you plug in your device, it should not go into doze mode and should load quickly."
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
Layout.preferredWidth: page.width / 2
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
2019-08-24 18:18:17 +01:00
|
|
|
}
|
|
|
|
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
property string initialMessage
|
2019-07-20 15:02:38 +01:00
|
|
|
property string initialDevice
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
|
|
|
|
header: Kirigami.InlineMessage {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: page.initialMessage.length > 0
|
2019-12-21 07:59:36 +00:00
|
|
|
text: i18nd("kdeconnect-sms", "Choose recipient")
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
|
|
|
|
actions: [
|
|
|
|
Kirigami.Action {
|
|
|
|
iconName: "dialog-cancel"
|
2019-12-21 07:59:36 +00:00
|
|
|
text: i18nd("kdeconnect-sms", "Cancel")
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
onTriggered: initialMessage = ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-10-30 20:01:13 +00:00
|
|
|
footer: ComboBox {
|
|
|
|
id: devicesCombo
|
|
|
|
enabled: count > 0
|
2019-12-21 07:59:36 +00:00
|
|
|
displayText: !enabled ? i18nd("kdeconnect-sms", "No devices available") : undefined
|
2018-10-30 20:01:13 +00:00
|
|
|
model: DevicesSortProxyModel {
|
|
|
|
id: devicesModel
|
2018-11-26 19:42:18 +00:00
|
|
|
//TODO: make it possible to filter if they can do sms
|
2018-10-30 20:01:13 +00:00
|
|
|
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable }
|
|
|
|
onRowsInserted: if (devicesCombo.currentIndex < 0) {
|
2019-07-20 15:02:38 +01:00
|
|
|
if (page.initialDevice)
|
|
|
|
devicesCombo.currentIndex = devicesModel.rowForDevice(page.initialDevice);
|
|
|
|
else
|
|
|
|
devicesCombo.currentIndex = 0
|
2018-10-30 20:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
textRole: "display"
|
|
|
|
}
|
|
|
|
|
2019-01-23 01:27:10 +00:00
|
|
|
readonly property bool deviceConnected: devicesCombo.enabled
|
2018-10-30 20:01:13 +00:00
|
|
|
readonly property QtObject device: devicesCombo.currentIndex >= 0 ? devicesModel.data(devicesModel.index(devicesCombo.currentIndex, 0), DevicesModel.DeviceRole) : null
|
2019-01-23 01:27:10 +00:00
|
|
|
readonly property alias lastDeviceId: conversationListModel.deviceId
|
2018-10-30 20:01:13 +00:00
|
|
|
|
2019-03-08 21:18:51 +00:00
|
|
|
Component {
|
2018-10-30 20:01:13 +00:00
|
|
|
id: chatView
|
2019-01-23 01:27:10 +00:00
|
|
|
ConversationDisplay {
|
|
|
|
deviceId: page.lastDeviceId
|
|
|
|
deviceConnected: page.deviceConnected
|
|
|
|
}
|
2018-10-30 20:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: view
|
|
|
|
currentIndex: 0
|
|
|
|
|
|
|
|
model: QSortFilterProxyModel {
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
filterCaseSensitivity: Qt.CaseInsensitive
|
|
|
|
sourceModel: ConversationListModel {
|
2019-01-23 01:27:10 +00:00
|
|
|
id: conversationListModel
|
2018-10-30 20:01:13 +00:00
|
|
|
deviceId: device ? device.id() : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-13 03:20:04 +01:00
|
|
|
header: RowLayout {
|
|
|
|
width: parent.width
|
2018-12-17 16:25:33 +00:00
|
|
|
z: 10
|
2020-04-13 03:20:04 +01:00
|
|
|
Keys.forwardTo: [filter]
|
|
|
|
TextField {
|
|
|
|
/**
|
|
|
|
* Used as the filter of the list of messages
|
|
|
|
*/
|
|
|
|
id: filter
|
|
|
|
placeholderText: i18nd("kdeconnect-sms", "Filter...")
|
|
|
|
Layout.fillWidth: true
|
2020-04-13 04:18:19 +01:00
|
|
|
Layout.fillHeight: true
|
2020-04-13 03:20:04 +01:00
|
|
|
onTextChanged: {
|
|
|
|
if (filter.text != "") {
|
2020-04-14 14:40:10 +01:00
|
|
|
view.model.setConversationsFilterRole(ConversationListModel.AddressesRole)
|
2020-04-08 18:15:20 +01:00
|
|
|
} else {
|
2020-04-13 03:20:04 +01:00
|
|
|
view.model.setConversationsFilterRole(ConversationListModel.ConversationIdRole)
|
2020-04-08 18:15:20 +01:00
|
|
|
}
|
2020-05-09 17:50:08 +01:00
|
|
|
view.model.setFilterFixedString(SmsHelper.canonicalizePhoneNumber(filter.text))
|
2020-03-21 22:57:28 +00:00
|
|
|
|
2020-04-13 03:20:04 +01:00
|
|
|
view.currentIndex = 0
|
|
|
|
}
|
|
|
|
onAccepted: {
|
|
|
|
view.currentItem.startChat()
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
event.accepted = true
|
|
|
|
filter.onAccepted()
|
|
|
|
}
|
|
|
|
Keys.onEscapePressed: {
|
|
|
|
event.accepted = filter.text != ""
|
|
|
|
filter.text = ""
|
|
|
|
}
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+F"
|
|
|
|
onActivated: filter.forceActiveFocus()
|
|
|
|
}
|
2018-10-30 20:01:13 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 03:20:04 +01:00
|
|
|
Button {
|
|
|
|
id: newButton
|
|
|
|
text: i18nd("kdeconnect-sms", "New")
|
|
|
|
visible: true
|
2020-05-09 17:50:08 +01:00
|
|
|
enabled: SmsHelper.isAddressValid(filter.text) && deviceConnected
|
2020-04-13 03:20:04 +01:00
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
|
|
|
ToolTip.text: i18nd("kdeconnect-sms", "Start new conversation")
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
// We have to disable the filter temporarily in order to avoid getting key inputs accidently while processing the request
|
|
|
|
filter.enabled = false
|
|
|
|
|
|
|
|
// If the address entered by the user already exists then ignore adding new contact
|
2020-05-12 00:05:38 +01:00
|
|
|
if (!view.model.doesAddressExists(filter.text) && SmsHelper.isAddressValid(filter.text)) {
|
2020-04-13 03:20:04 +01:00
|
|
|
conversationListModel.createConversationForAddress(filter.text)
|
|
|
|
view.currentIndex = 0
|
|
|
|
}
|
2020-05-07 14:22:28 +01:00
|
|
|
filter.enabled = true
|
2020-03-22 09:33:04 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 03:20:04 +01:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+N"
|
|
|
|
onActivated: newButton.onClicked()
|
|
|
|
}
|
2020-04-08 18:15:20 +01:00
|
|
|
}
|
2020-03-22 09:33:04 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 03:20:04 +01:00
|
|
|
headerPositioning: ListView.OverlayHeader
|
|
|
|
|
|
|
|
Keys.forwardTo: [headerItem]
|
|
|
|
|
2020-05-06 19:19:02 +01:00
|
|
|
delegate: Kirigami.BasicListItem
|
2018-10-30 20:01:13 +00:00
|
|
|
{
|
2019-07-21 11:35:04 +01:00
|
|
|
id: listItem
|
2020-05-06 19:19:02 +01:00
|
|
|
icon: decoration
|
|
|
|
reserveSpaceForIcon: true
|
|
|
|
label: display
|
|
|
|
subtitle: toolTip
|
2019-07-21 11:35:04 +01:00
|
|
|
|
2020-09-27 04:51:17 +01:00
|
|
|
property var thumbnail: attachmentPreview
|
2018-10-30 20:01:13 +00:00
|
|
|
|
|
|
|
function startChat() {
|
|
|
|
applicationWindow().pageStack.push(chatView, {
|
2019-07-19 18:33:15 +01:00
|
|
|
addresses: addresses,
|
2018-10-30 20:01:13 +00:00
|
|
|
conversationId: model.conversationId,
|
2019-07-19 16:29:28 +01:00
|
|
|
isMultitarget: isMultitarget,
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
initialMessage: page.initialMessage,
|
2020-05-18 03:41:26 +01:00
|
|
|
device: device})
|
[SMS App] Allow passing a message via args
Summary:
Add --message option to kdeconnect-sms to pass a message. The user only needs to choose a recepient and the message will be sent. Useful for integration with 3rd party
apps, e.g. via Purpose
Test Plan:
kdeconnect-sms --message "Hello World", choose chat, message is sent
Click another chat, no message sent
kdeconnect-sms without args, no message sent
Reviewers: #kde_connect, sredman
Reviewed By: #kde_connect, sredman
Subscribers: andyholmes, sredman, apol, kdeconnect
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D17292
2019-03-09 21:32:36 +00:00
|
|
|
initialMessage = ""
|
2018-10-30 20:01:13 +00:00
|
|
|
}
|
2020-03-21 22:57:28 +00:00
|
|
|
|
2019-02-27 05:45:54 +00:00
|
|
|
onClicked: {
|
|
|
|
startChat();
|
|
|
|
view.currentIndex = index
|
|
|
|
}
|
2020-09-27 04:51:17 +01:00
|
|
|
|
|
|
|
Kirigami.Icon {
|
|
|
|
id: thumbnailItem
|
|
|
|
source: {
|
|
|
|
if (!listItem.thumbnail) {
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
if (listItem.thumbnail.hasOwnProperty) {
|
|
|
|
if (listItem.thumbnail.hasOwnProperty("name") && listItem.thumbnail.name !== "")
|
|
|
|
return listItem.thumbnail.name;
|
|
|
|
if (listItem.thumbnail.hasOwnProperty("source"))
|
|
|
|
return listItem.thumbnail.source;
|
|
|
|
}
|
|
|
|
return listItem.thumbnail;
|
|
|
|
}
|
|
|
|
property int size: Kirigami.Units.iconSizes.huge
|
|
|
|
Layout.minimumHeight: size
|
|
|
|
Layout.maximumHeight: size
|
|
|
|
Layout.minimumWidth: size
|
|
|
|
selected: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents))
|
|
|
|
opacity: 1
|
|
|
|
visible: source != undefined
|
|
|
|
}
|
|
|
|
|
2019-02-27 05:45:54 +00:00
|
|
|
// Keep the currently-open chat highlighted even if this element is not focused
|
2020-05-06 19:19:02 +01:00
|
|
|
highlighted: view.currentIndex == index
|
2019-02-27 05:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
currentIndex = -1
|
|
|
|
focus = true
|
2018-10-30 20:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|