Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
1d286429
Commit
1d286429
authored
Mar 09, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ui/modules/Linphone/Chat/Message): use a `Logic` file
parent
f4faaf9c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
28 deletions
+34
-28
resources.qrc
linphone-desktop/resources.qrc
+1
-0
Message.js
linphone-desktop/ui/modules/Linphone/Chat/Message.js
+25
-0
Message.qml
linphone-desktop/ui/modules/Linphone/Chat/Message.qml
+8
-28
No files found.
linphone-desktop/resources.qrc
View file @
1d286429
...
...
@@ -271,6 +271,7 @@
<file>
ui/modules/Linphone/Chat/Event.qml
</file>
<file>
ui/modules/Linphone/Chat/FileMessage.qml
</file>
<file>
ui/modules/Linphone/Chat/IncomingMessage.qml
</file>
<file>
ui/modules/Linphone/Chat/Message.js
</file>
<file>
ui/modules/Linphone/Chat/Message.qml
</file>
<file>
ui/modules/Linphone/Chat/OutgoingMessage.qml
</file>
<file>
ui/modules/Linphone/Contact/Avatar.qml
</file>
...
...
linphone-desktop/ui/modules/Linphone/Chat/Message.js
0 → 100644
View file @
1d286429
// See: `ensureVisible` on http://doc.qt.io/qt-5/qml-qtquick-textedit.html
function
ensureVisible
(
cursor
)
{
// Case 1: No focused.
if
(
!
message
.
activeFocus
)
{
return
}
// Case 2: Scroll up.
var
contentItem
=
chat
.
contentItem
var
contentY
=
chat
.
contentY
var
messageY
=
message
.
mapToItem
(
contentItem
,
0
,
0
).
y
+
cursor
.
y
if
(
contentY
>=
messageY
)
{
chat
.
contentY
=
messageY
return
}
// Case 3: Scroll down.
var
chatHeight
=
chat
.
height
var
cursorHeight
=
cursor
.
height
if
(
contentY
+
chatHeight
<=
messageY
+
cursorHeight
)
{
chat
.
contentY
=
messageY
+
cursorHeight
-
chatHeight
}
}
linphone-desktop/ui/modules/Linphone/Chat/Message.qml
View file @
1d286429
...
...
@@ -4,6 +4,8 @@ import Common 1.0
import
Linphone
.
Styles
1.0
import
Utils
1.0
import
'
Message.js
'
as
Logic
// =============================================================================
Item
{
...
...
@@ -33,35 +35,13 @@ Item {
)
+
message
.
padding
*
2
}
// ---------------------------------------------------------------------------
// Message.
// ---------------------------------------------------------------------------
TextEdit
{
id
:
message
// See: `ensureVisible` on http://doc.qt.io/qt-5/qml-qtquick-textedit.html
function
ensureVisible
(
cursor
)
{
// Case 1: No focused.
if
(
!
message
.
activeFocus
)
{
return
}
// Case 2: Scroll up.
var
contentItem
=
chat
.
contentItem
var
contentY
=
chat
.
contentY
var
messageY
=
message
.
mapToItem
(
contentItem
,
0
,
0
).
y
+
cursor
.
y
if
(
contentY
>=
messageY
)
{
chat
.
contentY
=
messageY
return
}
// Case 3: Scroll down.
var
chatHeight
=
chat
.
height
var
cursorHeight
=
cursor
.
height
if
(
contentY
+
chatHeight
<=
messageY
+
cursorHeight
)
{
chat
.
contentY
=
messageY
+
cursorHeight
-
chatHeight
}
}
anchors
{
left
:
container
.
left
right
:
container
.
right
...
...
@@ -78,9 +58,9 @@ Item {
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
// and http://doc.qt.io/qt-5/richtext-html-subset.html
textFormat
:
Text
.
RichText
// To supports links and imgs.
wrapMode
:
TextEdit
.
Wrap
wrapMode
:
TextEdit
.
W
ordW
rap
onCursorRectangleChanged
:
ensureVisible
(
cursorRectangle
)
onCursorRectangleChanged
:
Logic
.
ensureVisible
(
cursorRectangle
)
onLinkActivated
:
Qt
.
openUrlExternally
(
link
)
onActiveFocusChanged
:
deselect
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment