Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mbox.cpp

Go to the documentation of this file.
00001 /*
00002 Opie-sh.  convinience app to allow you to use qdialogs in scripts (mainly shell scripts)
00003 Copyright (C) 2002 Thomas Stephens
00004 
00005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
00006 License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
00007 version.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
00010 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00011 Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
00014 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 }

Generated on Sat Nov 5 16:18:02 2005 for OPIE by  doxygen 1.4.2