Commit f398e7d2 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

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: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent 589aef89
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "colorschemeedit.h" #include "colorschemeedit.h"
#include "ui_colorschemeedit.h" #include "ui_colorschemeedit.h"
#include <utils/theme/theme.h>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QColorDialog> #include <QColorDialog>
...@@ -148,6 +150,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : ...@@ -148,6 +150,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) :
m_formatsModel(new FormatsModel(this)), m_formatsModel(new FormatsModel(this)),
m_readOnly(false) m_readOnly(false)
{ {
setPalette(Utils::Theme::initialPalette());
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->itemList->setModel(m_formatsModel); m_ui->itemList->setModel(m_formatsModel);
......
...@@ -253,15 +253,17 @@ FormatDescription::FormatDescription(TextStyle id, ...@@ -253,15 +253,17 @@ FormatDescription::FormatDescription(TextStyle id,
QColor FormatDescription::defaultForeground(TextStyle id) QColor FormatDescription::defaultForeground(TextStyle id)
{ {
if (id == C_LINE_NUMBER) { 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) if (bg.value() < 128)
return QApplication::palette().foreground().color(); return palette.foreground().color();
else else
return QApplication::palette().dark().color(); return palette.dark().color();
} else if (id == C_CURRENT_LINE_NUMBER) { } 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) if (bg.value() < 128)
return QApplication::palette().foreground().color(); return palette.foreground().color();
else else
return QColor(); return QColor();
} else if (id == C_PARENTHESES) { } else if (id == C_PARENTHESES) {
...@@ -277,7 +279,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) ...@@ -277,7 +279,7 @@ QColor FormatDescription::defaultBackground(TextStyle id)
if (id == C_TEXT) { if (id == C_TEXT) {
return Qt::white; return Qt::white;
} else if (id == C_LINE_NUMBER) { } else if (id == C_LINE_NUMBER) {
return QApplication::palette().background().color(); return Utils::Theme::initialPalette().background().color();
} else if (id == C_SEARCH_RESULT) { } else if (id == C_SEARCH_RESULT) {
return QColor(0xffef0b); return QColor(0xffef0b);
} else if (id == C_PARENTHESES) { } else if (id == C_PARENTHESES) {
...@@ -287,7 +289,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) ...@@ -287,7 +289,7 @@ QColor FormatDescription::defaultBackground(TextStyle id)
} else if (id == C_AUTOCOMPLETE) { } else if (id == C_AUTOCOMPLETE) {
return QColor(192, 192, 255); return QColor(192, 192, 255);
} else if (id == C_CURRENT_LINE || id == C_SEARCH_SCOPE) { } 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 &fg = palette.color(QPalette::Highlight);
const QColor &bg = palette.color(QPalette::Base); const QColor &bg = palette.color(QPalette::Base);
...@@ -308,8 +310,7 @@ QColor FormatDescription::defaultBackground(TextStyle id) ...@@ -308,8 +310,7 @@ QColor FormatDescription::defaultBackground(TextStyle id)
fg.blueF() * ratio + bg.blueF() * (1 - ratio)); fg.blueF() * ratio + bg.blueF() * (1 - ratio));
return col; return col;
} else if (id == C_SELECTION) { } else if (id == C_SELECTION) {
const QPalette palette = QApplication::palette(); return Utils::Theme::initialPalette().color(QPalette::Highlight);
return palette.color(QPalette::Highlight);
} else if (id == C_OCCURRENCES) { } else if (id == C_OCCURRENCES) {
return QColor(180, 180, 180); return QColor(180, 180, 180);
} else if (id == C_OCCURRENCES_RENAME) { } else if (id == C_OCCURRENCES_RENAME) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment