summaryrefslogtreecommitdiff
path: root/src/messagebox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/messagebox.cc')
-rw-r--r--src/messagebox.cc153
1 files changed, 111 insertions, 42 deletions
diff --git a/src/messagebox.cc b/src/messagebox.cc
index 47799b7..a636bd7 100644
--- a/src/messagebox.cc
+++ b/src/messagebox.cc
@@ -31,7 +31,11 @@
* or clear the number.
*/
-MessageBox::MessageBox(QWidget* parent, const char* name, const char* text, msg_type type)
+MessageBox::MessageBox(QWidget* parent,
+ const char* name,
+ const char* text,
+ msg_type type,
+ msg_icon icon)
: QDialog(parent, name, TRUE)
{
QFrame *topf = new QFrame(this);
@@ -41,7 +45,6 @@ MessageBox::MessageBox(QWidget* parent, const char* name, const char* text, msg_
bl->addWidget(topf);
QLabel *lbl_text = new QLabel(topf);
- // text->setText("CPR ikke gyldigt, ønsker du at forsætte?");
lbl_text->setText(text);
lbl_text->setFont(QFont("Lucida", 18));
QFrame *f = new QFrame(topf);
@@ -50,48 +53,114 @@ MessageBox::MessageBox(QWidget* parent, const char* name, const char* text, msg_
blayout->addWidget(lbl_text);
blayout->addWidget(f);
- switch(type) {
- case TYPE_OK: {
- QPushButton *bok = createButton(f, "Ok");
- QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20);
- glayout->addWidget(bok, 0, 0);
- connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
- break;
- }
- case TYPE_OK_CANCEL: {
- QPushButton *bok = createButton(f, "Ok");
- QPushButton *bcancel = createButton(f, "Cancel");
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
- glayout->addWidget(bcancel, 0, 1);
- glayout->addWidget(bok, 0, 2);
- connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
- connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
- break;
- }
- case TYPE_YES_NO: {
- QPushButton *byes = createButton(f, "Ja");
- QPushButton *bno = createButton(f, "Nej");
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
- glayout->addWidget(bno, 0, 0);
- glayout->addWidget(byes, 0, 1);
- connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
- connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
- break;
- }
- case TYPE_YES_NO_CANCEL: {
- QPushButton *byes = createButton(f, "Ja");
- QPushButton *bcancel = createButton(f, "Cancel");
- QPushButton *bno = createButton(f, "Nej");
- QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
- glayout->addWidget(bno, 0, 0);
- glayout->addWidget(bcancel, 0, 1);
- glayout->addWidget(byes, 0, 2);
- connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
- connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
- connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
- break;
+ // Setup the icon
+ pix_icon = new QPixmap();
+ switch(icon) {
+ case ICON_NONE: // No icon is used
+ {
+ break;
+ }
+ case ICON_DEFAULT: // An icon matching the buttons is used
+ {
+ switch(type) {
+ case TYPE_OK:
+ printf("using info icon!\n");
+ pix_icon->load( "info.png" );
+ break;
+ case TYPE_OK_CANCEL:
+ printf("using warning icon!\n");
+ pix_icon->load( "warning.png" );
+ break;
+ case TYPE_YES_NO:
+ printf("using question icon!\n");
+ pix_icon->load( "question.png" );
+ break;
+ case TYPE_YES_NO_CANCEL:
+ printf("using question icon!\n");
+ pix_icon->load( "question.png" );
+ break;
+ }
+ break;
+ }
+ case ICON_INFO: // An info icon (matching the ok button)
+ {
+ printf("using info icon!\n");
+ pix_icon->load( "info.png" );
+ break;
+ }
+ case ICON_WARN: // An warning icon (matching the ok/cancel button)
+ {
+ printf("using warning icon!\n");
+ pix_icon->load( "warning.png" );
+ break;
+ }
+ case ICON_ERROR: // An critical error icon
+ {
+ printf("using error icon!\n");
+ pix_icon->load( "error.png" );
+ break;
+ }
+ case ICON_QUESTION:// An question icon (matching the yes/no and yes/no/cancel buttons)
+ {
+ printf("using question icon!\n");
+ pix_icon->load( "question.png" );
+ break;
+ }
}
+
+ // Setup the buttons
+ switch(type) {
+ case TYPE_OK:
+ {
+ QPushButton *bok = createButton(f, "Ok");
+ QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20);
+ glayout->addWidget(bok, 0, 0);
+ connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
+ break;
+ }
+ case TYPE_OK_CANCEL:
+ {
+ QPushButton *bok = createButton(f, "Ok");
+ QPushButton *bcancel = createButton(f, "Cancel");
+ QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ glayout->addWidget(bcancel, 0, 1);
+ glayout->addWidget(bok, 0, 2);
+ connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
+ connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
+ break;
+ }
+ case TYPE_YES_NO:
+ {
+ QPushButton *byes = createButton(f, "Ja");
+ QPushButton *bno = createButton(f, "Nej");
+ QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ glayout->addWidget(bno, 0, 0);
+ glayout->addWidget(byes, 0, 1);
+ connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
+ connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
+ break;
+ }
+ case TYPE_YES_NO_CANCEL:
+ {
+ QPushButton *byes = createButton(f, "Ja");
+ QPushButton *bcancel = createButton(f, "Cancel");
+ QPushButton *bno = createButton(f, "Nej");
+ QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
+ glayout->addWidget(bno, 0, 0);
+ glayout->addWidget(bcancel, 0, 1);
+ glayout->addWidget(byes, 0, 2);
+ connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
+ connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
+ connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
+ break;
+ }
}
+
+}
+
+MessageBox::~MessageBox()
+{
+ delete pix_icon;
}
QPushButton *MessageBox::createButton(QWidget *parent, const char *text)