Commit 1e02108e authored by Julius Künzel's avatar Julius Künzel Committed by Vincent Pinon
Browse files

Fix invisible text cursor in title editor #165 and other minor tweaks

BUG: 403941
BUG: 407497
parent 86218927
......@@ -67,7 +67,8 @@ MyTextItem::MyTextItem(const QString &txt, QGraphicsItem *parent)
: QGraphicsTextItem(txt, parent)
, m_alignment(qApp->isLeftToRight() ? Qt::AlignRight : Qt::AlignLeft)
{
setCacheMode(QGraphicsItem::ItemCoordinateCache);
//Disabled because cache makes text cursor invisible and borders ugly
//setCacheMode(QGraphicsItem::ItemCoordinateCache);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
document()->setDocumentMargin(0);
m_shadowEffect = new MyQGraphicsEffect(this);
......@@ -409,6 +410,7 @@ void MyTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *evt)
// SetTextInteraction(true);
setTextInteractionFlags(Qt::TextEditorInteraction);
setFocus(Qt::MouseFocusReason);
setCursor(QCursor(Qt::IBeamCursor));
// 2. send a single click to this QGraphicsTextItem (this will set the cursor to the mouse position):
// create a new mouse event with the same parameters as evt
auto *click = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress);
......@@ -421,7 +423,8 @@ void MyTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *evt)
MyRectItem::MyRectItem(QGraphicsItem *parent)
: QGraphicsRectItem(parent)
{
setCacheMode(QGraphicsItem::ItemCoordinateCache);
//Disabled because cache makes text cursor invisible and borders ugly
//setCacheMode(QGraphicsItem::ItemCoordinateCache);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
......@@ -454,7 +457,8 @@ QVariant MyRectItem::itemChange(GraphicsItemChange change, const QVariant &value
MyPixmapItem::MyPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent)
: QGraphicsPixmapItem(pixmap, parent)
{
setCacheMode(QGraphicsItem::ItemCoordinateCache);
//Disabled because cache makes text cursor invisible and borders ugly
//setCacheMode(QGraphicsItem::ItemCoordinateCache);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
......@@ -477,7 +481,8 @@ QVariant MyPixmapItem::itemChange(GraphicsItemChange change, const QVariant &val
MySvgItem::MySvgItem(const QString &fileName, QGraphicsItem *parent)
: QGraphicsSvgItem(fileName, parent)
{
setCacheMode(QGraphicsItem::ItemCoordinateCache);
//Disabled because cache makes text cursor invisible and borders ugly
//setCacheMode(QGraphicsItem::ItemCoordinateCache);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
......@@ -783,6 +788,7 @@ void GraphicsSceneRectMove::clearTextSelection(bool reset)
QTextBlock cur = t->textCursor().block();
t->setTextCursor(QTextCursor(cur));
t->setTextInteractionFlags(Qt::NoTextInteraction);
t->unsetCursor();
}
if (reset) {
m_selectedItem = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment