2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2023-01-28 10:16:34 +01:00
|
|
|
* Copyright (C) 2007-2023 Cppcheck team.
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-09-27 17:08:31 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SETTINGSDIALOG_H
|
|
|
|
#define SETTINGSDIALOG_H
|
|
|
|
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QDialog>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <Qt>
|
2022-02-02 16:17:28 +01:00
|
|
|
|
2010-07-17 21:34:07 +02:00
|
|
|
class QSettings;
|
|
|
|
class QWidget;
|
|
|
|
class ApplicationList;
|
2011-01-09 23:21:51 +01:00
|
|
|
class TranslationHandler;
|
2019-06-23 19:04:53 +02:00
|
|
|
class CodeEditorStyle;
|
2022-03-19 19:54:20 +01:00
|
|
|
class QCheckBox;
|
|
|
|
namespace Ui {
|
|
|
|
class Settings;
|
|
|
|
}
|
2010-07-17 21:34:07 +02:00
|
|
|
|
2009-07-17 10:49:01 +02:00
|
|
|
/// @addtogroup GUI
|
|
|
|
/// @{
|
2009-03-01 08:38:21 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Settings dialog
|
|
|
|
*
|
|
|
|
*/
|
2011-10-13 20:53:06 +02:00
|
|
|
class SettingsDialog : public QDialog {
|
2009-05-23 12:37:30 +02:00
|
|
|
Q_OBJECT
|
2009-03-01 08:38:21 +01:00
|
|
|
public:
|
2011-05-13 09:25:52 +02:00
|
|
|
SettingsDialog(ApplicationList *list,
|
2011-01-09 23:21:51 +01:00
|
|
|
TranslationHandler *translator,
|
2022-10-30 10:59:43 +01:00
|
|
|
bool premium,
|
2019-06-30 21:39:22 +02:00
|
|
|
QWidget *parent = nullptr);
|
2018-05-01 09:35:53 +02:00
|
|
|
SettingsDialog(const SettingsDialog &) = delete;
|
2022-03-13 20:07:58 +01:00
|
|
|
~SettingsDialog() override;
|
2018-05-01 09:35:53 +02:00
|
|
|
SettingsDialog &operator=(const SettingsDialog &) = delete;
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Save all values to QSettings
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void saveSettingValues() const;
|
2009-05-23 12:37:30 +02:00
|
|
|
|
2009-06-03 20:18:22 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mShowFullPath
|
|
|
|
*
|
|
|
|
* @return should full path of errors be shown in the tree
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool showFullPath() const;
|
2009-06-03 20:18:22 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mSaveFullPath
|
|
|
|
*
|
|
|
|
* @return should full path of files be saved when creating a report
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool saveFullPath() const;
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2009-06-09 09:51:27 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mNoErrorsMessage
|
|
|
|
*
|
|
|
|
* @return Should "no errors message" be hidden
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool showNoErrorsMessage() const;
|
2009-06-09 09:51:27 +02:00
|
|
|
|
2012-10-27 11:16:52 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mShowIdColumn
|
|
|
|
*
|
|
|
|
* @return Should error id column be displayed
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool showErrorId() const;
|
2012-10-27 11:16:52 +02:00
|
|
|
|
2015-10-15 11:59:17 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mEnableInconclusive
|
|
|
|
*
|
|
|
|
* @return Should inconclusive column be displayed
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool showInconclusive() const;
|
2015-10-15 11:59:17 +02:00
|
|
|
|
2009-06-03 20:18:22 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Get checkbox value for mSaveAllErrors
|
|
|
|
*
|
|
|
|
* @return should all errors be saved to report
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
bool saveAllErrors() const;
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2009-05-23 12:37:30 +02:00
|
|
|
protected slots:
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Slot for clicking OK.
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void ok();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2020-09-12 10:35:00 +02:00
|
|
|
/** @brief Slot for validating input value in @c editPythonPath */
|
|
|
|
void validateEditPythonPath();
|
|
|
|
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Slot for adding a new application to the list
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void addApplication();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Slot for deleting an application from the list
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void removeApplication();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Slot for modifying an application in the list
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void editApplication();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Slot for making the selected application as the default (first)
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void defaultApplication();
|
2010-11-26 21:35:45 +01:00
|
|
|
|
2017-08-14 00:23:21 +02:00
|
|
|
/** @brief Slot for browsing for the python binary */
|
|
|
|
void browsePythonPath();
|
|
|
|
|
2017-08-10 15:47:20 +02:00
|
|
|
/** @brief Slot for browsing for the clang binary */
|
|
|
|
void browseClangPath();
|
2018-01-20 14:13:09 +01:00
|
|
|
|
2022-12-31 16:08:23 +01:00
|
|
|
/**
|
|
|
|
* @brief Browse for MISRA file
|
|
|
|
*/
|
|
|
|
void browseMisraFile();
|
|
|
|
|
2019-06-23 19:04:53 +02:00
|
|
|
/**
|
|
|
|
* @brief Set Code Editor Style to Default
|
|
|
|
*/
|
|
|
|
void setCodeEditorStyleDefault();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Edit Custom Code Editor Style
|
|
|
|
*/
|
|
|
|
void editCodeEditorStyle();
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
protected:
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Clear all applications from the list and re insert them from mTempApplications
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void populateApplicationList();
|
2009-05-24 11:08:51 +02:00
|
|
|
|
2009-03-22 14:15:16 +01:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Load saved values
|
|
|
|
* Loads dialog size and column widths.
|
|
|
|
*
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void loadSettings();
|
2009-03-22 13:32:07 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Save settings
|
|
|
|
* Save dialog size and column widths.
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void saveSettings() const;
|
2009-03-22 13:32:07 +01:00
|
|
|
|
|
|
|
/**
|
2011-05-13 09:25:52 +02:00
|
|
|
* @brief Save a single checkboxes value
|
|
|
|
*
|
|
|
|
* @param settings Pointer to Settings.
|
|
|
|
* @param box checkbox to save
|
|
|
|
* @param name name for QSettings to store the value
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
static void saveCheckboxValue(QSettings *settings, QCheckBox *box, const QString &name);
|
2009-03-22 13:32:07 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Convert bool to Qt::CheckState
|
|
|
|
*
|
|
|
|
* @param yes value to convert
|
|
|
|
* @return value converted to Qt::CheckState
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
static Qt::CheckState boolToCheckState(bool yes);
|
2009-03-22 13:32:07 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Converts Qt::CheckState to bool
|
|
|
|
*
|
|
|
|
* @param state Qt::CheckState to convert
|
|
|
|
* @return converted value
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
static bool checkStateToBool(Qt::CheckState state);
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2011-01-09 23:21:51 +01:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Populate the translations list.
|
|
|
|
*/
|
2017-07-28 13:43:49 +02:00
|
|
|
void initTranslationsList();
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2019-06-23 19:04:53 +02:00
|
|
|
/**
|
|
|
|
* @brief Current Code Editor Style
|
|
|
|
*/
|
|
|
|
CodeEditorStyle *mCurrentStyle;
|
|
|
|
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief List of applications user has specified
|
|
|
|
*
|
|
|
|
*/
|
2009-07-02 10:32:29 +02:00
|
|
|
ApplicationList *mApplications;
|
2009-05-24 11:08:51 +02:00
|
|
|
|
2009-06-02 22:32:58 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Temporary list of applications
|
|
|
|
* This will be copied to actual list of applications (mApplications)
|
|
|
|
* when user clicks ok.
|
|
|
|
*/
|
2009-07-02 10:32:29 +02:00
|
|
|
ApplicationList *mTempApplications;
|
2009-07-02 18:14:12 +02:00
|
|
|
|
2011-01-09 23:21:51 +01:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief List of translations.
|
|
|
|
*
|
|
|
|
*/
|
2011-01-09 23:21:51 +01:00
|
|
|
TranslationHandler *mTranslator;
|
|
|
|
|
2009-07-02 18:14:12 +02:00
|
|
|
/**
|
2021-08-07 20:51:18 +02:00
|
|
|
* @brief Dialog from UI designer
|
|
|
|
*
|
|
|
|
*/
|
2022-03-19 19:54:20 +01:00
|
|
|
Ui::Settings *mUI;
|
2009-03-01 08:38:21 +01:00
|
|
|
private:
|
2019-06-23 19:04:53 +02:00
|
|
|
void manageStyleControls();
|
|
|
|
|
2018-06-18 14:19:14 +02:00
|
|
|
static const int mLangCodeRole = Qt::UserRole;
|
2022-10-30 10:59:43 +01:00
|
|
|
|
|
|
|
bool mPremium;
|
2009-03-01 08:38:21 +01:00
|
|
|
};
|
2009-07-17 10:49:01 +02:00
|
|
|
/// @}
|
2009-03-01 08:38:21 +01:00
|
|
|
#endif // SETTINGSDIALOG_H
|