Compare commits

..

8 Commits
0.9.0 ... 0.9.1

Author SHA1 Message Date
Laurent Trinques
9354e1ad8d Resore qetshapeitem::polygon contextMenuEvent
reverted by commit: 0a8376c189
see:
https://qelectrotech.org/bugtracker/view.php?id=220
and
https://qelectrotech.org/forum/viewtopic.php?pid=18204#p18204
2023-05-16 09:35:38 +02:00
Laurent Trinques
7ab08bc99f Improve changeover contact view in list mode 2023-04-30 09:49:22 +02:00
joshua
b9ee6c7b5d Fix minor bug : conductor text is not updated when folio id is used
See https://qelectrotech.org/forum/viewtopic.php?pid=18157#p18157
2023-04-20 17:11:08 +02:00
Laurent
ad85d9b6bf macOS fix: add Move diagram item with the keyboard arrow 2023-03-30 10:31:53 +02:00
joshua
6dec80cfa3 Fix wrong display in widget used to link folio report 2023-03-01 19:35:28 +01:00
Laurent Trinques
9aaf8839dc Try to fix FTBS on not c++17 system 2023-02-28 13:20:00 +01:00
joshua
230fc76c78 Improve changelog 2023-02-24 19:30:26 +01:00
joshua
fbb2c18086 Fix minor bug
When two shapes item have line and filling color and the dock widget
used for edit the current selection is visible, switching selection
between the two shapes, the last selected shape filling color change
and become the filling color of the previous shape.
2023-02-24 19:22:27 +01:00
9 changed files with 85 additions and 80 deletions

View File

@@ -8,6 +8,10 @@ Improve 20 logic elements, thanks Vbxier
*Element Editor:
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.

View File

@@ -358,7 +358,11 @@ void Diagram::keyPressEvent(QKeyEvent *event)
#pragma message("@TODO move code to new function")
#endif
//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;
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
@@ -367,26 +371,26 @@ void Diagram::keyPressEvent(QKeyEvent *event)
Diagram::yKeyGrid).toInt();
switch(event->key())
{
case Qt::Key_Left:
case Qt::Key_Left:
for (Element *item : dc.m_elements)
{
left_position = item->sceneBoundingRect().x();
left_position = item->sceneBoundingRect().x();
if(left_position <= 5)
return;
}
movement = QPointF(-xKeyGrid, 0.0);
break;
case Qt::Key_Right:
break;
case Qt::Key_Right:
movement = QPointF(+xKeyGrid, 0.0);
break;
case Qt::Key_Up:
for(Element *item : dc.m_elements)
case Qt::Key_Up:
for(Element *item : dc.m_elements)
{
top_position = item->sceneBoundingRect().y();
if(top_position <= 5)
return;
}
movement = QPointF(0.0, -yKeyGrid);
movement = QPointF(0.0, -yKeyGrid);
break;
case Qt::Key_Down:
movement = QPointF(0.0, +yKeyGrid);
@@ -477,7 +481,7 @@ void Diagram::keyPressEvent(QKeyEvent *event)
Qt::AlignRight));
}
}
}
}
event->ignore();
QGraphicsScene::keyPressEvent(event);
}

View File

@@ -1219,6 +1219,11 @@ QList<QAction *> DiagramView::contextMenuActions() const
*/
void DiagramView::contextMenuEvent(QContextMenuEvent *e)
{
QGraphicsView::contextMenuEvent(e);
if(e->isAccepted())
return;
if (auto qgi = m_diagram->itemAt(mapToScene(e->pos()), transform()))
{
if (!qgi->isSelected()) {

View File

@@ -1765,25 +1765,29 @@ void Conductor::setSequenceNum(const autonum::sequentialNumbers& sn)
*/
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,
//we must replace %F by the real text, to check if the real text contains the variable %id
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"))
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.
if (m_freeze_label == true)
return;
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"))
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
connect(diagram_->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
}
}

View File

@@ -251,7 +251,6 @@ void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
{
Q_UNUSED(e);
qDebug() << "Leave mouse over";
m_mouse_hover = false;
update();
}

View File

@@ -765,7 +765,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
else if (flags &SW)
{
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
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)
{
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
QRectF r(8, offset+4, 5, 3);

View File

@@ -296,7 +296,7 @@ void LinkSingleElementWidget::buildTree()
QStringList search_list;
QStringList str_list;
if (elmt->conductors().size())
if (!elmt->conductors().isEmpty())
{
ConductorProperties cp = elmt->conductors().first()->properties();
str_list << cp.text;
@@ -316,7 +316,7 @@ void LinkSingleElementWidget::buildTree()
search_list << str_list.last();
}
else
str_list << "" << "" << "";
str_list << "" << "" << "" << "" << "";
if (Diagram *diag = elmt->diagram())
{

View File

@@ -64,13 +64,8 @@ ShapeGraphicsItemPropertiesWidget::~ShapeGraphicsItemPropertiesWidget()
*/
void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
{
if (m_shape != shape)
{
for (QMetaObject::Connection c : m_connect_list) {
disconnect(c);
}
m_connect_list.clear();
if (m_shape != shape) {
clearEditConnection();
}
if (!shape) {
return;
@@ -80,15 +75,8 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
ui->m_close_polygon->setVisible(m_shape->shapeType() == QetShapeItem::Polygon);
ui->m_filling_gb->setHidden(m_shape->shapeType() == QetShapeItem::Line);
if (m_live_edit)
{
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);
}
updateUi();
setUpEditConnection();
updateUi();
}
/**
@@ -98,14 +86,11 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
*/
void ShapeGraphicsItemPropertiesWidget::setItems(QList<QetShapeItem *> shapes_list)
{
for (QMetaObject::Connection c : m_connect_list) {
disconnect(c);
}
m_connect_list.clear();
clearEditConnection();
m_shapes_list.clear();
m_shape = nullptr;
if (shapes_list.size() == 0) {
if (shapes_list.isEmpty()) {
updateUi();
}
else if (shapes_list.size() == 1)
@@ -372,10 +357,7 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
//Disconnect every connections of editor widgets
//to avoid an unwanted edition (QSpinBox emit valueChanged no matter if changer by user or by program)
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
clearEditConnection();
if (m_shape)
{
@@ -473,37 +455,59 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
if (m_live_edit) {
setUpEditConnection();
}
else
{
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
} else {
clearEditConnection();
}
return true;
}
/**
@brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
Disconnect the previous connection, and reconnect the connection between the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function
* @brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
* Disconnect the previous connection, and reconnect the connection between
* the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function
*/
void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
{
for (QMetaObject::Connection c : m_edit_connection) {
disconnect(c);
}
m_edit_connection.clear();
clearEditConnection();
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_size_dsb, SIGNAL(valueChanged(double)), this, SLOT(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 (m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
m_edit_connection << connect (m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
}
m_edit_connection << connect (ui->m_style_cb, QOverload<int>::of(&QComboBox::activated),
this, &ShapeGraphicsItemPropertiesWidget::apply);
m_edit_connection << connect (ui->m_size_dsb, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &ShapeGraphicsItemPropertiesWidget::apply);
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()
@@ -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();
}
}

View File

@@ -53,13 +53,12 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
private:
void setUpEditConnection();
void clearEditConnection();
private slots:
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;
QetShapeItem *m_shape;
QList <QPointer<QetShapeItem>> m_shapes_list;