GUI: Suggest using project file if one is found.
If we there is project file in the directory to check then ask user if one wants to use the project file instead. If there are multiple project files then just tell there are project files and ask if user wants to continue without using them. Ticket: #2816 (GUI regression: Interrupted checking because of too many #ifdef configurations.)
This commit is contained in:
parent
faa1354445
commit
8bfbf82bdc
|
@ -359,7 +359,64 @@ void MainWindow::CheckFiles()
|
|||
|
||||
void MainWindow::CheckDirectory()
|
||||
{
|
||||
DoCheckFiles(SelectFilesToCheck(QFileDialog::DirectoryOnly));
|
||||
QStringList dir = SelectFilesToCheck(QFileDialog::DirectoryOnly);
|
||||
if (dir.isEmpty())
|
||||
return;
|
||||
|
||||
QDir checkDir(dir[0]);
|
||||
QStringList filters;
|
||||
filters << "*.cppcheck";
|
||||
checkDir.setNameFilters(filters);
|
||||
QStringList projFiles = checkDir.entryList();
|
||||
if (!projFiles.empty())
|
||||
{
|
||||
if (projFiles.size() == 1)
|
||||
{
|
||||
// If one project file found, suggest loading it
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Cppcheck"));
|
||||
const QString msg(tr("Found project file: %1\n\nDo you want to "
|
||||
"load this project file instead?").arg(projFiles[0]));
|
||||
msgBox.setText(msg);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.addButton(QMessageBox::Yes);
|
||||
msgBox.addButton(QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
int dlgResult = msgBox.exec();
|
||||
if (dlgResult == QMessageBox::Yes)
|
||||
{
|
||||
LoadProjectFile(projFiles[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoCheckFiles(dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If multiple project files found inform that there are project
|
||||
// files also available.
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Cppcheck"));
|
||||
const QString msg(tr("Found project files from the directory.\n\n"
|
||||
"Do you want to proceed checking without "
|
||||
"using any of these project files?"));
|
||||
msgBox.setText(msg);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.addButton(QMessageBox::Yes);
|
||||
msgBox.addButton(QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
int dlgResult = msgBox.exec();
|
||||
if (dlgResult == QMessageBox::Yes)
|
||||
{
|
||||
DoCheckFiles(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DoCheckFiles(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result)
|
||||
|
|
Loading…
Reference in New Issue