[qet] [4294] Improve Basic shapes Properties size function

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


Revision: 4294
Author:   scorpio810
Date:     2015-12-30 14:47:21 +0100 (Wed, 30 Dec 2015)
Log Message:
-----------
Improve Basic shapes Properties size function

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/qetshapeitem.cpp
    trunk/sources/qetgraphicsitem/qetshapeitem.h
    trunk/sources/ui/shapegraphicsitempropertieswidget.cpp
    trunk/sources/ui/shapegraphicsitempropertieswidget.h
    trunk/sources/ui/shapegraphicsitempropertieswidget.ui

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2015-12-30 09:39:22 UTC (rev 4293)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2015-12-30 13:47:21 UTC (rev 4294)
@@ -38,13 +38,14 @@
 	m_P2 (p2),
 	m_hovered(false),
 	m_mouse_grab_handler(false),
+	shape_size(1),
 	m_handler(10)
 {
 	if (type == Polygon) m_polygon << m_P1 << m_P2;
 	setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
 	setAcceptHoverEvents(true);
 	m_pen.setStyle(Qt::DashLine);
-	m_pen.setWidthF(1);
+
 }
 
 QetShapeItem::~QetShapeItem() {}
@@ -458,6 +459,7 @@
 
 	is_movable_ = (e.attribute("is_movable").toInt());
 	m_pen.setStyle(Qt::PenStyle(e.attribute("style","0").toInt()));
+	m_pen.setWidthF(e.attribute("shape_size", QString::number(shape_size)).toInt());
 
 	QString type = e.attribute("type");
 		//Compatibility for version older than N°4075, shape type was stored with an int
@@ -506,6 +508,7 @@
 	QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
 	result.setAttribute("type", me.valueToKey(m_shapeType));
 	result.setAttribute("style", QString::number(m_pen.style()));
+	result.setAttribute("shape_size", QString::number(m_pen.widthF()));
 	result.setAttribute("is_movable", bool(is_movable_));
 	if (m_shapeType != Polygon)
 	{

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.h	2015-12-30 09:39:22 UTC (rev 4293)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.h	2015-12-30 13:47:21 UTC (rev 4294)
@@ -96,13 +96,14 @@
 
 		///ATTRIBUTES
 	private:
-		ShapeType    m_shapeType;
+		ShapeType	 m_shapeType;
 		QPen		 m_pen;
 		QPointF		 m_P1, m_P2, m_old_P1, m_old_P2;
 		QPolygonF	 m_polygon, m_old_polygon;
-		bool         m_hovered,
+		bool		 m_hovered,
 					 m_mouse_grab_handler;
 		int			 m_vector_index;
+		int			 shape_size;
 		QetGraphicsHandlerUtility m_handler;
 };
 #endif // QETSHAPEITEM_H

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.cpp
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.cpp	2015-12-30 09:39:22 UTC (rev 4293)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.cpp	2015-12-30 13:47:21 UTC (rev 4294)
@@ -57,10 +57,13 @@
 
 	if (m_shape)
 		disconnect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
+		disconnect(m_shape, &QetShapeItem::widthChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
 
 	m_shape = shape;
 	connect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
+	connect(m_shape, &QetShapeItem::widthChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
 
+
 	updateUi();
 }
 
@@ -101,6 +104,7 @@
 	QPen old_pen = m_shape->pen();
 	QPen new_pen = old_pen;
 	new_pen.setStyle(Qt::PenStyle(ui->m_style_cb->currentIndex() + 1));
+	new_pen.setWidthF(ui->m_size_cb->value());
 	if (new_pen == old_pen) return nullptr;
 
 	QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_shape, "pen", old_pen, new_pen);
@@ -114,6 +118,7 @@
 void ShapeGraphicsItemPropertiesWidget::updateUi()
 {
 	ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->pen().style()) - 1);
+	ui->m_size_cb ->setValue(m_shape->pen().widthF());
 	ui->m_lock_pos_cb->setChecked(!m_shape->isMovable());
 }
 
@@ -127,11 +132,12 @@
 	if (live_edit == m_live_edit) return true;
 	m_live_edit = live_edit;
 
-	if (m_live_edit)
+	if (m_live_edit){
 		connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
-	else
+		connect (ui->m_size_cb, SIGNAL(valueChanged(int)), this, SLOT(apply()));
+	}else
 		disconnect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
-
+		disconnect (ui->m_size_cb, SIGNAL(valueChanged(int)), this, SLOT(apply()));
 	return true;
 }
 

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.h
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.h	2015-12-30 09:39:22 UTC (rev 4293)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.h	2015-12-30 13:47:21 UTC (rev 4294)
@@ -52,9 +52,10 @@
 	private slots:
 		void on_m_lock_pos_cb_clicked();
 
-	private:
+		private:
 		Ui::ShapeGraphicsItemPropertiesWidget *ui;
 		QetShapeItem *m_shape;
+		int       shape_size;
 };
 
 #endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H

Modified: trunk/sources/ui/shapegraphicsitempropertieswidget.ui
===================================================================
--- trunk/sources/ui/shapegraphicsitempropertieswidget.ui	2015-12-30 09:39:22 UTC (rev 4293)
+++ trunk/sources/ui/shapegraphicsitempropertieswidget.ui	2015-12-30 13:47:21 UTC (rev 4294)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>195</width>
+    <width>242</width>
     <height>183</height>
    </rect>
   </property>
@@ -54,7 +54,30 @@
      </item>
     </layout>
    </item>
+   <item alignment="Qt::AlignLeft">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Epaisseur de trait</string>
+     </property>
+    </widget>
+   </item>
    <item>
+    <widget class="QSpinBox" name="m_size_cb">
+     <property name="correctionMode">
+      <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
+     </property>
+     <property name="minimum">
+      <number>1</number>
+     </property>
+     <property name="maximum">
+      <number>20</number>
+     </property>
+     <property name="value">
+      <number>1</number>
+     </property>
+    </widget>
+   </item>
+   <item>
     <widget class="QCheckBox" name="m_lock_pos_cb">
      <property name="text">
       <string>Verrouiller la position</string>
@@ -75,6 +98,9 @@
     </spacer>
    </item>
   </layout>
+  <zorder>label_2</zorder>
+  <zorder>m_lock_pos_cb</zorder>
+  <zorder>m_size_cb</zorder>
  </widget>
  <resources/>
  <connections/>


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