Merge branch 'uiFixing/ResultDialog'
[speedfreak] / Client / welcomedialog.cpp
1 /*
2  * Welcome dialog
3  *
4  * @author     Toni Jussila <toni.jussila@fudeco.com>
5  * @author     Rikhard Kuutti <rikhard.kuutti@fudeco.com>
6  * @copyright  (c) 2010 Speed Freak team
7  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
8  */
9
10 #include "welcomedialog.h"
11 #include "ui_welcomedialog.h"
12 #include "instructionsdialog.h"
13
14 #include <QSettings>
15
16 WelcomeDialog::WelcomeDialog(QWidget *parent) :
17     QDialog(parent),
18     ui(new Ui::WelcomeDialog)
19 {
20     ui->setupUi(this);
21     this->setWindowTitle(" ");
22     movie = new QMovie("start.gif");
23     ui->labelWelcome->setMovie(movie);
24     movie->start();
25     connect(movie,SIGNAL(frameChanged(int)),this,SLOT(stop(int)));
26 }
27
28 WelcomeDialog::~WelcomeDialog()
29 {
30     delete ui;
31     movie->stop();
32     delete movie;
33 }
34
35 void WelcomeDialog::changeEvent(QEvent *e)
36 {
37     QDialog::changeEvent(e);
38     switch (e->type()) {
39     case QEvent::LanguageChange:
40         ui->retranslateUi(this);
41         break;
42     default:
43         break;
44     }
45 }
46
47 void WelcomeDialog::stop(int currentFrame)
48 {
49     if (currentFrame == 21)
50     {
51         movie->stop();
52         this->close();
53
54         // Show instructionsDialog if this is
55         // the first time the application is run
56         QSettings settings;
57         bool firstRunGone = settings.value("firstRunGone").toBool();
58         if (!firstRunGone) {
59             // show instructions
60             InstructionsDialog *instructionsDialog = new InstructionsDialog;
61             instructionsDialog->show();
62             settings.setValue("firstRunGone", true);
63         }
64     }
65 }