moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kmessedwords / kmessedwords / answer.cpp
blob088bb044163bf938439c56249f07714e90692994
1 /***************************************************************************
2 answer.cpp - description
3 -------------------
4 begin : Thu Mar 28 2002
5 copyright : (C) 2002 by Primoz Anzur
6 email : zerokode@gmx.net
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 #include <klocale.h>
19 #include "answer.h"
20 #include <kdebug.h>
21 #include <kstandarddirs.h>
22 #include <kpushbutton.h>
23 #include <kstdguiitem.h>
26 * Constructs a Answer which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f'.
29 * The dialog will by default be modeless, unless you set 'modal' to
30 * TRUE to construct a modal dialog.
32 Answer::Answer( QWidget* parent, const char* name, bool modal, WFlags )
33 : QDialog( parent, name, modal, true)
35 if ( !name )
36 setName( "Answer" );
37 resize( 256, 256 );
38 setMinimumSize( QSize( 256, 256 ) );
39 setMaximumSize( QSize( 256, 256 ) );
40 setCaption( tr2i18n( "Answer" ) );
41 AnswerLayout = new QGridLayout( this, 1, 1, 11, 6, "AnswerLayout");
43 Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2");
45 btnReplay = new QPushButton( this, "btnReplay" );
46 btnReplay->setText( tr2i18n( "&Play Again" ) );
47 Layout2->addWidget( btnReplay );
49 btnQuit = new KPushButton( this, "btnQuit" );
50 btnQuit->setText( tr2i18n( "Quit" ) );
51 Layout2->addWidget( btnQuit );
53 AnswerLayout->addLayout( Layout2, 1, 0 );
54 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
55 AnswerLayout->addItem( spacer, 0, 0 );
57 // signals and slots connections
58 connect( btnQuit, SIGNAL( clicked() ), this, SLOT( exitAnswer() ) );
59 connect( btnReplay, SIGNAL( clicked() ), this, SLOT( replayGame() ) );
63 * Destroys the object and frees any allocated resources
65 Answer::~Answer()
67 // no need to delete child widgets, Qt does it all for us
70 void Answer::exitAnswer()
72 if(getAnswer){
73 close(); //will show the "OK" button -- Simple close...
74 } else {
75 emit gameExit();
76 close();
80 void Answer::replayGame()
82 emit gameReplay();
83 close();
86 void Answer::doAnswer(bool result){
87 kdDebug() << result << endl;
89 if(result){
90 btnReplay->setEnabled(true);
91 btnQuit->setGuiItem(KStdGuiItem::quit());
92 setCaption(i18n("Congratulations!"));
93 setBackgroundPixmap(QPixmap(locate("data","kmessedwords/dudeyes.png")));
94 getAnswer=false;
95 } else {
96 btnReplay->setEnabled(false);
97 btnQuit->setGuiItem(KStdGuiItem::ok());
98 setCaption(i18n("You Missed!"));
99 setBackgroundPixmap(QPixmap(locate("data","kmessedwords/dudeoh.png")));
100 getAnswer=true;
104 #include "answer.moc"