cppcheck/gui/settingsdialog.h

237 lines
5.2 KiB
C
Raw Normal View History

/*
* Cppcheck - A tool for static C/C++ code analysis
2018-03-31 20:59:09 +02:00
* Copyright (C) 2007-2018 Cppcheck team.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include "ui_settings.h"
class QSettings;
class QWidget;
class ApplicationList;
class TranslationHandler;
class CodeEditorStyle;
/// @addtogroup GUI
/// @{
/**
* @brief Settings dialog
*
*/
2011-10-13 20:53:06 +02:00
class SettingsDialog : public QDialog {
Q_OBJECT
public:
SettingsDialog(ApplicationList *list,
TranslationHandler *translator,
QWidget *parent = 0);
SettingsDialog(const SettingsDialog &) = delete;
virtual ~SettingsDialog();
SettingsDialog &operator=(const SettingsDialog &) = delete;
/**
* @brief Save all values to QSettings
*
*/
2017-07-28 13:43:49 +02:00
void saveSettingValues() const;
/**
* @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;
/**
* @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;
/**
* @brief Get checkbox value for mNoErrorsMessage
*
* @return Should "no errors message" be hidden
*/
2017-07-28 13:43:49 +02:00
bool showNoErrorsMessage() const;
/**
* @brief Get checkbox value for mShowIdColumn
*
* @return Should error id column be displayed
*/
2017-07-28 13:43:49 +02:00
bool showErrorId() const;
/**
* @brief Get checkbox value for mEnableInconclusive
*
* @return Should inconclusive column be displayed
*/
2017-07-28 13:43:49 +02:00
bool showInconclusive() const;
/**
* @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;
protected slots:
/**
* @brief Slot for clicking OK.
*
*/
2017-07-28 13:43:49 +02:00
void ok();
/**
* @brief Slot for adding a new application to the list
*
*/
2017-07-28 13:43:49 +02:00
void addApplication();
/**
* @brief Slot for deleting an application from the list
*
*/
2017-07-28 13:43:49 +02:00
void removeApplication();
/**
* @brief Slot for modifying an application in the list
*
*/
2017-07-28 13:43:49 +02:00
void editApplication();
/**
* @brief Slot for making the selected application as the default (first)
*
*/
2017-07-28 13:43:49 +02:00
void defaultApplication();
/** @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();
/**
* @brief Browse for MISRA file
*/
void browseMisraFile();
/**
* @brief Set Code Editor Style to Default
*/
void setCodeEditorStyleDefault();
/**
* @brief Edit Custom Code Editor Style
*/
void editCodeEditorStyle();
protected:
/**
* @brief Clear all applications from the list and re insert them from mTempApplications
*
*/
2017-07-28 13:43:49 +02:00
void populateApplicationList();
2009-03-22 14:15:16 +01:00
/**
* @brief Load saved values
* Loads dialog size and column widths.
*
*/
2017-07-28 13:43:49 +02:00
void loadSettings();
/**
* @brief Save settings
* Save dialog size and column widths.
*/
2017-07-28 13:43:49 +02:00
void saveSettings() const;
/**
* @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);
/**
* @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);
/**
* @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);
/**
* @brief Populate the translations list.
*/
2017-07-28 13:43:49 +02:00
void initTranslationsList();
/**
* @brief Current Code Editor Style
*/
CodeEditorStyle *mCurrentStyle;
/**
* @brief List of applications user has specified
*
*/
ApplicationList *mApplications;
/**
* @brief Temporary list of applications
* This will be copied to actual list of applications (mApplications)
* when user clicks ok.
*/
ApplicationList *mTempApplications;
/**
* @brief List of translations.
*
*/
TranslationHandler *mTranslator;
/**
* @brief Dialog from UI designer
*
*/
Ui::Settings mUI;
private:
void manageStyleControls();
static const int mLangCodeRole = Qt::UserRole;
};
/// @}
#endif // SETTINGSDIALOG_H