From f398e7d22ac710dd8ed7bc110b56424e4e3c6b2f Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 24 Jul 2016 09:42:35 +0300 Subject: [PATCH] TextEditor: Use initial palette for default colors The theme might be incompatible with the text style settings, especially those that rely on the default palette (and were designed before themes were implemented). Task-number: QTCREATORBUG-16482 Change-Id: I8f63460ad250a494dcafd11366d7bacdbb71c142 Reviewed-by: Thomas Hartmann Reviewed-by: Alessandro Portale --- src/plugins/texteditor/colorschemeedit.cpp | 3 +++ src/plugins/texteditor/fontsettingspage.cpp | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index 198f03b11f5..18b719ba2fb 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -26,6 +26,8 @@ #include "colorschemeedit.h" #include "ui_colorschemeedit.h" +#include + #include #include @@ -148,6 +150,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : m_formatsModel(new FormatsModel(this)), m_readOnly(false) { + setPalette(Utils::Theme::initialPalette()); m_ui->setupUi(this); m_ui->itemList->setModel(m_formatsModel); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 97865a404ae..7357510abda 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -253,15 +253,17 @@ FormatDescription::FormatDescription(TextStyle id, QColor FormatDescription::defaultForeground(TextStyle id) { if (id == C_LINE_NUMBER) { - const QColor bg = QApplication::palette().background().color(); + const QPalette palette = Utils::Theme::initialPalette(); + const QColor bg = palette.background().color(); if (bg.value() < 128) - return QApplication::palette().foreground().color(); + return palette.foreground().color(); else - return QApplication::palette().dark().color(); + return palette.dark().color(); } else if (id == C_CURRENT_LINE_NUMBER) { - const QColor bg = QApplication::palette().background().color(); + const QPalette palette = Utils::Theme::initialPalette(); + const QColor bg = palette.background().color(); if (bg.value() < 128) - return QApplication::palette().foreground().color(); + return palette.foreground().color(); else return QColor(); } else if (id == C_PARENTHESES) { @@ -277,7 +279,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) if (id == C_TEXT) { return Qt::white; } else if (id == C_LINE_NUMBER) { - return QApplication::palette().background().color(); + return Utils::Theme::initialPalette().background().color(); } else if (id == C_SEARCH_RESULT) { return QColor(0xffef0b); } else if (id == C_PARENTHESES) { @@ -287,7 +289,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) } else if (id == C_AUTOCOMPLETE) { return QColor(192, 192, 255); } else if (id == C_CURRENT_LINE || id == C_SEARCH_SCOPE) { - const QPalette palette = QApplication::palette(); + const QPalette palette = Utils::Theme::initialPalette(); const QColor &fg = palette.color(QPalette::Highlight); const QColor &bg = palette.color(QPalette::Base); @@ -308,8 +310,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) fg.blueF() * ratio + bg.blueF() * (1 - ratio)); return col; } else if (id == C_SELECTION) { - const QPalette palette = QApplication::palette(); - return palette.color(QPalette::Highlight); + return Utils::Theme::initialPalette().color(QPalette::Highlight); } else if (id == C_OCCURRENCES) { return QColor(180, 180, 180); } else if (id == C_OCCURRENCES_RENAME) {