Gui: use default app text color for Python code instuctions highlighting
This allows to deal with OS native dark themes In such cases, Python instructions were black on a dark background
This commit is contained in:
@@ -68,7 +68,7 @@ DlgSettingsEditorImp::DlgSettingsEditorImp( QWidget* parent )
|
||||
|
||||
d = new DlgSettingsEditorP();
|
||||
QColor col;
|
||||
col = Qt::black;
|
||||
col = qApp->palette().windowText().color();
|
||||
unsigned int lText = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8);
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Text")), lText));
|
||||
|
||||
@@ -100,7 +100,7 @@ struct PythonConsoleP
|
||||
callTipsList = nullptr;
|
||||
interactive = false;
|
||||
historyFile = QString::fromUtf8((App::Application::getUserAppDataDir() + "PythonHistory.log").c_str());
|
||||
colormap[QLatin1String("Text")] = Qt::black;
|
||||
colormap[QLatin1String("Text")] = qApp->palette().windowText().color();
|
||||
colormap[QLatin1String("Bookmark")] = Qt::cyan;
|
||||
colormap[QLatin1String("Breakpoint")] = Qt::red;
|
||||
colormap[QLatin1String("Keyword")] = Qt::blue;
|
||||
@@ -932,7 +932,7 @@ void PythonConsole::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::StyleChange) {
|
||||
QPalette pal = palette();
|
||||
QPalette pal = qApp->palette();
|
||||
QColor color = pal.windowText().color();
|
||||
unsigned int text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8);
|
||||
auto value = static_cast<unsigned long>(text);
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
|
||||
#include "SyntaxHighlighter.h"
|
||||
|
||||
|
||||
@@ -33,11 +36,16 @@ class SyntaxHighlighterP
|
||||
public:
|
||||
SyntaxHighlighterP()
|
||||
{
|
||||
cNormalText.setRgb(0, 0, 0); cComment.setRgb(0, 170, 0);
|
||||
cBlockcomment.setRgb(160, 160, 164); cLiteral.setRgb(255, 0, 0);
|
||||
cNumber.setRgb(0, 0, 255); cOperator.setRgb(160, 160, 164);
|
||||
cKeyword.setRgb(0, 0, 255); cClassName.setRgb(255, 170, 0);
|
||||
cDefineName.setRgb(255, 170, 0); cOutput.setRgb(170, 170, 127);
|
||||
cNormalText = qApp->palette().windowText().color();
|
||||
cComment.setRgb(0, 170, 0);
|
||||
cBlockcomment.setRgb(160, 160, 164);
|
||||
cLiteral.setRgb(255, 0, 0);
|
||||
cNumber.setRgb(0, 0, 255);
|
||||
cOperator.setRgb(160, 160, 164);
|
||||
cKeyword.setRgb(0, 0, 255);
|
||||
cClassName.setRgb(255, 170, 0);
|
||||
cDefineName.setRgb(255, 170, 0);
|
||||
cOutput.setRgb(170, 170, 127);
|
||||
cError.setRgb(255, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QKeyEvent>
|
||||
# include <QPainter>
|
||||
# include <QRegularExpression>
|
||||
@@ -197,7 +198,7 @@ struct TextEditorP
|
||||
QMap<QString, QColor> colormap; // Color map
|
||||
TextEditorP()
|
||||
{
|
||||
colormap[QLatin1String("Text")] = Qt::black;
|
||||
colormap[QLatin1String("Text")] = qApp->palette().windowText().color();
|
||||
colormap[QLatin1String("Bookmark")] = Qt::cyan;
|
||||
colormap[QLatin1String("Breakpoint")] = Qt::red;
|
||||
colormap[QLatin1String("Keyword")] = Qt::blue;
|
||||
|
||||
Reference in New Issue
Block a user