Commit 41a737e6 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

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.
parent 777071c9
...@@ -143,7 +143,8 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) : ...@@ -143,7 +143,8 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) :
QWidget(parent), QWidget(parent),
m_curItem(-1), m_curItem(-1),
m_ui(new Ui::ColorSchemeEdit), m_ui(new Ui::ColorSchemeEdit),
m_formatsModel(new FormatsModel(this)) m_formatsModel(new FormatsModel(this)),
m_readOnly(false)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->itemList->setModel(m_formatsModel); m_ui->itemList->setModel(m_formatsModel);
...@@ -178,6 +179,11 @@ void ColorSchemeEdit::setBaseFont(const QFont &font) ...@@ -178,6 +179,11 @@ void ColorSchemeEdit::setBaseFont(const QFont &font)
void ColorSchemeEdit::setReadOnly(bool readOnly) void ColorSchemeEdit::setReadOnly(bool readOnly)
{ {
if (m_readOnly == readOnly)
return;
m_readOnly = readOnly;
const bool enabled = !readOnly; const bool enabled = !readOnly;
m_ui->foregroundLabel->setEnabled(enabled); m_ui->foregroundLabel->setEnabled(enabled);
m_ui->foregroundToolButton->setEnabled(enabled); m_ui->foregroundToolButton->setEnabled(enabled);
...@@ -216,7 +222,9 @@ void ColorSchemeEdit::updateControls() ...@@ -216,7 +222,9 @@ void ColorSchemeEdit::updateControls()
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground())); m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground()));
m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background())); 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); const bool boldBlocked = m_ui->boldCheckBox->blockSignals(true);
m_ui->boldCheckBox->setChecked(format.bold()); m_ui->boldCheckBox->setChecked(format.bold());
......
...@@ -82,6 +82,7 @@ private: ...@@ -82,6 +82,7 @@ private:
int m_curItem; int m_curItem;
Ui::ColorSchemeEdit *m_ui; Ui::ColorSchemeEdit *m_ui;
FormatsModel *m_formatsModel; FormatsModel *m_formatsModel;
bool m_readOnly;
}; };
......
Markdown is supported
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