1 (in-package :cl-smoke.qt.core)
3 (defclass qslot (qt:object)
4 ((arguments :reader arguments :initarg :argument-types
5 :documentation "List of the argument types for the slot.")
6 (function :reader slot-function :initarg :slot-function
7 :initform (error "no slot function specified")
8 :documentation "The function called when the slot is invoked."))
10 (:documentation "A Qt slot that calls its associated function"))
12 (defun qt:make-slot (function &optional (arguments nil arguments-p))
13 "Returns a slot that calls FUNCTION when it receives a signal."
16 :slot-function function
17 :argument-types arguments)
19 :slot-function function)))
21 (defmethod id ((slot qslot))
22 (cxx:method-count (cxx:meta-object slot)))
24 (defparameter *sender* nil "The sender of the signal.")
25 (defparameter *this* nil "The slot that is invoked.")
26 (defmacro qt:sender ()
27 "Returns the sender that invoked the slot."
30 (defmethod cxx:qt-metacall ((slot qslot) call id arguments)
31 "Invoke the slots function when it is called. The return value
32 of the invoked slot function is ignored."
34 (let ((id (call-next-method)))
37 (if (enum= call qt:meta-object.+invoke-meta-method+)
40 (0 (let ((*sender* (cxx:sender slot))
43 (continue "Skip the function ~A of slot ~A."
44 (slot-function slot) slot)
45 (apply (slot-function slot)
46 (arguments-to-lisp arguments (arguments slot)))))))
50 (defun find-signal-id (sender signal)
51 "Returns the ID of SIGNAL from SENDER."
52 ;; For efficiency assume that SIGNAL is normalized and fallback to
53 ;; normalizing when not. (Just like Qt does.)
54 (let ((id (cxx:index-of-signal (cxx:meta-object sender)
57 (setf id (cxx:index-of-signal (cxx:meta-object sender)
58 (qt:meta-object.normalized-signature signal))))
60 (error "No signal ~S for class ~S."
61 signal (class-of sender)))