[qet] [2645] image properties dialog: add hold position option

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


Revision: 2645
Author:   blacksun
Date:     2013-11-28 22:25:20 +0100 (Thu, 28 Nov 2013)
Log Message:
-----------
image properties dialog: add hold position option

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/diagramimageitem.cpp
    trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
    trunk/sources/qetgraphicsitem/qetgraphicsitem.h

Modified: trunk/sources/qetgraphicsitem/diagramimageitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramimageitem.cpp	2013-11-28 15:36:25 UTC (rev 2644)
+++ trunk/sources/qetgraphicsitem/diagramimageitem.cpp	2013-11-28 21:25:20 UTC (rev 2645)
@@ -104,42 +104,48 @@
 	int factor_range = 100;
 
 	//the dialog
-	QDialog property_dialog;
+	QDialog property_dialog(diagram()->views().at(0));
 	property_dialog.setWindowTitle(tr("\311diter les propri\351t\351s d'une image", "window title"));
 	//the main layout
-	QVBoxLayout *dialog_layout = new QVBoxLayout(&property_dialog);
+	QVBoxLayout dialog_layout(&property_dialog);
 
 	//GroupBox for resizer image
-	QGroupBox *resize_groupe = new QGroupBox(tr("Dimension de l'image", "image size"));
-	dialog_layout -> addWidget(resize_groupe);
-	QHBoxLayout *resize_layout = new QHBoxLayout(resize_groupe);
+	QGroupBox resize_groupe(tr("Dimension de l'image", "image size"));
+	dialog_layout.addWidget(&resize_groupe);
+	QHBoxLayout resize_layout(&resize_groupe);
 
-	//slider
-	QSlider *slider = new QSlider(Qt::Horizontal, &property_dialog);
-	slider->setRange(min_range, max_range);
+		//slider
+	QSlider slider(Qt::Horizontal, &property_dialog);
+	slider.setRange(min_range, max_range);
 	qreal scale_= scale();
-	slider -> setValue(scale_*factor_range);
-	//spinbox
-	QSpinBox *spin_box = new QSpinBox(&property_dialog);
-	spin_box -> setRange(min_range, max_range);
-	spin_box -> setValue(scale_*factor_range);
-	spin_box -> setSuffix(" %");
-	//synchro slider with spinbox
-	connect(slider, SIGNAL(valueChanged(int)), spin_box, SLOT(setValue(int)));
-	connect(slider, SIGNAL(valueChanged(int)), this, SLOT(PreviewScale(int)));
-	connect(spin_box, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
-	//add slider and spinbox to layout
-	resize_layout -> addWidget(slider);
-	resize_layout -> addWidget(spin_box);
+	slider.setValue(scale_*factor_range);
+		//spinbox
+	QSpinBox spin_box(&property_dialog);
+	spin_box.setRange(min_range, max_range);
+	spin_box.setValue(scale_*factor_range);
+	spin_box.setSuffix(" %");
+		//synchro slider with spinbox
+	connect(&slider, SIGNAL(valueChanged(int)), &spin_box, SLOT(setValue(int)));
+	connect(&slider, SIGNAL(valueChanged(int)), this, SLOT(PreviewScale(int)));
+	connect(&spin_box, SIGNAL(valueChanged(int)), &slider, SLOT(setValue(int)));
+		//add slider and spinbox to layout
+	resize_layout.addWidget(&slider);
+	resize_layout.addWidget(&spin_box);
+		//check box for disable move
+	QCheckBox cb(tr("Verrouiller la position"), &property_dialog);
+	cb.setChecked(!is_movable_);
+	dialog_layout.addWidget(&cb);
 
 	//dialog button, box
-	QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	dialog_layout -> addWidget(dbb);
-	connect(dbb, SIGNAL(accepted()), &property_dialog, SLOT(accept()));
-	connect(dbb, SIGNAL(rejected()), &property_dialog, SLOT(reject()));
+	QDialogButtonBox dbb(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+	dialog_layout.addWidget(&dbb);
+	connect(&dbb, SIGNAL(accepted()), &property_dialog, SLOT(accept()));
+	connect(&dbb, SIGNAL(rejected()), &property_dialog, SLOT(reject()));
+
 	//dialog is accepted...
 	if (property_dialog.exec() == QDialog::Accepted) {
-		qreal new_scale = slider -> value();
+		cb.isChecked() ? is_movable_=false : is_movable_=true;
+		qreal new_scale = slider.value();
 		new_scale /= factor_range;
 		if (scale_ != new_scale) diagram()->undoStack().push(new ImageResizerCommand(this, scale_, new_scale));
 	}

Modified: trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp	2013-11-28 15:36:25 UTC (rev 2644)
+++ trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp	2013-11-28 21:25:20 UTC (rev 2645)
@@ -25,6 +25,7 @@
  */
 QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
 	QGraphicsObject(parent),
+	is_movable_(true),
 	first_move_(true)
 {
 }
@@ -32,8 +33,6 @@
 QetGraphicsItem::~QetGraphicsItem()
 {}
 
-void QetGraphicsItem::editProperty(){}
-
 /**
  * @brief QetGraphicsItem::diagram
  *return the diagram of this item
@@ -48,7 +47,7 @@
  * @param p the new position of item
  */
 void QetGraphicsItem::setPos(const QPointF &p) {
-	if (p == pos()) return;
+	if (p == pos() || !is_movable_) return;
 	if (scene()) {
 		// arrondit l'abscisse a 10 px pres
 		int p_x = qRound(p.x() / (Diagram::xGrid * 1.0)) * Diagram::xGrid;

Modified: trunk/sources/qetgraphicsitem/qetgraphicsitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetgraphicsitem.h	2013-11-28 15:36:25 UTC (rev 2644)
+++ trunk/sources/qetgraphicsitem/qetgraphicsitem.h	2013-11-28 21:25:20 UTC (rev 2645)
@@ -28,15 +28,13 @@
 	QetGraphicsItem(QGraphicsItem *parent = 0);
 	virtual ~QetGraphicsItem() = 0;
 
-	//abstarct methode	
-	virtual void editProperty ();
-
 	//public methode
 	Diagram* diagram() const;
 	virtual void setPos(const QPointF &p);
 	virtual void setPos(qreal x, qreal y);
 	virtual void rotateBy(const qreal &);
 	virtual void applyRotation(const qreal &);
+	virtual void editProperty ()=0;
 
 	signals:
 
@@ -50,6 +48,7 @@
 	virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
 
 	protected:
+	bool is_movable_;
 	bool first_move_;
 	QPointF mouse_to_origin_movement_;
 


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