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.
|
;; Connect callback functions to widgets’ signals.
|
||||||
(define (window-callbacks window)
|
(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
|
;; We connect to https://doc.qt.io/qt-6/qaction.html#triggered
|
||||||
(if file→exit
|
(if file→exit
|
||||||
(qt:connect
|
(qt:connect
|
||||||
file→exit "triggered()"
|
file→exit "triggered()"
|
||||||
(qt:receiver exit))))
|
(qt:receiver exit)))
|
||||||
(textbox-callbacks window))
|
(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.
|
;; Connect a text-printing callback to each textbox.
|
||||||
|
@ -71,12 +84,18 @@
|
||||||
;; Cycle through each textbox, connecting them to a callback that prints
|
;; Cycle through each textbox, connecting them to a callback that prints
|
||||||
;; their contents each time you type in text.
|
;; their contents each time you type in text.
|
||||||
(map (lambda (textbox)
|
(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
|
(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:connect textbox "textChanged(QString)"
|
||||||
(qt:receiver
|
(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)))
|
textboxes)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,7 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
|
@ -235,6 +236,14 @@
|
||||||
<string>Exit</string>
|
<string>Exit</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Ŝarĝante…
Reference in New Issue