Commit 47046ec1 authored by mae's avatar mae

Fix editor color scheme

Use the defined foreground for search scope instead of calculating
something from background. Support empty foreground for the standard
selections (allows us to match certain popular colorschemes)
parent e179912a
......@@ -2433,7 +2433,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
TextEditorOverlay *overlay = new TextEditorOverlay(this);
overlay->addOverlaySelection(d->m_findScopeStart.position(),
d->m_findScopeEnd.position(),
d->m_searchScopeFormat.background().color().darker(120),
d->m_searchScopeFormat.foreground().color(),
d->m_searchScopeFormat.background().color(),
TextEditorOverlay::ExpandBegin);
overlay->setAlpha(false);
......@@ -2525,7 +2525,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
}
painter.fillRect(rr, d->m_searchScopeFormat.background());
QColor lineCol = d->m_searchScopeFormat.background().color().darker(120);
QColor lineCol = d->m_searchScopeFormat.foreground().color();
QPen pen = painter.pen();
painter.setPen(lineCol);
if (blockFS == d->m_findScopeStart.block())
......@@ -5078,7 +5078,9 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
p.setColor(QPalette::Highlight, (selectionFormat.background().style() != Qt::NoBrush) ?
selectionFormat.background().color() :
QApplication::palette().color(QPalette::Highlight));
p.setColor(QPalette::HighlightedText, selectionFormat.foreground().color());
p.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
p.setBrush(QPalette::Inactive, QPalette::Highlight, p.highlight());
p.setBrush(QPalette::Inactive, QPalette::HighlightedText, p.highlightedText());
setPalette(p);
......
......@@ -156,6 +156,7 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) :
connect(m_ui->foregroundToolButton, SIGNAL(clicked()), SLOT(changeForeColor()));
connect(m_ui->backgroundToolButton, SIGNAL(clicked()), SLOT(changeBackColor()));
connect(m_ui->eraseBackgroundToolButton, SIGNAL(clicked()), SLOT(eraseBackColor()));
connect(m_ui->eraseForegroundToolButton, SIGNAL(clicked()), SLOT(eraseForeColor()));
connect(m_ui->boldCheckBox, SIGNAL(toggled(bool)), SLOT(checkCheckBoxes()));
connect(m_ui->italicCheckBox, SIGNAL(toggled(bool)), SLOT(checkCheckBoxes()));
}
......@@ -192,6 +193,7 @@ void ColorSchemeEdit::setReadOnly(bool readOnly)
m_ui->backgroundLabel->setEnabled(enabled);
m_ui->backgroundToolButton->setEnabled(enabled);
m_ui->eraseBackgroundToolButton->setEnabled(enabled);
m_ui->eraseForegroundToolButton->setEnabled(enabled);
m_ui->boldCheckBox->setEnabled(enabled);
m_ui->italicCheckBox->setEnabled(enabled);
}
......@@ -227,6 +229,9 @@ void ColorSchemeEdit::updateControls()
m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly
&& m_curItem > 0
&& format.background().isValid());
m_ui->eraseForegroundToolButton->setEnabled(!m_readOnly
&& m_curItem > 0
&& format.foreground().isValid());
const bool boldBlocked = m_ui->boldCheckBox->blockSignals(true);
m_ui->boldCheckBox->setChecked(format.bold());
......@@ -247,6 +252,7 @@ void ColorSchemeEdit::changeForeColor()
QPalette p = m_ui->foregroundToolButton->palette();
p.setColor(QPalette::Active, QPalette::Button, newColor);
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
m_ui->eraseForegroundToolButton->setEnabled(true);
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
const QString category = m_descriptions[index.row()].id();
......@@ -291,6 +297,21 @@ void ColorSchemeEdit::eraseBackColor()
}
}
void ColorSchemeEdit::eraseForeColor()
{
if (m_curItem == -1)
return;
QColor newColor;
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
m_ui->eraseForegroundToolButton->setEnabled(false);
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
const QString category = m_descriptions[index.row()].id();
m_scheme.formatFor(category).setForeground(newColor);
m_formatsModel->emitDataChanged(index);
}
}
void ColorSchemeEdit::checkCheckBoxes()
{
if (m_curItem == -1)
......
......@@ -71,6 +71,7 @@ private slots:
void changeForeColor();
void changeBackColor();
void eraseBackColor();
void eraseForeColor();
void checkCheckBoxes();
private:
......
......@@ -10,17 +10,8 @@
<height>210</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="4">
<widget class="QListView" name="itemList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
......@@ -36,23 +27,25 @@
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="_2">
<item row="2" column="0">
<widget class="QCheckBox" name="boldCheckBox">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="italicCheckBox">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="1">
<widget class="QLabel" name="foregroundLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Foreground:</string>
</property>
<property name="buddy">
<cstring>foregroundToolButton</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="foregroundToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -65,24 +58,41 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="backgroundLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item>
<widget class="QToolButton" name="eraseForegroundToolButton">
<property name="toolTip">
<string>Erase foreground</string>
</property>
<property name="text">
<string>Background:</string>
<string>x</string>
</property>
<property name="buddy">
<cstring>backgroundToolButton</cstring>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="foregroundLabel">
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="backgroundLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Background:</string>
</property>
<property name="buddy">
<cstring>backgroundToolButton</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="backgroundToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -90,63 +100,56 @@
</sizepolicy>
</property>
<property name="text">
<string>Foreground:</string>
</property>
<property name="buddy">
<cstring>foregroundToolButton</cstring>
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
<item>
<widget class="QToolButton" name="eraseBackgroundToolButton">
<property name="toolTip">
<string>Erase background</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="text">
<string>x</string>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="backgroundToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="eraseBackgroundToolButton">
<property name="toolTip">
<string>Erase background</string>
</property>
<property name="text">
<string>x</string>
</property>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
</widget>
</item>
</layout>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="boldCheckBox">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="italicCheckBox">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>83</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>itemList</tabstop>
<tabstop>foregroundToolButton</tabstop>
<tabstop>backgroundToolButton</tabstop>
<tabstop>eraseBackgroundToolButton</tabstop>
<tabstop>boldCheckBox</tabstop>
......
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