Bugfix: Help dialog should kill sub help dialogs (e.g. acceleration help dialog)...
[speedfreak] / Client / helpdialog.cpp
1 /*
2  * Help dialog
3  *
4  * @author     Janne Änäkkälä <janne.anakkala@fudeco.com>
5  * @author     Toni Jussila     <toni.jussila@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 "helpdialog.h"
11 #include "ui_helpdialog.h"
12 #include <QDebug>
13
14 /**
15   * Constructor
16   */
17 HelpDialog::HelpDialog(QWidget *parent) :
18     QDialog(parent),
19     ui(new Ui::HelpDialog)
20 {
21     ui->setupUi(this);
22     helpResultsDialog = NULL;
23     helpAccelerationDialog = NULL;
24     helpRoutingDialog = NULL;
25     creditsDialog = NULL;
26     helpSettingsDialog = NULL;
27 }
28
29 /**
30   * Destructor
31   */
32 HelpDialog::~HelpDialog()
33 {
34     delete ui;
35 }
36
37 /**
38   *
39   */
40 void HelpDialog::changeEvent(QEvent *e)
41 {
42     QDialog::changeEvent(e);
43     switch (e->type()) {
44     case QEvent::LanguageChange:
45         ui->retranslateUi(this);
46         break;
47     default:
48         break;
49     }
50 }
51
52 /**
53   *
54   */
55 void HelpDialog::on_pushButtonHelpResults_clicked()
56 {
57     if(!helpResultsDialog)
58     {
59         helpResultsDialog = new HelpResultsDialog;
60     }
61     connect(helpResultsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialogs()));
62     helpResultsDialog->show();
63 }
64
65 /**
66   *
67   */
68 void HelpDialog::on_pushButtonHelpAccelerate_clicked()
69 {
70     if(!helpAccelerationDialog)
71     {
72         helpAccelerationDialog = new HelpAccelerationDialog;
73     }
74     connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialogs()));
75     helpAccelerationDialog->show();
76 }
77
78 /**
79   *
80   */
81 void HelpDialog::on_pushButtonHelpRoute_clicked()
82 {
83     if(!helpRoutingDialog)
84     {
85         helpRoutingDialog = new HelpRoutingDialog;
86     }
87     connect(helpRoutingDialog, SIGNAL(rejected()), this, SLOT(killHelpDialogs()));
88     helpRoutingDialog->show();
89 }
90
91 /**
92   *
93   */
94 void HelpDialog::on_pushButtonCredits_clicked()
95 {
96     if(!creditsDialog)
97     {
98         creditsDialog = new CreditsDialog;
99     }
100     connect(creditsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialogs()));
101     creditsDialog->show();
102 }
103
104 /**
105   *
106   */
107 void HelpDialog::on_pushButtonHelpSettings_clicked()
108 {
109     if(!helpSettingsDialog)
110     {
111         helpSettingsDialog = new HelpSettingsDialog;
112     }
113     connect(helpSettingsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialogs()));
114     helpSettingsDialog->show();
115 }
116
117 /**
118   * This slot function called when ever dialog rejected.
119   */
120 void HelpDialog::killHelpDialogs()
121 {
122     if(helpResultsDialog)
123     {
124         qDebug() << "__Help kill: helpResultsDialog";
125         delete helpResultsDialog;
126         helpResultsDialog = NULL;
127     }
128     if(helpAccelerationDialog)
129     {
130         qDebug() << "__Help kill: helpAccelerationDialog";
131         delete helpAccelerationDialog;
132         helpAccelerationDialog = NULL;
133     }
134     if(helpRoutingDialog)
135     {
136         qDebug() << "__Help kill: helpRoutingDialog";
137         delete helpRoutingDialog;
138         helpRoutingDialog = NULL;
139     }
140     if(creditsDialog)
141     {
142         qDebug() << "__Help kill: creditsDialog";
143         delete creditsDialog;
144         creditsDialog = NULL;
145     }
146
147     if(helpSettingsDialog)
148     {
149         qDebug() << "__Help kill: helpSettingsDialog";
150         delete helpSettingsDialog;
151         helpSettingsDialog = NULL;
152     }
153 }