mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 08:40:53 +01:00
Qet shape item properties widget : remove the scale widget
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4044 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -63,19 +63,6 @@ void QetShapeItem::setStyle(Qt::PenStyle newStyle)
|
|||||||
emit styleChanged();
|
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
|
* @brief QetShapeItem::setP2
|
||||||
* Set the second point of this item.
|
* Set the second point of this item.
|
||||||
|
|||||||
@@ -84,9 +84,6 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
private:
|
private:
|
||||||
void changeGraphicsItem (const ShapeType &newtype);
|
void changeGraphicsItem (const ShapeType &newtype);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void previewScale(int factor);
|
|
||||||
|
|
||||||
///ATTRIBUTES
|
///ATTRIBUTES
|
||||||
private:
|
private:
|
||||||
ShapeType m_shapeType;
|
ShapeType m_shapeType;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "ui_shapegraphicsitempropertieswidget.h"
|
#include "ui_shapegraphicsitempropertieswidget.h"
|
||||||
#include "qetshapeitem.h"
|
#include "qetshapeitem.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "itemresizercommand.h"
|
|
||||||
#include "changeshapestylecommand.h"
|
#include "changeshapestylecommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,17 +56,12 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
|||||||
if (shape == m_shape) return;
|
if (shape == m_shape) return;
|
||||||
|
|
||||||
if (m_shape)
|
if (m_shape)
|
||||||
{
|
|
||||||
disconnect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
}
|
|
||||||
|
|
||||||
m_shape = shape;
|
m_shape = shape;
|
||||||
connect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
|
|
||||||
m_old_pen_style = m_shape->penStyle();
|
m_old_pen_style = m_shape->penStyle();
|
||||||
m_old_scale = m_shape->scale();
|
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,23 +73,16 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
|||||||
void ShapeGraphicsItemPropertiesWidget::apply()
|
void ShapeGraphicsItemPropertiesWidget::apply()
|
||||||
{
|
{
|
||||||
if (m_live_edit)
|
if (m_live_edit)
|
||||||
{
|
|
||||||
disconnect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
disconnect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
}
|
|
||||||
|
|
||||||
if (m_shape->diagram())
|
if (m_shape->diagram())
|
||||||
if (QUndoCommand *undo = associatedUndo())
|
if (QUndoCommand *undo = associatedUndo())
|
||||||
m_shape->diagram()->undoStack().push(undo);
|
m_shape->diagram()->undoStack().push(undo);
|
||||||
|
|
||||||
m_old_pen_style = m_shape->penStyle();
|
m_old_pen_style = m_shape->penStyle();
|
||||||
m_old_scale = m_shape->scale();
|
|
||||||
|
|
||||||
if (m_live_edit)
|
if (m_live_edit)
|
||||||
{
|
|
||||||
connect(m_shape, &QGraphicsObject::scaleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
connect(m_shape, &QetShapeItem::styleChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,34 +92,21 @@ void ShapeGraphicsItemPropertiesWidget::apply()
|
|||||||
void ShapeGraphicsItemPropertiesWidget::reset()
|
void ShapeGraphicsItemPropertiesWidget::reset()
|
||||||
{
|
{
|
||||||
m_shape->setStyle(m_old_pen_style);
|
m_shape->setStyle(m_old_pen_style);
|
||||||
m_shape->setScale(m_old_scale);
|
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ShapeGraphicsItemPropertiesWidget::associatedUndo
|
* @brief ShapeGraphicsItemPropertiesWidget::associatedUndo
|
||||||
* @return an undo command that represent the change edited by this widget.
|
* @return an undo command that represent the change edited by this widget.
|
||||||
* The returned undo command can be a ChangeShapeStyleCommand, ItemResizerCommand or
|
* The returned undo command is a ChangeShapeStyleCommand.
|
||||||
* a ChangeShapeStyleCommand with a ItemResizerCommand as child.
|
|
||||||
* If there isn't change, return nullptr
|
* If there isn't change, return nullptr
|
||||||
*/
|
*/
|
||||||
QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||||
{
|
{
|
||||||
QUndoCommand *undo = nullptr;
|
|
||||||
Qt::PenStyle new_style = Qt::PenStyle(ui->m_style_cb->currentIndex() + 1);
|
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();
|
return nullptr;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +116,6 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
|
|||||||
{
|
{
|
||||||
ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->penStyle()) - 1);
|
ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->penStyle()) - 1);
|
||||||
ui->m_lock_pos_cb->setChecked(!m_shape->isMovable());
|
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;
|
m_live_edit = live_edit;
|
||||||
|
|
||||||
if (m_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()));
|
connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||||
}
|
|
||||||
else
|
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()));
|
disconnect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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() {
|
void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() {
|
||||||
m_shape->setMovable(!ui->m_lock_pos_cb->isChecked());
|
m_shape->setMovable(!ui->m_lock_pos_cb->isChecked());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
|||||||
virtual bool setLiveEdit(bool live_edit);
|
virtual bool setLiveEdit(bool live_edit);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_scale_slider_valueChanged(int value);
|
|
||||||
void on_m_lock_pos_cb_clicked();
|
void on_m_lock_pos_cb_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,7 +57,6 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
|||||||
QetShapeItem *m_shape;
|
QetShapeItem *m_shape;
|
||||||
|
|
||||||
Qt::PenStyle m_old_pen_style;
|
Qt::PenStyle m_old_pen_style;
|
||||||
qreal m_old_scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H
|
#endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>175</width>
|
<width>195</width>
|
||||||
<height>174</height>
|
<height>183</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -15,42 +15,44 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="title">
|
<item>
|
||||||
<string>Type de trait</string>
|
<widget class="QLabel" name="label">
|
||||||
</property>
|
<property name="text">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<string>Type de trait</string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QComboBox" name="m_style_cb">
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Normal</string>
|
<widget class="QComboBox" name="m_style_cb">
|
||||||
</property>
|
<item>
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Normal</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Tiret</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Tiret</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Pointillé</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Pointillé</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Traits et points</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Traits et points</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Traits points points</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</item>
|
<property name="text">
|
||||||
</widget>
|
<string>Traits points points</string>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="m_lock_pos_cb">
|
<widget class="QCheckBox" name="m_lock_pos_cb">
|
||||||
@@ -59,41 +61,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Échelle</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QSlider" name="m_scale_slider">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>200</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="m_scale_sb">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>200</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -110,38 +77,5 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>m_scale_slider</sender>
|
|
||||||
<signal>valueChanged(int)</signal>
|
|
||||||
<receiver>m_scale_sb</receiver>
|
|
||||||
<slot>setValue(int)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>174</x>
|
|
||||||
<y>234</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>355</x>
|
|
||||||
<y>234</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>m_scale_sb</sender>
|
|
||||||
<signal>valueChanged(int)</signal>
|
|
||||||
<receiver>m_scale_slider</receiver>
|
|
||||||
<slot>setValue(int)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>355</x>
|
|
||||||
<y>234</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>174</x>
|
|
||||||
<y>234</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user