┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorYifan Zhu <[email protected]>2023-10-24 18:40:39 -0700
committerMéven Car <[email protected]>2023-11-08 11:10:42 +0000
commit8297e0a8c97c6e1f6d46b9ecc9c5f495f294d5b8 (patch)
treea35a0ece88c0b090800837cab4cc82399d34e972 /src/kitemviews
parent91a4d5da94a6b0b60ad7989a402f654710103e99 (diff)
Improve size adjustment of itemlist editor
Currently multi-line file names in dolphin only display a single line when renaming. This commit ensures multi-line filenames have all lines displayed by calling `document()->adjustSize` in `KItemListRoleEditor::autoAdjustSize`, and by calling the latter function after setting up the editor. BUG: 452587
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp1
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp1
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.h10
3 files changed, 7 insertions, 5 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index e37013f95..54e1fa50b 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -821,6 +821,7 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray &current, const
rect.setWidth(parent->width() - rect.left());
}
m_roleEditor->setGeometry(rect.toRect());
+ m_roleEditor->autoAdjustSize();
m_roleEditor->show();
m_roleEditor->setFocus();
}
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp
index f305fadac..ea03dfa38 100644
--- a/src/kitemviews/private/kitemlistroleeditor.cpp
+++ b/src/kitemviews/private/kitemlistroleeditor.cpp
@@ -139,6 +139,7 @@ void KItemListRoleEditor::autoAdjustSize()
{
const qreal frameBorder = 2 * frameWidth();
+ document()->adjustSize();
const qreal requiredWidth = document()->size().width();
const qreal availableWidth = size().width() - frameBorder;
if (requiredWidth > availableWidth) {
diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h
index 18304374d..eb8a9cb5e 100644
--- a/src/kitemviews/private/kitemlistroleeditor.h
+++ b/src/kitemviews/private/kitemlistroleeditor.h
@@ -51,17 +51,17 @@ Q_SIGNALS:
void roleEditingFinished(const QByteArray &role, const QVariant &value);
void roleEditingCanceled(const QByteArray &role, const QVariant &value);
-protected:
- bool event(QEvent *event) override;
- void keyPressEvent(QKeyEvent *event) override;
-
-private Q_SLOTS:
+public Q_SLOTS:
/**
* Increases the size of the editor in case if there is not
* enough room for the text.
*/
void autoAdjustSize();
+protected:
+ bool event(QEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+
private:
/**
* Emits the signal roleEditingFinished if m_blockFinishedSignal