diff --git a/src/contents/ui/ContactList.qml b/src/contents/ui/ContactList.qml index 5a5bddb..cda72b3 100644 --- a/src/contents/ui/ContactList.qml +++ b/src/contents/ui/ContactList.qml @@ -1,193 +1,192 @@ /** * Copyright 2016 Martin Klapetek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import org.kde.people 1.0 as KPeople -import org.kde.plasma.private.kpeoplehelper 1.0 import org.kde.kquickcontrolsaddons 2.0 as ExtraComponents import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.kirigami 2.1 as Kirigami import org.kde.telepathy 0.1 ListView { id: contactsList property bool delegateSelected: false property string numberToCall property alias requiredProperties: kpeopleProxyModel.requiredProperties property QtObject sourceModel property string filterRegExp property bool executeDefaultAction: false signal contactClicked(string personUri) section.property: "display" section.criteria: ViewSection.FirstCharacter clip: true focus: true model: PlasmaCore.SortFilterModel { id: plasmaSortFilterModel sourceModel: KPeople.PersonsSortFilterProxyModel { id: kpeopleProxyModel sourceModel: contactsList.sourceModel } sortRole: "display" filterRole: "display" filterRegExp: ".*" + contactsList.filterRegExp + ".*" sortOrder: Qt.AscendingOrder } boundsBehavior: Flickable.StopAtBounds // highlightRangeMode: ListView.ApplyRange // highlight: PlasmaComponents.Highlight { // // } highlightMoveDuration: 0 KPeople.PersonActions { id: personActionsModel } onCurrentIndexChanged: print("---> " + currentIndex); delegate: Kirigami.AbstractListItem { supportsMouseEvents: true height: actionsRow.visible ? units.gridUnit * 6 : units.gridUnit * 3 enabled: true clip: true opacity: contactsList.delegateSelected && contactsList.currentIndex != index ? 0.4 : 1 onClicked: { contactsList.currentIndex = index; personActionsModel.personUri = model.personUri; if (contactsList.executeDefaultAction) { personActionsModel.triggerAction(0); } else { actionsListProxy.sourceModel = personActionsModel; } contactsList.contactClicked(model.personUri); } Item { anchors.fill: parent // Clear the actions model when index is switched Connections { target: contactsList onCurrentIndexChanged: { if (contactsList.currentIndex != index) { actionsListProxy.sourceModel = null; } } } ColumnLayout { anchors.fill: parent RowLayout { id: mainLayout Layout.fillHeight: true Layout.maximumHeight: units.gridUnit * 3 Layout.fillWidth: true ExtraComponents.QPixmapItem { id: avatarLabel Layout.maximumWidth: parent.height Layout.minimumWidth: parent.height Layout.fillHeight: true pixmap: model.decoration fillMode: ExtraComponents.QPixmapItem.PreserveAspectFit smooth: true } ColumnLayout { Layout.fillHeight: true Layout.fillWidth: true Kirigami.Label { id: nickLabel Layout.fillWidth: true text: model.display elide: Text.ElideRight } Kirigami.Label { id: dataLabel Layout.fillWidth: true text: model.phoneNumber !== undefined ? model.phoneNumber : (model.accountDisplayName !== undefined ? model.accountDisplayName : "") elide: Text.ElideRight visible: dataLabel.text != nickLabel.text opacity: 0.4 } } } RowLayout { id: actionsRow Layout.fillWidth: true Layout.fillHeight: true visible: actionsList.count > 0 ListView { id: actionsList Layout.fillWidth: true Layout.fillHeight: true orientation: ListView.Horizontal model: PlasmaCore.SortFilterModel { id: actionsListProxy filterRole: "actionType" filterCallback: function(source_row, value) { return value == KPeople.ActionType.TextChatAction; } } delegate: Button { Layout.fillWidth: true text: model.display iconSource: model.iconName onClicked: { personActionsModel.triggerAction(actionsListProxy.mapRowToSource(index)); } } } } } } } // CustomSectionScroller { // listView: contactsList // } } diff --git a/src/contents/ui/MainPage.qml b/src/contents/ui/MainPage.qml index 588b99a..337f598 100644 --- a/src/contents/ui/MainPage.qml +++ b/src/contents/ui/MainPage.qml @@ -1,157 +1,155 @@ /** * Copyright 2016 Martin Klapetek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.1 as Kirigami import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.telepathy 0.1 as KTp Kirigami.Page { - anchors.fill: parent - title: "Your Conversations" mainAction: Kirigami.Action { text: "Start New Conversation" iconName: "document-edit" onTriggered: { - if (root.pageStack.depth == 2) { + if (root.pageStack.depth === 2) { root.pageStack.pop(); } root.pageStack.push(newConversationPageComponent); print("Action button clicked") } } Loader { anchors.fill: parent active: telepathyManager.ready sourceComponent: mainModelComponent } Component { id: mainModelComponent ColumnLayout { id: rootLayout anchors.fill: parent ListView { Layout.fillHeight: true Layout.fillWidth: true clip: true model: PlasmaCore.SortFilterModel { id: plasmaSortFilterModel sortRole: "lastMessageDate" sortOrder: Qt.DescendingOrder sourceModel: KTp.MainLogModel { id: mainModel onNewRequestedChannel: { if (root.pageStack.currentPage.pageName === "newConversationPage" || openIncomingChannel) { root.pageStack.pop(); root.pageStack.push(conversationPageComponent); root.pageStack.currentPage.conversation = mainModel.data(index.row, "conversation"); openIncomingChannel = false; } } Component.onCompleted: { telepathyManager.registerClient(mainModel, "SpaceBar"); telepathyManager.registerClient(mainModel.observerProxy(), "SpaceBarObserverProxy"); mainModel.setAccountManager(telepathyManager.accountManager); } Component.onDestruction: { telepathyManager.unregisterClient(mainModel); } } } delegate: Kirigami.AbstractListItem { supportsMouseEvents: true onClicked: { if (root.pageStack.depth == 2) { root.pageStack.pop(); } root.pageStack.push(conversationPageComponent); root.pageStack.currentItem.conversation = model.conversation; // If the account is online, request a channel if (mainModel.canChat(accountId)) { mainModel.startChat(accountId, contactId); } } Rectangle { anchors.fill: parent color: "white" opacity: 0.8 visible: model.hasUnreadMessages } ColumnLayout { id: messageLayout width: parent.width PlasmaExtras.Heading { Layout.fillWidth: true text: { var t = model.contactDisplayName === "" ? model.contactId : model.contactDisplayName; if (model.hasUnreadMessages) { t += " "; t += i18nc("N unread messages", "(%1 unread)", model.unreadMessagesCount); } return t; } wrapMode: Text.WordWrap elide: Text.ElideRight maximumLineCount: 1 level: 4 } Kirigami.Label { Layout.fillWidth: true text: model.lastMessageText wrapMode: Text.WordWrap elide: Text.ElideRight maximumLineCount: 2 } Kirigami.Label { Layout.fillWidth: true text: Qt.formatDateTime(model.lastMessageDate) wrapMode: Text.WordWrap elide: Text.ElideRight maximumLineCount: 1 } } } } } } }