From 7f5eff2c5fff44c804511cde3894dca2e0013e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Thu, 16 Jul 2009 15:56:26 +0200 Subject: [PATCH] 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. --- .../texteditor/editcolorschemedialog.cpp | 51 ++++--------------- .../texteditor/editcolorschemedialog.h | 3 +- .../texteditor/editcolorschemedialog.ui | 35 +------------ 3 files changed, 13 insertions(+), 76 deletions(-) diff --git a/src/plugins/texteditor/editcolorschemedialog.cpp b/src/plugins/texteditor/editcolorschemedialog.cpp index 840908c7f9f..207cd50e43a 100644 --- a/src/plugins/texteditor/editcolorschemedialog.cpp +++ b/src/plugins/texteditor/editcolorschemedialog.cpp @@ -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 ¤tFormat = 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); } diff --git a/src/plugins/texteditor/editcolorschemedialog.h b/src/plugins/texteditor/editcolorschemedialog.h index 5aa5d9a8c67..ef637aea541 100644 --- a/src/plugins/texteditor/editcolorschemedialog.h +++ b/src/plugins/texteditor/editcolorschemedialog.h @@ -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; diff --git a/src/plugins/texteditor/editcolorschemedialog.ui b/src/plugins/texteditor/editcolorschemedialog.ui index bb81b75a6be..a23d8e2ca2d 100644 --- a/src/plugins/texteditor/editcolorschemedialog.ui +++ b/src/plugins/texteditor/editcolorschemedialog.ui @@ -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"> -- GitLab