Skip to content

Commit

Permalink
Cleanup QML
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Oct 16, 2023
1 parent 56d176b commit eeab9aa
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/qml/components/ConversationListDelegate.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018-2021 Chupligin Serhey <[email protected]>
/* Copyright (C) 2018-2023 Chupligin Serhey <[email protected]>
* Copyright (C) 2012 John Brooks <[email protected]>
* Copyright (C) 2011 Robin Burchell <[email protected]>
*
Expand Down
6 changes: 2 additions & 4 deletions src/qml/components/ConversationListWidget.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018 Chupligin Serhey <[email protected]>
/* Copyright (C) 2018-2023 Chupligin Serhey <[email protected]>
* Copyright (C) 2012 John Brooks <[email protected]>
* Copyright (C) 2011 Robin Burchell <[email protected]>
*
Expand Down Expand Up @@ -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 })
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/qml/components/MessagesView.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018-2021 Chupligin Sergey <[email protected]>
/* Copyright (C) 2018-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2012 John Brooks <[email protected]>
*
* You may use this file under the terms of the BSD license as follows:
Expand Down Expand Up @@ -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.
Expand All @@ -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{
Expand Down
17 changes: 17 additions & 0 deletions src/qml/glacier-messages.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
47 changes: 5 additions & 42 deletions src/qml/pages/ConversationPage.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018-2021 Chupligin Sergey <[email protected]>
/* Copyright (C) 2018-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2012 John Brooks <[email protected]>
* Copyright (C) 2011 Robin Burchell <[email protected]>
*
Expand Down Expand Up @@ -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: ""
Expand Down Expand Up @@ -75,7 +74,6 @@ Page {

TextField {
id: targetEditor
visible: !channel
width: parent.width-Theme.itemSpacingLarge*2
height: Theme.itemHeightExtraLarge-Theme.itemSpacingLarge*2

Expand Down Expand Up @@ -119,65 +117,30 @@ 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

function onGroupAdded(){ _updateGroup() }
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() {
Expand Down

0 comments on commit eeab9aa

Please sign in to comment.