Add a placeholder File→Save menubar item
It is toggled enabled when the user edits text, and provisionally displays a pop-up message saying “I do nothing lol”.
This commit is contained in:
parent
0259e06b99
commit
65e48e7f2d
31
contact.scm
31
contact.scm
|
@ -48,13 +48,26 @@
|
|||
|
||||
;; Connect callback functions to widgets’ signals.
|
||||
(define (window-callbacks window)
|
||||
(let* ([file→exit (qt:find window "actionQuit")])
|
||||
(menubar-callbacks window)
|
||||
(textbox-callbacks window))
|
||||
|
||||
|
||||
|
||||
;; Connect callback functions to menubar items.
|
||||
(define (menubar-callbacks window)
|
||||
(let* ([file→exit (qt:find window "actionQuit")]
|
||||
[file→save (qt:find window "actionSave")])
|
||||
;; We connect to https://doc.qt.io/qt-6/qaction.html#triggered
|
||||
(if file→exit
|
||||
(qt:connect
|
||||
file→exit "triggered()"
|
||||
(qt:receiver exit))))
|
||||
(textbox-callbacks window))
|
||||
(qt:receiver exit)))
|
||||
(if file→save
|
||||
(qt:connect
|
||||
file→save "triggered()"
|
||||
(qt:receiver
|
||||
(lambda ()
|
||||
(qt:message "Saving is not implemented." "Saving")))))))
|
||||
|
||||
|
||||
;; Connect a text-printing callback to each textbox.
|
||||
|
@ -71,12 +84,18 @@
|
|||
;; Cycle through each textbox, connecting them to a callback that prints
|
||||
;; their contents each time you type in text.
|
||||
(map (lambda (textbox)
|
||||
;; We connect to https://doc.qt.io/qt-6/qlineedit.html#textChanged
|
||||
;; … and print the value of https://doc.qt.io/qt-6/qlineedit.html#text-prop
|
||||
;; Also enable the File→Save menu-item (since, y’know, the user
|
||||
;; changed something). It defaults to disabled in the contact.ui file.
|
||||
(if textbox
|
||||
;; We connect to https://doc.qt.io/qt-6/qlineedit.html#textChanged
|
||||
;; … and print the value of https://doc.qt.io/qt-6/qlineedit.html#text-prop
|
||||
(qt:connect textbox "textChanged(QString)"
|
||||
(qt:receiver
|
||||
(lambda () (print (qt:property textbox "text")))))))
|
||||
(lambda ()
|
||||
(let ([file→save (qt:find window "actionSave")])
|
||||
(if file→save
|
||||
(set! (qt:property file→save "enabled") #t)))
|
||||
(print (qt:property textbox "text")))))))
|
||||
textboxes)))
|
||||
|
||||
|
||||
|
|
|
@ -225,6 +225,7 @@
|
|||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
|
@ -235,6 +236,14 @@
|
|||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Ŝarĝante…
Reference in New Issue