Commit d37e04da authored by Alexander Semke's avatar Alexander Semke
Browse files

Red-highlight the text field for the executable path if wrong path was provided in the settings.

parent fd4e9e0e
Pipeline #240245 passed with stage
in 22 minutes and 56 seconds
# Changelog
## 22.12
### New features
* Red-highlight the text field for the executable path if wrong path was provided in the settings
## 22.08
### New features
......
......@@ -15,15 +15,18 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#include "backendsettingswidget.h"
#include "qthelpconfig.h"
#include <QFile>
#include <QHBoxLayout>
#include <QTabWidget>
#include <KUrlRequester>
BackendSettingsWidget::BackendSettingsWidget(QWidget* parent, const QString& id) : QWidget(parent), m_id(id)
{
......@@ -44,3 +47,19 @@ void BackendSettingsWidget::tabChanged(int index) {
}
}
}
void BackendSettingsWidget::fileNameChanged(const QString& fileName) {
if (!m_urlRequester)
return;
bool invalid = (!fileName.isEmpty() && !QFile::exists(fileName));
if (invalid) {
QPalette p; \
if (qGray(p.color(QPalette::Base).rgb()) > 160) /* light */ \
m_urlRequester->setStyleSheet(QLatin1String("background: rgb(255, 200, 200);")); \
else /* dark */ \
m_urlRequester->setStyleSheet(QLatin1String("background: rgb(128, 0, 0);"));
}
else
m_urlRequester->setStyleSheet(QString());
}
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#ifndef BACKENDSETTINGSWIDGET_H
......@@ -25,6 +25,7 @@
class QTabWidget;
class QtHelpConfig;
class KUrlRequester;
class BackendSettingsWidget : public QWidget
{
......@@ -40,9 +41,11 @@ protected:
QString m_id;
QTabWidget* m_tabWidget = nullptr;
QWidget* m_tabDocumentation = nullptr;
KUrlRequester* m_urlRequester = nullptr;
public Q_SLOTS:
void tabChanged(int);
void fileNameChanged(const QString&);
};
#endif /* BACKENDSETTINGSWIDGET_H */
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#include "juliasettingswidget.h"
......@@ -26,5 +26,8 @@ JuliaSettingsWidget::JuliaSettingsWidget(QWidget* parent, const QString& id) : B
m_tabWidget = tabWidget;
m_tabDocumentation = tabDocumentation;
m_urlRequester = kcfg_replPath;
connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
connect(kcfg_replPath, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
}
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020 Shubham <aryan100jangid@gmail.com>
*/
......@@ -27,5 +27,8 @@ MaximaSettingsWidget::MaximaSettingsWidget(QWidget* parent, const QString& id) :
m_tabWidget = tabWidget;
m_tabDocumentation = tabDocumentation;
m_urlRequester = kcfg_Path;
connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
connect(kcfg_Path, &KUrlRequester::textChanged, this, &MaximaSettingsWidget::fileNameChanged);
}
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020 Shubham <aryan100jangid@gmail.com>
*/
......@@ -27,9 +27,9 @@
class MaximaSettingsWidget : public BackendSettingsWidget, public Ui::MaximaSettingsBase
{
Q_OBJECT
Q_OBJECT
public:
public:
explicit MaximaSettingsWidget(QWidget* parent = nullptr, const QString& id = QString());
};
......
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#include "octavesettingswidget.h"
......@@ -26,5 +26,8 @@ OctaveSettingsWidget::OctaveSettingsWidget(QWidget* parent, const QString& id) :
m_tabWidget = tabWidget;
m_tabDocumentation = tabDocumentation;
m_urlRequester = kcfg_Path;
connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
connect(kcfg_Path, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
}
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#include "sagesettingswidget.h"
......@@ -26,5 +26,8 @@ SageSettingsWidget::SageSettingsWidget(QWidget* parent, const QString& id) : Bac
m_tabWidget = tabWidget;
m_tabDocumentation = tabDocumentation;
m_urlRequester = kcfg_Path;
connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
connect(kcfg_Path, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
}
......@@ -15,7 +15,7 @@
Boston, MA 02110-1301, USA.
---
Copyright (C) 2020 Alexander Semke <alexander.semke@web.de>
Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
*/
#include "scilabsettingswidget.h"
......@@ -26,5 +26,8 @@ ScilabSettingsWidget::ScilabSettingsWidget(QWidget* parent, const QString& id) :
m_tabWidget = tabWidget;
m_tabDocumentation = tabDocumentation;
m_urlRequester = kcfg_Path;
connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
connect(kcfg_Path, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment