Add type: parameter to qt:message

This allows a message of any of the standard types
to be displayed: Critical, Question, Information,
and Warning.
This commit is contained in:
Jaidyn Ann 2024-02-24 12:10:34 -06:00
parent e7e46e31f3
commit 694da457b0
3 changed files with 28 additions and 5 deletions

View File

@ -213,8 +213,24 @@ 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)
{
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);
}

View File

@ -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);

View File

@ -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) )