diff --git a/src/plugins/cppcheck/cppcheckoptions.cpp b/src/plugins/cppcheck/cppcheckoptions.cpp index 735557daf23..d6c7b0196c0 100644 --- a/src/plugins/cppcheck/cppcheckoptions.cpp +++ b/src/plugins/cppcheck/cppcheckoptions.cpp @@ -39,9 +39,10 @@ #include #include -#include #include +using namespace Utils; + namespace Cppcheck { namespace Internal { @@ -102,7 +103,7 @@ OptionsWidget::OptionsWidget(QWidget *parent) void OptionsWidget::load(const CppcheckOptions &options) { - m_binary->setPath(options.binary); + m_binary->setFilePath(options.binary); m_customArguments->setText(options.customArguments); m_ignorePatterns->setText(options.ignoredPatterns); m_warning->setChecked(options.warning); @@ -121,7 +122,7 @@ void OptionsWidget::load(const CppcheckOptions &options) void OptionsWidget::save(CppcheckOptions &options) const { - options.binary = m_binary->filePath().toString(); + options.binary = m_binary->filePath(); options.customArguments = m_customArguments->text(); options.ignoredPatterns = m_ignorePatterns->text(); options.warning = m_warning->isChecked(); @@ -149,14 +150,13 @@ CppcheckOptionsPage::CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &tr setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); CppcheckOptions options; - if (Utils::HostOsInfo::isAnyUnixHost()) { + if (HostOsInfo::isAnyUnixHost()) { options.binary = "cppcheck"; } else { - QString programFiles = QDir::fromNativeSeparators( - QString::fromLocal8Bit(qgetenv("PROGRAMFILES"))); + FilePath programFiles = FilePath::fromUserInput(qEnvironmentVariable("PROGRAMFILES")); if (programFiles.isEmpty()) programFiles = "C:/Program Files"; - options.binary = programFiles + "/Cppcheck/cppcheck.exe"; + options.binary = programFiles / "Cppcheck/cppcheck.exe"; } load(options); @@ -190,7 +190,7 @@ void CppcheckOptionsPage::save(const CppcheckOptions &options) const QSettings *s = Core::ICore::settings(); QTC_ASSERT(s, return); s->beginGroup(Constants::SETTINGS_ID); - s->setValue(Constants::SETTINGS_BINARY, options.binary); + s->setValue(Constants::SETTINGS_BINARY, options.binary.toString()); s->setValue(Constants::SETTINGS_CUSTOM_ARGUMENTS, options.customArguments); s->setValue(Constants::SETTINGS_IGNORE_PATTERNS, options.ignoredPatterns); s->setValue(Constants::SETTINGS_WARNING, options.warning); @@ -213,8 +213,8 @@ void CppcheckOptionsPage::load(CppcheckOptions &options) const QSettings *s = Core::ICore::settings(); QTC_ASSERT(s, return); s->beginGroup(Constants::SETTINGS_ID); - options.binary = s->value(Constants::SETTINGS_BINARY, - options.binary).toString(); + options.binary = FilePath::fromString(s->value(Constants::SETTINGS_BINARY, + options.binary.toString()).toString()); options.customArguments = s->value(Constants::SETTINGS_CUSTOM_ARGUMENTS, options.customArguments).toString(); options.ignoredPatterns = s->value(Constants::SETTINGS_IGNORE_PATTERNS, diff --git a/src/plugins/cppcheck/cppcheckoptions.h b/src/plugins/cppcheck/cppcheckoptions.h index 639ffca6c94..4d4ca83cb65 100644 --- a/src/plugins/cppcheck/cppcheckoptions.h +++ b/src/plugins/cppcheck/cppcheckoptions.h @@ -26,6 +26,7 @@ #pragma once #include +#include #include #include @@ -36,9 +37,7 @@ class QLineEdit; class QCheckBox; QT_END_NAMESPACE -namespace Utils { -class PathChooser; -} +namespace Utils { class PathChooser; } namespace Cppcheck { namespace Internal { @@ -50,7 +49,7 @@ class OptionsWidget; class CppcheckOptions final { public: - QString binary; + Utils::FilePath binary; bool warning = true; bool style = true; diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index 2f6cffb1eb2..261ccb3b638 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -74,7 +74,7 @@ CppcheckRunner::~CppcheckRunner() m_queueTimer.stop(); } -void CppcheckRunner::reconfigure(const QString &binary, const QString &arguments) +void CppcheckRunner::reconfigure(const FilePath &binary, const QString &arguments) { m_binary = binary; m_arguments = arguments; @@ -157,7 +157,7 @@ void CppcheckRunner::checkQueued() else m_queue.begin().value() = files; - m_process->setCommand(CommandLine(FilePath::fromString(m_binary), arguments, CommandLine::Raw)); + m_process->setCommand(CommandLine(m_binary, arguments, CommandLine::Raw)); m_process->start(); } diff --git a/src/plugins/cppcheck/cppcheckrunner.h b/src/plugins/cppcheck/cppcheckrunner.h index 83aca95192f..d49a9016dea 100644 --- a/src/plugins/cppcheck/cppcheckrunner.h +++ b/src/plugins/cppcheck/cppcheckrunner.h @@ -45,7 +45,7 @@ public: explicit CppcheckRunner(CppcheckTool &tool); ~CppcheckRunner() override; - void reconfigure(const QString &binary, const QString &arguments); + void reconfigure(const Utils::FilePath &binary, const QString &arguments); void addToQueue(const Utils::FilePaths &files, const QString &additionalArguments = {}); void removeFromQueue(const Utils::FilePaths &files); @@ -63,7 +63,7 @@ private: CppcheckTool &m_tool; Utils::QtcProcess *m_process = nullptr; - QString m_binary; + Utils::FilePath m_binary; QString m_arguments; QHash m_queue; Utils::FilePaths m_currentFiles;