ui: Fixed path checking in project setup wizzard
This commit is contained in:
@@ -225,24 +225,24 @@ void ProjectSettings::setProjectName(const std::string& name)
|
||||
m_projectName = name;
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getProjectFileLocation() const
|
||||
FilePath ProjectSettings::getProjectFileLocation() const
|
||||
{
|
||||
if (m_projectFileLocation.size())
|
||||
if (!m_projectFileLocation.empty())
|
||||
{
|
||||
return m_projectFileLocation;
|
||||
}
|
||||
|
||||
return getFilePath().parentDirectory().str();
|
||||
return getFilePath().parentDirectory();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectFileLocation(const std::string& location)
|
||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
{
|
||||
m_projectFileLocation = location;
|
||||
}
|
||||
|
||||
void ProjectSettings::makePathsAbsolute(std::vector<FilePath>& paths) const
|
||||
{
|
||||
FilePath basePath = getFilePath().parentDirectory();
|
||||
FilePath basePath = getProjectFileLocation();
|
||||
for (size_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
if (!paths[i].isAbsolute())
|
||||
|
||||
@@ -67,14 +67,14 @@ public:
|
||||
std::string getProjectName() const;
|
||||
void setProjectName(const std::string& name);
|
||||
|
||||
std::string getProjectFileLocation() const;
|
||||
void setProjectFileLocation(const std::string& location);
|
||||
FilePath getProjectFileLocation() const;
|
||||
void setProjectFileLocation(const FilePath& location);
|
||||
|
||||
private:
|
||||
void makePathsAbsolute(std::vector<FilePath>& paths) const;
|
||||
|
||||
std::string m_projectName;
|
||||
std::string m_projectFileLocation;
|
||||
FilePath m_projectFileLocation;
|
||||
|
||||
static std::shared_ptr<ProjectSettings> s_instance;
|
||||
};
|
||||
|
||||
@@ -517,6 +517,13 @@ void QtProjectWizzard::headerPathsCDBDone()
|
||||
|
||||
void QtProjectWizzard::showFiles(QtProjectWizzardContent* content)
|
||||
{
|
||||
QWidget* widget = m_windowStack.getTopWindow();
|
||||
if (widget)
|
||||
{
|
||||
QtProjectWizzardWindow* win = dynamic_cast<QtProjectWizzardWindow*>(widget);
|
||||
win->content()->save();
|
||||
}
|
||||
|
||||
QtProjectWizzardWindow* window = createPopupWithContent<QtProjectWizzardContentSourceList>();
|
||||
dynamic_cast<QtProjectWizzardContentSourceList*>(window->content())->showFilesFromContent(content);
|
||||
}
|
||||
@@ -591,7 +598,7 @@ void QtProjectWizzard::showSummary()
|
||||
|
||||
void QtProjectWizzard::createProject()
|
||||
{
|
||||
std::string path = m_settings.getProjectFileLocation() + "/" + m_settings.getProjectName() + ".coatiproject";
|
||||
std::string path = m_settings.getProjectFileLocation().str() + "/" + m_settings.getProjectName() + ".coatiproject";
|
||||
|
||||
m_settings.save(path);
|
||||
|
||||
|
||||
@@ -129,7 +129,5 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
|
||||
|
||||
void QtProjectWizzardContent::buttonClicked()
|
||||
{
|
||||
save();
|
||||
|
||||
emit filesButtonClicked(this);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void QtProjectWizzardContentData::populateForm(QGridLayout* layout, int& row)
|
||||
void QtProjectWizzardContentData::load()
|
||||
{
|
||||
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
|
||||
|
||||
if (m_settings->getLanguage().length() > 0)
|
||||
{
|
||||
|
||||
@@ -97,24 +97,25 @@ bool QtProjectWizzardContentPaths::check()
|
||||
QString missingPaths;
|
||||
for (FilePath f : m_list->getList())
|
||||
{
|
||||
f = f.expandEnvironmentVariables();
|
||||
|
||||
if (!f.exists())
|
||||
FilePath fi = f.expandEnvironmentVariables();
|
||||
if (!fi.isAbsolute())
|
||||
{
|
||||
if (!missingPaths.isEmpty())
|
||||
{
|
||||
missingPaths.append("\n");
|
||||
}
|
||||
fi = FilePath(m_settings->getProjectFileLocation()).concat(fi);
|
||||
}
|
||||
|
||||
if (!fi.exists())
|
||||
{
|
||||
missingPaths.append("\n");
|
||||
missingPaths.append(f.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (!missingPaths.isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("These paths do not exist:\n" + missingPaths);
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
if (!missingPaths.isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("These paths do not exist:" + missingPaths);
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -267,8 +268,7 @@ QStringList QtProjectWizzardContentPathsSource::getSourceFileNames(bool headersO
|
||||
utility::append(extensions, m_settings->getHeaderExtensions());
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
|
||||
|
||||
FilePath projectPath = FilePath(m_settings->getProjectFileLocation());
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
|
||||
QStringList list;
|
||||
for (const FileInfo& info : fileInfos)
|
||||
|
||||
@@ -84,9 +84,10 @@ void QtProjectWizzardWindow::handleNext()
|
||||
emit next();
|
||||
}
|
||||
|
||||
m_content->save();
|
||||
|
||||
if (m_content->check())
|
||||
{
|
||||
m_content->save();
|
||||
emit next();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user