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_frame_cb->setChecked(m_text_field.data()->frame());
ui->m_user_text_le->setText(m_text_field.data()->text()); ui->m_user_text_le->setText(m_text_field.data()->text());
ui->m_size_sb->setValue(m_text_field.data()->font().pointSize()); 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_width_sb->setValue(m_text_field.data()->textWidth());
ui->m_font_pb->setText(m_text_field->font().family()); 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 * @brief DynamicTextFieldEditor::fillInfoComboBox
* Fill the combo box "element information" * Fill the combo box "element information"
@@ -201,19 +194,6 @@ void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
undoStack().push(undo); 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() void DynamicTextFieldEditor::on_m_frame_cb_clicked()
{ {
bool frame = ui->m_frame_cb->isChecked(); bool frame = ui->m_frame_cb->isChecked();
@@ -321,3 +301,13 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
undoStack().push(undo); 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);
}
}

View File

@@ -35,14 +35,13 @@ class DynamicTextFieldEditor : public ElementItemEditor
public: public:
explicit DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field = nullptr, QWidget *parent = nullptr); explicit DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field = nullptr, QWidget *parent = nullptr);
~DynamicTextFieldEditor(); ~DynamicTextFieldEditor() override;
bool setPart(CustomElementPart *part) override; bool setPart(CustomElementPart *part) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
void updateForm() override; void updateForm() override;
private: private:
void setColorPushButton(const QColor& color);
void fillInfoComboBox(); void fillInfoComboBox();
private slots: private slots:
@@ -51,7 +50,6 @@ class DynamicTextFieldEditor : public ElementItemEditor
void on_m_rotation_sb_editingFinished(); void on_m_rotation_sb_editingFinished();
void on_m_user_text_le_editingFinished(); void on_m_user_text_le_editingFinished();
void on_m_size_sb_editingFinished(); void on_m_size_sb_editingFinished();
void on_m_color_pb_clicked();
void on_m_frame_cb_clicked(); void on_m_frame_cb_clicked();
void on_m_width_sb_editingFinished(); void on_m_width_sb_editingFinished();
void on_m_elmt_info_cb_activated(const QString &arg1); 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_alignment_pb_clicked();
void on_m_font_pb_clicked(); void on_m_font_pb_clicked();
private: void on_m_color_kpb_changed(const QColor &newColor);
private:
Ui::DynamicTextFieldEditor *ui; Ui::DynamicTextFieldEditor *ui;
QPointer<PartDynamicTextField> m_text_field; QPointer<PartDynamicTextField> m_text_field;
QList<QMetaObject::Connection> m_connection_list; QList<QMetaObject::Connection> m_connection_list;

View File

@@ -40,13 +40,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="2">
<widget class="QPushButton" name="m_color_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="1"> <item row="8" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@@ -213,8 +206,18 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="2">
<widget class="KColorButton" name="m_color_kpb"/>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@@ -73,8 +73,6 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
m_properties = properties; 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)); int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style));
if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index); 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_pen_cb -> setChecked (m_properties.singleLineProperties.isPen());
ui->m_phase_cb -> setChecked (m_properties.singleLineProperties.phasesCount()); ui->m_phase_cb -> setChecked (m_properties.singleLineProperties.phasesCount());
ui->m_phase_slider -> setValue (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_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); 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; if (ui -> m_multiwires_gb -> isChecked()) properties_.type = ConductorProperties::Multi;
else if (ui -> m_singlewire_gb -> isChecked()) properties_.type = ConductorProperties::Single; 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_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_.m_dash_size = ui->m_dash_size_sb->value();
properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style(); properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
properties_.m_formula = ui->m_formula_le->text(); 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); 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 * @brief ConductorPropertiesWidget::on_m_update_preview_pb_clicked
* Update the preview of single line. * Update the preview of single line.
@@ -335,14 +302,3 @@ void ConductorPropertiesWidget::setColorButton2(const QColor &color)
void ConductorPropertiesWidget::on_m_update_preview_pb_clicked() { void ConductorPropertiesWidget::on_m_update_preview_pb_clicked() {
updatePreview(); 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);
}

View File

