GUI: Fix enabling project closing action.
Project closing action was not enabled when the project file was opened from the checked directory. Also update the window caption to contain project file name that was opened from the checked directory.
This commit is contained in:
parent
ff4ebbede3
commit
b6bef44f61
|
@ -101,6 +101,7 @@ MainWindow::MainWindow() :
|
||||||
mUI.mActionClearResults->setEnabled(false);
|
mUI.mActionClearResults->setEnabled(false);
|
||||||
mUI.mActionSave->setEnabled(false);
|
mUI.mActionSave->setEnabled(false);
|
||||||
mUI.mActionRecheck->setEnabled(false);
|
mUI.mActionRecheck->setEnabled(false);
|
||||||
|
EnableProjectActions(false);
|
||||||
|
|
||||||
QStringList args = QCoreApplication::arguments();
|
QStringList args = QCoreApplication::arguments();
|
||||||
//Remove the application itself
|
//Remove the application itself
|
||||||
|
@ -233,12 +234,10 @@ void MainWindow::DoCheckFiles(const QStringList &files)
|
||||||
EnableCheckButtons(false);
|
EnableCheckButtons(false);
|
||||||
mUI.mActionSettings->setEnabled(false);
|
mUI.mActionSettings->setEnabled(false);
|
||||||
mUI.mActionOpenXML->setEnabled(false);
|
mUI.mActionOpenXML->setEnabled(false);
|
||||||
mUI.mActionNewProjectFile->setEnabled(false);
|
|
||||||
mUI.mActionOpenProjectFile->setEnabled(false);
|
|
||||||
|
|
||||||
mUI.mResults->SetCheckDirectory(checkPath);
|
mUI.mResults->SetCheckDirectory(checkPath);
|
||||||
|
|
||||||
Settings checkSettings = GetCppcheckSettings();
|
Settings checkSettings = GetCppcheckSettings();
|
||||||
|
EnableProjectActions(false);
|
||||||
mThread->Check(checkSettings, false);
|
mThread->Check(checkSettings, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,12 +312,14 @@ bool MainWindow::GetCheckProject()
|
||||||
// Format project filename (directory name + .cppcheck) and load
|
// Format project filename (directory name + .cppcheck) and load
|
||||||
// the project file if it is found.
|
// the project file if it is found.
|
||||||
QStringList parts = mCurrentDirectory.split("/");
|
QStringList parts = mCurrentDirectory.split("/");
|
||||||
QString projfile = mCurrentDirectory + "/" + parts[parts.count() - 1] + ".cppcheck";
|
const QString filename = parts[parts.count() - 1] + ".cppcheck";;
|
||||||
|
const QString projfile = mCurrentDirectory + "/" + filename;
|
||||||
if (QFile::exists(projfile))
|
if (QFile::exists(projfile))
|
||||||
{
|
{
|
||||||
qDebug() << "Opening project file: " << projfile;
|
qDebug() << "Opening project file: " << projfile;
|
||||||
mProject = new Project();
|
mProject = new Project();
|
||||||
mProject->SetFilename(projfile);
|
mProject->SetFilename(projfile);
|
||||||
|
FormatAndSetTitle(tr("Project: ") + QString(" ") + filename);
|
||||||
return mProject->Open();
|
return mProject->Open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,8 +386,7 @@ void MainWindow::CheckDone()
|
||||||
EnableCheckButtons(true);
|
EnableCheckButtons(true);
|
||||||
mUI.mActionSettings->setEnabled(true);
|
mUI.mActionSettings->setEnabled(true);
|
||||||
mUI.mActionOpenXML->setEnabled(true);
|
mUI.mActionOpenXML->setEnabled(true);
|
||||||
mUI.mActionNewProjectFile->setEnabled(false);
|
EnableProjectActions(true);
|
||||||
mUI.mActionOpenProjectFile->setEnabled(false);
|
|
||||||
|
|
||||||
if (mUI.mResults->HasResults())
|
if (mUI.mResults->HasResults())
|
||||||
{
|
{
|
||||||
|
@ -702,7 +702,7 @@ void MainWindow::OpenProjectFile()
|
||||||
{
|
{
|
||||||
QFileInfo inf(filepath);
|
QFileInfo inf(filepath);
|
||||||
const QString filename = inf.fileName();
|
const QString filename = inf.fileName();
|
||||||
FormatAndSetTitle(tr("Project:") + QString(" ") + filename);
|
FormatAndSetTitle(tr("Project: ") + QString(" ") + filename);
|
||||||
|
|
||||||
mUI.mActionCloseProjectFile->setEnabled(true);
|
mUI.mActionCloseProjectFile->setEnabled(true);
|
||||||
mUI.mActionEditProjectFile->setEnabled(true);
|
mUI.mActionEditProjectFile->setEnabled(true);
|
||||||
|
@ -745,11 +745,10 @@ void MainWindow::NewProjectFile()
|
||||||
|
|
||||||
if (!filepath.isEmpty())
|
if (!filepath.isEmpty())
|
||||||
{
|
{
|
||||||
mUI.mActionCloseProjectFile->setEnabled(true);
|
EnableProjectActions(true);
|
||||||
mUI.mActionEditProjectFile->setEnabled(true);
|
|
||||||
QFileInfo inf(filepath);
|
QFileInfo inf(filepath);
|
||||||
const QString filename = inf.fileName();
|
const QString filename = inf.fileName();
|
||||||
FormatAndSetTitle(tr("Project:") + QString(" ") + filename);
|
FormatAndSetTitle(tr("Project: ") + QString(" ") + filename);
|
||||||
|
|
||||||
delete mProject;
|
delete mProject;
|
||||||
mProject = new Project(filepath, this);
|
mProject = new Project(filepath, this);
|
||||||
|
@ -762,8 +761,7 @@ void MainWindow::CloseProjectFile()
|
||||||
{
|
{
|
||||||
delete mProject;
|
delete mProject;
|
||||||
mProject = NULL;
|
mProject = NULL;
|
||||||
mUI.mActionCloseProjectFile->setEnabled(false);
|
EnableProjectActions(false);
|
||||||
mUI.mActionEditProjectFile->setEnabled(false);
|
|
||||||
FormatAndSetTitle();
|
FormatAndSetTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,3 +797,9 @@ void MainWindow::Log(const QString &logline)
|
||||||
mLogView->AppendLine(logline);
|
mLogView->AppendLine(logline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::EnableProjectActions(bool enable)
|
||||||
|
{
|
||||||
|
mUI.mActionCloseProjectFile->setEnabled(enable);
|
||||||
|
mUI.mActionEditProjectFile->setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
|
@ -305,6 +305,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
void OpenHtmlHelpContents();
|
void OpenHtmlHelpContents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable or disable project file actions.
|
||||||
|
* @param enable If true then actions are enabled.
|
||||||
|
*/
|
||||||
|
void EnableProjectActions(bool enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Program settings
|
* @brief Program settings
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue