forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -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)
|
|||||||
|
|
||||||
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()
|
|||||||
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:
|
|||||||
int m_curItem;
|
int m_curItem;
|
||||||
Ui::ColorSchemeEdit *m_ui;
|
Ui::ColorSchemeEdit *m_ui;
|
||||||
FormatsModel *m_formatsModel;
|
FormatsModel *m_formatsModel;
|
||||||
|
bool m_readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user