From eeab9aa3677659d3175413d03b53d0c43e5c26d0 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Mon, 16 Oct 2023 13:52:56 +0000 Subject: [PATCH] Cleanup QML --- .../components/ConversationListDelegate.qml | 2 +- src/qml/components/ConversationListWidget.qml | 6 +-- src/qml/components/MessagesView.qml | 8 ++-- src/qml/glacier-messages.qml | 17 +++++++ src/qml/pages/ConversationPage.qml | 47 ++----------------- 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/src/qml/components/ConversationListDelegate.qml b/src/qml/components/ConversationListDelegate.qml index 728b43b..eb532d1 100644 --- a/src/qml/components/ConversationListDelegate.qml +++ b/src/qml/components/ConversationListDelegate.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Serhey +/* Copyright (C) 2018-2023 Chupligin Serhey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * diff --git a/src/qml/components/ConversationListWidget.qml b/src/qml/components/ConversationListWidget.qml index beff9fc..e438efc 100644 --- a/src/qml/components/ConversationListWidget.qml +++ b/src/qml/components/ConversationListWidget.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Chupligin Serhey +/* Copyright (C) 2018-2023 Chupligin Serhey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * @@ -54,9 +54,7 @@ Item { delegate: ConversationListDelegate { onClicked: { - var group = model.group - var channel = channelManager.getConversation(group.localUid, group.remoteUids[0]) - pageStack.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), { "channel": channel, "group": group }) + app.push(Qt.resolvedUrl("../pages/ConversationPage.qml"), { "group": model.group }) } } diff --git a/src/qml/components/MessagesView.qml b/src/qml/components/MessagesView.qml index 2a7ac59..ae9bc60 100644 --- a/src/qml/components/MessagesView.qml +++ b/src/qml/components/MessagesView.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Sergey +/* Copyright (C) 2018-2023 Chupligin Sergey * Copyright (C) 2012 John Brooks * * You may use this file under the terms of the BSD license as follows: @@ -35,6 +35,8 @@ import QtQuick.Controls import Nemo import Nemo.Controls +import org.nemomobile.commhistory 1.0 + Item { property alias model: view.model // The event model is in descending order, but we need to display ascending. @@ -51,12 +53,12 @@ Item { Connections { target: model || null - onRowsInserted: { + function onRowsInserted(first, last) { if (first === 0) { view.positionViewAtBeginning() } } - onModelReset: view.positionViewAtBeginning() + function onModelReset() { view.positionViewAtBeginning() } } delegate: Item{ diff --git a/src/qml/glacier-messages.qml b/src/qml/glacier-messages.qml index 6ab8237..a211c28 100644 --- a/src/qml/glacier-messages.qml +++ b/src/qml/glacier-messages.qml @@ -58,6 +58,23 @@ ApplicationWindow { useBackgroundThread: true } + OfonoManager { + id: manager + } + + OfonoMessageManager{ + id: messageManager + modemPath: manager.defaultModem + onMessageAdded: { + console.log("HELLO MESSAGE") + console.log(message) + } + + Component.onCompleted: { + messageManager.sendMessage("+79962491221", "Hello nemo") + } + } + PeopleModel { id: peopleModel } diff --git a/src/qml/pages/ConversationPage.qml b/src/qml/pages/ConversationPage.qml index c062834..2c7fb3e 100644 --- a/src/qml/pages/ConversationPage.qml +++ b/src/qml/pages/ConversationPage.qml @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Chupligin Sergey +/* Copyright (C) 2018-2023 Chupligin Sergey * Copyright (C) 2012 John Brooks * Copyright (C) 2011 Robin Burchell * @@ -47,7 +47,6 @@ import "../components" Page { id: conversationPage - property QtObject channel: null property QtObject group property QtObject person: group ? peopleModel.personById(group.contactId) : null property string remoteUid: "" @@ -75,7 +74,6 @@ Page { TextField { id: targetEditor - visible: !channel width: parent.width-Theme.itemSpacingLarge*2 height: Theme.itemHeightExtraLarge-Theme.itemSpacingLarge*2 @@ -119,50 +117,20 @@ Page { width: parent.width onSendMessage: { - if (text.length < 1 && (!channel && targetEditor.length < 1)) { + if (text.length < 1 && (targetEditor.length < 1)) { return } - if(!channel) { - channel = channelManager.getConversation(accountsModel.get(0, TelepathyAccountsModel.AccountUidRole),targetEditor.text) - hTools.title = targetEditor.text - } - - groupManager.createOutgoingMessageEvent(group.id, channel.localUid, group.remoteUids[0], text, function(eventId) { + groupManager.createOutgoingMessageEvent(group.id, group.localUid, group.remoteUids[0], text, function(eventId) { console.log("groupId" + group.id) - console.log("channel.localUid" + channel.localUid) + console.log("group.localUid" + group.localUid) console.log("group.remoteUids[0]" + group.remoteUids[0]) console.log("eventId" + eventId) - channel.sendMessage(text, eventId) }) clear() } } - states: [ - State { - name: "new" - when: channel == null - - PropertyChanges { - target: targetEditor - visible: true - } - - AnchorChanges { - target: messagesView - anchors.top: targetEditor.bottom - } - } - ] - - onChannelChanged: { - if (channel != null) { - channel.ensureChannel() - _updateGroup() - } - } - Connections { target: groupManager @@ -170,14 +138,9 @@ Page { function onGroupUpdated() { _updateGroup() } } - Connections { - target: Qt.application - onActiveChanged: markAsRead() - } - function _updateGroup() { if (group === null) - group = groupManager.findGroup(channel.localUid, channel.remoteUid) + group = groupManager.findGroup(group.localUid, group.remoteUid) } function markAsRead() {