Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

questionDialog.cpp

Go to the documentation of this file.
00001 //==============================================
00002 //  copyright            : (C) 2003 by Will Stokes
00003 //==============================================
00004 //  This program is free software; you can redistribute it 
00005 //  and/or modify it under the terms of the GNU General 
00006 //  Public License as published by the Free Software 
00007 //  Foundation; either version 2 of the License, or  
00008 //  (at your option) any later version.         
00009 //
00010 //  As a special exception, Will Stokes gives permission to 
00011 //  link this program with Qt non-commercial edition, and 
00012 //  distribute the resulting executable, without including the 
00013 //  source code for the Qt non-commercial edition in the 
00014 //  source distribution. 
00015 //==============================================
00016 
00017 //Systemwide includes
00018 #include <qdialog.h>
00019 #include <qlayout.h>
00020 #include <qlabel.h>
00021 #include <qtextedit.h>
00022 #include <qfont.h>
00023 #include <qpushbutton.h>
00024 #include <qpixmap.h>
00025 
00026 //Projectwide includes
00027 #include "questionDialog.h"
00028 #include "../config.h"
00029 
00030 //==============================================
00031 QuestionDialog::QuestionDialog( QString question,
00032                                               QString message,
00033                                               QString questionIconName,
00034                                               QWidget* parent,
00035                                               const char* name ) : 
00036                                               QDialog(parent, name, true )
00037 {
00038   //-------------------------------
00039   //create widgets   
00040   windowIcon = new QPixmap(QString(IMAGE_PATH)+"albumShaperIcon.png");
00041   
00042   topFrame = new QFrame( this );  
00043   
00044   questionText = new QLabel( topFrame );
00045   questionText->setText( question );
00046   questionText->setFont( QFont( "Times", 12, QFont::Bold ) );
00047 
00048   questionIcon = new QPixmap(QString(IMAGE_PATH)+questionIconName);
00049   questionIconLabel = new QLabel( topFrame );
00050   questionIconLabel->setPixmap( *questionIcon );
00051     
00052   messageText = new QTextEdit( this );
00053   messageText->setReadOnly(true);  
00054   messageText->setText( message );
00055   messageText->setFont( QFont( "Times", 12, QFont::Normal ) );  
00056 
00057   bottomFrame = new QFrame( this );
00058     
00059   okButton = new QPushButton( QPixmap(QString(IMAGE_PATH)+"button_ok.png"), 
00060                               tr("Ok"), 
00061                               bottomFrame );
00062   okButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
00063   okButton->setDefault(true);
00064   okButton->setFocus();
00065   
00066   connect( okButton, SIGNAL(clicked()), SLOT(accept()) );
00067 
00068   cancelButton = new QPushButton( QPixmap(QString(IMAGE_PATH)+"button_cancel.png"), 
00069                                   tr("Cancel"), 
00070                                   bottomFrame );
00071   cancelButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
00072   connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) );
00073   //-------------------------------
00074   //create grid and place widgets
00075   gridTop     = new QGridLayout( topFrame, 1, 2, 0);
00076   gridTop->addWidget( questionText, 0, 0 );
00077   gridTop->addWidget( questionIconLabel, 0, 1, Qt::AlignRight );
00078   
00079   gridBottom  = new QGridLayout( bottomFrame, 1, 2, 0);
00080   gridBottom->addWidget( okButton, 0, 0 );
00081   gridBottom->addWidget( cancelButton, 0, 1);
00082   
00083   gridFull    = new QGridLayout( this, 3, 1, 0);
00084   gridFull->addWidget( topFrame, 0, 0);
00085   gridFull->addWidget( messageText, 1, 0);
00086   gridFull->addWidget( bottomFrame, 2, 0);
00087   
00088   gridFull->setRowStretch( 1, 1 );     
00089   gridFull->setResizeMode( QLayout::FreeResize );
00090   
00091   setMinimumWidth(300);
00092   setMaximumWidth(300);
00093   //-------------------------------
00094   //set the background of the widget to be white
00095   setPaletteBackgroundColor( QColor(255, 255, 255) );
00096   //-------------------------------
00097   //setup window title bar
00098   setIcon( *windowIcon );
00099   setCaption( question );
00100   //-------------------------------
00101   //set window to not be resizeable
00102   this->show();
00103   setFixedSize(size());
00104   //-------------------------------
00105 }
00106 //==============================================
00107 QuestionDialog::~QuestionDialog()
00108 {
00109   delete windowIcon;
00110   delete questionIcon;
00111 }
00112 //==============================================

Generated on Thu Nov 13 00:10:54 2003 for AlbumShaper by doxygen 1.3.4