annotate examples/dialogs/trivialwizard/trivialwizard.d @ 126:4e461c92ccad

fix and enable trivialwizard
author mandel
date Fri, 05 Jun 2009 15:27:23 +0000
parents 884f947e6f74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
1 /****************************************************************************
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
2 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
4 ** Contact: Qt Software Information (qt-info@nokia.com)
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
5 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
6 ** This file is part of the examples of the Qt Toolkit.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
7 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
8 ** $QT_BEGIN_LICENSE:LGPL$
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
9 ** Commercial Usage
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
10 ** Licensees holding valid Qt Commercial licenses may use this file in
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
11 ** accordance with the Qt Commercial License Agreement provided with the
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
12 ** Software or, alternatively, in accordance with the terms contained in
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
13 ** a written agreement between you and Nokia.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
14 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
15 ** GNU Lesser General Public License Usage
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
16 ** Alternatively, this file may be used under the terms of the GNU Lesser
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
17 ** General Public License version 2.1 as published by the Free Software
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
18 ** Foundation and appearing in the file LICENSE.LGPL included in the
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
19 ** packaging of this file. Please review the following information to
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
20 ** ensure the GNU Lesser General Public License version 2.1 requirements
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
22 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
23 ** In addition, as a special exception, Nokia gives you certain
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
24 ** additional rights. These rights are described in the Nokia Qt LGPL
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
26 ** package.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
27 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
28 ** GNU General Public License Usage
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
29 ** Alternatively, this file may be used under the terms of the GNU
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
30 ** General Public License version 3.0 as published by the Free Software
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
31 ** Foundation and appearing in the file LICENSE.GPL included in the
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
32 ** packaging of this file. Please review the following information to
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
33 ** ensure the GNU General Public License version 3.0 requirements will be
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
34 ** met: http://www.gnu.org/copyleft/gpl.html.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
35 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
36 ** If you are unsure which license is appropriate for your use, please
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
37 ** contact the sales department at qt-sales@nokia.com.
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
38 ** $QT_END_LICENSE$
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
39 **
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
40 ****************************************************************************/
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
41 module trivialwizard;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
42
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
43
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
44 import qt.core.QTranslator;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
45 import qt.core.QLocale;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
46 import qt.core.QLibraryInfo;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
47 import qt.gui.QGridLayout;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
48 import qt.gui.QWizardPage;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
49 import qt.gui.QLabel;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
50 import qt.gui.QVBoxLayout;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
51 import qt.gui.QLineEdit;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
52
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
53 QWizardPage createIntroPage()
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
54 {
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
55 QWizardPage page = new QWizardPage;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
56 page.setTitle("Introduction");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
57
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
58 QLabel label = new QLabel("This wizard will help you register your copy of Super Product Two.");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
59 label.setWordWrap(true);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
60
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
61 QVBoxLayout layout = new QVBoxLayout;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
62 layout.addWidget(label);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
63 page.setLayout(layout);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
64
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
65 return page;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
66 }
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
67
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
68 QWizardPage createRegistrationPage()
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
69 {
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
70 QWizardPage page = new QWizardPage;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
71 page.setTitle("Registration");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
72 page.setSubTitle("Please fill both fields.");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
73
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
74 QLabel nameLabel = new QLabel("Name:");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
75 QLineEdit nameLineEdit = new QLineEdit;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
76
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
77 QLabel emailLabel = new QLabel("Email address:");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
78 QLineEdit emailLineEdit = new QLineEdit;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
79
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
80 QGridLayout layout = new QGridLayout;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
81 layout.addWidget(nameLabel, 0, 0);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
82 layout.addWidget(nameLineEdit, 0, 1);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
83 layout.addWidget(emailLabel, 1, 0);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
84 layout.addWidget(emailLineEdit, 1, 1);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
85 page.setLayout(layout);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
86
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
87 return page;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
88 }
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
89
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
90 QWizardPage createConclusionPage()
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
91 {
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
92 QWizardPage page = new QWizardPage;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
93 page.setTitle("Conclusion");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
94
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
95 QLabel label = new QLabel("You are now successfully registered. Have a nice day!");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
96 label.setWordWrap(true);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
97
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
98 QVBoxLayout layout = new QVBoxLayout;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
99 layout.addWidget(label);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
100 page.setLayout(layout);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
101
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
102 return page;
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
103 }
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
104
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
105 int main(string[] args)
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
106 {
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
107 scope app = new QApplication(args);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
108
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
109 string translatorFileName = "qt_";
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
110 translatorFileName ~= QLocale.system().name();
126
4e461c92ccad fix and enable trivialwizard
mandel
parents: 121
diff changeset
111 scope translator = new QTranslator(app);
121
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
112 if (translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)))
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
113 app.installTranslator(translator);
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
114
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
115
126
4e461c92ccad fix and enable trivialwizard
mandel
parents: 121
diff changeset
116 scope wizard = new QWizard;
121
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
117 wizard.addPage(createIntroPage());
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
118 wizard.addPage(createRegistrationPage());
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
119 wizard.addPage(createConclusionPage());
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
120
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
121 wizard.setWindowTitle("Trivial Wizard");
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
122 wizard.show();
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
123
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
124 return app.exec();
884f947e6f74 add trivialwizard example
mandel
parents:
diff changeset
125 }