┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2024-08-25 11:50:21 +0200
committerMéven Car <[email protected]>2024-08-28 09:04:28 +0200
commit4a0188e5006c1a5cf5a8d607f50560e97fc95770 (patch)
treebe2746c6edd7da360b881b69fd39a88e1d7c5020 /src/kitemviews
parent6b1a5a2779f404165fd1e0b117fdac6dbdf75cc5 (diff)
KItemListRoleEditor: minimize resize() occurences
Adjust document width to match its widget width. BUG: 479695
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp
index fd290327a..895a97aea 100644
--- a/src/kitemviews/private/kitemlistroleeditor.cpp
+++ b/src/kitemviews/private/kitemlistroleeditor.cpp
@@ -140,6 +140,9 @@ void KItemListRoleEditor::autoAdjustSize()
{
const qreal frameBorder = 2 * frameWidth();
+ const auto originalSize = size();
+ auto newSize = originalSize;
+
document()->adjustSize();
const qreal requiredWidth = document()->size().width();
const qreal availableWidth = size().width() - frameBorder;
@@ -148,7 +151,7 @@ void KItemListRoleEditor::autoAdjustSize()
if (parentWidget() && pos().x() + newWidth > parentWidget()->width()) {
newWidth = parentWidget()->width() - pos().x();
}
- resize(newWidth, size().height());
+ newSize.setWidth(newWidth);
}
const qreal requiredHeight = document()->size().height();
@@ -158,8 +161,15 @@ void KItemListRoleEditor::autoAdjustSize()
if (parentWidget() && pos().y() + newHeight > parentWidget()->height()) {
newHeight = parentWidget()->height() - pos().y();
}
- resize(size().width(), newHeight);
+ newSize.setHeight(newHeight);
+ }
+
+ if (originalSize != newSize) {
+ resize(newSize);
}
+ // reset the document width to the widget width
+ // to allow alignment to be properly rendered
+ document()->setTextWidth(newSize.width());
}
void KItemListRoleEditor::emitRoleEditingFinished(EditResultDirection direction)