AlbumShaper  1.0a3
alertDialog.cpp
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 //Systemwide includes
12 #include <qdialog.h>
13 #include <qlayout.h>
14 #include <qlabel.h>
15 #include <q3textedit.h>
16 #include <qfont.h>
17 #include <qpushbutton.h>
18 #include <qpixmap.h>
19 //Added by qt3to4:
20 #include <Q3GridLayout>
21 #include <Q3Frame>
22 
23 //Projectwide includes
24 #include "alertDialog.h"
25 #include "../../config.h"
26 
27 //==============================================
28 AlertDialog::AlertDialog( QString message,
29  QString description,
30  QString alertIconName,
31  QWidget* parent,
32  const char* name ) :
33  QDialog(parent, name, true )
34 {
35  //-------------------------------
36  //create widgets
37  topFrame = new Q3Frame( this );
38 
39  alertText = new QLabel( topFrame );
40  alertText->setText( message );
41 
42  QFont alertFont = alertText->font();
43  alertFont.setWeight(QFont::Bold);
44  alertText->setFont( alertFont );
45 
46  alertIcon = new QPixmap(QString(IMAGE_PATH)+alertIconName);
48  alertIconLabel->setPixmap( *alertIcon );
49 
50  descriptionText = new Q3TextEdit( this );
51  descriptionText->setReadOnly(true);
52  descriptionText->setText( description );
53 
54  bottomFrame = new Q3Frame( this );
55  okButton = new QPushButton( tr("OK"), bottomFrame );
56  okButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
57  okButton->setDefault(true);
58  okButton->setFocus();
59 
60  connect( okButton, SIGNAL(clicked()), SLOT(accept()) );
61  //-------------------------------
62  //create grid and place widgets
63  gridTop = new Q3GridLayout( topFrame, 1, 2, 0);
64  gridTop->addWidget( alertText, 0, 0 );
65  gridTop->addWidget( alertIconLabel, 0, 1, Qt::AlignRight );
66 
67  gridBottom = new Q3GridLayout( bottomFrame, 1, 1, 0);
68  gridBottom->addWidget( okButton, 0, 0 );
69 
70  gridFull = new Q3GridLayout( this, 3, 1, 0);
71  gridFull->addWidget( topFrame, 0, 0);
72  gridFull->addWidget( descriptionText, 1, 0);
73  gridFull->addWidget( bottomFrame, 2, 0);
74 
75  gridFull->setRowStretch( 1, 1 );
76  gridFull->setResizeMode( QLayout::SetNoConstraint );
77  gridFull->setMargin(WIDGET_SPACING);
78  gridFull->setSpacing(WIDGET_SPACING);
79 
80  setMinimumWidth(300);
81  setMaximumWidth(300);
82  //-------------------------------
83  //setup window title bar
84  setCaption( message );
85  //-------------------------------
86  //set window to not be resizeable
87  this->show();
88  setFixedSize(size());
89  //-------------------------------
90 }
91 //==============================================
93 {
94  delete alertIcon;
95 }
96 //==============================================
Q3Frame * bottomFrame
Definition: alertDialog.h:71
QLabel * alertText
Message displayed in window.
Definition: alertDialog.h:56
AlertDialog(QString message, QString description, QString alertIconName, QWidget *parent=0, const char *name=0)
Basic constructor.
Definition: alertDialog.cpp:28
Q3TextEdit * descriptionText
Description displayed in window.
Definition: alertDialog.h:59
QLabel * alertIconLabel
Label which shows alert icon.
Definition: alertDialog.h:68
Q3GridLayout * gridFull
Definition: alertDialog.h:53
Q3GridLayout * gridTop
Grids objects placed in.
Definition: alertDialog.h:53
QPixmap * alertIcon
Alert icon.
Definition: alertDialog.h:65
QString IMAGE_PATH
Definition: config.cpp:18
#define WIDGET_SPACING
Definition: config.h:31
Q3GridLayout * gridBottom
Definition: alertDialog.h:53
~AlertDialog()
Destructor.
Definition: alertDialog.cpp:92
Q3Frame * topFrame
Top and bottom frames.
Definition: alertDialog.h:71
QPushButton * okButton
Ok button.
Definition: alertDialog.h:62