repos
/
qt.gui
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
filehistory
normal
|
plain
|
shade
|
zebra
Break API compatibility for qt:with-app and qt:exec & spellcheck
Annotate for file src/timer.lisp
2010-01-10 tobias
1
(in-package :cl-smoke.qt-impl)
08:52:49 '
2
'
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
'
21
(defmacro qt:do-delayed-initialize (&body body)
'
22
"Run body when the event loop starts.
'
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)
2009-07-01 tobias
28
(declare (ignore event))
2010-01-10 tobias
29
(cxx:kill-timer timer (slot-value timer 'timer-id))
08:52:49 '
30
(funcall (slot-value timer 'function))
'
31
(remove timer *single-shot-timers*))