From 65e48e7f2d5e8f3abe2c03b82f0e121f0093750d Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:00:06 -0600 Subject: [PATCH] =?UTF-8?q?Add=20a=20placeholder=20File=E2=86=92Save=20men?= =?UTF-8?q?ubar=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is toggled enabled when the user edits text, and provisionally displays a pop-up message saying “I do nothing lol”. --- contact.scm | 31 +++++++++++++++++++++++++------ contact.ui | 9 +++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) 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 + +