GUI: Check the project after creation.
Earlier the GUI (project) went into some weird state after creating a new project. The project could not be checked in any discoverable way. This commit fixes the above bug by automatically checking the new project after the project dialog is closed. I think this is what most users expect to happen.
This commit is contained in:
parent
6e78b51071
commit
1f4e1e0ffe
|
@ -856,8 +856,16 @@ void MainWindow::LoadProjectFile(const QString &filePath)
|
|||
mUI.mActionEditProjectFile->setEnabled(true);
|
||||
delete mProject;
|
||||
mProject = new Project(filePath, this);
|
||||
mProject->Open();
|
||||
const QString rootpath = mProject->GetProjectFile()->GetRootPath();
|
||||
CheckProject(mProject);
|
||||
}
|
||||
|
||||
void MainWindow::CheckProject(Project *project)
|
||||
{
|
||||
if (!project->IsOpen())
|
||||
project->Open();
|
||||
|
||||
QFileInfo inf(project->Filename());
|
||||
const QString rootpath = project->GetProjectFile()->GetRootPath();
|
||||
|
||||
// If the root path is not given or is not "current dir", use project
|
||||
// file's location directory as root path
|
||||
|
@ -866,7 +874,7 @@ void MainWindow::LoadProjectFile(const QString &filePath)
|
|||
else
|
||||
mCurrentDirectory = rootpath;
|
||||
|
||||
QStringList paths = mProject->GetProjectFile()->GetCheckPaths();
|
||||
QStringList paths = project->GetProjectFile()->GetCheckPaths();
|
||||
|
||||
// If paths not given then check the root path (which may be the project
|
||||
// file's location, see above). This is to keep the compatibility with
|
||||
|
@ -911,6 +919,7 @@ void MainWindow::NewProjectFile()
|
|||
mProject->Edit();
|
||||
}
|
||||
AddProjectMRU(filepath);
|
||||
CheckProject(mProject);
|
||||
}
|
||||
|
||||
void MainWindow::CloseProjectFile()
|
||||
|
|
|
@ -169,6 +169,12 @@ public slots:
|
|||
*/
|
||||
void Save();
|
||||
|
||||
/**
|
||||
* @brief Check the project.
|
||||
* @param project Pointer to the project to check.
|
||||
*/
|
||||
void CheckProject(Project *project);
|
||||
|
||||
/**
|
||||
* @brief Slot to create new project file..
|
||||
*
|
||||
|
|
|
@ -47,11 +47,21 @@ Project::~Project()
|
|||
delete mPFile;
|
||||
}
|
||||
|
||||
QString Project::Filename() const
|
||||
{
|
||||
return mFilename;
|
||||
}
|
||||
|
||||
void Project::SetFilename(const QString &filename)
|
||||
{
|
||||
mFilename = filename;
|
||||
}
|
||||
|
||||
bool Project::IsOpen() const
|
||||
{
|
||||
return mPFile != NULL;
|
||||
}
|
||||
|
||||
bool Project::Open()
|
||||
{
|
||||
mPFile = new ProjectFile(mFilename, this);
|
||||
|
|
|
@ -41,12 +41,25 @@ public:
|
|||
Project(const QString &filename, QWidget *parent = 0);
|
||||
~Project();
|
||||
|
||||
/**
|
||||
* @brief Return the filename of the project.
|
||||
* @return Project's filename.
|
||||
*/
|
||||
QString Filename() const;
|
||||
|
||||
/**
|
||||
* @brief Set filename for the project file.
|
||||
* @param filename Filename.
|
||||
*/
|
||||
void SetFilename(const QString &filename);
|
||||
|
||||
/**
|
||||
* @brief Is the project open?
|
||||
* The project is considered to be open if it has an opened project file.
|
||||
* @return true if the project is open, false otherwise.
|
||||
*/
|
||||
bool IsOpen() const;
|
||||
|
||||
/**
|
||||
* @brief Open existing project file.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue