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.
This commit is contained in:
Thorbjørn Lindeijer
2009-07-16 15:56:26 +02:00
parent 51acee8ebe
commit 7f5eff2c5f
3 changed files with 13 additions and 76 deletions

View File

@@ -85,8 +85,6 @@ public:
QColor background = m_scheme.formatFor(description.name()).background(); QColor background = m_scheme.formatFor(description.name()).background();
if (background.isValid()) if (background.isValid())
return background; return background;
else
return m_scheme.formatFor(QLatin1String(TextEditor::Constants::C_TEXT)).background();
} }
case Qt::FontRole: { case Qt::FontRole: {
QFont font = m_baseFont; QFont font = m_baseFont;
@@ -141,6 +139,8 @@ EditColorSchemeDialog::EditColorSchemeDialog(const FormatDescriptions &fd,
if (!m_descriptions.empty()) if (!m_descriptions.empty())
m_ui->itemList->setCurrentIndex(m_formatsModel->index(0)); m_ui->itemList->setCurrentIndex(m_formatsModel->index(0));
setItemListBackground(m_scheme.formatFor(QLatin1String(TextEditor::Constants::C_TEXT)).background());
} }
EditColorSchemeDialog::~EditColorSchemeDialog() EditColorSchemeDialog::~EditColorSchemeDialog()
@@ -173,7 +173,6 @@ void EditColorSchemeDialog::itemChanged(const QModelIndex &index)
const bool italicBlocked = m_ui->italicCheckBox->blockSignals(true); const bool italicBlocked = m_ui->italicCheckBox->blockSignals(true);
m_ui->italicCheckBox->setChecked(format.italic()); m_ui->italicCheckBox->setChecked(format.italic());
m_ui->italicCheckBox->blockSignals(italicBlocked); m_ui->italicCheckBox->blockSignals(italicBlocked);
updatePreview();
} }
void EditColorSchemeDialog::changeForeColor() void EditColorSchemeDialog::changeForeColor()
@@ -193,8 +192,6 @@ void EditColorSchemeDialog::changeForeColor()
m_scheme.formatFor(category).setForeground(newColor); m_scheme.formatFor(category).setForeground(newColor);
m_formatsModel->emitDataChanged(index); m_formatsModel->emitDataChanged(index);
} }
updatePreview();
} }
void EditColorSchemeDialog::changeBackColor() void EditColorSchemeDialog::changeBackColor()
@@ -212,9 +209,10 @@ void EditColorSchemeDialog::changeBackColor()
const QString category = m_descriptions[index.row()].name(); const QString category = m_descriptions[index.row()].name();
m_scheme.formatFor(category).setBackground(newColor); m_scheme.formatFor(category).setBackground(newColor);
m_formatsModel->emitDataChanged(index); m_formatsModel->emitDataChanged(index);
// Synchronize item list background with text background
if (index.row() == 0)
setItemListBackground(newColor);
} }
updatePreview();
} }
void EditColorSchemeDialog::eraseBackColor() void EditColorSchemeDialog::eraseBackColor()
@@ -230,8 +228,6 @@ void EditColorSchemeDialog::eraseBackColor()
m_scheme.formatFor(category).setBackground(newColor); m_scheme.formatFor(category).setBackground(newColor);
m_formatsModel->emitDataChanged(index); m_formatsModel->emitDataChanged(index);
} }
updatePreview();
} }
void EditColorSchemeDialog::checkCheckBoxes() void EditColorSchemeDialog::checkCheckBoxes()
@@ -245,40 +241,11 @@ void EditColorSchemeDialog::checkCheckBoxes()
m_scheme.formatFor(category).setItalic(m_ui->italicCheckBox->isChecked()); m_scheme.formatFor(category).setItalic(m_ui->italicCheckBox->isChecked());
m_formatsModel->emitDataChanged(index); m_formatsModel->emitDataChanged(index);
} }
updatePreview();
} }
void EditColorSchemeDialog::updatePreview() void EditColorSchemeDialog::setItemListBackground(const QColor &color)
{ {
if (m_curItem == -1) QPalette pal = m_ui->itemList->palette();
return; pal.setColor(QPalette::Base, color);
m_ui->itemList->setPalette(pal);
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."));
} }

View File

@@ -69,9 +69,10 @@ private slots:
void changeBackColor(); void changeBackColor();
void eraseBackColor(); void eraseBackColor();
void checkCheckBoxes(); void checkCheckBoxes();
void updatePreview();
private: private:
void setItemListBackground(const QColor &color);
const TextEditor::FormatDescriptions m_descriptions; const TextEditor::FormatDescriptions m_descriptions;
const FontSettings m_fontSettings; const FontSettings m_fontSettings;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>425</width> <width>461</width>
<height>461</height> <height>352</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -157,37 +157,6 @@
</layout> </layout>
</widget> </widget>
</item> </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> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">