Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Konheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Konheko
Commits
c3984bd4
Commit
c3984bd4
authored
5 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Basic text message sending
parent
b4962abb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
qml/pages/ChatPage.qml
+55
-7
55 additions, 7 deletions
qml/pages/ChatPage.qml
src/models/roommodel.cpp
+18
-0
18 additions, 0 deletions
src/models/roommodel.cpp
src/models/roommodel.h
+1
-0
1 addition, 0 deletions
src/models/roommodel.h
with
74 additions
and
7 deletions
qml/pages/ChatPage.qml
+
55
−
7
View file @
c3984bd4
...
...
@@ -6,33 +6,41 @@ import dev.neko.spoon 1.0
Page
{
id
:
chatPage
anchors.fill
:
parent
// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations
:
Orientation
.
All
property
alias
room
:
chatView
.
model
PageHeader
{
title
:
room
.
roomName
}
SilicaListView
{
id
:
chatView
ScrollDecorator
{
flickable
:
chatView
}
boundsBehavior
:
Flickable
.
DragOverBounds
anchors.fill
:
parent
anchors.leftMargin
:
Theme
.
horizontalPageMargin
anchors.rightMargin
:
Theme
.
horizontalPageMargin
//ScrollDecorator { flickable: chatView }
header
:
PageHeader
{
id
:
header
title
:
"
Room:
"
+
room
.
roomName
}
headerPositioning
:
ListView
.
PullBackHeader
property
bool
atEnd
:
false
ListView.onAdd
:
{
console
.
log
(
"
atYEnd::
"
+
atYEnd
)
console
.
log
(
"
atYEnd::
"
+
atYEnd
)
atEnd
=
atYEnd
}
onCountChanged
:
{
console
.
log
(
"
atEnd::
"
+
atEnd
)
if
(
atEnd
)
scrollToBottom
()
scrollToBottom
()
}
onMovementEnded
:
{
...
...
@@ -51,6 +59,7 @@ Page {
delegate
:
ListItem
{
id
:
messageItem
contentHeight
:
loader
.
item
.
contentHeight
Loader
{
id
:
loader
source
:
switch
(
model
.
Type
)
{
...
...
@@ -72,7 +81,7 @@ Page {
property
variant
modelData
:
model
onLoaded
:
{
console
.
log
(
"
Loaded item with hight:
"
+
item
.
height
)
console
.
log
(
"
Loaded item with h
e
ight:
"
+
item
.
height
)
messageItem
.
contentHeight
=
item
.
height
}
}
...
...
@@ -84,5 +93,44 @@ Page {
text
:
room
.
userIdToUserName
(
section
)
color
:
room
.
userColor
(
section
,
"
#00000000
"
)
}
footer
:
Item
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
height
:
messageText
.
height
id
:
messageArea
TextArea
{
anchors.left
:
parent
.
left
anchors.bottom
:
parent
.
bottom
id
:
messageText
placeholderText
:
qsTr
(
"
Enter your message
"
)
//text: "asksfgjs afiguse aifdsvugsfd adfivuhsf aisdfuvs aiudsvhcas"
wrapMode
:
Text
.
Wrap
width
:
parent
.
width
-
sendButton
.
width
}
IconButton
{
anchors.right
:
parent
.
right
anchors.top
:
parent
.
top
//anchors.left: messageText.right
id
:
sendButton
height
:
100
width
:
100
icon.source
:
"
image://theme/icon-m-enter
"
onClicked
:
{
if
(
messageText
.
text
!=
""
)
{
room
.
sendTextMessage
(
messageText
.
text
)
}
messageText
.
text
=
""
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/models/roommodel.cpp
+
18
−
0
View file @
c3984bd4
...
...
@@ -297,6 +297,24 @@ void Room::fetchOlderMessages() {
});
}
void
Room
::
sendTextMessage
(
QString
message
)
{
using
mtx
::
events
::
EventType
;
mtx
::
events
::
msg
::
Text
text
;
text
.
body
=
message
.
trimmed
().
toStdString
();
http
::
client
().
send_room_message
<
msg
::
Text
,
EventType
::
RoomMessage
>
(
this
->
id
,
http
::
client
().
generate_txn_id
(),
text
,
[
this
](
const
mtx
::
responses
::
EventId
&
res
,
mtx
::
http
::
RequestErr
err
)
{
if
(
err
)
{
qDebug
()
<<
"failed to send message: "
<<
*
err
;
return
;
}
qDebug
()
<<
"send event as: $"
<<
QString
::
fromStdString
(
res
.
event_id
.
to_string
());
});
}
QHash
<
int
,
QByteArray
>
Room
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Type
]
=
"Type"
;
...
...
This diff is collapsed.
Click to expand it.
src/models/roommodel.h
+
1
−
0
View file @
c3984bd4
...
...
@@ -146,6 +146,7 @@ struct Room : public QAbstractListModel {
void
addEvents
(
std
::
vector
<
mtx
::
events
::
collections
::
TimelineEvents
>
events
,
std
::
string
prev_batch
,
std
::
string
next_batch
);
void
fetchOlderMessages
();
void
sendTextMessage
(
QString
message
);
private
:
std
::
vector
<
mtx
::
events
::
collections
::
TimelineEvents
>
events
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment