mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-05 18:20:33 -08:00
example 'meshtastic': add broadcast messages
This commit is contained in:
parent
1d0bafb4f8
commit
62a97d2b4b
6 changed files with 56 additions and 25 deletions
|
|
@ -13,6 +13,14 @@
|
|||
"Adds passed PERSON (a PLIST) to QML item model.
|
||||
The model keys are:
|
||||
:radio-name :custom-name :node-num :unread :current"
|
||||
(when (zerop (q< |count| ui:*group*))
|
||||
;; special item 'Broadcast'
|
||||
(qjs |addPerson| ui:*group*
|
||||
(list :radio-name lora:*broadcast-name*
|
||||
:custom-name (tr "Broadcast")
|
||||
:node-num lora:+broadcast-id+
|
||||
:current (equal (app:setting :latest-receiver)
|
||||
lora:*broadcast-name*))))
|
||||
(qjs |addPerson| ui:*group* person))
|
||||
|
||||
(defun clear ()
|
||||
|
|
@ -31,18 +39,20 @@
|
|||
(q> |visible| ui:*unread-messages* state))
|
||||
|
||||
(defun set-unread (name n)
|
||||
(qjs |setUnread| ui:*group*
|
||||
name n)
|
||||
(when (plusp n)
|
||||
(set-unread-state t)))
|
||||
(unless (string= lora:*broadcast-name* name)
|
||||
(qjs |setUnread| ui:*group*
|
||||
name n)
|
||||
(when (plusp n)
|
||||
(set-unread-state t))))
|
||||
|
||||
(defun receiver-changed ()
|
||||
(let ((curr-name (app:setting :latest-receiver)))
|
||||
(app:change-setting curr-name 0 :sub-key :unread-messages)
|
||||
(set-unread curr-name 0)
|
||||
(dolist (name (radio-names))
|
||||
(x:when-it (app:setting name :unread-messages)
|
||||
(unless (zerop x:it)
|
||||
(return-from receiver-changed))))
|
||||
(set-unread-state nil)))
|
||||
(unless (string= lora:*broadcast-name* curr-name)
|
||||
(app:change-setting curr-name 0 :sub-key :unread-messages)
|
||||
(set-unread curr-name 0)
|
||||
(dolist (name (radio-names))
|
||||
(x:when-it (app:setting name :unread-messages)
|
||||
(unless (zerop x:it)
|
||||
(return-from receiver-changed))))
|
||||
(set-unread-state nil))))
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
;;; ini/send/receive
|
||||
|
||||
(defconstant +broadcast-id+ #xffffffff)
|
||||
(defparameter *broadcast-name* "ffff")
|
||||
|
||||
(defvar *config-id* 0)
|
||||
(defvar *config-complete* nil)
|
||||
(defvar *notify-id* nil)
|
||||
|
|
@ -162,9 +165,11 @@
|
|||
(values))
|
||||
|
||||
(defun node-to-name (num)
|
||||
(dolist (info *node-infos*)
|
||||
(when (= num (me:num info))
|
||||
(return (me:short-name (me:user info))))))
|
||||
(if (= +broadcast-id+ num)
|
||||
*broadcast-name*
|
||||
(dolist (info *node-infos*)
|
||||
(when (= num (me:num info))
|
||||
(return (me:short-name (me:user info)))))))
|
||||
|
||||
(defun name-to-node (name)
|
||||
(dolist (info *node-infos*)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
(:local-nicknames (:pr :cl-protobufs)
|
||||
(:me :cl-protobufs.meshtastic))
|
||||
(:export
|
||||
#:+broadcast-id+
|
||||
#:*broadcast-name*
|
||||
#:*channel*
|
||||
#:*channels*
|
||||
#:*config-complete*
|
||||
|
|
|
|||
|
|
@ -54,27 +54,28 @@ Rectangle {
|
|||
|
||||
function addPerson(person) {
|
||||
// insert sorted
|
||||
var i = 0;
|
||||
var i = 1; // 0 is broadcast
|
||||
var broadcast = (count === 0)
|
||||
for (; i < count; i++) {
|
||||
if (person.customName < get(i).customName) {
|
||||
insert(i, person)
|
||||
break
|
||||
}
|
||||
}
|
||||
if (i === count) {
|
||||
if (broadcast || (i === count)) {
|
||||
append(person)
|
||||
}
|
||||
|
||||
if (person.current) {
|
||||
view.currentIndex = i
|
||||
view.currentIndex = broadcast ? 0 : i
|
||||
view.positionViewAtIndex(view.currentIndex, ListView.Contain)
|
||||
}
|
||||
}
|
||||
|
||||
function sortRenamed(name, index) {
|
||||
var to = -1
|
||||
if (name < get(0).customName) {
|
||||
to = 0
|
||||
if (name < get(1).customName) { // 0 is broadcast
|
||||
to = 1
|
||||
} else if (name >= get(count - 1).customName) {
|
||||
to = count - 1
|
||||
} else {
|
||||
|
|
@ -124,13 +125,21 @@ Rectangle {
|
|||
|
||||
Rectangle {
|
||||
id: rectRadio
|
||||
x: 10
|
||||
width: 42
|
||||
height: 15
|
||||
x: (index === 0) ? 18 : 10
|
||||
width: (index === 0) ? 28 : 42
|
||||
height: (index === 0) ? width : 15
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: "#f0f0f0"
|
||||
radius: height / 2
|
||||
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
width: 20
|
||||
height: width
|
||||
source: "../img/broadcast.png"
|
||||
visible: (index === 0)
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 12
|
||||
|
|
@ -138,6 +147,7 @@ Rectangle {
|
|||
font.weight: Font.DemiBold
|
||||
color: "black"
|
||||
text: model.radioName
|
||||
visible: (index !== 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,9 +188,11 @@ Rectangle {
|
|||
}
|
||||
|
||||
onPressAndHold: {
|
||||
readOnly = false
|
||||
selectAll()
|
||||
forceActiveFocus()
|
||||
if (index !== 0) {
|
||||
readOnly = false
|
||||
selectAll()
|
||||
forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
onEditingFinished: {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import "." as Ext
|
|||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
property alias currentIndex: swipeView.currentIndex
|
||||
|
||||
Rectangle {
|
||||
id: header
|
||||
width: parent.width
|
||||
|
|
|
|||
BIN
examples/meshtastic/qml/img/broadcast.png
Normal file
BIN
examples/meshtastic/qml/img/broadcast.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Loading…
Add table
Add a link
Reference in a new issue