[qet] qet/qet: [5125] Dynamic element text item editor : add entry for edit the rotation of the edited text. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 5125
Author: blacksun
Date: 2017-11-29 20:17:02 +0100 (Wed, 29 Nov 2017)
Log Message:
-----------
Dynamic element text item editor : add entry for edit the rotation of the edited text.
Modified Paths:
--------------
trunk/sources/ui/dynamicelementtextmodel.cpp
trunk/sources/ui/dynamicelementtextmodel.h
Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp 2017-11-29 14:49:12 UTC (rev 5124)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp 2017-11-29 19:17:02 UTC (rev 5125)
@@ -242,6 +242,19 @@
qsi_list.clear();
qsi_list << y_pos << y_pos_a;
qsi->appendRow(qsi_list);
+
+ //Rotation
+ QStandardItem *rot = new QStandardItem(tr("Rotation"));
+ rot->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+
+ QStandardItem *rot_a = new QStandardItem;
+ rot_a->setData(deti->rotation(), Qt::EditRole);
+ rot_a->setData(DynamicElementTextModel::rotation, Qt::UserRole+1);
+ rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+
+ qsi_list.clear();;
+ qsi_list << rot << rot_a;
+ qsi->appendRow(qsi_list);
}
@@ -447,6 +460,17 @@
quc->setText(tr("Déplacer un texte d'élément"));
}
}
+ //When text is in a group, they're isn't item for the rotation of the text
+ if(text_qsi->child(7,1))
+ {
+ qreal rot = text_qsi->child(7,1)->data(Qt::EditRole).toDouble();
+ rot = QET::correctAngle(rot);
+ if(rot != deti->rotation())
+ {
+ QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "rotation", QVariant(deti->rotation()), QVariant(rot), undo);
+ quc->setText(tr("Pivoter un texte d'élément"));
+ }
+ }
return undo;
}
@@ -686,6 +710,7 @@
connection_list << connect(deti, &DynamicElementTextItem::xChanged, [deti,this](){this->updateDataFromText(deti, pos);});
connection_list << connect(deti, &DynamicElementTextItem::yChanged, [deti,this](){this->updateDataFromText(deti, pos);});
connection_list << connect(deti, &DynamicElementTextItem::frameChanged, [deti,this](){this->updateDataFromText(deti, frame);});
+ connection_list << connect(deti, &DynamicElementTextItem::rotationChanged, [deti,this](){this->updateDataFromText(deti, rotation);});
connection_list << connect(deti, &DynamicElementTextItem::compositeTextChanged, [deti, this]() {this->updateDataFromText(deti, compositeText);});
m_hash_text_connect.insert(deti, connection_list);
@@ -775,6 +800,12 @@
qsi->child(4,1)->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
break;
}
+ case rotation:
+ {
+ if(qsi->child(7,1))
+ qsi->child(7,1)->setData(deti->rotation(), Qt::EditRole);
+ break;
+ }
}
m_block_dataForTextChanged = false;
@@ -867,6 +898,16 @@
sb->setSuffix(" px");
return sb;
}
+ case DynamicElementTextModel::rotation:
+ {
+ QSpinBox *sb = new QSpinBox(parent);
+ sb->setObjectName("rot_spinbox");
+ sb->setRange(0, 359);
+ sb->setWrapping(true);
+ sb->setFrame(false);
+ sb->setSuffix(" °");
+ return sb;
+ }
}
return QStyledItemDelegate::createEditor(parent, option, index);
}
@@ -942,7 +983,7 @@
//in normal behavior, the value is commited when the spinbox lose focus or enter key is pressed
//With this hack the value is commited each time the value change, so the text is moved in live.
//We also use this hack for the font size spinbox
- if(object->objectName() == "pos_dialog" || object->objectName() == "font_size")
+ if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox")
{
QSpinBox *sb = static_cast<QSpinBox *>(object);
if(event->type() == QEvent::KeyRelease)
Modified: trunk/sources/ui/dynamicelementtextmodel.h
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.h 2017-11-29 14:49:12 UTC (rev 5124)
+++ trunk/sources/ui/dynamicelementtextmodel.h 2017-11-29 19:17:02 UTC (rev 5125)
@@ -46,7 +46,8 @@
tagg,
color,
pos,
- frame
+ frame,
+ rotation
};
DynamicElementTextModel(Element *element, QObject *parent = nullptr);