~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to examples/dialogs/complexwizard/licensewizard.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the example classes of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include <QtGui>
 
30
 
 
31
#include "licensewizard.h"
 
32
 
 
33
LicenseWizard::LicenseWizard(QWidget *parent)
 
34
    : ComplexWizard(parent)
 
35
{
 
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);
 
41
 
 
42
    setFirstPage(titlePage);
 
43
 
 
44
    setWindowTitle(tr("Complex Wizard"));
 
45
    resize(480, 200);
 
46
}
 
47
 
 
48
TitlePage::TitlePage(LicenseWizard *wizard)
 
49
    : LicenseWizardPage(wizard)
 
50
{
 
51
    topLabel = new QLabel(tr("<center><font color=\"blue\" size=\"5\"><b><i>"
 
52
                             "Super Product One</i></b></font></center>"));
 
53
 
 
54
    registerRadioButton = new QRadioButton(tr("&Register your copy"));
 
55
    evaluateRadioButton = new QRadioButton(tr("&Evaluate our product"));
 
56
    setFocusProxy(registerRadioButton);
 
57
 
 
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);
 
64
    setLayout(layout);
 
65
}
 
66
 
 
67
void TitlePage::resetPage()
 
68
{
 
69
    registerRadioButton->setChecked(true);
 
70
}
 
71
 
 
72
WizardPage *TitlePage::nextPage()
 
73
{
 
74
    if (evaluateRadioButton->isChecked())
 
75
        return wizard->evaluatePage;
 
76
    else
 
77
        return wizard->registerPage;
 
78
}
 
79
 
 
80
EvaluatePage::EvaluatePage(LicenseWizard *wizard)
 
81
    : LicenseWizardPage(wizard)
 
82
{
 
83
    topLabel = new QLabel(tr("<center><b>Evaluate Super Product One"
 
84
                             "</b></center>"));
 
85
 
 
86
    nameLabel = new QLabel(tr("&Name:"));
 
87
    nameLineEdit = new QLineEdit;
 
88
    nameLabel->setBuddy(nameLineEdit);
 
89
    setFocusProxy(nameLineEdit);
 
90
 
 
91
    emailLabel = new QLabel(tr("&Email address:"));
 
92
    emailLineEdit = new QLineEdit;
 
93
    emailLabel->setBuddy(emailLineEdit);
 
94
 
 
95
    bottomLabel = new QLabel(tr("Please fill in both fields.\nThis will "
 
96
                                "entitle you to a 30-day evaluation."));
 
97
 
 
98
    connect(nameLineEdit, SIGNAL(textChanged(QString)),
 
99
            this, SIGNAL(completeStateChanged()));
 
100
    connect(emailLineEdit, SIGNAL(textChanged(QString)),
 
101
            this, SIGNAL(completeStateChanged()));
 
102
 
 
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);
 
113
    setLayout(layout);
 
114
}
 
115
 
 
116
void EvaluatePage::resetPage()
 
117
{
 
118
    nameLineEdit->clear();
 
119
    emailLineEdit->clear();
 
120
}
 
121
 
 
122
WizardPage *EvaluatePage::nextPage()
 
123
{
 
124
    return wizard->finishPage;
 
125
}
 
126
 
 
127
bool EvaluatePage::isComplete()
 
128
{
 
129
    return !nameLineEdit->text().isEmpty() && !emailLineEdit->text().isEmpty();
 
130
}
 
131
 
 
132
RegisterPage::RegisterPage(LicenseWizard *wizard)
 
133
    : LicenseWizardPage(wizard)
 
134
{
 
135
    topLabel = new QLabel(tr("<center><b>Register your copy of Super Product "
 
136
                             "One</b></center>"));
 
137
 
 
138
    nameLabel = new QLabel(tr("&Name:"));
 
139
    nameLineEdit = new QLineEdit;
 
140
    nameLabel->setBuddy(nameLineEdit);
 
141
    setFocusProxy(nameLineEdit);
 
142
 
 
143
    upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
 
144
    upgradeKeyLineEdit = new QLineEdit;
 
145
    upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);
 
