diff options
Diffstat (limited to 'src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp')
-rw-r--r-- | src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp index f65a8a6931..dd3e59d2c4 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp @@ -47,7 +47,7 @@ ClangStaticAnalyzerConfigWidget::ClangStaticAnalyzerConfigWidget( chooser->setExpectedKind(Utils::PathChooser::ExistingCommand); chooser->setHistoryCompleter(QLatin1String("ClangStaticAnalyzer.ClangCommand.History")); chooser->setPromptDialogTitle(tr("Clang Command")); - const auto validator = [chooser](Utils::FancyLineEdit *edit, QString *errorMessage) { + const auto validator = [chooser, this](Utils::FancyLineEdit *edit, QString *errorMessage) { const QString currentFilePath = chooser->fileName().toString(); Utils::PathChooser pc; Utils::PathChooser *helperPathChooser; @@ -58,8 +58,17 @@ ClangStaticAnalyzerConfigWidget::ClangStaticAnalyzerConfigWidget( } else { helperPathChooser = chooser; } - return chooser->defaultValidationFunction()(helperPathChooser->lineEdit(), errorMessage) + + const bool isExecutableValid = + chooser->defaultValidationFunction()(helperPathChooser->lineEdit(), errorMessage) && isClangExecutableUsable(helperPathChooser->fileName().toString(), errorMessage); + + const ClangExecutableVersion detectedVersion = isExecutableValid + ? clangExecutableVersion(helperPathChooser->fileName().toString()) + : ClangExecutableVersion(); + updateDetectedVersionLabel(isExecutableValid, detectedVersion); + + return isExecutableValid; }; chooser->setValidationFunction(validator); bool clangExeIsSet; @@ -90,5 +99,29 @@ ClangStaticAnalyzerConfigWidget::~ClangStaticAnalyzerConfigWidget() delete m_ui; } +void ClangStaticAnalyzerConfigWidget::updateDetectedVersionLabel( + bool isExecutableValid, + const ClangExecutableVersion &providedVersion) +{ + QLabel &label = *m_ui->detectedVersionLabel; + + if (isExecutableValid) { + if (providedVersion.isValid()) { + if (providedVersion.isSupportedVersion()) { + label.setText(tr("Version: %1, supported.") + .arg(providedVersion.toString())); + } else { + label.setText(tr("Version: %1, unsupported (supported version is %2).") + .arg(providedVersion.toString()) + .arg(ClangExecutableVersion::supportedVersionAsString())); + } + } else { + label.setText(tr("Version: Could not determine version.")); + } + } else { + label.setText(tr("Version: Set valid executable first.")); + } +} + } // namespace Internal } // namespace ClangStaticAnalyzer |