You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
974 B

#include "textitem.hpp"
#include <QInputDialog>
#include <QtMath>
bool TextItem::init(CropScene *s) {
bool ok;
s->hide();
text = QInputDialog::getText(nullptr, tr("Text to add"), tr("Input"), QLineEdit::Normal, QString(), &ok);
s->show();
return ok;
}
void TextItem::mouseDragEvent(QGraphicsSceneMouseEvent *, CropScene *scene) {
if (!textItem) {
textItem = scene->addSimpleText(text, scene->font());
textItem->setPos(scene->cursorPosition());
textItem->setPen(scene->pen().color());
textItem->setBrush(scene->pen().color());
} else {
auto ee = 180 + qRadiansToDegrees(qAtan2((textItem->pos().y() - scene->cursorPosition().y()),
(textItem->pos().x() - scene->cursorPosition().x())));
textItem->setRotation(ee);
}
}
void TextItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) {
}
QString TextItem::name() {
return "Text";
}