[qet] qet/qet: [5787] use KColorButton instead of QPushButton when needed

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5787
Author:   blacksun
Date:     2019-03-15 19:07:57 +0100 (Fri, 15 Mar 2019)
Log Message:
-----------
use KColorButton instead of QPushButton when needed 

Modified Paths:
--------------
    trunk/sources/editor/ui/dynamictextfieldeditor.cpp
    trunk/sources/editor/ui/dynamictextfieldeditor.h
    trunk/sources/editor/ui/dynamictextfieldeditor.ui
    trunk/sources/ui/conductorpropertieswidget.cpp
    trunk/sources/ui/conductorpropertieswidget.h
    trunk/sources/ui/conductorpropertieswidget.ui
    trunk/sources/ui/configpage/generalconfigurationpage.ui
    trunk/sources/ui/shapegraphicsitempropertieswidget.cpp
    trunk/sources/ui/shapegraphicsitempropertieswidget.h
    trunk/sources/ui/shapegraphicsitempropertieswidget.ui

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.cpp
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.cpp	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.cpp	2019-03-15 18:07:57 UTC (rev 5787)
@@ -105,7 +105,7 @@
 		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::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 @@
 	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 @@
 		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);
+	}
+}

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.h
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.h	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.h	2019-03-15 18:07:57 UTC (rev 5787)
@@ -35,7 +35,7 @@
 	
 	public:
 		explicit DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field = nullptr, QWidget *parent = nullptr);
-		~DynamicTextFieldEditor();
+		~DynamicTextFieldEditor() override;
 	
 		bool setPart(CustomElementPart *part) override;
 		CustomElementPart *currentPart() const override;
@@ -42,7 +42,6 @@
 		void updateForm() override;
 		
 	private:
-		void setColorPushButton(const QColor& color);
 		void fillInfoComboBox();
 	
 	private slots:
@@ -50,8 +49,7 @@
 		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 @@
 		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<PartDynamicTextField> m_text_field;
 		QList<QMetaObject::Connection> m_connection_list;

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.ui
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.ui	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.ui	2019-03-15 18:07:57 UTC (rev 5787)
@@ -40,13 +40,6 @@
      </property>
     </widget>
    </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">
     <spacer name="verticalSpacer">
      <property name="orientation">
@@ -213,8 +206,18 @@
      </property>
     </widget>
    </item>
+   <item row="7" column="1" colspan="2">
+    <widget class="KColorButton" name="m_color_kpb"/>
+   </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KColorButton</class>
+   <extends>QPushButton</extends>
+   <header>kcolorbutton.h</header>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>

Modified: trunk/sources/ui/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.cpp	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/conductorpropertieswidget.cpp	2019-03-15 18:07:57 UTC (rev 5787)
@@ -73,8 +73,6 @@
 	
 	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 @@
 	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 @@
 	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<QPen>().style();
 	properties_.m_formula               = ui->m_formula_le->text();
