+ improve handling of default colors of report view and Python console when using style sheets
This commit is contained in:
@@ -852,6 +852,14 @@ void PythonConsole::changeEvent(QEvent *e)
|
||||
this, SLOT(visibilityChanged(bool)));
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::StyleChange) {
|
||||
QPalette pal = palette();
|
||||
QColor color = pal.windowText().color();
|
||||
unsigned long text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8);
|
||||
// if this parameter is not already set use the style's window text color
|
||||
text = getWindowParameter()->GetUnsigned("Text", text);
|
||||
getWindowParameter()->SetUnsigned("Text", text);
|
||||
}
|
||||
TextEdit::changeEvent(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ using namespace Gui;
|
||||
namespace Gui {
|
||||
struct PythonEditorP
|
||||
{
|
||||
QMap<QString, QColor> colormap; // Color map
|
||||
int debugLine;
|
||||
QRect debugRect;
|
||||
QPixmap breakpoint;
|
||||
@@ -60,22 +59,6 @@ struct PythonEditorP
|
||||
debugMarker(QLatin1String(":/icons/debug-marker.png"))
|
||||
{
|
||||
debugger = Application::Instance->macroManager()->debugger();
|
||||
|
||||
colormap[QLatin1String("Text")] = Qt::black;
|
||||
colormap[QLatin1String("Bookmark")] = Qt::cyan;
|
||||
colormap[QLatin1String("Breakpoint")] = Qt::red;
|
||||
colormap[QLatin1String("Keyword")] = Qt::blue;
|
||||
colormap[QLatin1String("Comment")] = QColor(0, 170, 0);
|
||||
colormap[QLatin1String("Block comment")] = QColor(160, 160, 164);
|
||||
colormap[QLatin1String("Number")] = Qt::blue;
|
||||
colormap[QLatin1String("String")] = Qt::red;
|
||||
colormap[QLatin1String("Character")] = Qt::red;
|
||||
colormap[QLatin1String("Class name")] = QColor(255, 170, 0);
|
||||
colormap[QLatin1String("Define name")] = QColor(255, 170, 0);
|
||||
colormap[QLatin1String("Operator")] = QColor(160, 160, 164);
|
||||
colormap[QLatin1String("Python output")] = QColor(170, 170, 127);
|
||||
colormap[QLatin1String("Python error")] = Qt::red;
|
||||
colormap[QLatin1String("Current line highlight")] = QColor(224,224,224);
|
||||
}
|
||||
};
|
||||
} // namespace Gui
|
||||
|
||||
@@ -121,7 +121,8 @@ struct TextBlockData : public QTextBlockUserData
|
||||
ReportHighlighter::ReportHighlighter(QTextEdit* edit)
|
||||
: QSyntaxHighlighter(edit), type(Message)
|
||||
{
|
||||
txtCol = Qt::black;
|
||||
QPalette pal = edit->palette();
|
||||
txtCol = pal.windowText().color();
|
||||
logCol = Qt::blue;
|
||||
warnCol = QColor(255, 170, 0);
|
||||
errCol = Qt::red;
|
||||
@@ -372,6 +373,19 @@ void ReportOutput::customEvent ( QEvent* ev )
|
||||
}
|
||||
}
|
||||
|
||||
void ReportOutput::changeEvent(QEvent *ev)
|
||||
{
|
||||
if (ev->type() == QEvent::StyleChange) {
|
||||
QPalette pal = palette();
|
||||
QColor color = pal.windowText().color();
|
||||
unsigned long text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8);
|
||||
// if this parameter is not already set use the style's window text color
|
||||
text = getWindowParameter()->GetUnsigned("colorText", text);
|
||||
getWindowParameter()->SetUnsigned("colorText", text);
|
||||
}
|
||||
QTextEdit::changeEvent(ev);
|
||||
}
|
||||
|
||||
void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
|
||||
{
|
||||
QMenu* menu = createStandardContextMenu();
|
||||
|
||||
@@ -157,6 +157,8 @@ public:
|
||||
protected:
|
||||
/** For internal use only */
|
||||
void customEvent ( QEvent* ev );
|
||||
/** Handles the change of style sheets */
|
||||
void changeEvent(QEvent *);
|
||||
/** Pops up the context menu with some extensions */
|
||||
void contextMenuEvent ( QContextMenuEvent* e );
|
||||
|
||||
|
||||
@@ -304,7 +304,9 @@ void TextEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||
while (block.isValid() && top <= event->rect().bottom()) {
|
||||
if (block.isVisible() && bottom >= event->rect().top()) {
|
||||
QString number = QString::number(blockNumber + 1);
|
||||
painter.setPen(Qt::black);
|
||||
QPalette pal = palette();
|
||||
QColor color = pal.windowText().color();
|
||||
painter.setPen(color);
|
||||
painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
|
||||
Qt::AlignRight, number);
|
||||
drawMarker(blockNumber + 1, 1, top, &painter);
|
||||
|
||||
Reference in New Issue
Block a user