00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "mbox.h"
00018
00019 #include <opie2/oresource.h>
00020
00021 MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0, QString *btext1, QString *btext2, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f)
00022 {
00023 QVBoxLayout *layout = new QVBoxLayout(this);
00024
00025 QHBoxLayout *hlayout1 = new QHBoxLayout(this);
00026 QHBoxLayout *hlayout2 = new QHBoxLayout(this);
00027
00028 int x, y;
00029
00030 layout->addLayout(hlayout1);
00031 layout->addLayout(hlayout2);
00032
00033 setCaption(title);
00034
00035 QLabel *image = new QLabel(this, "image");
00036 QLabel *text = new QLabel(message, this, "text");
00037
00038 switch (type)
00039 {
00040 case 0:
00041 image->setPixmap(Opie::Core::OResource::loadPixmap("opie-sh/info", Opie::Core::OResource::SmallIcon));
00042 break;
00043 case 1:
00044 image->setPixmap(Opie::Core::OResource::loadPixmap("opie-sh/warning", Opie::Core::OResource::SmallIcon));
00045 break;
00046 case 2:
00047 image->setPixmap(Opie::Core::OResource::loadPixmap("opie-sh/error", Opie::Core::OResource::SmallIcon));
00048 break;
00049 }
00050
00051 hlayout1->addWidget(image);
00052 hlayout1->addSpacing(5);
00053 hlayout1->addWidget(text);
00054
00055 if(!btext0->isNull())
00056 {
00057 QPushButton *button0 = new QPushButton((const QString)*btext0, this, "button0");
00058 hlayout2->addSpacing(5);
00059 hlayout2->addWidget(button0);
00060 hlayout2->addSpacing(5);
00061 connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) );
00062 }
00063 else
00064 {
00065 QPushButton *button0 = new QPushButton("Ok", this, "button0");
00066 hlayout2->addSpacing(5);
00067 hlayout2->addWidget(button0);
00068 hlayout2->addSpacing(5);
00069 connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) );
00070 }
00071
00072 if(!btext1->isNull())
00073 {
00074 QPushButton *button1 = new QPushButton((const QString)*btext1, this, "button1");
00075 hlayout2->addWidget(button1);
00076 hlayout2->addSpacing(5);
00077 connect(button1, SIGNAL(clicked()), this, SLOT(b1pressed()) );
00078 }
00079
00080 if(!btext2->isNull())
00081 {
00082 QPushButton *button2 = new QPushButton((const QString)*btext2, this, "button2");
00083 hlayout2->addWidget(button2);
00084 hlayout2->addSpacing(5);
00085 connect(button2, SIGNAL(clicked()), this, SLOT(b2pressed()) );
00086 }
00087
00088 x=(w/2)-(width()/2);
00089 y=(h/2)-(height()/2);
00090
00091 move(x, y);
00092 }