diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index d8cbafbd8..7834cd622 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -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); + } +} diff --git a/sources/editor/ui/dynamictextfieldeditor.h b/sources/editor/ui/dynamictextfieldeditor.h index ad7b730bd..a1a074db4 100644 --- a/sources/editor/ui/dynamictextfieldeditor.h +++ b/sources/editor/ui/dynamictextfieldeditor.h @@ -35,14 +35,13 @@ class DynamicTextFieldEditor : public ElementItemEditor public: explicit DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field = nullptr, QWidget *parent = nullptr); - ~DynamicTextFieldEditor(); + ~DynamicTextFieldEditor() override; bool setPart(CustomElementPart *part) override; CustomElementPart *currentPart() const override; void updateForm() override; private: - void setColorPushButton(const QColor& color); void fillInfoComboBox(); private slots: @@ -50,8 +49,7 @@ class DynamicTextFieldEditor : public ElementItemEditor void on_m_y_sb_editingFinished(); void on_m_rotation_sb_editingFinished(); void on_m_user_text_le_editingFinished(); - void on_m_size_sb_editingFinished(); - void on_m_color_pb_clicked(); + void on_m_size_sb_editingFinished(); void on_m_frame_cb_clicked(); void on_m_width_sb_editingFinished(); void on_m_elmt_info_cb_activated(const QString &arg1); @@ -60,7 +58,9 @@ class DynamicTextFieldEditor : public ElementItemEditor void on_m_alignment_pb_clicked(); void on_m_font_pb_clicked(); - private: + void on_m_color_kpb_changed(const QColor &newColor); + + private: Ui::DynamicTextFieldEditor *ui; QPointer m_text_field; QList m_connection_list; diff --git a/sources/editor/ui/dynamictextfieldeditor.ui b/sources/editor/ui/dynamictextfieldeditor.ui index c62fb586b..5a8fc1f27 100644 --- a/sources/editor/ui/dynamictextfieldeditor.ui +++ b/sources/editor/ui/dynamictextfieldeditor.ui @@ -40,13 +40,6 @@ - - - - - - - @@ -213,8 +206,18 @@ + + + + + + KColorButton + QPushButton +
kcolorbutton.h
+
+
diff --git a/sources/ui/conductorpropertieswidget.cpp b/sources/ui/conductorpropertieswidget.cpp index 5351a46e8..571669106 100644 --- a/sources/ui/conductorpropertieswidget.cpp +++ b/sources/ui/conductorpropertieswidget.cpp @@ -73,8 +73,6 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert m_properties = properties; - setColorButton(m_properties.color); - setColorButton2(m_properties.m_color_2); int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style)); if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index); @@ -93,6 +91,8 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert ui->m_pen_cb -> setChecked (m_properties.singleLineProperties.isPen()); ui->m_phase_cb -> setChecked (m_properties.singleLineProperties.phasesCount()); ui->m_phase_slider -> setValue (m_properties.singleLineProperties.phasesCount()); + ui->m_color_kpb -> setColor(m_properties.color); + ui->m_color_2_kpb -> setColor(m_properties.m_color_2); ui->m_horiz_cb->setCurrentIndex(m_properties.m_horizontal_alignment == Qt::AlignTop? 0 : 1); ui->m_verti_cb->setCurrentIndex(m_properties.m_vertical_alignment == Qt::AlignLeft? 0 : 1); @@ -113,9 +113,9 @@ ConductorProperties ConductorPropertiesWidget::properties() const if (ui -> m_multiwires_gb -> isChecked()) properties_.type = ConductorProperties::Multi; else if (ui -> m_singlewire_gb -> isChecked()) properties_.type = ConductorProperties::Single; - properties_.color = ui -> m_color_pb->palette().color(QPalette::Button); + properties_.color = ui -> m_color_kpb->color(); properties_.m_bicolor = ui->m_color_2_gb->isChecked(); - properties_.m_color_2 = ui->m_color_2_pb->palette().color(QPalette::Button); + properties_.m_color_2 = ui->m_color_2_kpb->color(); properties_.m_dash_size = ui->m_dash_size_sb->value(); properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value().style(); properties_.m_formula = ui->m_formula_le->text(); @@ -292,39 +292,6 @@ void ConductorPropertiesWidget::on_m_neutral_cb_toggled(bool checked) { else ui -> m_pen_cb -> setDisabled(true); } -/** - * @brief ConductorPropertiesWidget::on_m_color_pb_clicked - * Open a color dialog, for choose the color of conductor - */ -void ConductorPropertiesWidget::on_m_color_pb_clicked() { - QColor color = QColorDialog::getColor(m_properties.color, this); - if (color.isValid()) - setColorButton(color); -} - -/** - * @brief ConductorPropertiesWidget::setColorButton - * Set m_color_pb to @color - * @param color - */ -void ConductorPropertiesWidget::setColorButton(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 ConductorPropertiesWidget::setColorButton2 - * Set m_color_2_pb to @color - * @param color - */ -void ConductorPropertiesWidget::setColorButton2(const QColor &color) -{ - QPalette palette; - palette.setColor(QPalette::Button, color); - ui->m_color_2_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 ConductorPropertiesWidget::on_m_update_preview_pb_clicked * Update the preview of single line. @@ -335,14 +302,3 @@ void ConductorPropertiesWidget::setColorButton2(const QColor &color) void ConductorPropertiesWidget::on_m_update_preview_pb_clicked() { updatePreview(); } - -/** - * @brief ConductorPropertiesWidget::on_m_color_2_pb_clicked - * Open a color dialog, for choose the second color of conductor - */ -void ConductorPropertiesWidget::on_m_color_2_pb_clicked() -{ - QColor color = QColorDialog::getColor(m_properties.m_color_2, this); - if (color.isValid()) - setColorButton2(color); -} diff --git a/sources/ui/conductorpropertieswidget.h b/sources/ui/conductorpropertieswidget.h index d5d053483..65a4d3e75 100644 --- a/sources/ui/conductorpropertieswidget.h +++ b/sources/ui/conductorpropertieswidget.h @@ -63,13 +63,8 @@ class ConductorPropertiesWidget : public QWidget private slots: void on_m_earth_cb_toggled(bool checked); void on_m_neutral_cb_toggled(bool checked); - void on_m_color_pb_clicked(); - void setColorButton (const QColor &color); - void setColorButton2 (const QColor &color); void on_m_update_preview_pb_clicked(); - void on_m_color_2_pb_clicked(); - private: Ui::ConductorPropertiesWidget *ui; ConductorProperties m_properties; diff --git a/sources/ui/conductorpropertieswidget.ui b/sources/ui/conductorpropertieswidget.ui index 6ee184ce3..2a0be7211 100644 --- a/sources/ui/conductorpropertieswidget.ui +++ b/sources/ui/conductorpropertieswidget.ui @@ -6,8 +6,8 @@ 0 0 - 716 - 1073 + 346 + 512 @@ -27,7 +27,7 @@ - Multifilaire + &Multifilaire true @@ -352,54 +352,18 @@ Apparence - - - - Couleur secondaire : + + + + Qt::Vertical - - true + + + 20 + 40 + - - true - - - false - - - - - - px - - - 2 - - - - - - - - - - - - - - Couleur : - - - - - - - Taille de trait : - - - - - + @@ -411,49 +375,6 @@ - - - - Couleur du conducteur - - - - - - false - - - - - - false - - - - - - - Taille : - - - - - - - Style du conducteur - - - Style : - - - - - - - Style du conducteur - - - @@ -470,18 +391,77 @@ - - - - Qt::Vertical + + + + Couleur secondaire : - - - 20 - 40 - + + true - + + true + + + false + + + + + + Taille de trait : + + + + + + + px + + + 2 + + + + + + + Couleur : + + + + + + + + + + + + + Taille : + + + + + + + Style du conducteur + + + + + + + Style du conducteur + + + Style : + + + + + @@ -489,6 +469,13 @@ + + + KColorButton + QPushButton +
kcolorbutton.h
+
+
diff --git a/sources/ui/configpage/generalconfigurationpage.ui b/sources/ui/configpage/generalconfigurationpage.ui index 96e72fabd..402988956 100644 --- a/sources/ui/configpage/generalconfigurationpage.ui +++ b/sources/ui/configpage/generalconfigurationpage.ui @@ -17,7 +17,7 @@ - 4 + 0 diff --git a/sources/ui/shapegraphicsitempropertieswidget.cpp b/sources/ui/shapegraphicsitempropertieswidget.cpp index 9acef8c53..f0788760c 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.cpp +++ b/sources/ui/shapegraphicsitempropertieswidget.cpp @@ -184,7 +184,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const new_pen.setStyle( Qt::CustomDashLine ); } //painter.setPen( new_pen ); - new_pen.setColor(ui->m_color_pb->palette().color(QPalette::Button)); + new_pen.setColor(ui->m_color_kpb->color()); if (new_pen != old_pen) { @@ -195,7 +195,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const QBrush old_brush = m_shape->brush(); QBrush new_brush = old_brush; new_brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex())); - new_brush.setColor(ui->m_brush_color_pb->palette().color(QPalette::Button)); + new_brush.setColor(ui->m_brush_color_kpb->color()); if (new_brush != old_brush) { @@ -257,7 +257,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const } } - QColor c =ui->m_color_pb->palette().color(QPalette::Button); + QColor c =ui->m_color_kpb->color(); if (c != QPalette().color(QPalette::Button) && shape_->pen().color() != c) { for (QPointer qsi : m_shapes_list) @@ -289,7 +289,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const } } - c = ui->m_brush_color_pb->palette().color(QPalette::Button); + c = ui->m_brush_color_kpb->color(); if (c != QPalette().color(QPalette::Button) && shape_->brush().color() != c) { for (QPointer qsi : m_shapes_list) @@ -327,7 +327,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const new_pen.setStyle( Qt::CustomDashLine ); } //painter.setPen( new_pen ); - new_pen.setColor(ui->m_color_pb->palette().color(QPalette::Button)); + new_pen.setColor(ui->m_color_kpb->color()); if (new_pen != old_pen) { new QPropertyUndoCommand(m_shape, "pen", old_pen, new_pen, undo); @@ -336,7 +336,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const QBrush old_brush = m_shape->brush(); QBrush new_brush = old_brush; new_brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex())); - new_brush.setColor(ui->m_brush_color_pb->palette().color(QPalette::Button)); + new_brush.setColor(ui->m_brush_color_kpb->color()); if (new_brush != old_brush) { new QPropertyUndoCommand(m_shape, "brush", old_brush, new_brush, undo); @@ -379,7 +379,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() //Pen ui->m_style_cb->setCurrentIndex(static_cast(m_shape->pen().style()) - 1); ui->m_size_dsb ->setValue(m_shape->pen().widthF()); - setPenColorButton(m_shape->pen().color()); + ui->m_color_kpb->setColor(m_shape->pen().color()); ui->m_color_kpb->setColor(m_shape->pen().color()); //Brush @@ -387,7 +387,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() ui->m_filling_gb->setVisible(m_shape->isClosed()); ui->m_brush_style_cb->setCurrentIndex(static_cast(m_shape->brush().style())); - setBrushColorButton(m_shape->brush().color()); + ui->m_brush_color_kpb->setColor(m_shape->brush().color()); ui->m_lock_pos_cb->setChecked(!m_shape->isMovable()); ui->m_close_polygon->setChecked(m_shape->isClosed()); @@ -424,7 +424,6 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() break; } } - setPenColorButton(same ? pc : QColor()); ui->m_color_kpb->setColor(same ? pc : QColor()); //Brush @@ -448,7 +447,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() break; } } - setBrushColorButton(same ? bc : QColor()); + ui->m_brush_color_kpb->setColor(same ? bc : QColor()); ui->m_lock_pos_cb->setChecked(false); ui->m_close_polygon->setChecked(false); @@ -482,36 +481,6 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit) return true; } -/** - * @brief ShapeGraphicsItemPropertiesWidget::setPenColorButton - * Set the color of pen push button to the current color of the shape pen - * @param color - */ -void ShapeGraphicsItemPropertiesWidget::setPenColorButton(const QColor &color) -{ - if (!color.isValid()) { - ui->m_color_pb->setStyleSheet(""); - return; - } - - ui->m_color_pb->setStyleSheet(QString("background-color : %1").arg(color.name())); -} - -/** - * @brief ShapeGraphicsItemPropertiesWidget::setBrushColorButton - * Set the color of brush push button to the current color of shape brush - * @param color - */ -void ShapeGraphicsItemPropertiesWidget::setBrushColorButton(const QColor &color) -{ - if (!color.isValid()) { - ui->m_brush_color_pb->setStyleSheet(""); - return; - } - - ui->m_brush_color_pb->setStyleSheet(QString("background-color : %1").arg(color.name())); -} - /** * @brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection * Disconnect the previous connection, and reconnect the connection between the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function @@ -546,54 +515,16 @@ void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() } } -/** - * @brief ShapeGraphicsItemPropertiesWidget::on_m_color_pb_clicked - * Pen color button was clicked, we open a QColorDialog for select the color to apply to the shape pen. - */ -void ShapeGraphicsItemPropertiesWidget::on_m_color_pb_clicked() -{ - if (!m_shape && m_shapes_list.isEmpty()) { - return; - } - QetShapeItem *shape_ = m_shape ? m_shape : m_shapes_list.first().data(); - QColor color = QColorDialog::getColor(shape_->pen().color(), this); - if (color.isValid()) { - setPenColorButton(color); - } - if (m_live_edit) { - apply(); - } -} - -/** - * @brief ShapeGraphicsItemPropertiesWidget::on_m_brush_color_pb_clicked - * Brush color button was clicked, we open a QColorDialog for select the color to apply to the shape brush. - */ -void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_pb_clicked() -{ - if (!m_shape && m_shapes_list.isEmpty()) { - return; - } - QetShapeItem *shape_ = m_shape ? m_shape : m_shapes_list.first().data(); - - QColor color = QColorDialog::getColor(shape_->brush().color(), this); - if (color.isValid()) { - setBrushColorButton(color); - } - if (m_live_edit) { - apply(); - } -} - - - void ShapeGraphicsItemPropertiesWidget::on_m_color_kpb_changed(const QColor &newColor) { - if (newColor.isValid()) - { - setPenColorButton(newColor); - if (m_live_edit) { - apply(); - } + if(newColor.isValid() && m_live_edit) { + apply(); + } +} + +void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_kpb_changed(const QColor &newColor) +{ + if(newColor.isValid() && m_live_edit) { + apply(); } } diff --git a/sources/ui/shapegraphicsitempropertieswidget.h b/sources/ui/shapegraphicsitempropertieswidget.h index 05ce690e4..02bee42ff 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.h +++ b/sources/ui/shapegraphicsitempropertieswidget.h @@ -52,18 +52,12 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget bool setLiveEdit(bool live_edit) override; private: - void setPenColorButton(const QColor &color); - void setBrushColorButton(const QColor &color); void setUpEditConnection(); private slots: void on_m_lock_pos_cb_clicked(); - void on_m_color_pb_clicked(); - void on_m_brush_color_pb_clicked(); - - - void on_m_color_kpb_changed(const QColor &newColor); + void on_m_brush_color_kpb_changed(const QColor &newColor); private: Ui::ShapeGraphicsItemPropertiesWidget *ui; diff --git a/sources/ui/shapegraphicsitempropertieswidget.ui b/sources/ui/shapegraphicsitempropertieswidget.ui index 4e97bcd0d..ae1b547fa 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.ui +++ b/sources/ui/shapegraphicsitempropertieswidget.ui @@ -20,13 +20,6 @@ Trait
- - - - Épaisseur - - - @@ -34,6 +27,13 @@ + + + + Épaisseur + + + @@ -42,16 +42,9 @@ - - - - - - - - + @@ -85,7 +78,7 @@ - + @@ -128,13 +121,6 @@ Remplissage - - - - Style - - - @@ -214,6 +200,13 @@ + + + + Style + + + @@ -222,11 +215,7 @@ - - - - - +