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 @@
#include "colorschemeedit.h"
#include "ui_colorschemeedit.h"
#include <utils/theme/theme.h>
#include <QAbstractListModel>
#include <QColorDialog>
......@@ -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);
......
......@@ -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) {
......
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