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