Commit 7f5eff2c authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Removed the preview, which was now pretty useless

Also, the background color of the list now gets synchronized with the
text background color. This is to make the bottom of the list look
nicer.
parent 51acee8e
......@@ -85,8 +85,6 @@ public:
QColor background = m_scheme.formatFor(description.name()).background();
if (background.isValid())
return background;
else
return m_scheme.formatFor(QLatin1String(TextEditor::Constants::C_TEXT)).background();
}
case Qt::FontRole: {
QFont font = m_baseFont;
......@@ -141,6 +139,8 @@ EditColorSchemeDialog::EditColorSchemeDialog(const FormatDescriptions &fd,
if (!m_descriptions.empty())
m_ui->itemList->setCurrentIndex(m_formatsModel->index(0));
setItemListBackground(m_scheme.formatFor(QLatin1String(TextEditor::Constants::C_TEXT)).background());
}
EditColorSchemeDialog::~EditColorSchemeDialog()
......@@ -173,7 +173,6 @@ void EditColorSchemeDialog::itemChanged(const QModelIndex &index)
const bool italicBlocked = m_ui->italicCheckBox->blockSignals(true);
m_ui->italicCheckBox->setChecked(format.italic());
m_ui->italicCheckBox->blockSignals(italicBlocked);
updatePreview();
}
void EditColorSchemeDialog::changeForeColor()
......@@ -193,8 +192,6 @@ void EditColorSchemeDialog::changeForeColor()
m_scheme.formatFor(category).setForeground(newColor);
m_formatsModel->emitDataChanged(index);
}
updatePreview();
}
void EditColorSchemeDialog::changeBackColor()
......@@ -212,9 +209,10 @@ void EditColorSchemeDialog::changeBackColor()
const QString category = m_descriptions[index.row()].name();
m_scheme.formatFor(category).setBackground(newColor);
m_formatsModel->emitDataChanged(index);
// Synchronize item list background with text background
if (index.row() == 0)
setItemListBackground(newColor);
}
updatePreview();
}
void EditColorSchemeDialog::eraseBackColor()
......@@ -230,8 +228,6 @@ void EditColorSchemeDialog::eraseBackColor()
m_scheme.formatFor(category).setBackground(newColor);
m_formatsModel->emitDataChanged(index);
}
updatePreview();
}
void EditColorSchemeDialog::checkCheckBoxes()
......@@ -245,40 +241,11 @@ void EditColorSchemeDialog::checkCheckBoxes()
m_scheme.formatFor(category).setItalic(m_ui->italicCheckBox->isChecked());
m_formatsModel->emitDataChanged(index);
}
updatePreview();
}
void EditColorSchemeDialog::updatePreview()
void EditColorSchemeDialog::setItemListBackground(const QColor &color)
{
if (m_curItem == -1)
return;
const Format &currentFormat = m_scheme.formatFor(m_descriptions[m_curItem].name());
const Format &baseFormat = m_scheme.formatFor(QLatin1String("Text"));
QPalette pal = QApplication::palette();
if (baseFormat.foreground().isValid()) {
pal.setColor(QPalette::Text, baseFormat.foreground());
pal.setColor(QPalette::Foreground, baseFormat.foreground());
}
if (baseFormat.background().isValid())
pal.setColor(QPalette::Base, baseFormat.background());
m_ui->previewTextEdit->setPalette(pal);
QTextCharFormat format;
if (currentFormat.foreground().isValid())
format.setForeground(QBrush(currentFormat.foreground()));
if (currentFormat.background().isValid())
format.setBackground(QBrush(currentFormat.background()));
format.setFontFamily(m_fontSettings.family());
format.setFontStyleStrategy(m_fontSettings.antialias() ? QFont::PreferAntialias : QFont::NoAntialias);
format.setFontPointSize(m_fontSettings.fontSize());
format.setFontItalic(currentFormat.italic());
if (currentFormat.bold())
format.setFontWeight(QFont::Bold);
m_ui->previewTextEdit->setCurrentCharFormat(format);
m_ui->previewTextEdit->setPlainText(tr("\n\tThis is only an example."));
QPalette pal = m_ui->itemList->palette();
pal.setColor(QPalette::Base, color);
m_ui->itemList->setPalette(pal);
}
......@@ -69,9 +69,10 @@ private slots:
void changeBackColor();
void eraseBackColor();
void checkCheckBoxes();
void updatePreview();
private:
void setItemListBackground(const QColor &color);
const TextEditor::FormatDescriptions m_descriptions;
const FontSettings m_fontSettings;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>461</height>
<width>461</width>
<height>352</height>
</rect>
</property>
<property name="windowTitle">
......@@ -157,37 +157,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextEdit" name="previewTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
......
Supports Markdown
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