mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
Inline renaming: Improve focus handling
Fix issue that cancelling the inline-renaming by clicking on the other split view applies the wrong focus. Thanks to Frank Reininghaus for the initial patch and noticing this issue. CCBUG: 301252
This commit is contained in:
parent
ba6b4a6632
commit
1ddd9c4032
|
@ -688,8 +688,7 @@ void KStandardItemListWidget::slotRoleEditingCanceled(int index,
|
|||
const QByteArray& role,
|
||||
const QVariant& value)
|
||||
{
|
||||
m_roleEditor->deleteLater();
|
||||
m_roleEditor = 0;
|
||||
closeRoleEditor();
|
||||
emit roleEditingCanceled(index, role, value);
|
||||
setEditedRole(QByteArray());
|
||||
}
|
||||
|
@ -698,8 +697,7 @@ void KStandardItemListWidget::slotRoleEditingFinished(int index,
|
|||
const QByteArray& role,
|
||||
const QVariant& value)
|
||||
{
|
||||
m_roleEditor->deleteLater();
|
||||
m_roleEditor = 0;
|
||||
closeRoleEditor();
|
||||
emit roleEditingFinished(index, role, value);
|
||||
setEditedRole(QByteArray());
|
||||
}
|
||||
|
@ -1241,6 +1239,17 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
|
|||
return rect;
|
||||
}
|
||||
|
||||
void KStandardItemListWidget::closeRoleEditor()
|
||||
{
|
||||
if (m_roleEditor->hasFocus()) {
|
||||
// If the editing was not ended by a FocusOut event, we have
|
||||
// to transfer the keyboard focus back to the KItemListContainer.
|
||||
scene()->views()[0]->parentWidget()->setFocus();
|
||||
}
|
||||
m_roleEditor->deleteLater();
|
||||
m_roleEditor = 0;
|
||||
}
|
||||
|
||||
QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, int size)
|
||||
{
|
||||
const KIcon icon(name);
|
||||
|
|
|
@ -165,6 +165,12 @@ private:
|
|||
|
||||
QRectF roleEditingRect(const QByteArray &role) const;
|
||||
|
||||
/**
|
||||
* Closes the role editor and returns the focus back
|
||||
* to the KItemListContainer.
|
||||
*/
|
||||
void closeRoleEditor();
|
||||
|
||||
static QPixmap pixmapForIcon(const QString& name, int size);
|
||||
|
||||
/**
|
||||
|
|
|
@ -168,8 +168,6 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
|
|||
this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
|
||||
connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
|
||||
this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
|
||||
connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
|
||||
this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
|
||||
connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
|
||||
this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
|
||||
connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
|
||||
|
@ -1320,14 +1318,6 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
|
|||
emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles);
|
||||
}
|
||||
|
||||
void DolphinView::slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(role);
|
||||
Q_UNUSED(value);
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
|
||||
{
|
||||
if (role == "text") {
|
||||
|
@ -1343,7 +1333,6 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
|
|||
KonqOperations::rename(this, oldUrl, newName);
|
||||
}
|
||||
}
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void DolphinView::loadDirectory(const KUrl& url, bool reload)
|
||||
|
|
|
@ -628,7 +628,6 @@ private slots:
|
|||
void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current,
|
||||
const QList<QByteArray>& previous);
|
||||
|
||||
void slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
|
||||
void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue