:qt and :qt-impl packages to prevent collision with :cl symbols and fix object with non smoke parent.
Annotate for file src/timer.lisp
2009-06-11 tobias 1 (in-package :cl-smoke.qt-impl)
2010-01-10 tobias 2
08:52:49 ' 3 (defclass single-shot-timer (qt:object)
' 4 ((function :initarg :function
' 5 :type function)
' 6 (timer-id :type integer))
' 7 (:metaclass cxx:class))
' 8
' 9 (defvar *single-shot-timers* nil "Pending timers.")
' 10
' 11 (defun single-shot (function &optional (timeout 0))
' 12 "Run FUNCTION after TIMEOUT seconds, or as soon as all window events
' 13 have been processed when TIMEOUT is 0. Equivalent to QTimer::singleShot,
' 14 but calls a function instead of a slot."
' 15 (let ((timer (make-instance 'single-shot-timer
' 16 :function function)))
' 17 (setf (slot-value timer 'timer-id)
' 18 (cxx:start-timer timer (floor timeout 100)))
' 19 (push timer *single-shot-timers*)))
' 20
2009-06-11 tobias 21 (defmacro qt:do-delayed-initialize (&body body)
2010-01-10 tobias 22 "Run body when the event loop starts.
08:52:49 ' 23
' 24 http://techbase.kde.org/Development/Tutorials/Common_Programming_Mistakes#Delayed_Initialization"
' 25 `(single-shot #'(lambda () ,@body)))
' 26
' 27 (defmethod cxx:timer-event ((timer single-shot-timer) event)
' 28 (cxx:kill-timer timer (slot-value timer 'timer-id))
' 29 (funcall (slot-value timer 'function))
' 30 (remove timer *single-shot-timers*))