AlbumShaper  1.0a3
questionDialog.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 
20 //Projectwide includes
21 #include "questionDialog.h"
22 //Added by qt3to4:
23 #include <Q3GridLayout>
24 #include <Q3Frame>
25 #include "../../config.h"
26 
27 //==============================================
29  QString message,
30  QString questionIconName,
31  QWidget* parent,
32  const char* name ) :
33  QDialog(parent, name, true )
34 {
35  //-------------------------------
36  //create widgets
37  topFrame = new Q3Frame( this );
38 
39  questionText = new QLabel( topFrame );
40  questionText->setText( question );
41 
42  QFont questionFont = questionText->font();
43  questionFont.setWeight(QFont::Bold);
44  questionText->setFont( questionFont );
45 
46  questionIcon = new QPixmap(QString(IMAGE_PATH)+questionIconName);
48  questionIconLabel->setPixmap( *questionIcon );
49 
50  messageText = new Q3TextEdit( this );
51  messageText->setReadOnly(true);
52  messageText->setText( message );
53 
54 
55  bottomFrame = new Q3Frame( this );
56 
57  okButton = new QPushButton( tr("Yes"), bottomFrame );
58  okButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
59  okButton->setDefault(true);
60  okButton->setFocus();
61 
62  connect( okButton, SIGNAL(clicked()), SLOT(accept()) );
63 
64  cancelButton = new QPushButton( tr("No"), bottomFrame );
65  cancelButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
66  connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) );
67  //-------------------------------
68  //create grid and place widgets
69  gridTop = new Q3GridLayout( topFrame, 1, 2, 0);
70  gridTop->addWidget( questionText, 0, 0 );
71  gridTop->addWidget( questionIconLabel, 0, 1, Qt::AlignRight );
72 
73  gridBottom = new Q3GridLayout( bottomFrame, 1, 2, 0);
74  gridBottom->addWidget( okButton, 0, 0 );
75  gridBottom->addWidget( cancelButton, 0, 1);
76 
77  gridFull = new Q3GridLayout( this, 3, 1, 0);
78  gridFull->addWidget( topFrame, 0, 0);
79  gridFull->addWidget( messageText, 1, 0);
80  gridFull->addWidget( bottomFrame, 2, 0);
81 
82  gridFull->setRowStretch( 1, 1 );
83  gridFull->setResizeMode( QLayout::SetNoConstraint );
84  gridFull->setMargin(WIDGET_SPACING);
85  gridFull->setSpacing(WIDGET_SPACING);
86 
87  //-------------------------------
88  //setup window title bar
89  setCaption( question );
90  //-------------------------------
91  //set window to not be resizeable
92  setMinimumWidth(300);
93  this->show();
94  setFixedSize(size());
95  //-------------------------------
96 }
97 //==============================================
99 {
100  delete questionIcon;
101 }
102 //==============================================
Q3GridLayout * gridFull
Q3GridLayout * gridBottom
QLabel * questionText
Question displayed in window.
QString IMAGE_PATH
Definition: config.cpp:18
Q3Frame * topFrame
Top and bottom frames.
#define WIDGET_SPACING
Definition: config.h:31
Q3TextEdit * messageText
Message displayed in window.
~QuestionDialog()
Destructor.
QLabel * questionIconLabel
Label which shows question icon.
Q3GridLayout * gridTop
Grids objects placed in.
QPixmap * questionIcon
Question icon.
QPushButton * okButton
Ok button.
Q3Frame * bottomFrame
QuestionDialog(QString question, QString message, QString questionIconName, QWidget *parent=0, const char *name=0)
Basic constructor.
QPushButton * cancelButton
Cancel button.