-
Notifications
You must be signed in to change notification settings - Fork 0
/
newprojectwizard.cpp
68 lines (53 loc) · 1.69 KB
/
newprojectwizard.cpp
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
#include "newprojectwizard.h"
#include "config.h"
#include "version.h"
#include <QVBoxLayout>
#include <QLayoutItem>
#include <QDebug>
#include <QDir>
#include <QDialog>
NewProjectWizard::NewProjectWizard(QWidget *parent) : QWizard(parent)
{
setWindowTitle(QString("New %1 Project").arg(shortName));
addPage(new IntroPage);
addPage(new ProjectPage);
}
void NewProjectWizard::accept()
{
QString projectName = field("projectName").toString();
QString projectPath = field("projectPath").toString();
QDir project(projectPath);
QDialog::accept();
if (!project.mkdir(projectName))
{
qDebug() << "Could not create project directory, exiting";
return;
}
project.cd(projectName);
Config cfg{project.filePath("create.cfg")};
cfg.set("meta.version", appVersion);
cfg.set("frames.location", "frames");
cfg.save();
emit projectCreated(project.path());
}
IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent)
{
setTitle("Introduction");
label = new QLabel(QString("Welcome to %1. This wizard will help "
"you create a new project.").arg(fullName), this);
label->setWordWrap(true);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
setLayout(layout);
}
ProjectPage::ProjectPage(QWidget *parent) : QWizardPage(parent)
{
projectName = new QLineEdit(this);
filePicker = new FilePicker("", FilePicker::Directory, this);
form = new QFormLayout;
form->addRow("Project Name", projectName);
form->addRow("Project Location", filePicker);
registerField("projectName", projectName);
registerField("projectPath", filePicker->getPathTextField());
setLayout(form);
}