29 #include "ui_settings.h"
32 #include <QDialogButtonBox>
34 #include <QFileDialog>
40 #include <QListWidget>
41 #include <QListWidgetItem>
42 #include <QPushButton>
43 #include <QRadioButton>
57 mTranslator(translator),
62 mUI->mPythonPathWarning->setStyleSheet(
"color: red");
81 mUI->mGroupBoxMisra->setVisible(
false);
90 mUI->mTabClang->setVisible(
false);
95 connect(
mUI->mEditPythonPath, SIGNAL(textEdited(QString)),
99 connect(
mUI->mButtons, &QDialogButtonBox::rejected,
this, &SettingsDialog::reject);
100 connect(
mUI->mBtnAddApplication, SIGNAL(clicked()),
102 connect(
mUI->mBtnRemoveApplication, SIGNAL(clicked()),
104 connect(
mUI->mBtnEditApplication, SIGNAL(clicked()),
106 connect(
mUI->mBtnDefaultApplication, SIGNAL(clicked()),
108 connect(
mUI->mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
117 connect(
mUI->mThemeCustom, SIGNAL(toggled(
bool)),
mUI->mBtnEditTheme, SLOT(setEnabled(
bool)));
119 mUI->mListWidget->setSortingEnabled(
false);
122 const int count = QThread::idealThreadCount();
124 mUI->mLblIdealThreads->setText(QString::number(count));
126 mUI->mLblIdealThreads->setText(tr(
"N/A"));
143 auto *item =
new QListWidgetItem;
144 item->setText(translation.mName);
146 mUI->mListLanguages->addItem(item);
147 if (translation.mCode == current || translation.mCode == current.mid(0, 2))
148 mUI->mListLanguages->setCurrentItem(item);
157 return Qt::Unchecked;
162 return state == Qt::Checked;
182 int jobs =
mUI->mJobs->text().toInt();
209 const QListWidgetItem *currentLang =
mUI->mListLanguages->currentItem();
211 const QString langcode = currentLang->data(
mLangCodeRole).toString();
225 const auto pythonPath =
mUI->mEditPythonPath->text();
226 if (pythonPath.isEmpty()) {
227 mUI->mEditPythonPath->setStyleSheet(
"");
228 mUI->mPythonPathWarning->hide();
232 QFileInfo pythonPathInfo(pythonPath);
233 if (!pythonPathInfo.exists() ||
234 !pythonPathInfo.isFile() ||
235 !pythonPathInfo.isExecutable()) {
236 mUI->mEditPythonPath->setStyleSheet(
"QLineEdit {border: 1px solid red}");
237 mUI->mPythonPathWarning->setText(tr(
"The executable file \"%1\" is not available").arg(pythonPath));
238 mUI->mPythonPathWarning->show();
240 mUI->mEditPythonPath->setStyleSheet(
"");
241 mUI->mPythonPathWarning->hide();
250 if (dialog.exec() == QDialog::Accepted) {
258 for (QListWidgetItem *item :
mUI->mListWidget->selectedItems()) {
259 const int removeIndex =
mUI->mListWidget->row(item);
262 if (removeIndex == currentDefault)
265 else if (removeIndex < currentDefault)
269 mUI->mListWidget->clear();
275 for (QListWidgetItem *item :
mUI->mListWidget->selectedItems()) {
276 const int row =
mUI->mListWidget->row(item);
280 if (dialog.exec() == QDialog::Accepted) {
283 name += tr(
" [Default]");
291 QList<QListWidgetItem *> selected =
mUI->mListWidget->selectedItems();
292 if (!selected.isEmpty()) {
293 const int index =
mUI->mListWidget->row(selected[0]);
295 mUI->mListWidget->clear();
308 name += tr(
"[Default]");
310 mUI->mListWidget->addItem(name);
316 mUI->mListWidget->setCurrentRow(0);
319 mUI->mListWidget->setCurrentRow(defapp);
321 mUI->mListWidget->setCurrentRow(0);
363 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select python binary"), QDir::rootPath());
364 if (fileName.contains(
"python", Qt::CaseInsensitive))
365 mUI->mEditPythonPath->setText(fileName);
370 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select MISRA File"), QDir::homePath(),
"Misra File (*.pdf *.txt)");
371 if (!fileName.isEmpty())
372 mUI->mEditMisraFile->setText(fileName);
378 if (
mUI->mThemeSystem->isChecked())
380 if (
mUI->mThemeLight->isChecked())
382 if (
mUI->mThemeDark->isChecked())
391 const int nResult = dlg.exec();
392 if (nResult == QDialog::Accepted) {
400 QString selectedDir = QFileDialog::getExistingDirectory(
this,
401 tr(
"Select clang path"),
404 if (!selectedDir.isEmpty()) {
405 mUI->mEditClangPath->setText(selectedDir);
414 mUI->mThemeSystem->setChecked(isSystemTheme);
415 mUI->mThemeLight->setChecked(isDefaultLight && !isDefaultDark);
416 mUI->mThemeDark->setChecked(!isDefaultLight && isDefaultDark);
417 mUI->mThemeCustom->setChecked(!isSystemTheme && !isDefaultLight && !isDefaultDark);
418 mUI->mBtnEditTheme->setEnabled(!isSystemTheme && !isDefaultLight && !isDefaultDark);
Dialog to edit a startable application.
List of applications user has specified to open errors with.
void copy(const ApplicationList *list)
Remove all applications from this list and copy all applications from list given as a parameter.
void setDefault(const int index)
Set application as default application.
int getApplicationCount() const
Get the amount of applications in the list.
const Application & getApplication(const int index) const
Get specific application's name.
void removeApplication(const int index)
Remove an application from the list.
void addApplication(const Application &app)
Add a new application.
int getDefaultApplication() const
Return the default application.
A class containing information of the application to execute.
const QString & getName() const
Get application name.
static void saveSettings(QSettings *settings, const CodeEditorStyle &theStyle)
static CodeEditorStyle getSystemTheme()
static CodeEditorStyle loadSettings(QSettings *settings)
bool isSystemTheme() const
bool showNoErrorsMessage() const
Get checkbox value for mNoErrorsMessage.
void browsePythonPath()
Slot for browsing for the python binary.
void ok()
Slot for clicking OK.
bool saveAllErrors() const
Get checkbox value for mSaveAllErrors.
void browseClangPath()
Slot for browsing for the clang binary.
void saveSettingValues() const
Save all values to QSettings.
static void saveCheckboxValue(QSettings *settings, const QCheckBox *box, const QString &name)
Save a single checkboxes value.
void populateApplicationList()
Clear all applications from the list and re insert them from mTempApplications.
bool saveFullPath() const
Get checkbox value for mSaveFullPath.
CodeEditorStyle * mCurrentStyle
Current Code Editor Style.
void editApplication()
Slot for modifying an application in the list.
void addApplication()
Slot for adding a new application to the list.
void removeApplication()
Slot for deleting an application from the list.
void browseMisraFile()
Browse for MISRA file.
void editCodeEditorStyle()
Edit Custom Code Editor Style.
ApplicationList * mTempApplications
Temporary list of applications This will be copied to actual list of applications (mApplications) whe...
TranslationHandler * mTranslator
List of translations.
void validateEditPythonPath()
Slot for validating input value in editPythonPath.
~SettingsDialog() override
void loadSettings()
Load saved values Loads dialog size and column widths.
void initTranslationsList()
Populate the translations list.
static constexpr int mLangCodeRole
void manageStyleControls()
static bool checkStateToBool(Qt::CheckState state)
Converts Qt::CheckState to bool.
void saveSettings() const
Save settings Save dialog size and column widths.
SettingsDialog(ApplicationList *list, TranslationHandler *translator, bool premium, QWidget *parent=nullptr)
bool showInconclusive() const
Get checkbox value for mEnableInconclusive.
Ui::Settings * mUI
Dialog from UI designer.
static Qt::CheckState boolToCheckState(bool yes)
Convert bool to Qt::CheckState.
ApplicationList * mApplications
List of applications user has specified.
void defaultApplication()
Slot for making the selected application as the default (first)
void setCodeEditorStyleDefault()
Set Code Editor Style to Default.
bool showFullPath() const
Get checkbox value for mShowFullPath.
bool showErrorId() const
Get checkbox value for mShowIdColumn.
This is just a container for general settings so that we don't need to pass individual values to func...
CodeEditorStyle getStyle()
A class handling the available translations.
const QList< TranslationInfo > & getTranslations() const
Get a list of available translations.
const QString & getCurrentLanguage() const
Get currently selected translation.
static const CodeEditorStyle defaultStyleLight(Qt::black, QColor(240, 240, 240), QColor(255, 220, 220), Qt::black, QColor(240, 240, 240), Qt::darkBlue, QFont::Bold, Qt::darkMagenta, QFont::Bold, Qt::darkGreen, QFont::Normal, Qt::gray, QFont::Normal, Qt::red, QColor(220, 220, 255), QFont::Normal)
static const CodeEditorStyle defaultStyleDark(QColor(218, 218, 218), QColor(16, 16, 32), QColor(64, 64, 64), QColor(43, 145, 175), QColor(16, 16, 32), QColor(0, 204, 204), QFont::Bold, QColor(218, 0, 218), QFont::Bold, QColor(0, 204, 0), QFont::Normal, QColor(180, 180, 180), QFont::Normal, QColor(218, 32, 32), QColor(32, 32, 108), QFont::Normal)
std::string toString(Color c)
#define SETTINGS_PYTHON_PATH
#define SETTINGS_CHECK_DIALOG_HEIGHT
#define SETTINGS_INLINE_SUPPRESSIONS
#define SETTINGS_CLANG_PATH
#define SETTINGS_SHOW_NO_ERRORS
#define SETTINGS_SHOW_FULL_PATH
#define SETTINGS_CHECK_DIALOG_WIDTH
#define SETTINGS_CHECK_FOR_UPDATES
#define SETTINGS_CHECK_FORCE
#define SETTINGS_VS_INCLUDE_PATHS
#define SETTINGS_SAVE_FULL_PATH
#define SETTINGS_LANGUAGE
#define SETTINGS_SHOW_DEBUG_WARNINGS
#define SETTINGS_INCONCLUSIVE_ERRORS
#define SETTINGS_MISRA_FILE
#define SETTINGS_SHOW_ERROR_ID
#define SETTINGS_SHOW_STATISTICS
#define SETTINGS_SAVE_ALL_ERRORS
#define SETTINGS_CHECK_THREADS
Information for one translation.