mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Script highlighter changed
This commit is contained in:
parent
ab3236f669
commit
bea84a3320
@ -1,4 +1,5 @@
|
|||||||
#include "lrscripthighlighter.h"
|
#include "lrscripthighlighter.h"
|
||||||
|
#include "lrglobal.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
@ -180,17 +181,11 @@ bool ScriptHighlighter::isKeyWord(const QString& word)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptHighlighter::isDark(QColor color)
|
|
||||||
{
|
|
||||||
double a = 1 - ( 0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
|
|
||||||
return (a < 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptHighlighter::ScriptHighlighter(QTextDocument* parent):
|
ScriptHighlighter::ScriptHighlighter(QTextDocument* parent):
|
||||||
QSyntaxHighlighter(parent)
|
QSyntaxHighlighter(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( isDark(QPalette().background().color())){
|
if ( isColorDark(QPalette().background().color())){
|
||||||
m_formats[NumberFormat].setForeground(Qt::darkBlue);
|
m_formats[NumberFormat].setForeground(Qt::darkBlue);
|
||||||
m_formats[StringFormat].setForeground(Qt::darkGreen);
|
m_formats[StringFormat].setForeground(Qt::darkGreen);
|
||||||
m_formats[KeywordFormat].setForeground(Qt::darkYellow);
|
m_formats[KeywordFormat].setForeground(Qt::darkYellow);
|
||||||
|
@ -42,7 +42,6 @@ protected:
|
|||||||
};
|
};
|
||||||
QTextCharFormat m_formats[FormatsCount];
|
QTextCharFormat m_formats[FormatsCount];
|
||||||
bool isKeyWord(const QString& word);
|
bool isKeyWord(const QString& word);
|
||||||
bool isDark(QColor color);
|
|
||||||
void createParentheisisInfo(const char& literal, TextBlockData *data, const QString& text);
|
void createParentheisisInfo(const char& literal, TextBlockData *data, const QString& text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user