1
/****************************************************************************
3
** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
5
** This file is part of the example classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
31
#include "licensewizard.h"
33
LicenseWizard::LicenseWizard(QWidget *parent)
34
: ComplexWizard(parent)
36
titlePage = new TitlePage(this);
37
evaluatePage = new EvaluatePage(this);
38
registerPage = new RegisterPage(this);
39
detailsPage = new DetailsPage(this);
40
finishPage = new FinishPage(this);
42
setFirstPage(titlePage);
44
setWindowTitle(tr("Complex Wizard"));
48
TitlePage::TitlePage(LicenseWizard *wizard)
49
: LicenseWizardPage(wizard)
51
topLabel = new QLabel(tr("<center><font color=\"blue\" size=\"5\"><b><i>"
52
"Super Product One</i></b></font></center>"));
54
registerRadioButton = new QRadioButton(tr("&Register your copy"));
55
evaluateRadioButton = new QRadioButton(tr("&Evaluate our product"));
56
setFocusProxy(registerRadioButton);
58
QVBoxLayout *layout = new QVBoxLayout;
59
layout->addWidget(topLabel);
60
layout->addSpacing(10);
61
layout->addWidget(registerRadioButton);
62
layout->addWidget(evaluateRadioButton);
63
layout->addStretch(1);
67
void TitlePage::resetPage()
69
registerRadioButton->setChecked(true);
72
WizardPage *TitlePage::nextPage()
74
if (evaluateRadioButton->isChecked())
75
return wizard->evaluatePage;
77
return wizard->registerPage;
80
EvaluatePage::EvaluatePage(LicenseWizard *wizard)
81
: LicenseWizardPage(wizard)
83
topLabel = new QLabel(tr("<center><b>Evaluate Super Product One"
86
nameLabel = new QLabel(tr("&Name:"));
87
nameLineEdit = new QLineEdit;
88
nameLabel->setBuddy(nameLineEdit);
89
setFocusProxy(nameLineEdit);
91
emailLabel = new QLabel(tr("&Email address:"));
92
emailLineEdit = new QLineEdit;
93
emailLabel->setBuddy(emailLineEdit);
95
bottomLabel = new QLabel(tr("Please fill in both fields.\nThis will "
96
"entitle you to a 30-day evaluation."));
98
connect(nameLineEdit, SIGNAL(textChanged(QString)),
99
this, SIGNAL(completeStateChanged()));
100
connect(emailLineEdit, SIGNAL(textChanged(QString)),
101
this, SIGNAL(completeStateChanged()));
103
QGridLayout *layout = new QGridLayout;
104
layout->addWidget(topLabel, 0, 0, 1, 2);
105
layout->setRowMinimumHeight(1, 10);
106
layout->addWidget(nameLabel, 2, 0);
107
layout->addWidget(nameLineEdit, 2, 1);
108
layout->addWidget(emailLabel, 3, 0);
109
layout->addWidget(emailLineEdit, 3, 1);
110
layout->setRowMinimumHeight(4, 10);
111
layout->addWidget(bottomLabel, 5, 0, 1, 2);
112
layout->setRowStretch(6, 1);
116
void EvaluatePage::resetPage()
118
nameLineEdit->clear();
119
emailLineEdit->clear();
122
WizardPage *EvaluatePage::nextPage()
124
return wizard->finishPage;
127
bool EvaluatePage::isComplete()
129
return !nameLineEdit->text().isEmpty() && !emailLineEdit->text().isEmpty();
132
RegisterPage::RegisterPage(LicenseWizard *wizard)
133
: LicenseWizardPage(wizard)
135
topLabel = new QLabel(tr("<center><b>Register your copy of Super Product "
136
"One</b></center>"));
138
nameLabel = new QLabel(tr("&Name:"));
139
nameLineEdit = new QLineEdit;
140
nameLabel->setBuddy(nameLineEdit);
141
setFocusProxy(nameLineEdit);
143
upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
144
upgradeKeyLineEdit = new QLineEdit;
145
upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);
147
bottomLabel = new QLabel(tr("If you have an upgrade key, please fill in "
148
"the appropriate field."));
150
connect(nameLineEdit, SIGNAL(textChanged(QString)),
151
this, SIGNAL(completeStateChanged()));
153
QGridLayout *layout = new QGridLayout;
154
layout->addWidget(topLabel, 0, 0, 1, 2);
155
layout->setRowMinimumHeight(1, 10);
156
layout->addWidget(nameLabel, 2, 0);
157
layout->addWidget(nameLineEdit, 2, 1);
158
layout->addWidget(upgradeKeyLabel, 3, 0);
159
layout->addWidget(upgradeKeyLineEdit, 3, 1);
160
layout->setRowMinimumHeight(4, 10);
161
layout->addWidget(bottomLabel, 5, 0, 1, 2);
162
layout->setRowStretch(6, 1);
166
void RegisterPage::resetPage()
168
nameLineEdit->clear();
169
upgradeKeyLineEdit->clear();
172
WizardPage *RegisterPage::nextPage()
174
if (upgradeKeyLineEdit->text().isEmpty())
175
return wizard->detailsPage;
177
return wizard->finishPage;
180
bool RegisterPage::isComplete()
182
return !nameLineEdit->text().isEmpty();
185
DetailsPage::DetailsPage(LicenseWizard *wizard)
186
: LicenseWizardPage(wizard)
188
topLabel = new QLabel(tr("<center><b>Fill in your details</b></center>"));
190
companyLabel = new QLabel(tr("&Company name:"));
191
companyLineEdit = new QLineEdit;
192
companyLabel->setBuddy(companyLineEdit);
193
setFocusProxy(companyLineEdit);
195
emailLabel = new QLabel(tr("&Email address:"));
196
emailLineEdit = new QLineEdit;
197
emailLabel->setBuddy(emailLineEdit);
199
postalLabel = new QLabel(tr("&Postal address:"));
200
postalLineEdit = new QLineEdit;
201
postalLabel->setBuddy(postalLineEdit);
203
connect(companyLineEdit, SIGNAL(textChanged(QString)),
204
this, SIGNAL(completeStateChanged()));
205
connect(emailLineEdit, SIGNAL(textChanged(QString)),
206
this, SIGNAL(completeStateChanged()));
207
connect(postalLineEdit, SIGNAL(textChanged(QString)),
208
this, SIGNAL(completeStateChanged()));
210
QGridLayout *layout = new QGridLayout;
211
layout->addWidget(topLabel, 0, 0, 1, 2);
212
layout->setRowMinimumHeight(1, 10);
213
layout->addWidget(companyLabel, 2, 0);
214
layout->addWidget(companyLineEdit, 2, 1);
215
layout->addWidget(emailLabel, 3, 0);
216
layout->addWidget(emailLineEdit, 3, 1);
217
layout->addWidget(postalLabel, 4, 0);
218
layout->addWidget(postalLineEdit, 4, 1);
219
layout->setRowStretch(5, 1);
223
void DetailsPage::resetPage()
225
companyLineEdit->clear();
226
emailLineEdit->clear();
227
postalLineEdit->clear();
230
WizardPage *DetailsPage::nextPage()
232
return wizard->finishPage;
235
bool DetailsPage::isComplete()
237
return !companyLineEdit->text().isEmpty()
238
&& !emailLineEdit->text().isEmpty()
239
&& !postalLineEdit->text().isEmpty();
242
FinishPage::FinishPage(LicenseWizard *wizard)
243
: LicenseWizardPage(wizard)
245
topLabel = new QLabel(tr("<center><b>Complete your registration"
248
bottomLabel = new QLabel;
249
bottomLabel->setWordWrap(true);
251
agreeCheckBox = new QCheckBox(tr("I agree to the terms and conditions of "
253
setFocusProxy(agreeCheckBox);
255
connect(agreeCheckBox, SIGNAL(toggled(bool)),
256
this, SIGNAL(completeStateChanged()));
258
QVBoxLayout *layout = new QVBoxLayout;
259
layout->addWidget(topLabel);
260
layout->addSpacing(10);
261
layout->addWidget(bottomLabel);
262
layout->addWidget(agreeCheckBox);
263
layout->addStretch(1);
267
void FinishPage::resetPage()
271
if (wizard->historyPages().contains(wizard->evaluatePage)) {
272
licenseText = tr("Evaluation License Agreement: "
273
"You can use this software for 30 days and make one "
274
"back up, but you are not allowed to distribute it.");
275
} else if (wizard->historyPages().contains(wizard->detailsPage)) {
276
licenseText = tr("First-Time License Agreement: "
277
"You can use this software subject to the license "
278
"you will receive by email.");
280
licenseText = tr("Upgrade License Agreement: "
281
"This software is licensed under the terms of your "
284
bottomLabel->setText(licenseText);
285
agreeCheckBox->setChecked(false);
288
bool FinishPage::isComplete()
290
return agreeCheckBox->isChecked();