From 9466b3042bc7314915a15f499bd0b087f569654d Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 24 Mar 2005 12:14:44 +0000 Subject: Initial revision --- src/messagebox.cc | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 src/messagebox.cc (limited to 'src/messagebox.cc') diff --git a/src/messagebox.cc b/src/messagebox.cc new file mode 100644 index 0000000..47799b7 --- /dev/null +++ b/src/messagebox.cc @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * messagebox.cc + * + * Fri Feb 25 20:23:19 CET 2005 + * Copyright 2005 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "messagebox.h" + +//////////////////////////////////////////////////////////////////////////////////////// +/* If the cpr input by the user is not valid, this dialog + * ask the user what to do. Edit the number, use it as it is, + * or clear the number. + */ + +MessageBox::MessageBox(QWidget* parent, const char* name, const char* text, msg_type type) + : QDialog(parent, name, TRUE) +{ + QFrame *topf = new QFrame(this); + topf->setFrameStyle(QFrame::Box | QFrame::Raised); + topf->setLineWidth(3); + QVBoxLayout *bl = new QVBoxLayout(this); + 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); + + QVBoxLayout *blayout = new QVBoxLayout(topf, 20, 20); + 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; + } + } +} + +QPushButton *MessageBox::createButton(QWidget *parent, const char *text) +{ + QPushButton *q = new QPushButton(parent); + q->setText(text); + q->setFont(QFont("Lucida", 18)); + q->setFixedSize(200, 75); + return q; +} + +void MessageBox::bok_clicked() +{ + done(MSG_OK); +} + +void MessageBox::bcancel_clicked() +{ + done(MSG_CANCEL); +} + +void MessageBox::byes_clicked() +{ + done(MSG_YES); +} + +void MessageBox::bno_clicked() +{ + done(MSG_NO); +} + + +/* +//////////////////////////////////////////////////////////////////////////////////////// +// A generic alert dialog that can either give the user a choice +// (yes or no - returns true or false) or simply give a statement and await the users +// acknowledgement (OK - returns true) +// + +Alert::Alert(QWidget *parent, const char *text, bool single, const char* name, bool mode) +: QDialog(parent, name, mode) +// Sets up the dialog. Two buttons if mode=true otherwise one button +{ + + QPushButton *b_true; ; + QPushButton *b_false; + + QFrame *topf = new QFrame(this); + topf->setFrameStyle(QFrame::Box | QFrame::Raised); + topf->setLineWidth(3); + QVBoxLayout *bl1 = new QVBoxLayout(topf, 20, 20); + + QLabel *l_text = new QLabel(topf); + QFont font("Lucida", 18); + l_text->setText(text); + l_text->setFont(font); + + QFrame *f = new QFrame(topf); + QHBoxLayout *bl2 = new QHBoxLayout(f, 20, 20); + + + QVBoxLayout *toplayout = new QVBoxLayout(this); + toplayout->addWidget(topf); + bl1->addWidget(l_text); + bl1->addWidget(f); + if(!single) + { + b_true = createButton(f, M_YES); + b_false = createButton(f, M_NO); + bl2->addWidget(b_false); + bl2->addWidget(b_true); + connect(b_false, SIGNAL(clicked()), SLOT(false_clicked())); + connect(b_true, SIGNAL(clicked()), SLOT(true_clicked())); + } + else + { + b_true = createButton(f, M_OK); + bl2->addWidget(b_true); + connect(b_true, SIGNAL(clicked()), SLOT(true_clicked())); + } + +} + +QPushButton *Alert::createButton(QWidget *parent, const char *text) +{ + QPushButton *q = new QPushButton(parent); + QFont font("Lucida", 18); + q->setFont(font); + q->setText(text); + q->setFixedSize(200,75); + return q; +} + +void Alert::true_clicked() +{ + accept(); +} + +void Alert::false_clicked() +{ + reject(); +} +*/ -- cgit v1.2.3