From 41a737e6de4dcfed6c9b886294560e5248844ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 17 Dec 2009 11:46:55 +0100 Subject: [PATCH] Fixed enabled state of erase background button in color scheme edit Remember the read-only state so that it can be taken into account when changing the enabled state of the erase background button. --- src/plugins/texteditor/colorschemeedit.cpp | 12 ++++++++++-- src/plugins/texteditor/colorschemeedit.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index c47534e5a2e..9f70d3154d6 100644 --- a/src/plugins/texteditor/colorschemeedit.cpp +++ b/src/plugins/texteditor/colorschemeedit.cpp @@ -143,7 +143,8 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : QWidget(parent), m_curItem(-1), m_ui(new Ui::ColorSchemeEdit), - m_formatsModel(new FormatsModel(this)) + m_formatsModel(new FormatsModel(this)), + m_readOnly(false) { m_ui->setupUi(this); m_ui->itemList->setModel(m_formatsModel); @@ -178,6 +179,11 @@ void ColorSchemeEdit::setBaseFont(const QFont &font) void ColorSchemeEdit::setReadOnly(bool readOnly) { + if (m_readOnly == readOnly) + return; + + m_readOnly = readOnly; + const bool enabled = !readOnly; m_ui->foregroundLabel->setEnabled(enabled); m_ui->foregroundToolButton->setEnabled(enabled); @@ -216,7 +222,9 @@ void ColorSchemeEdit::updateControls() m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground())); m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background())); - m_ui->eraseBackgroundToolButton->setEnabled(m_curItem > 0 && format.background().isValid()); + m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly + && m_curItem > 0 + && format.background().isValid()); const bool boldBlocked = m_ui->boldCheckBox->blockSignals(true); m_ui->boldCheckBox->setChecked(format.bold()); diff --git a/src/plugins/texteditor/colorschemeedit.h b/src/plugins/texteditor/colorschemeedit.h index b0c57784298..98d9829e56c 100644 --- a/src/plugins/texteditor/colorschemeedit.h +++ b/src/plugins/texteditor/colorschemeedit.h @@ -82,6 +82,7 @@ private: int m_curItem; Ui::ColorSchemeEdit *m_ui; FormatsModel *m_formatsModel; + bool m_readOnly; };