17 #include <QFileDialog>
20 #include <QPushButton>
21 #include <QVBoxLayout>
26 , m_projectNameEdit(0)
32 , m_valid_projectName(true)
33 , m_valid_projectPath(true)
36 setMinimumSize(480, 280);
37 setWindowTitle(mode ==
CREATE ?
"New project" :
"Save project");
39 QLabel* nameLabel =
new QLabel(
"Project name:");
46 QLabel* parentDirLabel =
new QLabel(mode ==
CREATE ?
"Create in:" :
"Save in:");
48 m_workDirEdit->setText(QDir::toNativeSeparators(QDir::homePath()));
62 connect(
m_cancelButton, &QPushButton::clicked,
this, &NewProjectDialog::reject);
64 QGroupBox* projectGroup =
new QGroupBox(
"Project name and location");
66 QGridLayout* layout =
new QGridLayout;
67 layout->addWidget(nameLabel, 0, 0);
69 layout->addWidget(parentDirLabel, 1, 0);
73 projectGroup->setLayout(layout);
75 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
76 buttonsLayout->addStretch(1);
80 QVBoxLayout* mainLayout =
new QVBoxLayout;
81 mainLayout->addWidget(projectGroup);
83 mainLayout->addStretch();
84 mainLayout->addLayout(buttonsLayout);
86 setLayout(mainLayout);
111 QString result =
projectDir + QString(
"/") + projectFile;
118 QString dirname = QFileDialog::getExistingDirectory(
120 QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);
122 if (!dirname.isEmpty()) {
157 palette.setColor(QPalette::Text, Qt::black);
159 palette.setColor(QPalette::Text, Qt::darkRed);
171 palette.setColor(QPalette::Text, Qt::black);
173 palette.setColor(QPalette::Text, Qt::darkRed);
188 +
"' does not exist. </font>");
192 m_warningLabel->setText(
"<font color='darkRed'> Please specify project name. </font>");
195 +
"' already exists. </font>");
205 m_warningLabel->setText(
"<font color='darkRed'> Can't make subdirectory' '"
void checkIfProjectPathIsValid(const QString &dirname)
Checks whether ProjectPath is valid and sets warning state accordingly.
NewProjectDialog(QWidget *parent, Mode mode, const QString &workingDirectory="", const QString &projectName="")
QLineEdit * m_workDirEdit
void checkIfProjectNameIsValid(const QString &projectName)
Checks whether project name is valid and sets warning state accordingly.
QLineEdit * m_projectNameEdit
void setValidProjectName(bool status)
sets flags whether project name is valid and then updates color of LineEdit and warning message
QPushButton * m_cancelButton
void updateWarningStatus()
updates warning label depending on validity of project name and path
QPushButton * m_createButton
QString getWorkingDirectory() const
QPushButton * m_browseButton
void createProjectDir()
creates directory with selected ProjectName in selected ProjectPath
void setWorkingDirectory(const QString &text)
void setValidProjectPath(bool status)
sets flags wether project path is valid and then updates color of LineEdit and warning message
void setProjectName(const QString &text)
QString getProjectFileName() const
void onBrowseDirectory()
calls directory selection dialog
QString getProjectName() const
static QString projectFileExtension()
bool exists(const QString &fileName)
Returns true if file exists.
QString projectName(const QString &projectFileName)
Returns project name deduced from project file name.
QString projectDir(const QString &projectFileName)
Returns project directory deduced from project file name.
Defines class NewProjectDialog.
Defines class ProjectDocument.