diff --git a/sources/qetgraphicsitem/qetshapeitem.cpp b/sources/qetgraphicsitem/qetshapeitem.cpp index ad53d6c94..e3bfcfda6 100644 --- a/sources/qetgraphicsitem/qetshapeitem.cpp +++ b/sources/qetgraphicsitem/qetshapeitem.cpp @@ -63,19 +63,6 @@ void QetShapeItem::setStyle(Qt::PenStyle newStyle) emit styleChanged(); } -/** - * @brief QetShapeItem::scale - * Scale this item by (factor / 100 ). - * @param factor - */ -void QetShapeItem::previewScale(int factor) { - if (factor >= 1 && factor <= 200) { - qreal new_scale = factor; - new_scale /= 100; - setScale(new_scale); - } -} - /** * @brief QetShapeItem::setP2 * Set the second point of this item. diff --git a/sources/qetgraphicsitem/qetshapeitem.h b/sources/qetgraphicsitem/qetshapeitem.h index 7ca2c8d55..af023b06d 100644 --- a/sources/qetgraphicsitem/qetshapeitem.h +++ b/sources/qetgraphicsitem/qetshapeitem.h @@ -84,9 +84,6 @@ class QetShapeItem : public QetGraphicsItem private: void changeGraphicsItem (const ShapeType &newtype); - private slots: - void previewScale(int factor); - ///ATTRIBUTES private: ShapeType m_shapeType; diff --git a/sources/ui/shapegraphicsitempropertieswidget.cpp b/sources/ui/shapegraphicsitempropertieswidget.cpp index 2150842cf..649e88d54 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.cpp +++ b/sources/ui/shapegraphicsitempropertieswidget.cpp @@ -19,7 +19,6 @@ #include "ui_shapegraphicsitempropertieswidget.h" #include "qetshapeitem.h" #include "diagram.h" -#include "itemresizercommand.h" #include "changeshapestylecommand.h" /** @@ -57,17 +56,12 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape) if (shape == m_shape) return; if (m_shape) - { - disconnect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); - } m_shape = shape; - connect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); m_old_pen_style = m_shape->penStyle(); - m_old_scale = m_shape->scale(); updateUi(); } @@ -79,23 +73,16 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape) void ShapeGraphicsItemPropertiesWidget::apply() { if (m_live_edit) - { - disconnect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); - } if (m_shape->diagram()) if (QUndoCommand *undo = associatedUndo()) m_shape->diagram()->undoStack().push(undo); m_old_pen_style = m_shape->penStyle(); - m_old_scale = m_shape->scale(); if (m_live_edit) - { - connect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi); - } } /** @@ -105,34 +92,21 @@ void ShapeGraphicsItemPropertiesWidget::apply() void ShapeGraphicsItemPropertiesWidget::reset() { m_shape->setStyle(m_old_pen_style); - m_shape->setScale(m_old_scale); updateUi(); } /** * @brief ShapeGraphicsItemPropertiesWidget::associatedUndo * @return an undo command that represent the change edited by this widget. - * The returned undo command can be a ChangeShapeStyleCommand, ItemResizerCommand or - * a ChangeShapeStyleCommand with a ItemResizerCommand as child. + * The returned undo command is a ChangeShapeStyleCommand. * If there isn't change, return nullptr */ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const { - QUndoCommand *undo = nullptr; Qt::PenStyle new_style = Qt::PenStyle(ui->m_style_cb->currentIndex() + 1); - if (new_style != m_old_pen_style) undo = new ChangeShapeStyleCommand(m_shape, m_old_pen_style, new_style); + if (new_style != m_old_pen_style) return (new ChangeShapeStyleCommand(m_shape, m_old_pen_style, new_style)); - qreal value = ui->m_scale_slider->value(); - value /= 100; - if (value != m_old_scale) - { - if (undo) - new ItemResizerCommand(m_shape, m_old_scale, value, tr("une shape"), undo); - else - undo = new ItemResizerCommand(m_shape, m_old_scale, value, tr("une shape")); - } - - return undo; + return nullptr; } /** @@ -142,7 +116,6 @@ void ShapeGraphicsItemPropertiesWidget::updateUi() { ui->m_style_cb->setCurrentIndex(static_cast(m_shape->penStyle()) - 1); ui->m_lock_pos_cb->setChecked(!m_shape->isMovable()); - ui->m_scale_slider->setValue(m_shape->scale() * 100); } /** @@ -156,26 +129,13 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit) m_live_edit = live_edit; if (m_live_edit) - { - connect (ui->m_scale_slider, &QSlider::sliderReleased, this, &ShapeGraphicsItemPropertiesWidget::apply); - connect (ui->m_scale_sb, &QSpinBox::editingFinished, this, &ShapeGraphicsItemPropertiesWidget::apply); connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply())); - } else - { - disconnect (ui->m_scale_slider, &QSlider::sliderReleased, this, &ShapeGraphicsItemPropertiesWidget::apply); - disconnect (ui->m_scale_sb, &QSpinBox::editingFinished, this, &ShapeGraphicsItemPropertiesWidget::apply); disconnect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply())); - } return true; } -void ShapeGraphicsItemPropertiesWidget::on_m_scale_slider_valueChanged(int value) { - qreal scale = value; - m_shape->setScale(scale / 100); -} - void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() { m_shape->setMovable(!ui->m_lock_pos_cb->isChecked()); } diff --git a/sources/ui/shapegraphicsitempropertieswidget.h b/sources/ui/shapegraphicsitempropertieswidget.h index 082287766..88356c488 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.h +++ b/sources/ui/shapegraphicsitempropertieswidget.h @@ -50,7 +50,6 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget virtual bool setLiveEdit(bool live_edit); private slots: - void on_m_scale_slider_valueChanged(int value); void on_m_lock_pos_cb_clicked(); private: @@ -58,7 +57,6 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget QetShapeItem *m_shape; Qt::PenStyle m_old_pen_style; - qreal m_old_scale; }; #endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H diff --git a/sources/ui/shapegraphicsitempropertieswidget.ui b/sources/ui/shapegraphicsitempropertieswidget.ui index f02f6b5ca..bb109bcf0 100644 --- a/sources/ui/shapegraphicsitempropertieswidget.ui +++ b/sources/ui/shapegraphicsitempropertieswidget.ui @@ -6,8 +6,8 @@ 0 0 - 175 - 174 + 195 + 183 @@ -15,42 +15,44 @@ - - - Type de trait - - - - - - - Normal - - - - - Tiret - - - - - Pointillé - - - - - Traits et points - - - - - Traits points points - - - - - - + + + + + Type de trait + + + + + + + + Normal + + + + + Tiret + + + + + Pointillé + + + + + Traits et points + + + + + Traits points points + + + + + @@ -59,41 +61,6 @@ - - - - Échelle - - - false - - - - - - 1 - - - 200 - - - Qt::Horizontal - - - - - - - 1 - - - 200 - - - - - - @@ -110,38 +77,5 @@ - - - m_scale_slider - valueChanged(int) - m_scale_sb - setValue(int) - - - 174 - 234 - - - 355 - 234 - - - - - m_scale_sb - valueChanged(int) - m_scale_slider - setValue(int) - - - 355 - 234 - - - 174 - 234 - - - - +