From 694da457b071d33d64337333807e8ba55c947c24 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sat, 24 Feb 2024 12:10:34 -0600 Subject: [PATCH] Add type: parameter to qt:message This allows a message of any of the standard types to be displayed: Critical, Question, Information, and Warning. --- main.cpp | 20 ++++++++++++++++++-- prototypes.h | 2 +- qt-light.scm | 11 +++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 3c90ebf..ef37ee6 100644 --- a/main.cpp +++ b/main.cpp @@ -213,9 +213,25 @@ qticon qt_pixmaptoicon(QPixmap* px) } -int qt_message(char *caption, char *text, QWidget *parent, char *b0, char *b1, char *b2) +enum { + INFORMATION = 0, + QUESTION = 1, + WARNING = 2, + CRITICAL = 3 +}; + + +int qt_message(char *caption, char *text, QWidget *parent, char *b0, char *b1, char *b2, int msg_type) { - return QMessageBox::information(parent, caption, text, b0, b1, b2); + switch(msg_type) { + case QUESTION: + return QMessageBox::question(parent, caption, text, b0, b1, b2); + case WARNING: + return QMessageBox::warning(parent, caption, text, b0, b1, b2); + case CRITICAL: + return QMessageBox::critical(parent, caption, text, b0, b1, b2); + } + return QMessageBox::information(parent, caption, text, b0, b1, b2); } diff --git a/prototypes.h b/prototypes.h index d239851..161e7c7 100644 --- a/prototypes.h +++ b/prototypes.h @@ -17,7 +17,7 @@ qticon qt_pixmaptoicon(qtpixmap px); ___bool qt_connect(qtwidget w1, char *sig, qtobject w2, char *slot); qtobject qt_find(qtobject parent, char *name); qtobject qt_receiver(char *name, C_word proc); -int qt_message(char *caption, char *text, qtwidget parent, char *b0, char *b1, char *b2); +int qt_message(char *caption, char *text, qtwidget parent, char *b0, char *b1, char *b2, int msg_type); const char *qt_classname(qtobject w); ___bool qt_setstringproperty(qtwidget w, char *prop, char *val); ___bool qt_setboolproperty(qtwidget w, char *prop, ___bool val); diff --git a/qt-light.scm b/qt-light.scm index e0caf25..5941fb6 100644 --- a/qt-light.scm +++ b/qt-light.scm @@ -131,8 +131,15 @@ extern "C" { (define qt:message (let ((qt:message qt:message)) - (lambda (text #!key (caption "") parent (button1 "OK") (button2 "Cancel") button3) - (qt:message caption text parent button1 button2 button3) ) ) ) + (lambda (text #!key (caption "") (title "") parent + (button1 "OK") (button2 "Cancel") button3 + (type 'information)) + (qt:message (or title caption) text parent button1 button2 button3 + (case type + ['information 3] + ['question 1] + ['warning 2] + ['critical 3]))))) (define (qt:widget fname #!optional parent) (qt:create fname parent) )