-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCImportProjectWizard.cpp
More file actions
122 lines (103 loc) · 3.1 KB
/
CImportProjectWizard.cpp
File metadata and controls
122 lines (103 loc) · 3.1 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
#include "CImportProjectWizard.h"
#include "ui_CImportProjectWizard.h"
#include <QDebug>
#include <QFileDialog>
#include <QFileInfo>
#include <QDir>
#include <QDirIterator>
#include <QPropertyAnimation>
#include <CProjectManager.h>
#include <CArchiver.h>
#include <UtilsQt.h>
CImportProjectWizard::CImportProjectWizard(QWidget *parent) :
QWidget(parent),
ui(new Ui::CImportProjectWizard)
{
ui->setupUi(this);
connect(ui->acceptButton, SIGNAL(clicked(bool)), this, SLOT(clickOnValidate()));
connect(ui->pathExplorerButton, SIGNAL(clicked(bool)), this, SLOT(clickOnPathExplorer()));
connect(ui->archiveExplorerButton, SIGNAL(clicked(bool)), this, SLOT(clickOnArchiveExplorer()));
this->AnimatedOpening();
}
CImportProjectWizard::~CImportProjectWizard()
{
delete ui;
}
void CImportProjectWizard::ClearError()
{
ui->errorLabel->setText("");
}
void CImportProjectWizard::AnimatedOpening()
{
this->setMaximumWidth(0);
this->setVisible(true);
QPropertyAnimation *animation = new QPropertyAnimation(this, "maximumWidth");
animation->setDuration(350);
animation->setStartValue(0);
animation->setEndValue(800);
animation->start();
}
bool CImportProjectWizard::CheckMandatoryFields()
{
QString text = "";
int numberMissingFields = 0;
if(ui->pathLineEdit->text().isEmpty())
{
text += " Le chemin du projet \r\n";
numberMissingFields++;
}
if(ui->archivePathLineEdit->text().isEmpty())
{
text += " Le chemin de l'archive \r\n";
numberMissingFields++;
}
if(numberMissingFields > 0)
{
if(numberMissingFields > 1)
{
text = "Veuillez remplir les champs suivants : \r\n" + text;
}
else
{
text = "Veuillez remplir le champ suivant : \r\n" + text;
}
ui->errorLabel->setText(text);
return false;
}
else
{
return true;
}
}
void CImportProjectWizard::clickOnValidate()
{
// Test mandatory fields
if(!this->CheckMandatoryFields())
{
return;
}
// Create all directories
QString archivePath = ui->archivePathLineEdit->text();
QString projectPath = ui->pathLineEdit->text();
CArchiver archiver(this);
archiver.ExtractArchive(archivePath, projectPath);
//emit importProjectFile
}
void CImportProjectWizard::clickOnPathExplorer()
{
QString dialogPath = ui->pathLineEdit->text() == "" ? QDir::homePath() : ui->pathLineEdit->text();
QString projectPath = QFileDialog::getExistingDirectory(this, "Sélectionner le chemin vers lequel importer le scénario", dialogPath, QFileDialog::ShowDirsOnly);
if (projectPath != "")
{
ui->pathLineEdit->setText(projectPath);
}
}
void CImportProjectWizard::clickOnArchiveExplorer()
{
QString dialogPath = ui->archivePathLineEdit->text() == "" ? QDir::homePath() : ui->archivePathLineEdit->text();
QString archiveFilePath = QFileDialog::getOpenFileName(this, "Sélectionnez l'archive LudoMuse", dialogPath, "*.lm");
if (archiveFilePath != "")
{
ui->archivePathLineEdit->setText(archiveFilePath);
}
}