1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

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());
}
m_roleEditor->setGeometry(rect.toRect());
m_roleEditor->autoAdjustSize();
m_roleEditor->show();
m_roleEditor->setFocus();
}

View File

@ -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) {

View File

@ -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