-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplexwizard.cc
More file actions
191 lines (165 loc) · 5.62 KB
/
complexwizard.cc
File metadata and controls
191 lines (165 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/****************************************************************************
**
** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
**
** This file is part of the documentation of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://www.trolltech.com/products/qt/opensource.html
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://www.trolltech.com/products/qt/licensing.html or contact the
** sales department at sales@trolltech.com.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <QtGui>
#include <QTimer>
#include "complexwizard.h"
#include "installer.h"
ComplexWizard::ComplexWizard(QWidget *parent)
: QWidget(parent)
{
cancelButton = new QPushButton(tr("Cancel"));
backButton = new QPushButton(tr("< &Back"));
nextButton = new QPushButton(tr("Next >"));
connect(cancelButton, SIGNAL(clicked()), qApp, SLOT(closeAllWindows()));
connect(backButton, SIGNAL(clicked()), this, SLOT(backButtonClicked()));
// nextButton is connected in switchPage
buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(cancelButton);
buttonLayout->addSpacing(5);
buttonLayout->addWidget(backButton);
buttonLayout->addWidget(nextButton);
// nice generic titles for widgets that don't provide 'em
pageTitle = new QLabel (tr ("<b>iPodLinux Installer</b>"));
pageDesc = new QLabel (tr ("Follow the directions on this page and click Next."));
pageDesc->setAlignment (Qt::AlignLeft);
pageDesc->setIndent (20);
toptextLayout = new QVBoxLayout;
toptextLayout->addWidget (pageTitle);
toptextLayout->addSpacing (10);
toptextLayout->addWidget (pageDesc);
icon = new QLabel;
icon->setPixmap (QPixmap (":/icon.png"));
topbarLayout = new QHBoxLayout;
topbarLayout->addLayout (toptextLayout);
topbarLayout->addStretch (1);
topbarLayout->addWidget (icon);
topbar = new QFrame;
topbar->setLayout (topbarLayout);
topbar->setFrameShape (QFrame::StyledPanel);
topbar->setFrameShadow (QFrame::Raised);
topbar->setLineWidth (2);
topbar->setMaximumHeight (90);
QPalette framePal = topbar->palette();
framePal.setColor (QPalette::Background, QColor (240, 240, 240));
topbar->setPalette (framePal);
mainLayout = new QVBoxLayout;
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
}
void ComplexWizard::setBackEnabled (bool enabled)
{
backButton->setEnabled (enabled);
}
void ComplexWizard::setFirstPage(WizardPage *page)
{
page->resetPage();
history.append(page);
switchPage(0);
}
void ComplexWizard::backButtonClicked()
{
WizardPage *oldPage = history.takeLast();
oldPage->resetPage();
setInfoText (history_titles.takeLast(), history_descriptions.takeLast());
switchPage(oldPage);
}
void ComplexWizard::nextButtonClicked()
{
changePage (history.last()->nextPage());
}
void ComplexWizard::changePage (WizardPage *newPage)
{
history_titles.append (pageTitle->text());
history_descriptions.append (pageDesc->text());
WizardPage *oldPage = history.last();
newPage->resetPage();
history.append(newPage);
switchPage(oldPage);
}
void ComplexWizard::completeStateChanged()
{
WizardPage *currentPage = history.last();
nextButton->setEnabled(currentPage->isComplete());
if (InstallAutomatically && currentPage->isComplete())
QTimer::singleShot (100, nextButton, SLOT(animateClick()));
}
void ComplexWizard::switchPage(WizardPage *oldPage)
{
if (oldPage) {
oldPage->hide();
mainLayout->removeWidget(oldPage);
disconnect(oldPage, SIGNAL(completeStateChanged()),
this, SLOT(completeStateChanged()));
}
mainLayout->removeWidget(topbar);
topbar->hide();
WizardPage *newPage = history.last();
if (history.size() == 1) {
mainLayout->insertWidget(0, newPage);
topbar->hide();
} else {
mainLayout->insertWidget(0, newPage);
mainLayout->insertWidget(0, topbar);
topbar->show();
}
newPage->show();
newPage->setFocus();
connect(newPage, SIGNAL(completeStateChanged()),
this, SLOT(completeStateChanged()));
backButton->setEnabled(history.size() != 1);
nextButton->setDefault(true);
nextButton->setEnabled(false);
if (newPage->isLastPage()) {
disconnect (nextButton, SIGNAL(clicked()), qApp, 0);
disconnect (nextButton, SIGNAL(clicked()), this, 0);
connect(nextButton, SIGNAL(clicked()), qApp, SLOT(closeAllWindows()));
nextButton->setText (tr ("&Finish"));
} else {
disconnect (nextButton, SIGNAL(clicked()), qApp, 0);
disconnect (nextButton, SIGNAL(clicked()), this, 0);
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextButtonClicked()));
nextButton->setText (tr ("Next >"));
}
completeStateChanged();
}
WizardPage::WizardPage(QWidget *parent)
: QWidget(parent)
{
hide();
}
void WizardPage::resetPage()
{
}
WizardPage *WizardPage::nextPage()
{
return 0;
}
bool WizardPage::isLastPage()
{
return false;
}
bool WizardPage::isComplete()
{
return true;
}