better class finder for "-qgui"; small revisions;

This commit is contained in:
polos 2017-01-07 10:42:37 +01:00
parent 45ba32cd0d
commit abf60c2baa
4 changed files with 42 additions and 28 deletions

View file

@ -304,7 +304,7 @@
(qset-color *main* |QPalette.Window| (if active *color-pause* *background*))))
(#.|Qt.Key_S|
(let ((widget (|viewport| *view*)))
(|save| (|grabWidget(QWidget*,QRect).QPixmap| widget (|rect| widget))
(|save| (|grab| widget (|rect| widget))
"screenshot.png")))
(#.|Qt.Key_Escape|
(qquit))))))

View file

@ -30,6 +30,8 @@
*display*
*edit*
*help*
*hint-copy-1*
*hint-copy-2*
*main-tab*
*n-methods*
*n-names*
@ -64,6 +66,7 @@
(qset *gui* "windowTitle" "EQL - Embedded Qt Lisp")
(qset *select* "toolTip" (tr "Select any (child) widget (see qsel:*q*)"))
(qset *help* "source" (! "fromLocalFile" "QUrl" (in-home "doc/auto-doc.htm")))
(qset *hint-copy-2* "text" (qget *hint-copy-1* "text"))
(qset-color *help* |QPalette.Highlight| "yellow")
(qset-color *help* |QPalette.HighlightedText| "black")
(set-tree *q-override*)
@ -74,13 +77,14 @@
(set-tree *n-methods* 3 nil (tr "Method") (tr "Static"))
(set-tree *n-override*)
(set-tree *primitives* 2 (tr "Qt/C++ type") (tr "Lisp example / type"))
;; please see example 9: editor.lisp for better completer examples
(populate-primitives)
;; please see example 9, "editor.lisp" for better completer examples
(let ((cpl (qnew "QCompleter")))
(dolist (w (list *display* *edit* *package-name* *selected-widget* *search-class* (! "popup" cpl)))
(qset w "font" *code-font*))
(! "setModel" cpl *completer-list*)
(! "setCompleter" *edit* cpl))
(let ((cpl (qnew "QCompleter(QStringList)" (qobject-names))))
(let ((cpl (qnew "QCompleter(QStringList)" (append (qobject-names) (primitives)))))
(! "setCompletionMode" cpl |QCompleter.InlineCompletion|)
(! "setCaseSensitivity" cpl |Qt.CaseInsensitive|)
(! "setCompleter" *search-class* cpl))
@ -99,7 +103,6 @@
(qoverride *edit* "keyPressEvent(QKeyEvent*)" 'history-move)
(change-class-q-object "QWidget" :super)
(change-class-n-object "QMetaObject" :super)
(populate-primitives)
(qsingle-shot 500 'show-package-name)
(x:do-with (qset *gui*)
("pos" (list 50 50))
@ -173,20 +176,22 @@
(! "setOverrideCursor" "QGuiApplication" cross-cursor)))
(defun select-class ()
(flet ((find-name (name q-n)
(find name (qobject-names q-n) :test 'string-equal))
(let ((name (! "text" *search-class*))
found)
(flet ((find-name (q-n)
(unless found
(setf found (find name (if q-n (qobject-names q-n) (primitives))
:test 'string-equal))))
(set-tab-index (i)
(! "setCurrentIndex" *qt-tab* i)))
(let* ((name (! "text" *search-class*))
(q-name (find-name name :q))
(n-name (unless q-name
(find-name name :n))))
(cond (q-name
(cond ((find-name :q) ; QObject
(set-tab-index 0)
(change-class-q-object q-name :super))
(n-name
(change-class-q-object found :super))
((find-name :n) ; non QObject
(set-tab-index 1)
(change-class-n-object n-name :super))))))
(change-class-n-object found :super))
((find-name nil) ; primitive
(set-tab-index 2))))))
(defun change-class-q-object (s &optional super)
(let ((i (! "findText" *q-names* s)))
@ -285,6 +290,19 @@
("resizeColumnToContents" 0)
("sortByColumn" 0 |Qt.AscendingOrder|)))
(let (primitives)
(defun primitives ()
(or primitives
(setf primitives
(let (names)
(dotimes (i (! "topLevelItemCount" *primitives*))
(let ((name (! "text" (! "topLevelItem" *primitives* i) 0)))
(if (find #\/ name)
(dolist (el (x:split name #\/))
(push (string-trim " " el) names))
(push name names))))
names)))))
(defun show-super-classes (type)
(qset (if (eql :q type) *q-super-classes* *n-super-classes*) "text"
(with-output-to-string (s)

View file

@ -92,7 +92,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="hint_search_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
@ -100,7 +100,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Type class name and hit Return</string>
<string>&lt;small&gt;type class name and hit Return&lt;/small&gt;</string>
</property>
</widget>
</item>
@ -228,9 +228,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="hint_copy_1">
<property name="text">
<string>Double-click to add to command line (and clipboard)</string>
<string>&lt;small&gt;double-click to add to command line (and clipboard)&lt;/small&gt;</string>
</property>
</widget>
</item>
@ -313,11 +313,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Double-click to add to command line (and clipboard)</string>
</property>
</widget>
<widget class="QLabel" name="hint_copy_2"/>
</item>
</layout>
</widget>
@ -359,7 +355,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="hint_search_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
@ -367,7 +363,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Hit Return to find next</string>
<string>&lt;small&gt;hit Return to find next&lt;/small&gt;</string>
</property>
</widget>
</item>

View file

@ -135,7 +135,7 @@
"args: (function)
Convenience macro: a <code>qsingle-shot</code> with a <code>0</code> timeout.<br>This will call <code>function</code> as soon as the Qt event loop is idle.
(qlater 'delayed-ini)"
`(%qsingle-shot 0 ,function))
`(qsingle-shot 0 ,function))
(defun %ensure-persistent-function (fun)
(typecase fun