-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetupAssistant.cpp
More file actions
96 lines (82 loc) · 4.18 KB
/
Copy pathSetupAssistant.cpp
File metadata and controls
96 lines (82 loc) · 4.18 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
#include "SetupAssistant.h"
#include <QtCore/QFile>
#include <QtCore/QTextStream>
#include <QtCore/QDir>
#include <QtGui/QMessageBox>
#include "mainwindow.h"
SetupAssistant::SetupAssistant(QWidget *parent) : QWidget(parent) {
desktopWidget = new QDesktopWidget;
welcomeView = new WelcomeView(this);
licenseReader = new LicenseReader(this);
downloadSetup = new DownloadSetup(this);
finishSetup = new FinishSetup(this);
stateMachine = new QStateMachine;
welcomeState = new QState;
licenseReaderState = new QState;
downloadSetupState = new QState;
finishState = new QState;
welcomeState->assignProperty(welcomeView,"pos",QVariant(QPointF(0,0)));
welcomeState->assignProperty(licenseReader,"pos",QVariant(QPointF(810,0)));
welcomeState->assignProperty(downloadSetup,"pos",QVariant(QPointF(1620,0)));
welcomeState->assignProperty(finishSetup,"pos",QVariant(QPointF(2430,0)));
licenseReaderState->assignProperty(welcomeView,"pos",QVariant(QPointF(-810,0)));
licenseReaderState->assignProperty(licenseReader,"pos",QVariant(QPointF(0,0)));
licenseReaderState->assignProperty(downloadSetup,"pos",QVariant(QPointF(810,0)));
licenseReaderState->assignProperty(finishSetup,"pos",QVariant(QPointF(1620,0)));
downloadSetupState->assignProperty(welcomeView,"pos",QVariant(QPointF(-1620,0)));
downloadSetupState->assignProperty(licenseReader,"pos",QVariant(QPointF(-810,0)));
downloadSetupState->assignProperty(downloadSetup,"pos",QVariant(QPointF(0,0)));
downloadSetupState->assignProperty(finishSetup,"pos",QVariant(QPointF(810,0)));
finishState->assignProperty(welcomeView,"pos",QVariant(QPointF(-2430,0)));
finishState->assignProperty(licenseReader,"pos",QVariant(QPointF(-1620,0)));
finishState->assignProperty(downloadSetup,"pos",QVariant(QPointF(-810,0)));
finishState->assignProperty(finishSetup,"pos",QVariant(QPointF(0,0)));
transition1 = welcomeState->addTransition(welcomeView, SIGNAL(nextClicked()), licenseReaderState);
transition2 = licenseReaderState->addTransition(licenseReader, SIGNAL(accepted()), downloadSetupState);
transition3 = downloadSetupState->addTransition(downloadSetup, SIGNAL(setupFinished()), finishState);
transition1->addAnimation(new QPropertyAnimation(welcomeView,"pos"));
transition1->addAnimation(new QPropertyAnimation(licenseReader,"pos"));
transition2->addAnimation(new QPropertyAnimation(licenseReader,"pos"));
transition2->addAnimation(new QPropertyAnimation(downloadSetup,"pos"));
transition3->addAnimation(new QPropertyAnimation(downloadSetup,"pos"));
transition3->addAnimation(new QPropertyAnimation(finishSetup,"pos"));
stateMachine->addState(welcomeState);
stateMachine->addState(licenseReaderState);
stateMachine->addState(downloadSetupState);
stateMachine->addState(finishState);
stateMachine->setInitialState(welcomeState);
stateMachine->start();
setFixedSize(810,610);
setWindowTitle(tr("WebRender Setup Assistant"));
connect(licenseReader, SIGNAL(rejected()),this,SLOT(close()));
connect(finishSetup, SIGNAL(setupFinished()), this, SLOT(saveSettings()));
connect(downloadSetup, SIGNAL(setupFinished()), finishSetup, SLOT(getReady()));
}
void SetupAssistant::showAnimated()
{
this->show();
this->move((desktopWidget->availableGeometry(this).width()/2)- width()/2,(desktopWidget->availableGeometry(this).height()/2)- height()/2);
welcomeView->startAnimation();
}
void SetupAssistant::saveSettings()
{
QDir homeDir = QDir::home();
homeDir.mkdir(".WebRender");
if(!homeDir.cd(".WebRender")) {
QMessageBox::critical(this,tr("Error"),tr("WebRender is unable to create the configuration directory. Check the permissions and run setup again."));
return;
}
QFile file(homeDir.absoluteFilePath("download.path"));
QFile versionFile(homeDir.absoluteFilePath("version.info"));
if(!file.open(QIODevice::WriteOnly) || !versionFile.open(QIODevice::WriteOnly)) {
QMessageBox::critical(this,tr("Error"),tr("WebRender is unable to save the configuration settings. Check the permissions and run setup again."));
return;
}
QTextStream stream(&file);
QTextStream versionFileStream(&versionFile);
stream<<downloadSetup->getDownloadPath();
versionFileStream<<QString("RC 3");
close();
(new MainWindow)->show();
emit setupFinished();
}