Set window-title based on current contact-file
This commit is contained in:
parent
6100da7744
commit
51de5b4df2
27
contact.scm
27
contact.scm
|
@ -56,10 +56,6 @@
|
|||
(thread-join! qt-thread))))
|
||||
|
||||
|
||||
(define (last-free-arg cli-args)
|
||||
(condition-case (last (car cli-args)) (var () #f)))
|
||||
|
||||
|
||||
;; Set up some global variables (for easier live REPL use), prepare the QT app.
|
||||
(define (init-qt cli-args)
|
||||
(set! *qt-app* (qt:init))
|
||||
|
@ -69,9 +65,9 @@
|
|||
;; Kick off the QT thread, then open the cli free-arg vCard file, if provided.
|
||||
;; That is, like `$ contact freeArgFile.vcf`.
|
||||
(let [(qt-thread (thread-start! qt-loop))
|
||||
(last-arg (last-free-arg cli-args))]
|
||||
(when (string? last-arg)
|
||||
(open-vcard-file *qt-win* last-arg))
|
||||
(last-free-arg (condition-case (last (car cli-args)) (var () #f)))]
|
||||
(when (string? last-free-arg)
|
||||
(open-vcard-file *qt-win* last-free-arg))
|
||||
qt-thread))
|
||||
|
||||
|
||||
|
@ -140,7 +136,9 @@
|
|||
(or (qt:theme-icon "person") (qt:theme-icon "contact-new")))]
|
||||
(if default-profile-pic
|
||||
(set! (qt:property (qt:find window "avatarLabel") "pixmap")
|
||||
(qt:icon->pixmap default-profile-pic 100 100))))
|
||||
(qt:icon->pixmap default-profile-pic 100 100))))
|
||||
;; Set the window’s title.
|
||||
(set-window-title! window "New contact")
|
||||
;; Now prepare callbacks and show the window.
|
||||
(window-callbacks window)
|
||||
(qt:show window))
|
||||
|
@ -214,6 +212,7 @@
|
|||
;; Parse a vCard file and populate the window’s forms with its contents.
|
||||
(define (open-vcard-file window file)
|
||||
(set! *vcard-pathname* file)
|
||||
(set-window-title! window (pathname-file file))
|
||||
(thread-start!
|
||||
(lambda ()
|
||||
(condition-case
|
||||
|
@ -223,12 +222,14 @@
|
|||
vcard:read-vcard))
|
||||
[(vcard)
|
||||
(set! *vcard-pathname* #f)
|
||||
(set-window-title! window "New contact")
|
||||
(qt:message
|
||||
(string-join (list "This file doesn’t seem to be a valid vCard file."
|
||||
"Please make sure you selected the right file, and take a look at it manually."))
|
||||
title: "Parsing error" type: 'critical)]
|
||||
[exn (file)
|
||||
(set! *vcard-pathname* #f)
|
||||
(set-window-title! window "New contact")
|
||||
(qt:message
|
||||
(string-join (list "Failed to open the file."
|
||||
((condition-property-accessor 'exn 'message) exn)))
|
||||
|
@ -277,7 +278,15 @@
|
|||
(if avatar (u8vector->pixmap (cadr (last property))))]]
|
||||
(when avatar
|
||||
(set! (qt:property avatar "pixmap") new-pixmap)))])))
|
||||
vcard-alist))
|
||||
vcard-alist)
|
||||
(when (alist-ref 'FN vcard-alist)
|
||||
(set-window-title! window (last (alist-ref 'FN vcard-alist)))))
|
||||
|
||||
|
||||
;; Set a QT window’s title, suffixing with the program name (Contact).
|
||||
(define (set-window-title! window title)
|
||||
(set! (qt:property window "windowTitle")
|
||||
(string-concatenate (list title " - Contact"))))
|
||||
|
||||
|
||||
;; Given a image bytevector (u8vector), create a corresponding pixmap.
|
||||
|
|
Ŝarĝante…
Reference in New Issue