use KColorButton instead of QPushButton when needed

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5787 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2019-03-15 18:07:57 +00:00
parent d4b49ed07c
commit 47b78bfec1
10 changed files with 156 additions and 311 deletions

View File

@@ -105,7 +105,7 @@ void DynamicTextFieldEditor::updateForm()
ui->m_frame_cb->setChecked(m_text_field.data()->frame());
ui->m_user_text_le->setText(m_text_field.data()->text());
ui->m_size_sb->setValue(m_text_field.data()->font().pointSize());
setColorPushButton(m_text_field.data()->color());
ui->m_color_kpb->setColor(m_text_field.data()->color());
ui->m_width_sb->setValue(m_text_field.data()->textWidth());
ui->m_font_pb->setText(m_text_field->font().family());
@@ -128,13 +128,6 @@ void DynamicTextFieldEditor::updateForm()
}
}
void DynamicTextFieldEditor::setColorPushButton(const QColor& color)
{
QPalette palette;
palette.setColor(QPalette::Button, color);
ui->m_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
}
/**
* @brief DynamicTextFieldEditor::fillInfoComboBox
* Fill the combo box "element information"
@@ -201,19 +194,6 @@ void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
undoStack().push(undo);
}
void DynamicTextFieldEditor::on_m_color_pb_clicked()
{
QColor color = QColorDialog::getColor(m_text_field.data()->color(), this, tr("Couleur du texte"));
if(color.isValid() && color != m_text_field.data()->color())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "color", m_text_field.data()->color(), color);
undo->setText(tr("Modifier la couleur d'un champ texte"));
undoStack().push(undo);
setColorPushButton(m_text_field.data()->color());
}
}
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
{
bool frame = ui->m_frame_cb->isChecked();
@@ -321,3 +301,13 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
undoStack().push(undo);
}
}
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
{
if(newColor.isValid() && newColor != m_text_field.data()->color())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "color", m_text_field.data()->color(), newColor);
undo->setText(tr("Modifier la couleur d'un champ texte"));
undoStack().push(undo);
}
}