19 #include <QFileDialog>
22 #include <QPushButton>
23 #include <QVBoxLayout>
28 , m_projectNameEdit(nullptr)
29 , m_workDirEdit(nullptr)
30 , m_browseButton(nullptr)
31 , m_warningLabel(nullptr)
32 , m_cancelButton(nullptr)
33 , m_createButton(nullptr)
34 , m_valid_projectName(true)
35 , m_valid_projectPath(true)
38 setMinimumSize(480, 280);
39 setWindowTitle(
"Save project");
41 auto* nameLabel =
new QLabel(
"Project name:");
48 auto* parentDirLabel =
new QLabel(
"Save in:");
50 m_workDirEdit->setText(QDir::toNativeSeparators(QDir::homePath()));
64 connect(
m_cancelButton, &QPushButton::clicked,
this, &NewProjectDialog::reject);
66 auto* projectGroup =
new QGroupBox(
"Project name and location");
68 auto* layout =
new QGridLayout;
69 layout->addWidget(nameLabel, 0, 0);
71 layout->addWidget(parentDirLabel, 1, 0);
75 projectGroup->setLayout(layout);
77 auto* buttonsLayout =
new QHBoxLayout;
78 buttonsLayout->addStretch(1);
82 auto* mainLayout =
new QVBoxLayout;
83 mainLayout->addWidget(projectGroup);
85 mainLayout->addStretch();
86 mainLayout->addLayout(buttonsLayout);
88 setLayout(mainLayout);
107 return projectDir + QString(
"/") + projectFile;
113 QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly;
116 options |= QFileDialog::DontUseNativeDialog;
118 const QString dirname =
119 QFileDialog::getExistingDirectory(
this,
"Select directory",
getWorkingDirectory(), options);
121 if (dirname.isEmpty())
132 if (QFile::exists(dirname)) {
180 +
"' does not exist. </font>");
184 m_warningLabel->setText(
"<font color='darkRed'> Please specify project name. </font>");
187 +
"' already exists. </font>");
197 m_warningLabel->setText(
"<font color='darkRed'> Can't make subdirectory' '"
ApplicationSettings * appSettings
global pointer to the instance
Defines class ApplicationSettings.
Defines class NewProjectDialog.
Defines class ProjectDocument.
Defines namespace GUI::Project::Utils.
bool useNativeFileDialog() const
void checkIfProjectPathIsValid(const QString &dirname)
Checks whether ProjectPath is valid and sets warning state accordingly. Corresponding directory shoul...
QLineEdit * m_workDirEdit
void checkIfProjectNameIsValid(const QString &projectName)
Checks whether project name is valid and sets warning state accordingly. There should not be the dire...
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
QString getProjectFileName() const
void onBrowseDirectory()
calls directory selection dialog
QString getProjectName() const
NewProjectDialog(QWidget *parent, const QString &workingDirectory="", const QString &projectName="")
constexpr const char * projectFileExtension
QString projectDir(const QString &projectFileName)
Returns project directory deduced from project file name.
QString projectName(const QString &projectFileName)
Returns project name deduced from project file name.