mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 12:46:24 +00:00
27 lines
737 B
Nim
27 lines
737 B
Nim
## Please note we are using templates where ordinarily we would like to use procedures
|
|
## due to bug: https://github.com/Araq/Nim/issues/1821
|
|
import NimQml, NimQmlMacros
|
|
|
|
QtObject:
|
|
type Contact = ref object of QObject
|
|
m_name: string
|
|
|
|
template newContact*(): Contact =
|
|
var result = Contact(m_name: "initialName")
|
|
result.create
|
|
result
|
|
|
|
method getName*(contact: Contact): string {.slot.} =
|
|
result = contact.m_name
|
|
|
|
method nameChanged*(contact: Contact) {.signal.}
|
|
|
|
method setName*(contact: Contact, name: string) {.slot.} =
|
|
if contact.m_name != name:
|
|
contact.m_name = name
|
|
contact.nameChanged()
|
|
|
|
QtProperty name of string:
|
|
read = getName
|
|
write = setName
|
|
notify = nameChanged |