mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-23 10:30:53 +01:00
Improve Basic shapes Properties size function
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4294 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -57,9 +57,12 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
||||
|
||||
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 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||
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 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||
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 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,10 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
||||
private slots:
|
||||
void on_m_lock_pos_cb_clicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::ShapeGraphicsItemPropertiesWidget *ui;
|
||||
QetShapeItem *m_shape;
|
||||
int shape_size;
|
||||
};
|
||||
|
||||
#endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>195</width>
|
||||
<width>242</width>
|
||||
<height>183</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -54,6 +54,29 @@
|
||||
</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">
|
||||
@@ -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/>
|
||||
|
||||
Reference in New Issue
Block a user