146
 
 
147
    bottomLabel = new QLabel(tr("If you have an upgrade key, please fill in "
 
148
                                "the appropriate field."));
 
149
 
 
150
    connect(nameLineEdit, SIGNAL(textChanged(QString)),
 
151
            this, SIGNAL(completeStateChanged()));
 
152
 
 
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);
 
163
    setLayout(layout);
 
164
}
 
165
 
 
166
void RegisterPage::resetPage()
 
167
{
 
168
    nameLineEdit->clear();
 
169
    upgradeKeyLineEdit->clear();
 
170
}
 
171
 
 
172
WizardPage *RegisterPage::nextPage()
 
173
{
 
174
    if (upgradeKeyLineEdit->text().isEmpty())
 
175
        return wizard->detailsPage;
 
176
    else
 
177
        return wizard->finishPage;
 
178
}
 
179
 
 
180
bool RegisterPage::isComplete()
 
181
{
 
182
    return !nameLineEdit->text().isEmpty();
 
183
}
 
184
 
 
185
DetailsPage::DetailsPage(LicenseWizard *wizard)
 
186
    : LicenseWizardPage(wizard)
 
187
{
 
188
    topLabel = new QLabel(tr("<center><b>Fill in your details</b></center>"));
 
189
 
 
190
    companyLabel = new QLabel(tr("&Company name:"));
 
191
    companyLineEdit = new QLineEdit;
 
192
    companyLabel->setBuddy(companyLineEdit);
 
193
    setFocusProxy(companyLineEdit);
 
194
 
 
195
    emailLabel = new QLabel(tr("&Email address:"));
 
196
    emailLineEdit = new QLineEdit;
 
197
    emailLabel->setBuddy(emailLineEdit);
 
198
 
 
199
    postalLabel = new QLabel(tr("&Postal address:"));
 
200
    postalLineEdit = new QLineEdit;
 
201
    postalLabel->setBuddy(postalLineEdit);
 
202
 
 
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()));
 
209
 
 
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);
 
220
    setLayout(layout);
 
221
}
 
222
 
 
223
void DetailsPage::resetPage()
 
224
{
 
225
    companyLineEdit->clear();
 
226
    emailLineEdit->clear();
 
227
    postalLineEdit->clear();
 
228
}
 
229
 
 
230
WizardPage *DetailsPage::nextPage()
 
231
{
 
232
    return wizard->finishPage;
 
233
}
 
234
 
 
235
bool DetailsPage::isComplete()
 
236
{
 
237
    return !companyLineEdit->text().isEmpty()
 
238
           && !emailLineEdit->text().isEmpty()
 
239
           && !postalLineEdit->text().isEmpty();
 
240
}
 
241
 
 
242
FinishPage::FinishPage(LicenseWizard *wizard)
 
243
    : LicenseWizardPage(wizard)
 
244
{
 
245
    topLabel = new QLabel(tr("<center><b>Complete your registration"
 
246
                             "</b></center>"));
 
247
 
 
248
    bottomLabel = new QLabel;
 
249
    bottomLabel->setWordWrap(true);
 
250
 
 
251
    agreeCheckBox = new QCheckBox(tr("I agree to the terms and conditions of "
 
252
                                     "the license"));
 
253
    setFocusProxy(agreeCheckBox);
 
254
 
 
255
    connect(agreeCheckBox, SIGNAL(toggled(bool)),
 
256
            this, SIGNAL(completeStateChanged()));
 
257
 
 
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);
 
264
    setLayout(layout);
 
265
}
 
266
 
 
267
void FinishPage::resetPage()
 
268
{
 
269
    QString licenseText;
 
270
 
 
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.");
 
279
    } else {
 
280
        licenseText = tr("Upgrade License Agreement: "
 
281
                         "This software is licensed under the terms of your "
 
282
                         "current license.");
 
283
    }
 
284
    bottomLabel->setText(licenseText);
 
285
    agreeCheckBox->setChecked(false);
 
286
}
 
287
 
 
288
bool FinishPage::isComplete()
 
289
{
 
290
    return agreeCheckBox->isChecked();
 
291
}