mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9354e1ad8d | ||
|
|
7ab08bc99f | ||
|
|
b9ee6c7b5d | ||
|
|
ad85d9b6bf | ||
|
|
6dec80cfa3 | ||
|
|
9aaf8839dc | ||
|
|
230fc76c78 | ||
|
|
fbb2c18086 |
@@ -8,6 +8,10 @@ Improve 20 logic elements, thanks Vbxier
|
|||||||
*Element Editor:
|
*Element Editor:
|
||||||
Fix wrong calculation of the bounding rect of an arc
|
Fix wrong calculation of the bounding rect of an arc
|
||||||
|
|
||||||
|
*Diagram editor:
|
||||||
|
Improve conductor first and last segment position.
|
||||||
|
Unwanted change of the filling color of shapes in some condition.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -358,7 +358,11 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
#pragma message("@TODO move code to new function")
|
#pragma message("@TODO move code to new function")
|
||||||
#endif
|
#endif
|
||||||
//Move item with the keyboard arrow
|
//Move item with the keyboard arrow
|
||||||
if(event->modifiers() == Qt::NoModifier)
|
#ifdef Q_OS_MACOS
|
||||||
|
if(event->modifiers() == Qt::KeypadModifier)
|
||||||
|
#else
|
||||||
|
if(event->modifiers() == Qt::NoModifier)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
|
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
|
||||||
@@ -367,26 +371,26 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
Diagram::yKeyGrid).toInt();
|
Diagram::yKeyGrid).toInt();
|
||||||
switch(event->key())
|
switch(event->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
for (Element *item : dc.m_elements)
|
for (Element *item : dc.m_elements)
|
||||||
{
|
{
|
||||||
left_position = item->sceneBoundingRect().x();
|
left_position = item->sceneBoundingRect().x();
|
||||||
if(left_position <= 5)
|
if(left_position <= 5)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
movement = QPointF(-xKeyGrid, 0.0);
|
movement = QPointF(-xKeyGrid, 0.0);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
movement = QPointF(+xKeyGrid, 0.0);
|
movement = QPointF(+xKeyGrid, 0.0);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
for(Element *item : dc.m_elements)
|
for(Element *item : dc.m_elements)
|
||||||
{
|
{
|
||||||
top_position = item->sceneBoundingRect().y();
|
top_position = item->sceneBoundingRect().y();
|
||||||
if(top_position <= 5)
|
if(top_position <= 5)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
movement = QPointF(0.0, -yKeyGrid);
|
movement = QPointF(0.0, -yKeyGrid);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
movement = QPointF(0.0, +yKeyGrid);
|
movement = QPointF(0.0, +yKeyGrid);
|
||||||
@@ -477,7 +481,7 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
Qt::AlignRight));
|
Qt::AlignRight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QGraphicsScene::keyPressEvent(event);
|
QGraphicsScene::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1219,6 +1219,11 @@ QList<QAction *> DiagramView::contextMenuActions() const
|
|||||||
*/
|
*/
|
||||||
void DiagramView::contextMenuEvent(QContextMenuEvent *e)
|
void DiagramView::contextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
|
QGraphicsView::contextMenuEvent(e);
|
||||||
|
if(e->isAccepted())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (auto qgi = m_diagram->itemAt(mapToScene(e->pos()), transform()))
|
if (auto qgi = m_diagram->itemAt(mapToScene(e->pos()), transform()))
|
||||||
{
|
{
|
||||||
if (!qgi->isSelected()) {
|
if (!qgi->isSelected()) {
|
||||||
|
|||||||
@@ -1765,25 +1765,29 @@ void Conductor::setSequenceNum(const autonum::sequentialNumbers& sn)
|
|||||||
*/
|
*/
|
||||||
void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formula)
|
void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formula)
|
||||||
{
|
{
|
||||||
if (diagram())
|
Diagram *diagram_ {diagram()};
|
||||||
|
if (!diagram_) {
|
||||||
|
diagram_ = terminal1->diagram();
|
||||||
|
}
|
||||||
|
if (diagram_)
|
||||||
{
|
{
|
||||||
//Because the variable %F is a reference to another text which can contain variables,
|
//Because the variable %F is a reference to another text which can contain variables,
|
||||||
//we must replace %F by the real text, to check if the real text contains the variable %id
|
//we must replace %F by the real text, to check if the real text contains the variable %id
|
||||||
if (old_formula.contains("%F"))
|
if (old_formula.contains("%F"))
|
||||||
old_formula.replace("%F", diagram()->border_and_titleblock.folio());
|
old_formula.replace("%F", diagram_->border_and_titleblock.folio());
|
||||||
|
|
||||||
if (old_formula.contains("%id"))
|
if (old_formula.contains("%id"))
|
||||||
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
disconnect(diagram_->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
||||||
|
|
||||||
//Label is frozen, so we don't update it.
|
//Label is frozen, so we don't update it.
|
||||||
if (m_freeze_label == true)
|
if (m_freeze_label == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (new_formula.contains("%F"))
|
if (new_formula.contains("%F"))
|
||||||
new_formula.replace("%F", diagram()->border_and_titleblock.folio());
|
new_formula.replace("%F", diagram_->border_and_titleblock.folio());
|
||||||
|
|
||||||
if (new_formula.contains("%id"))
|
if (new_formula.contains("%id"))
|
||||||
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
connect(diagram_->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
|||||||
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
qDebug() << "Leave mouse over";
|
|
||||||
m_mouse_hover = false;
|
m_mouse_hover = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
|||||||
else if (flags &SW)
|
else if (flags &SW)
|
||||||
{
|
{
|
||||||
bounding_rect = QRectF(0, offset, 24, 20);
|
bounding_rect = QRectF(0, offset, 24, 20);
|
||||||
bounding_rect.adjust(-20, -4, 4, 4);
|
bounding_rect.adjust(0, -4, 4, 4);
|
||||||
|
|
||||||
//draw the NO side
|
//draw the NO side
|
||||||
painter.drawLine(0, offset+6, 8, offset+6);
|
painter.drawLine(0, offset+6, 8, offset+6);
|
||||||
@@ -832,7 +832,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
|||||||
else if(flags &Other)
|
else if(flags &Other)
|
||||||
{
|
{
|
||||||
bounding_rect = QRectF(0, offset, 24, 20);
|
bounding_rect = QRectF(0, offset, 24, 20);
|
||||||
bounding_rect.adjust(-20, -4, 4, 4);
|
bounding_rect.adjust(0, -4, 4, 4);
|
||||||
|
|
||||||
//Draw the first arc symbol
|
//Draw the first arc symbol
|
||||||
QRectF r(8, offset+4, 5, 3);
|
QRectF r(8, offset+4, 5, 3);
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ void LinkSingleElementWidget::buildTree()
|
|||||||
QStringList search_list;
|
QStringList search_list;
|
||||||
QStringList str_list;
|
QStringList str_list;
|
||||||
|
|
||||||
if (elmt->conductors().size())
|
if (!elmt->conductors().isEmpty())
|
||||||
{
|
{
|
||||||
ConductorProperties cp = elmt->conductors().first()->properties();
|
ConductorProperties cp = elmt->conductors().first()->properties();
|
||||||
str_list << cp.text;
|
str_list << cp.text;
|
||||||
@@ -316,7 +316,7 @@ void LinkSingleElementWidget::buildTree()
|
|||||||
search_list << str_list.last();
|
search_list << str_list.last();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str_list << "" << "" << "";
|
str_list << "" << "" << "" << "" << "";
|
||||||
|
|
||||||
if (Diagram *diag = elmt->diagram())
|
if (Diagram *diag = elmt->diagram())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,13 +64,8 @@ ShapeGraphicsItemPropertiesWidget::~ShapeGraphicsItemPropertiesWidget()
|
|||||||
*/
|
*/
|
||||||
void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
||||||
{
|
{
|
||||||
if (m_shape != shape)
|
if (m_shape != shape) {
|
||||||
{
|
clearEditConnection();
|
||||||
for (QMetaObject::Connection c : m_connect_list) {
|
|
||||||
disconnect(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_connect_list.clear();
|
|
||||||
}
|
}
|
||||||
if (!shape) {
|
if (!shape) {
|
||||||
return;
|
return;
|
||||||
@@ -80,15 +75,8 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
|||||||
ui->m_close_polygon->setVisible(m_shape->shapeType() == QetShapeItem::Polygon);
|
ui->m_close_polygon->setVisible(m_shape->shapeType() == QetShapeItem::Polygon);
|
||||||
ui->m_filling_gb->setHidden(m_shape->shapeType() == QetShapeItem::Line);
|
ui->m_filling_gb->setHidden(m_shape->shapeType() == QetShapeItem::Line);
|
||||||
|
|
||||||
if (m_live_edit)
|
updateUi();
|
||||||
{
|
|
||||||
m_connect_list << connect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
m_connect_list << connect(m_shape, &QetShapeItem::brushChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
m_connect_list << connect(m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpEditConnection();
|
setUpEditConnection();
|
||||||
updateUi();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,14 +86,11 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
|||||||
*/
|
*/
|
||||||
void ShapeGraphicsItemPropertiesWidget::setItems(QList<QetShapeItem *> shapes_list)
|
void ShapeGraphicsItemPropertiesWidget::setItems(QList<QetShapeItem *> shapes_list)
|
||||||
{
|
{
|
||||||
for (QMetaObject::Connection c : m_connect_list) {
|
clearEditConnection();
|
||||||
disconnect(c);
|
|
||||||
}
|
|
||||||
m_connect_list.clear();
|
|
||||||
m_shapes_list.clear();
|
m_shapes_list.clear();
|
||||||
m_shape = nullptr;
|
m_shape = nullptr;
|
||||||
|
|
||||||
if (shapes_list.size() == 0) {
|
if (shapes_list.isEmpty()) {
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
else if (shapes_list.size() == 1)
|
else if (shapes_list.size() == 1)
|
||||||
@@ -372,10 +357,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
|
|||||||
|
|
||||||
//Disconnect every connections of editor widgets
|
//Disconnect every connections of editor widgets
|
||||||
//to avoid an unwanted edition (QSpinBox emit valueChanged no matter if changer by user or by program)
|
//to avoid an unwanted edition (QSpinBox emit valueChanged no matter if changer by user or by program)
|
||||||
for (QMetaObject::Connection c : m_edit_connection) {
|
clearEditConnection();
|
||||||
disconnect(c);
|
|
||||||
}
|
|
||||||
m_edit_connection.clear();
|
|
||||||
|
|
||||||
if (m_shape)
|
if (m_shape)
|
||||||
{
|
{
|
||||||
@@ -473,37 +455,59 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
|
|||||||
|
|
||||||
if (m_live_edit) {
|
if (m_live_edit) {
|
||||||
setUpEditConnection();
|
setUpEditConnection();
|
||||||
}
|
} else {
|
||||||
else
|
clearEditConnection();
|
||||||
{
|
|
||||||
for (QMetaObject::Connection c : m_edit_connection) {
|
|
||||||
disconnect(c);
|
|
||||||
}
|
|
||||||
m_edit_connection.clear();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
|
* @brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
|
||||||
Disconnect the previous connection, and reconnect the connection between the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function
|
* Disconnect the previous connection, and reconnect the connection between
|
||||||
|
* the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function
|
||||||
*/
|
*/
|
||||||
void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
|
void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
|
||||||
{
|
{
|
||||||
for (QMetaObject::Connection c : m_edit_connection) {
|
clearEditConnection();
|
||||||
disconnect(c);
|
|
||||||
}
|
|
||||||
m_edit_connection.clear();
|
|
||||||
|
|
||||||
if (m_shape || !m_shapes_list.isEmpty())
|
if (m_shape || !m_shapes_list.isEmpty())
|
||||||
{
|
{
|
||||||
m_edit_connection << connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
m_edit_connection << connect (ui->m_style_cb, QOverload<int>::of(&QComboBox::activated),
|
||||||
m_edit_connection << connect (ui->m_size_dsb, SIGNAL(valueChanged(double)), this, SLOT(apply()));
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
m_edit_connection << connect (ui->m_brush_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
|
||||||
m_edit_connection << connect (ui->m_close_polygon, &QCheckBox::clicked, this, &ShapeGraphicsItemPropertiesWidget::apply);
|
m_edit_connection << connect (ui->m_size_dsb, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
m_edit_connection << connect (m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
m_edit_connection << connect (m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
|
||||||
}
|
m_edit_connection << connect (ui->m_color_kpb, &KColorButton::changed,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
|
m_edit_connection << connect (ui->m_brush_style_cb, QOverload<int>::of(&QComboBox::activated),
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
|
m_edit_connection << connect (ui->m_brush_color_kpb, &KColorButton::changed,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
|
m_edit_connection << connect (ui->m_close_polygon, &QCheckBox::clicked,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
|
m_edit_connection << connect (m_shape, &QetShapeItem::penChanged,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
|
|
||||||
|
m_edit_connection << connect (m_shape, &QetShapeItem::closeChanged,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
|
|
||||||
|
m_edit_connection << connect (m_shape, &QetShapeItem::brushChanged,
|
||||||
|
this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapeGraphicsItemPropertiesWidget::clearEditConnection()
|
||||||
|
{
|
||||||
|
for (const auto &c : qAsConst(m_edit_connection)) {
|
||||||
|
disconnect(c);
|
||||||
|
}
|
||||||
|
m_edit_connection.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked()
|
void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked()
|
||||||
@@ -517,17 +521,3 @@ void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeGraphicsItemPropertiesWidget::on_m_color_kpb_changed(const QColor &newColor)
|
|
||||||
{
|
|
||||||
if(newColor.isValid() && m_live_edit) {
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_kpb_changed(const QColor &newColor)
|
|
||||||
{
|
|
||||||
if(newColor.isValid() && m_live_edit) {
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,13 +53,12 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpEditConnection();
|
void setUpEditConnection();
|
||||||
|
void clearEditConnection();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_lock_pos_cb_clicked();
|
void on_m_lock_pos_cb_clicked();
|
||||||
void on_m_color_kpb_changed(const QColor &newColor);
|
|
||||||
void on_m_brush_color_kpb_changed(const QColor &newColor);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ShapeGraphicsItemPropertiesWidget *ui;
|
Ui::ShapeGraphicsItemPropertiesWidget *ui;
|
||||||
QetShapeItem *m_shape;
|
QetShapeItem *m_shape;
|
||||||
QList <QPointer<QetShapeItem>> m_shapes_list;
|
QList <QPointer<QetShapeItem>> m_shapes_list;
|
||||||
|
|||||||
Reference in New Issue
Block a user