(ql:quickload '(lorem-ipsum qtools qtcore qtgui qtsvg)) (named-readtables:in-readtable :qtools) (in-package #:cl+qt) ;;; FIXED-QTEXTEDIT (define-widget fixed-qtextedit (qtextedit) ()) (define-subwidget (fixed-qtextedit fix-context-menu-widget) (q+:make-qwidget)) (define-override (fixed-qtextedit context-menu-event) (event) ;; Display the context menu. (with-finalizing ((menu (q+:create-standard-context-menu fixed-qtextedit))) (q+:exec menu (q+:global-pos event))) ;; Work around the bug. (q+:show fix-context-menu-widget) (setf (q+:focus fix-context-menu-widget) 0) (q+:hide fix-context-menu-widget) ;; Fix cursor position after the context menu disappears. (let* ((position (q+:pos event)) (cursor (q+:cursor-for-position fixed-qtextedit position))) (setf (q+:text-cursor fixed-qtextedit) cursor))) (defun test () (with-main-window (editor 'my-editor) (dotimes (i 5) (q+:append editor (lorem-ipsum:paragraph :prologue nil))) (let ((document (q+:document editor)) (pathnames (directory *pathname*))) (dolist (pathname pathnames) (let ((svg-path (uiop:native-namestring pathname))) (with-finalizing ((icon (q+:make-qicon svg-path))) (let ((pixmap (q+:pixmap icon (q+:make-qsize))) (format (q+:make-qtextimageformat)) (url (uiop:strcat "gateway://" (pathname-name pathname)))) (q+:add-resource document (q+:qtextdocument.image-resource) (q+:make-qurl url) (q+:to-image pixmap)) (setf (q+:name format) url) (q+:append editor (format nil "

" url))))))))) (defun test2 () (with-main-window (label (q+:make-qlabel)) (with-finalizing ((renderer (q+:make-qsvgrenderer))) (q+:load renderer "/home/phoe/Projects/Lisp/Gateway-UI-Assets/Page-Dividers/webdesignhot-1-1.svg") (let* ((size (q+:default-size renderer)) (x (q+:width size)) (y (q+:height size)) (pixmap (q+:make-qpixmap (* 4 x) (* 4 y)))) (with-finalizing ((color (q+:make-qcolor 0 0 0 0))) (q+:fill pixmap color)) (with-finalizing ((painter (q+:make-qpainter pixmap))) (q+:render renderer painter (q+:make-qrectf (q+:rect pixmap)))) (setf (q+:pixmap label) pixmap)))))