diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index e900b51680..31614a9f4c 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -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); } diff --git a/src/Gui/PythonEditor.cpp b/src/Gui/PythonEditor.cpp index f735b581f3..9da12c88ef 100644 --- a/src/Gui/PythonEditor.cpp +++ b/src/Gui/PythonEditor.cpp @@ -47,7 +47,6 @@ using namespace Gui; namespace Gui { struct PythonEditorP { - QMap 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 diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index 7732b91715..3936bd5ad0 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -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(); diff --git a/src/Gui/ReportView.h b/src/Gui/ReportView.h index 0b748e4971..1ab5038d36 100644 --- a/src/Gui/ReportView.h +++ b/src/Gui/ReportView.h @@ -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 ); diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index bbb06d8b68..2bb69905e9 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -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);