@@ -293,39 +293,6 @@
 }
 
 /**
- * @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.
  * m_update_preview_pb is a no used button and hidden, his role is only
@@ -335,14 +302,3 @@
 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);
-}

Modified: trunk/sources/ui/conductorpropertieswidget.h
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.h	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/conductorpropertieswidget.h	2019-03-15 18:07:57 UTC (rev 5787)
@@ -63,13 +63,8 @@
 	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;

Modified: trunk/sources/ui/conductorpropertieswidget.ui
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.ui	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/conductorpropertieswidget.ui	2019-03-15 18:07:57 UTC (rev 5787)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>716</width>
-    <height>1073</height>
+    <width>346</width>
+    <height>512</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -27,7 +27,7 @@
        <item>
         <widget class="QGroupBox" name="m_multiwires_gb">
          <property name="title">
-          <string>Multifilaire</string>
+          <string>&amp;Multifilaire</string>
          </property>
          <property name="checkable">
           <bool>true</bool>
@@ -352,6 +352,45 @@
        <string>Apparence</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_4">
+       <item row="4" column="0">
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item row="0" column="0">
+        <widget class="QLabel" name="label_6">
+         <property name="toolTip">
+          <string>Couleur du conducteur</string>
+         </property>
+         <property name="text">
+          <string>Couleur :</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1">
+        <widget class="QDoubleSpinBox" name="m_cond_size_sb">
+         <property name="minimum">
+          <double>0.400000000000000</double>
+         </property>
+         <property name="maximum">
+          <double>10.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>0.200000000000000</double>
+         </property>
+         <property name="value">
+          <double>1.000000000000000</double>
+         </property>
+        </widget>
+       </item>
        <item row="3" column="0" colspan="2">
         <widget class="QGroupBox" name="m_color_2_gb">
          <property name="title">
@@ -367,6 +406,13 @@
           <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">
@@ -377,13 +423,6 @@
             </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">
@@ -391,52 +430,26 @@
             </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 row="0" column="1">
+           <widget class="KColorButton" name="m_color_2_kpb"/>
           </item>
          </layout>
         </widget>
        </item>
-       <item row="0" column="0">
-        <widget class="QLabel" name="label_6">
-         <property name="toolTip">
-          <string>Couleur du conducteur</string>
-         </property>
+       <item row="2" column="0">
+        <widget class="QLabel" name="label_10">
          <property name="text">
-          <string>Couleur :</string>
+          <string>Taille :</string>
          </property>
         </widget>
        </item>
-       <item row="0" column="1">
-        <widget class="QPushButton" name="m_color_pb">
+       <item row="1" column="1">
+        <widget class="QComboBox" name="m_line_style_cb">
          <property name="toolTip">
-          <string>Couleur du conducteur</string>
+          <string>Style 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">
@@ -447,42 +460,9 @@
          </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 row="0" column="1">
+        <widget class="KColorButton" name="m_color_kpb"/>
        </item>
-       <item row="2" column="1">
-        <widget class="QDoubleSpinBox" name="m_cond_size_sb">
-         <property name="minimum">
-          <double>0.400000000000000</double>
-         </property>
-         <property name="maximum">
-          <double>10.000000000000000</double>
-         </property>
-         <property name="singleStep">
-          <double>0.200000000000000</double>
-         </property>
-         <property name="value">
-          <double>1.000000000000000</double>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="0">
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
       </layout>
      </widget>
     </widget>
@@ -489,6 +469,13 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KColorButton</class>
+   <extends>QPushButton</extends>
+   <header>kcolorbutton.h</header>
+  </customwidget>
+ </customwidgets>
  <resources>
   <include location="../../qelectrotech.qrc"/>
  </resources>

Modified: trunk/sources/ui/configpage/generalconfigurationpage.ui
===================================================================
--- trunk/sources/ui/configpage/generalconfigurationpage.ui	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/configpage/generalconfigurationpage.ui	2019-03-15 18:07:57 UTC (rev 5787)
@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>4</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="tab_3">
       <attribute name="title">

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.cpp
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.cpp	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.cpp	2019-03-15 18:07:57 UTC (rev 5787)
@@ -184,7 +184,7 @@
 				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 @@
 			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 @@
 				}
 			}
 
-			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<QetShapeItem> qsi : m_shapes_list)
@@ -289,7 +289,7 @@
 				}
 			}
 
-			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<QetShapeItem> qsi : m_shapes_list)
@@ -327,7 +327,7 @@
 			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 @@
 		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,8 +379,8 @@
 		//Pen
 		ui->m_style_cb->setCurrentIndex(static_cast<int>(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
 		if (m_shape->shapeType() == QetShapeItem::Polygon)
@@ -387,7 +387,7 @@
 			ui->m_filling_gb->setVisible(m_shape->isClosed());
 
 		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_close_polygon->setChecked(m_shape->isClosed());
@@ -424,7 +424,6 @@
 				break;
 			}
 		}
-		setPenColorButton(same ? pc : QColor());
 		ui->m_color_kpb->setColor(same ? pc : QColor());
 
 			//Brush
@@ -448,7 +447,7 @@
 				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);
@@ -483,36 +482,6 @@
 }
 
 /**
- * @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 @@
 	}
 }
 
-/**
- * @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()
+void ShapeGraphicsItemPropertiesWidget::on_m_color_kpb_changed(const QColor &newColor)
 {
-	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) {
+	if(newColor.isValid() && 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()
+void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_kpb_changed(const QColor &newColor)
 {
-	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) {
+	if(newColor.isValid() && m_live_edit) {
 		apply();
 	}
 }
-
-
-
-void ShapeGraphicsItemPropertiesWidget::on_m_color_kpb_changed(const QColor &newColor)
-{
-	if (newColor.isValid())
-	{
-		setPenColorButton(newColor);
-		if (m_live_edit) {
-			apply();
-		}
-	}
-}

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.h
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.h	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.h	2019-03-15 18:07:57 UTC (rev 5787)
@@ -52,18 +52,12 @@
 		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;

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.ui
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.ui	2019-03-15 16:53:13 UTC (rev 5786)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.ui	2019-03-15 18:07:57 UTC (rev 5787)
@@ -20,17 +20,17 @@
       <string>Trait</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_2">
-      <item row="1" column="0">
-       <widget class="QLabel" name="label_2">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label">
         <property name="text">
-         <string>Épaisseur</string>
+         <string>Type</string>
         </property>
        </widget>
       </item>
-      <item row="0" column="0">
-       <widget class="QLabel" name="label">
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_2">
         <property name="text">
-         <string>Type</string>
+         <string>Épaisseur</string>
         </property>
        </widget>
       </item>
@@ -42,16 +42,9 @@
        </widget>
       </item>
       <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"/>
       </item>
-      <item row="1" column="1" colspan="2">
+      <item row="1" column="1">
        <widget class="QDoubleSpinBox" name="m_size_dsb">
         <property name="maximumSize">
          <size>
@@ -85,7 +78,7 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1" colspan="2">
+      <item row="0" column="1">
        <widget class="QComboBox" name="m_style_cb">
         <item>
          <property name="text">
@@ -128,13 +121,6 @@
       <string>Remplissage</string>
      </property>
      <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">
        <widget class="QComboBox" name="m_brush_style_cb">
         <item>
@@ -214,6 +200,13 @@
         </item>
        </widget>
       </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">
        <widget class="QLabel" name="label_5">
         <property name="text">
@@ -222,11 +215,7 @@
        </widget>
       </item>
       <item row="1" column="1">
-       <widget class="QPushButton" name="m_brush_color_pb">
-        <property name="text">
-         <string/>
-        </property>
-       </widget>
+       <widget class="KColorButton" name="m_brush_color_kpb"/>
       </item>
      </layout>
     </widget>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/