Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkwidget
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#543
  • Loading branch information
deepin-ci-robot committed Jan 9, 2024
1 parent 53e1c44 commit f688e95
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/widgets/dcrumbedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate

void registerHandler(QAbstractTextDocumentLayout *layout)
{
D_Q(DCrumbEdit);

for (int i = QTextFormat::UserObject + 1; ; ++i) {
if (!layout->handlerForObject(i)) {
objectType = i;
Expand Down Expand Up @@ -379,7 +377,9 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate
if (cursor.charFormat().objectType() != objectType)
return false;

DCrumbTextFormat format(cursor.charFormat());
auto fmt = q->document()->documentLayout()->formatAt(mousePos);
DCrumbTextFormat format = formats.value(fmt.stringProperty(QTextFormat::UserProperty + 1));

currentText = format.text();
currentBrush = format.background();

Expand All @@ -391,7 +391,8 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate

makeCrumb();

if (mousePos.x() < q->cursorRect().left())
if (mousePos.x() < q->cursorRect().left() ||
mousePos.y() < q->cursorRect().top())
cursor.setPosition(cursor.position() - 1, QTextCursor::KeepAnchor);
else
cursor.setPosition(cursor.position() + 1, QTextCursor::KeepAnchor);
Expand Down

0 comments on commit f688e95

Please sign in to comment.