diff --git a/contact.scm b/contact.scm index 9fe193b..68612a1 100644 --- a/contact.scm +++ b/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))) diff --git a/contact.ui b/contact.ui index 64f0a62..128ea85 100644 --- a/contact.ui +++ b/contact.ui @@ -225,6 +225,7 @@ File + @@ -235,6 +236,14 @@ Exit + + + false + + + Save + +