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
This commit is contained in:
Yifan Zhu 2023-10-24 18:40:39 -07:00 committed by Méven Car
parent 91a4d5da94
commit 8297e0a8c9
3 changed files with 7 additions and 5 deletions

View file

@ -821,6 +821,7 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray &current, const
rect.setWidth(parent->width() - rect.left()); rect.setWidth(parent->width() - rect.left());
} }
m_roleEditor->setGeometry(rect.toRect()); m_roleEditor->setGeometry(rect.toRect());
m_roleEditor->autoAdjustSize();
m_roleEditor->show(); m_roleEditor->show();
m_roleEditor->setFocus(); m_roleEditor->setFocus();
} }

View file

@ -139,6 +139,7 @@ void KItemListRoleEditor::autoAdjustSize()
{ {
const qreal frameBorder = 2 * frameWidth(); const qreal frameBorder = 2 * frameWidth();
document()->adjustSize();
const qreal requiredWidth = document()->size().width(); const qreal requiredWidth = document()->size().width();
const qreal availableWidth = size().width() - frameBorder; const qreal availableWidth = size().width() - frameBorder;
if (requiredWidth > availableWidth) { if (requiredWidth > availableWidth) {

View file

@ -51,17 +51,17 @@ Q_SIGNALS:
void roleEditingFinished(const QByteArray &role, const QVariant &value); void roleEditingFinished(const QByteArray &role, const QVariant &value);
void roleEditingCanceled(const QByteArray &role, const QVariant &value); void roleEditingCanceled(const QByteArray &role, const QVariant &value);
protected: public Q_SLOTS:
bool event(QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private Q_SLOTS:
/** /**
* Increases the size of the editor in case if there is not * Increases the size of the editor in case if there is not
* enough room for the text. * enough room for the text.
*/ */
void autoAdjustSize(); void autoAdjustSize();
protected:
bool event(QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private: private:
/** /**
* Emits the signal roleEditingFinished if m_blockFinishedSignal * Emits the signal roleEditingFinished if m_blockFinishedSignal