diff --git a/gui/settings.ui b/gui/settings.ui
index c3b9c25c7..924d15b54 100644
--- a/gui/settings.ui
+++ b/gui/settings.ui
@@ -292,17 +292,28 @@
Python binary (leave this empty to use python in the PATH)
-
- -
-
-
- -
-
-
- ...
-
-
-
+
+ -
+
+
-
+
+
+ -
+
+
+ ...
+
+
+
+
+
+ -
+
+
+
+
+
+
diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp
index 04c637816..1c7490d16 100644
--- a/gui/settingsdialog.cpp
+++ b/gui/settingsdialog.cpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#include
#include "settingsdialog.h"
#include "applicationdialog.h"
@@ -41,6 +42,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mTranslator(translator)
{
mUI.setupUi(this);
+ mUI.mPythonPathWarning->setStyleSheet("color: red");
QSettings settings;
mTempApplications->copy(list);
@@ -56,6 +58,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mUI.mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool()));
mUI.mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
mUI.mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
+ validateEditPythonPath();
mUI.mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
#ifdef Q_OS_WIN
@@ -69,6 +72,9 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mCurrentStyle = new CodeEditorStyle(CodeEditorStyle::loadSettings(&settings));
manageStyleControls();
+ connect(mUI.mEditPythonPath, SIGNAL(textEdited(const QString &)),
+ this, SLOT(validateEditPythonPath()));
+
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
connect(mUI.mBtnAddApplication, SIGNAL(clicked()),
@@ -194,6 +200,28 @@ void SettingsDialog::saveCheckboxValue(QSettings *settings, QCheckBox *box,
settings->setValue(name, checkStateToBool(box->checkState()));
}
+void SettingsDialog::validateEditPythonPath()
+{
+ const auto pythonPath = mUI.mEditPythonPath->text();
+ if (pythonPath.isEmpty()) {
+ mUI.mEditPythonPath->setStyleSheet("");
+ mUI.mPythonPathWarning->hide();
+ return;
+ }
+
+ QFileInfo pythonPathInfo(pythonPath);
+ if (!pythonPathInfo.exists() ||
+ !pythonPathInfo.isFile() ||
+ !pythonPathInfo.isExecutable()) {
+ mUI.mEditPythonPath->setStyleSheet("QLineEdit {border: 1px solid red}");
+ mUI.mPythonPathWarning->setText(tr("The executable file \"%1\" is not available").arg(pythonPath));
+ mUI.mPythonPathWarning->show();
+ } else {
+ mUI.mEditPythonPath->setStyleSheet("");
+ mUI.mPythonPathWarning->hide();
+ }
+}
+
void SettingsDialog::addApplication()
{
Application app;
diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h
index 8c66f8b84..1fcede7f9 100644
--- a/gui/settingsdialog.h
+++ b/gui/settingsdialog.h
@@ -103,6 +103,9 @@ protected slots:
*/
void ok();
+ /** @brief Slot for validating input value in @c editPythonPath */
+ void validateEditPythonPath();
+
/**
* @brief Slot for adding a new application to the list
*