mirror of
https://gitlab.com/eql/EQL5.git
synced 2026-03-14 18:50:58 -07:00
add "properties.lisp" to QML palindrome example
This commit is contained in:
parent
db9ca1e542
commit
7f459e54c0
3 changed files with 84 additions and 0 deletions
|
|
@ -14,3 +14,17 @@ You need to generate the QML first, running:
|
|||
Then you can run it:
|
||||
|
||||
eql5 run.lisp
|
||||
|
||||
|
||||
HELP
|
||||
====
|
||||
|
||||
For inspecting the single items, run
|
||||
|
||||
(show-properties-dialog) ; see "properties.lisp"
|
||||
|
||||
and use button [Select] to select an item.
|
||||
|
||||
You can use QML-GET and QML-SET on a selected item:
|
||||
|
||||
(qml-set qsel:*q* "opacity" 2/3)
|
||||
|
|
|
|||
68
examples/M-modules/quick/palindrome/properties.lisp
Normal file
68
examples/M-modules/quick/palindrome/properties.lisp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
;;; properties dialog and QML utils
|
||||
|
||||
;; QML utils
|
||||
|
||||
(defun root-item ()
|
||||
(when *quick-view*
|
||||
(qt-object-? (|rootObject| *quick-view*))))
|
||||
|
||||
(defun find-quick-item (object-name)
|
||||
"Finds the first QQuickItem matching OBJECT-NAME."
|
||||
(if (string= (|objectName| (root-item)) object-name)
|
||||
(root-item)
|
||||
(qt-object-? (qfind-child (root-item) object-name))))
|
||||
|
||||
(defun quick-item (item/name)
|
||||
(cond ((stringp item/name)
|
||||
(find-quick-item item/name))
|
||||
((qt-object-p item/name)
|
||||
item/name)
|
||||
((not item/name)
|
||||
(root-item))))
|
||||
|
||||
(defun qml-get (item/name property-name)
|
||||
"Gets QQmlProperty of either ITEM or first object matching NAME."
|
||||
(qlet ((property "QQmlProperty(QObject*,QString)"
|
||||
(quick-item item/name)
|
||||
property-name))
|
||||
(if (|isValid| property)
|
||||
(qlet ((variant (|read| property)))
|
||||
(values (qvariant-value variant)
|
||||
t))
|
||||
(eql::%error-msg "QML-GET" (list item/name property-name)))))
|
||||
|
||||
(defun qml-set (item/name property-name value &optional update)
|
||||
"Sets QQmlProperty of either ITEM, or first object matching NAME. Returns T on success. If UPDATE is not NIL and ITEM is a QQuickPaintedItem, |update| will be called on it."
|
||||
(let ((item (quick-item item/name)))
|
||||
(qlet ((property "QQmlProperty(QObject*,QString)" item property-name))
|
||||
(if (|isValid| property)
|
||||
(qlet ((variant (qvariant-from-value value (|propertyTypeName| property))))
|
||||
(prog1
|
||||
(|write| property variant)
|
||||
(when (and update (= (qt-object-id item) #.(qid "QQuickPaintedItem")))
|
||||
(|update| item))))
|
||||
(eql::%error-msg "QML-SET" (list item/name property-name value))))))
|
||||
|
||||
(defun children (item/name)
|
||||
"Like QML function 'children'."
|
||||
(mapcar 'qt-object-? (|childItems| (quick-item item/name))))
|
||||
|
||||
(defun reload ()
|
||||
"Force reloading of QML file after changes made to it."
|
||||
(|clearComponentCache| (|engine| *quick-view*))
|
||||
(|setSource| *quick-view* (|source| *quick-view*)))
|
||||
|
||||
;; properties dialog
|
||||
|
||||
(defun sym (name package)
|
||||
(find-symbol (symbol-name name) package))
|
||||
|
||||
(defun show-properties-dialog (&optional item)
|
||||
"Lists all instance properties of a QML item (either a QQuickItem or an 'objectName')."
|
||||
(unless (find-package :properties)
|
||||
(load (in-home "gui/properties")))
|
||||
(funcall (sym :show :properties)
|
||||
(if (stringp item)
|
||||
(find-quick-item item)
|
||||
item)))
|
||||
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
(qrequire :quick)
|
||||
|
||||
(require :properties "properties")
|
||||
|
||||
(defvar *quick-view* (qnew "QQuickView")) ; either a QQuickView or a QQuickWidget
|
||||
|
||||
(defun run ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue