diff --git a/src/plugins/texteditor/colorschemeedit.cpp b/src/plugins/texteditor/colorschemeedit.cpp index c47534e5a2e208f817690bdae4a4e443045806ac..9f70d3154d6dff5437bfa1d04cf6d5b7e6d62931 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 b0c5778429882f80ee0f079c302c068f02849b46..98d9829e56c2303dd942cf002920c7ecbba79761 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; };