1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2018 Sergey Morozov 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include <coreplugin/dialogs/ioptionspage.h> 29 30 #include <QCoreApplication> 31 #include <QPointer> 32 #include <QWidget> 33 34 QT_BEGIN_NAMESPACE 35 class QLineEdit; 36 class QCheckBox; 37 QT_END_NAMESPACE 38 39 namespace Utils { 40 class PathChooser; 41 } 42 43 namespace Cppcheck { 44 namespace Internal { 45 46 class CppcheckTool; 47 class CppcheckTrigger; 48 class OptionsWidget; 49 50 class CppcheckOptions final 51 { 52 public: 53 QString binary; 54 55 bool warning = true; 56 bool style = true; 57 bool performance = true; 58 bool portability = true; 59 bool information = true; 60 bool unusedFunction = false; 61 bool missingInclude = false; 62 bool inconclusive = false; 63 bool forceDefines = false; 64 65 QString customArguments; 66 QString ignoredPatterns; 67 bool showOutput = false; 68 bool addIncludePaths = false; 69 bool guessArguments = true; 70 }; 71 72 class OptionsWidget final : public QWidget 73 { 74 Q_DECLARE_TR_FUNCTIONS(CppcheckOptionsPage) 75 public: 76 explicit OptionsWidget(QWidget *parent = nullptr); 77 void load(const CppcheckOptions &options); 78 void save(CppcheckOptions &options) const; 79 80 private: 81 Utils::PathChooser *m_binary = nullptr; 82 QLineEdit *m_customArguments = nullptr; 83 QLineEdit *m_ignorePatterns = nullptr; 84 QCheckBox *m_warning = nullptr; 85 QCheckBox *m_style = nullptr; 86 QCheckBox *m_performance = nullptr; 87 QCheckBox *m_portability = nullptr; 88 QCheckBox *m_information = nullptr; 89 QCheckBox *m_unusedFunction = nullptr; 90 QCheckBox *m_missingInclude = nullptr; 91 QCheckBox *m_inconclusive = nullptr; 92 QCheckBox *m_forceDefines = nullptr; 93 QCheckBox *m_showOutput = nullptr; 94 QCheckBox *m_addIncludePaths = nullptr; 95 QCheckBox *m_guessArguments = nullptr; 96 }; 97 98 class CppcheckOptionsPage final : public Core::IOptionsPage 99 { 100 Q_OBJECT 101 public: 102 explicit CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &trigger); 103 104 QWidget *widget() final; 105 void apply() final; 106 void finish() final; 107 108 private: 109 void save(const CppcheckOptions &options) const; 110 void load(CppcheckOptions &options) const; 111 112 CppcheckTool &m_tool; 113 CppcheckTrigger &m_trigger; 114 QPointer<OptionsWidget> m_widget; 115 }; 116 117 } // namespace Internal 118 } // namespace Cppcheck 119