@@ -63,13 +63,8 @@ class ConductorPropertiesWidget : public QWidget
private slots: private slots:
void on_m_earth_cb_toggled(bool checked); void on_m_earth_cb_toggled(bool checked);
void on_m_neutral_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_update_preview_pb_clicked();
void on_m_color_2_pb_clicked();
private: private:
Ui::ConductorPropertiesWidget *ui; Ui::ConductorPropertiesWidget *ui;
ConductorProperties m_properties; ConductorProperties m_properties;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>716</width> <width>346</width>
<height>1073</height> <height>512</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -27,7 +27,7 @@
<item> <item>
<widget class="QGroupBox" name="m_multiwires_gb"> <widget class="QGroupBox" name="m_multiwires_gb">
<property name="title"> <property name="title">
<string>Multifilaire</string> <string>&amp;Multifilaire</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@@ -352,54 +352,18 @@
<string>Apparence</string> <string>Apparence</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="0" colspan="2"> <item row="4" column="0">
<widget class="QGroupBox" name="m_color_2_gb"> <spacer name="verticalSpacer">
<property name="title"> <property name="orientation">
<string>Couleur secondaire :</string> <enum>Qt::Vertical</enum>
</property> </property>
<property name="flat"> <property name="sizeHint" stdset="0">
<bool>true</bool> <size>
<width>20</width>
<height>40</height>
</size>
</property> </property>
<property name="checkable"> </spacer>
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QSpinBox" name="m_dash_size_sb">
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>2</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="m_color_2_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Couleur :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Taille de trait :</string>
</property>
</widget>
</item>
</layout>
</widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
@@ -411,49 +375,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QPushButton" name="m_color_pb">
<property name="toolTip">
<string>Couleur du conducteur</string>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Taille :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Style du conducteur</string>
</property>
<property name="text">
<string>Style :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_line_style_cb">
<property name="toolTip">
<string>Style du conducteur</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QDoubleSpinBox" name="m_cond_size_sb"> <widget class="QDoubleSpinBox" name="m_cond_size_sb">
<property name="minimum"> <property name="minimum">
@@ -470,18 +391,77 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="3" column="0" colspan="2">
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="m_color_2_gb">
<property name="orientation"> <property name="title">
<enum>Qt::Vertical</enum> <string>Couleur secondaire :</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="flat">
<size> <bool>true</bool>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> <property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Taille de trait :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_dash_size_sb">
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>2</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Couleur :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KColorButton" name="m_color_2_kpb"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Taille :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_line_style_cb">
<property name="toolTip">
<string>Style du conducteur</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Style du conducteur</string>
</property>
<property name="text">
<string>Style :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KColorButton" name="m_color_kpb"/>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -489,6 +469,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="../../qelectrotech.qrc"/> <include location="../../qelectrotech.qrc"/>
</resources> </resources>

View File

@@ -17,7 +17,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
<attribute name="title"> <attribute name="title">

View File

@@ -184,7 +184,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
new_pen.setStyle( Qt::CustomDashLine ); new_pen.setStyle( Qt::CustomDashLine );
} }
//painter.setPen( new_pen ); //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) if (new_pen != old_pen)
{ {
@@ -195,7 +195,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
QBrush old_brush = m_shape->brush(); QBrush old_brush = m_shape->brush();
QBrush new_brush = old_brush; QBrush new_brush = old_brush;
new_brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex())); 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) 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) if (c != QPalette().color(QPalette::Button) && shape_->pen().color() != c)
{ {
for (QPointer<QetShapeItem> qsi : m_shapes_list) for (QPointer<QetShapeItem> 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) if (c != QPalette().color(QPalette::Button) && shape_->brush().color() != c)
{ {
for (QPointer<QetShapeItem> qsi : m_shapes_list) for (QPointer<QetShapeItem> qsi : m_shapes_list)
@@ -327,7 +327,7 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
new_pen.setStyle( Qt::CustomDashLine ); new_pen.setStyle( Qt::CustomDashLine );
} }
//painter.setPen( new_pen ); //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) { if (new_pen != old_pen) {
new QPropertyUndoCommand(m_shape, "pen", old_pen, new_pen, undo); 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 old_brush = m_shape->brush();
QBrush new_brush = old_brush; QBrush new_brush = old_brush;
new_brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex())); 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) { if (new_brush != old_brush) {
new QPropertyUndoCommand(m_shape, "brush", old_brush, new_brush, undo); new QPropertyUndoCommand(m_shape, "brush", old_brush, new_brush, undo);
@@ -379,7 +379,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
//Pen //Pen
ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->pen().style()) - 1); ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->pen().style()) - 1);
ui->m_size_dsb ->setValue(m_shape->pen().widthF()); 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()); ui->m_color_kpb->setColor(m_shape->pen().color());
//Brush //Brush
@@ -387,7 +387,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
ui->m_filling_gb->setVisible(m_shape->isClosed()); ui->m_filling_gb->setVisible(m_shape->isClosed());
ui->m_brush_style_cb->setCurrentIndex(static_cast<int>(m_shape->brush().style())); ui->m_brush_style_cb->setCurrentIndex(static_cast<int>(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_lock_pos_cb->setChecked(!m_shape->isMovable());
ui->m_close_polygon->setChecked(m_shape->isClosed()); ui->m_close_polygon->setChecked(m_shape->isClosed());
@@ -424,7 +424,6 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
break; break;
} }
} }
setPenColorButton(same ? pc : QColor());
ui->m_color_kpb->setColor(same ? pc : QColor()); ui->m_color_kpb->setColor(same ? pc : QColor());
//Brush //Brush
@@ -448,7 +447,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
break; break;
} }
} }
setBrushColorButton(same ? bc : QColor()); ui->m_brush_color_kpb->setColor(same ? bc : QColor());
ui->m_lock_pos_cb->setChecked(false); ui->m_lock_pos_cb->setChecked(false);
ui->m_close_polygon->setChecked(false); ui->m_close_polygon->setChecked(false);
@@ -482,36 +481,6 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
return true; 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 * @brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
* Disconnect the previous connection, and reconnect the connection between the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function * 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) void ShapeGraphicsItemPropertiesWidget::on_m_color_kpb_changed(const QColor &newColor)
{ {
if (newColor.isValid()) if(newColor.isValid() && m_live_edit) {
{ apply();
setPenColorButton(newColor); }
if (m_live_edit) { }
apply();
} void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_kpb_changed(const QColor &newColor)
{
if(newColor.isValid() && m_live_edit) {
apply();
} }
} }

View File

@@ -52,18 +52,12 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
bool setLiveEdit(bool live_edit) override; bool setLiveEdit(bool live_edit) override;
private: private:
void setPenColorButton(const QColor &color);
void setBrushColorButton(const QColor &color);
void setUpEditConnection(); void setUpEditConnection();
private slots: private slots:
void on_m_lock_pos_cb_clicked(); 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_color_kpb_changed(const QColor &newColor);
void on_m_brush_color_kpb_changed(const QColor &newColor);
private: private:
Ui::ShapeGraphicsItemPropertiesWidget *ui; Ui::ShapeGraphicsItemPropertiesWidget *ui;

View File

@@ -20,13 +20,6 @@
<string>Trait</string> <string>Trait</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Épaisseur</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@@ -34,6 +27,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Épaisseur</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
@@ -42,16 +42,9 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QPushButton" name="m_color_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="KColorButton" name="m_color_kpb"/> <widget class="KColorButton" name="m_color_kpb"/>
</item> </item>
<item row="1" column="1" colspan="2"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_size_dsb"> <widget class="QDoubleSpinBox" name="m_size_dsb">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@@ -85,7 +78,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="2"> <item row="0" column="1">
<widget class="QComboBox" name="m_style_cb"> <widget class="QComboBox" name="m_style_cb">
<item> <item>
<property name="text"> <property name="text">
@@ -128,13 +121,6 @@
<string>Remplissage</string> <string>Remplissage</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="m_brush_style_cb"> <widget class="QComboBox" name="m_brush_style_cb">
<item> <item>
@@ -214,6 +200,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
@@ -222,11 +215,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="m_brush_color_pb"> <widget class="KColorButton" name="m_brush_color_kpb"/>
<property name="text">
<string/>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>